NeoMutt  2024-11-14-138-ge5ca67
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 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
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:

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