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

GPGME 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 "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 175 of file sort_gpgme.c.

176{
177 const short c_pgp_sort_keys = cs_subset_sort(NeoMutt->sub, "pgp_key_sort");
178 sort_t fn = NULL;
179 switch (c_pgp_sort_keys & SORT_MASK)
180 {
181 case KEY_SORT_ADDRESS:
183 break;
184 case KEY_SORT_DATE:
185 fn = crypt_sort_date;
186 break;
187 case KEY_SORT_KEYID:
188 fn = crypt_sort_keyid;
189 break;
190 case KEY_SORT_TRUST:
191 default:
192 fn = crypt_sort_trust;
193 break;
194 }
195
196 if (ARRAY_SIZE(ckia) > 1)
197 {
198 bool sort_reverse = c_pgp_sort_keys & SORT_REVERSE;
199 ARRAY_SORT(ckia, fn, &sort_reverse);
200 }
201}
#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 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:117
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:43
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:81
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:62
@ 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: