NeoMutt  2024-11-14-138-ge5ca67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
sort_pgp.c File Reference

PGP Key Sorting. More...

#include "config.h"
#include <locale.h>
#include <stdbool.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "lib.h"
#include "pgp.h"
#include "pgplib.h"
#include "sort.h"
+ Include dependency graph for sort_pgp.c:

Go to the source code of this file.

Functions

static int pgp_sort_address (const void *a, const void *b, void *sdata)
 Compare two keys by their addresses - Implements sort_t -.
 
static int pgp_sort_date (const void *a, const void *b, void *sdata)
 Compare two keys by their dates - Implements sort_t -.
 
static int pgp_sort_keyid (const void *a, const void *b, void *sdata)
 Compare two keys by their IDs - Implements sort_t -.
 
static int pgp_sort_trust (const void *a, const void *b, void *sdata)
 Compare two keys by their trust levels - Implements sort_t -.
 
void pgp_sort_keys (struct PgpUidArray *pua)
 Sort an array of PGP keys.
 

Detailed Description

PGP Key Sorting.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file sort_pgp.c.

Function Documentation

◆ pgp_sort_keys()

void pgp_sort_keys ( struct PgpUidArray *  pua)

Sort an array of PGP keys.

Parameters
puaArray to sort

Sort PGP keys according to $pgp_sort_keys

Definition at line 142 of file sort_pgp.c.

143{
144 if (!pua)
145 return;
146
147 sort_t fn = NULL;
148 short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_key_sort");
149 switch (c_pgp_sort_keys & SORT_MASK)
150 {
151 case KEY_SORT_ADDRESS:
152 fn = pgp_sort_address;
153 break;
154 case KEY_SORT_DATE:
155 fn = pgp_sort_date;
156 break;
157 case KEY_SORT_KEYID:
158 fn = pgp_sort_keyid;
159 break;
160 case KEY_SORT_TRUST:
161 default:
162 fn = pgp_sort_trust;
163 break;
164 }
165
166 if (ARRAY_SIZE(pua) > 1)
167 {
168 bool sort_reverse = c_pgp_sort_keys & SORT_REVERSE;
169 ARRAY_SORT(pua, fn, &sort_reverse);
170 }
171}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition: array.h:279
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:266
#define SORT_MASK
Mask for the sort id.
Definition: sort.h:38
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort.h:39
static int pgp_sort_trust(const void *a, const void *b, void *sdata)
Compare two keys by their trust levels - Implements sort_t -.
Definition: sort_pgp.c:100
static int pgp_sort_keyid(const void *a, const void *b, void *sdata)
Compare two keys by their IDs - Implements sort_t -.
Definition: sort_pgp.c:81
static int pgp_sort_date(const void *a, const void *b, void *sdata)
Compare two keys by their dates - Implements sort_t -.
Definition: sort_pgp.c:62
static int pgp_sort_address(const void *a, const void *b, void *sdata)
Compare two keys by their addresses - Implements sort_t -.
Definition: sort_pgp.c:43
@ KEY_SORT_ADDRESS
Sort by address.
Definition: sort.h:34
@ KEY_SORT_DATE
Sort by date.
Definition: sort.h:35
@ KEY_SORT_TRUST
Sort by trust level.
Definition: sort.h:37
@ KEY_SORT_KEYID
Sort by key id.
Definition: sort.h:36
int(* sort_t)(const void *a, const void *b, void *sdata)
Definition: qsort_r.h:41
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function: