1 /** 2 * @file 3 * Assorted sorting methods 4 * 5 * @authors 6 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org> 7 * Copyright (C) 2019 Pietro Cerutti <gahr@gahr.ch> 8 * 9 * @copyright 10 * This program is free software: you can redistribute it and/or modify it under 11 * the terms of the GNU General Public License as published by the Free Software 12 * Foundation, either version 2 of the License, or (at your option) any later 13 * version. 14 * 15 * This program is distributed in the hope that it will be useful, but WITHOUT 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 18 * details. 19 * 20 * You should have received a copy of the GNU General Public License along with 21 * this program. If not, see <http://www.gnu.org/licenses/>. 22 */ 23 24 #ifndef MUTT_SORT_H 25 #define MUTT_SORT_H 26 27 #include <stdbool.h> 28 #include <sys/types.h> 29 #include "core/lib.h" 30 #include "options.h" // IWYU pragma: keep 31 32 struct Address; 33 struct Email; 34 struct ThreadsContext; 35 36 /** 37 * @defgroup sort_api Sorting API 38 * 39 * Prototype for generic comparison function, compatible with qsort() 40 * 41 * @param a First item 42 * @param b Second item 43 * @retval <0 a precedes b 44 * @retval 0 a and b are identical 45 * @retval >0 b precedes a 46 */ 47 typedef int (*sort_t)(const void *a, const void *b); 48 49 /** 50 * @defgroup sort_mail_api Mail Sorting API 51 * 52 * Prototype for an email comparison function 53 * 54 * @param a First item 55 * @param b Second item 56 * @param reverse true if this is a reverse sort (smaller b precedes a) 57 * @retval <0 a precedes b 58 * @retval 0 a and b are identical 59 * @retval >0 b precedes a 60 */ 61 typedef int (*sort_mail_t)(const struct Email *a, const struct Email *b, bool reverse); 62 63 int mutt_compare_emails(const struct Email *a, const struct Email *b, 64 enum MailboxType type, short sort, short sort_aux); 65 66 void mutt_sort_headers(struct Mailbox *m, struct ThreadsContext *threads, bool init, off_t *vsize); 67 68 const char *mutt_get_name(const struct Address *a); 69 70 #endif /* MUTT_SORT_H */ 71