/**
* mutt_select_sort - Ask the user for a sort method
* @param reverse If true make it a reverse sort
- * @retval num Sort type, e.g. #SORT_DATE
+ * @retval num Sort type, see #SortType
*/
-int mutt_select_sort(int reverse)
+int mutt_select_sort(bool reverse)
{
- int method = C_Sort; /* save the current method in case of abort */
- int new_sort = -1;
+ enum SortType method = C_Sort; /* save the current method in case of abort */
+ enum SortType new_sort = C_Sort;
switch (mutt_multi_choice(reverse ?
/* L10N: The highlighted letters must match the "Sort" options */
void mutt_print_message(struct Mailbox *m, struct EmailList *el);
int mutt_save_message_ctx(struct Email *e, bool delete, bool decode, bool decrypt, struct Mailbox *m);
int mutt_save_message(struct Mailbox *m, struct EmailList *el, bool delete, bool decode, bool decrypt);
-int mutt_select_sort(int reverse);
+int mutt_select_sort(bool reverse);
void mutt_shell_escape(void);
#endif /* MUTT_COMMANDS_H */
#define DT_SORT_AUX 0x200 /**< Sort id for #SortAliasMethods */
#define DT_SORT_SIDEBAR 0x400 /**< Sort id for #SortSidebarMethods */
-#define SORT_DATE 1 /**< Sort by the date the email was sent. */
-#define SORT_SIZE 2 /**< Sort by the size of the email */
-#define SORT_ALPHA 3 /**< Required by makedoc.c */
-#define SORT_SUBJECT 3 /**< Sort by the email's subject */
-#define SORT_FROM 4 /**< Sort by the email's From field */
-#define SORT_ORDER 5 /**< Sort by the order the messages appear in the mailbox */
-#define SORT_THREADS 6 /**< Sort by email threads */
-#define SORT_RECEIVED 7 /**< Sort by when the message were delivered locally */
-#define SORT_TO 8 /**< Sort by the email's To field */
-#define SORT_SCORE 9 /**< Sort by the email's score */
-#define SORT_ALIAS 10 /**< Sort by email alias */
-#define SORT_ADDRESS 11 /**< Sort by email address */
-#define SORT_KEYID 12 /**< Sort by the encryption key's ID */
-#define SORT_TRUST 13 /**< Sort by encryption key's trust level */
-#define SORT_SPAM 14 /**< Sort by the email's spam score */
-#define SORT_COUNT 15 /**< Sort by number of emails in a folder */
-#define SORT_UNREAD 16 /**< Sort by the number of unread emails */
-#define SORT_FLAGGED 17 /**< Sort by the number of flagged emails */
-#define SORT_PATH 18 /**< Sort by the folder's path */
-#define SORT_LABEL 19 /**< Sort by the emails label */
-#define SORT_DESC 20 /**< Sort by the folder's description */
+/**
+ * enum SortType - Methods for sorting
+ */
+enum SortType
+{
+ SORT_DATE = 1, ///< Sort by the date the email was sent
+ SORT_SIZE = 2, ///< Sort by the size of the email
+ SORT_ALPHA = 3, ///< Required by makedoc.c
+ SORT_SUBJECT = 3, ///< Sort by the email's subject
+ SORT_FROM = 4, ///< Sort by the email's From field
+ SORT_ORDER = 5, ///< Sort by the order the messages appear in the mailbox
+ SORT_THREADS = 6, ///< Sort by email threads
+ SORT_RECEIVED = 7, ///< Sort by when the message were delivered locally
+ SORT_TO = 8, ///< Sort by the email's To field
+ SORT_SCORE = 9, ///< Sort by the email's score
+ SORT_ALIAS = 10, ///< Sort by email alias
+ SORT_ADDRESS = 11, ///< Sort by email address
+ SORT_KEYID = 12, ///< Sort by the encryption key's ID
+ SORT_TRUST = 13, ///< Sort by encryption key's trust level
+ SORT_SPAM = 14, ///< Sort by the email's spam score
+ SORT_COUNT = 15, ///< Sort by number of emails in a folder
+ SORT_UNREAD = 16, ///< Sort by the number of unread emails
+ SORT_FLAGGED = 17, ///< Sort by the number of flagged emails
+ SORT_PATH = 18, ///< Sort by the folder's path
+ SORT_LABEL = 19, ///< Sort by the emails label
+ SORT_DESC = 20, ///< Sort by the folder's description
+
+ SORT_MAX,
+};
/* C_Sort and C_SortAux are shorts, and are a composite of a constant sort
* operation number and a set of compounded bitflags.
* @param[out] pos Cursor used for multiple calls to this function
* @retval num Messages in the set
*
- * @note Headers must be in SORT_ORDER. See imap_exec_msgset() for args.
+ * @note Headers must be in #SORT_ORDER. See imap_exec_msgset() for args.
* Pos is an opaque pointer a la strtok(). It should be 0 at first call.
*/
static int make_msg_set(struct Mailbox *m, struct Buffer *buf, int flag,
if (C_Sort != SORT_ORDER)
{
- const short old_sort = C_Sort;
+ const enum SortType old_sort = C_Sort;
C_Sort = SORT_ORDER;
mutt_sort_headers(ctx, true);
C_Sort = old_sort;
char tempfile[PATH_MAX];
char buf[32];
- int i, j, save_sort = SORT_ORDER;
+ int i, j;
+ enum SortType save_sort = SORT_ORDER;
int rc = -1;
int need_sort = 0; /* flag to resort mailbox if new mail arrives */
int first = -1; /* first message to be written */
*/
else
{
- sort_func = mutt_get_sort_func(C_Sort);
+ sort_func = mutt_get_sort_func(C_Sort & SORT_MASK);
return sort_func ? 1 : 0;
}
}
struct NntpMboxData *mdata = m->mdata;
anum_t last = 0, first = 1;
bool series;
- int save_sort = SORT_ORDER;
+ enum SortType save_sort = SORT_ORDER;
unsigned int entries;
if (C_Sort != SORT_ORDER)
*/
static void sort_entries(void)
{
- short ssm = (C_SidebarSortMethod & SORT_MASK);
+ enum SortType ssm = (C_SidebarSortMethod & SORT_MASK);
/* These are the only sort methods we understand */
if ((ssm == SORT_COUNT) || (ssm == SORT_UNREAD) || (ssm == SORT_FLAGGED) || (ssm == SORT_PATH))
/**
* mutt_get_sort_func - Get the sort function for a given sort id
- * @param method Sort id, e.g. #SORT_DATE
+ * @param method Sort type, see #SortType
* @retval ptr sort function - Implements ::sort_t
*/
-sort_t *mutt_get_sort_func(int method)
+sort_t *mutt_get_sort_func(enum SortType method)
{
- switch (method & SORT_MASK)
+ switch (method)
{
case SORT_DATE:
return compare_date_sent;
}
mutt_sort_threads(ctx, init);
}
- else if (!(sortfunc = mutt_get_sort_func(C_Sort)) ||
- !(AuxSort = mutt_get_sort_func(C_SortAux)))
+ else if (!(sortfunc = mutt_get_sort_func(C_Sort & SORT_MASK)) ||
+ !(AuxSort = mutt_get_sort_func(C_SortAux & SORT_MASK)))
{
mutt_error(_("Could not find sorting function [report this bug]"));
return;
*/
typedef int sort_t(const void *a, const void *b);
-sort_t *mutt_get_sort_func(int method);
+sort_t *mutt_get_sort_func(enum SortType method);
void mutt_sort_headers(struct Context *ctx, bool init);
int perform_auxsort(int retval, const void *a, const void *b);
* get_sort_str - Get the sort method as a string
* @param buf Buffer for the sort string
* @param buflen Length of the buffer
- * @param method Sort method, e.g. #SORT_DATE
+ * @param method Sort method, see #SortType
* @retval ptr Buffer pointer
*/
-static char *get_sort_str(char *buf, size_t buflen, int method)
+static char *get_sort_str(char *buf, size_t buflen, enum SortType method)
{
snprintf(buf, buflen, "%s%s%s", (method & SORT_REVERSE) ? "reverse-" : "",
(method & SORT_LAST) ? "last-" : "",