NeoMutt  2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
sort.h File Reference

Crypto Key sorting functions. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  KeySortType { KEY_SORT_ADDRESS , KEY_SORT_DATE , KEY_SORT_KEYID , KEY_SORT_TRUST }
 Methods for sorting Crypto Keys. More...

Functions

void gpgme_sort_keys (struct CryptKeyInfoArray *ckia)
 Sort an array of GPGME keys.
void pgp_sort_keys (struct PgpUidArray *pua)
 Sort an array of PGP keys.

Detailed Description

Crypto Key sorting functions.

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.h.

Enumeration Type Documentation

◆ KeySortType

Methods for sorting Crypto Keys.

Enumerator
KEY_SORT_ADDRESS 

Sort by address.

KEY_SORT_DATE 

Sort by date.

KEY_SORT_KEYID 

Sort by key id.

KEY_SORT_TRUST 

Sort by trust level.

Definition at line 32 of file sort.h.

33{
38};
@ 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

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
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:

◆ 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}
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
Here is the call graph for this function:
Here is the caller graph for this function: