NeoMutt  2025-12-11-980-ge38c27
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
sort_gpgme.c File Reference

GPGME Key Sorting. More...

#include "config.h"
#include <gpgme.h>
#include <locale.h>
#include <stdbool.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "lib.h"
#include "crypt_gpgme.h"
#include "sort.h"
+ Include dependency graph for sort_gpgme.c:

Go to the source code of this file.

Functions

static int crypt_sort_address (const void *a, const void *b, void *sdata)
 Compare two keys by their addresses - Implements sort_t -.
 
static int crypt_sort_keyid (const void *a, const void *b, void *sdata)
 Compare two keys by their IDs - Implements sort_t -.
 
static int crypt_sort_date (const void *a, const void *b, void *sdata)
 Compare two keys by their dates - Implements sort_t -.
 
static int crypt_sort_trust (const void *a, const void *b, void *sdata)
 Compare two keys by their trust levels - Implements sort_t -.
 
void gpgme_sort_keys (struct CryptKeyInfoArray *ckia)
 Sort an array of GPGME keys.
 

Detailed Description

GPGME 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_gpgme.c.

Function Documentation

◆ gpgme_sort_keys()

void gpgme_sort_keys ( struct CryptKeyInfoArray * ckia)

Sort an array of GPGME keys.

Parameters
ckiaArray to sort

Sort GPGME keys according to $pgp_sort_keys

Definition at line 176 of file sort_gpgme.c.

177{
178 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_key_sort");
179 sort_t fn = NULL;
180 switch (c_pgp_sort_keys & SORT_MASK)
181 {
182 case KEY_SORT_ADDRESS:
184 break;
185 case KEY_SORT_DATE:
186 fn = crypt_sort_date;
187 break;
188 case KEY_SORT_KEYID:
189 fn = crypt_sort_keyid;
190 break;
191 case KEY_SORT_TRUST:
192 default:
193 fn = crypt_sort_trust;
194 break;
195 }
196
197 if (ARRAY_SIZE(ckia) > 1)
198 {
199 bool sort_reverse = c_pgp_sort_keys & SORT_REVERSE;
200 ARRAY_SORT(ckia, fn, &sort_reverse);
201 }
202}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition array.h:373
#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:39
#define SORT_REVERSE
Reverse the order of the sort.
Definition sort.h:40
static int crypt_sort_trust(const void *a, const void *b, void *sdata)
Compare two keys by their trust levels - Implements sort_t -.
Definition sort_gpgme.c:118
static int crypt_sort_address(const void *a, const void *b, void *sdata)
Compare two keys by their addresses - Implements sort_t -.
Definition sort_gpgme.c:44
static int crypt_sort_date(const void *a, const void *b, void *sdata)
Compare two keys by their dates - Implements sort_t -.
Definition sort_gpgme.c:82
static int crypt_sort_keyid(const void *a, const void *b, void *sdata)
Compare two keys by their IDs - Implements sort_t -.
Definition sort_gpgme.c:63
@ 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:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function: