NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
sort.c File Reference

Address book sorting functions. More...

#include "config.h"
#include <stddef.h>
#include <stdbool.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "sort.h"
#include "alias.h"
#include "gui.h"
+ Include dependency graph for sort.c:

Go to the source code of this file.

Functions

static int alias_sort_name (const void *a, const void *b, void *sdata)
 Compare two Aliases by their short names - Implements sort_t -.
 
static int alias_sort_address (const void *a, const void *b, void *sdata)
 Compare two Aliases by their Addresses - Implements sort_t -.
 
static int alias_sort_unsort (const void *a, const void *b, void *sdata)
 Compare two Aliases by their original configuration position - Implements sort_t -.
 
static sort_t alias_get_sort_function (short sort)
 Sorting function decision logic.
 
void alias_array_sort (struct AliasViewArray *ava, const struct ConfigSubset *sub)
 Sort and reindex an AliasViewArray.
 

Detailed Description

Address book sorting functions.

Authors
  • Romeu Vieira
  • Richard Russon
  • Dennis Schön

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

Function Documentation

◆ alias_get_sort_function()

static sort_t alias_get_sort_function ( short  sort)
static

Sorting function decision logic.

Parameters
sortSort method, e.g. SORT_ALIAS

Definition at line 148 of file sort.c.

149{
150 switch ((sort & SORT_MASK))
151 {
152 case SORT_ALIAS:
153 return alias_sort_name;
154 case SORT_ADDRESS:
155 return alias_sort_address;
156 case SORT_ORDER:
157 return alias_sort_unsort;
158 default:
159 return alias_sort_name;
160 }
161}
static int alias_sort_unsort(const void *a, const void *b, void *sdata)
Compare two Aliases by their original configuration position - Implements sort_t -.
Definition: sort.c:128
static int alias_sort_address(const void *a, const void *b, void *sdata)
Compare two Aliases by their Addresses - Implements sort_t -.
Definition: sort.c:67
static int alias_sort_name(const void *a, const void *b, void *sdata)
Compare two Aliases by their short names - Implements sort_t -.
Definition: sort.c:46
#define SORT_MASK
Mask for the sort id.
Definition: sort2.h:70
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:40
@ SORT_ALIAS
Sort by email alias.
Definition: sort2.h:45
@ SORT_ADDRESS
Sort by email address.
Definition: sort2.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alias_array_sort()

void alias_array_sort ( struct AliasViewArray *  ava,
const struct ConfigSubset sub 
)

Sort and reindex an AliasViewArray.

Parameters
avaArray of Aliases
subConfig items

Definition at line 168 of file sort.c.

169{
170 if (!ava || ARRAY_EMPTY(ava))
171 return;
172
173 const short c_sort_alias = cs_subset_sort(sub, "sort_alias");
174 bool sort_reverse = (c_sort_alias & SORT_REVERSE);
175 ARRAY_SORT(ava, alias_get_sort_function(c_sort_alias), &sort_reverse);
176
177 struct AliasView *avp = NULL;
178 ARRAY_FOREACH(avp, ava)
179 {
180 avp->num = ARRAY_FOREACH_IDX;
181 }
182}
static sort_t alias_get_sort_function(short sort)
Sorting function decision logic.
Definition: sort.c:148
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition: array.h:279
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:74
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition: helpers.c:267
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort2.h:71
GUI data wrapping an Alias.
Definition: gui.h:38
int num
Index number in list.
Definition: gui.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function: