1 /* 2 */ 3 #ifndef imaprefs_h 4 #define imaprefs_h 5 6 /* 7 ** Copyright 2000-2003 Double Precision, Inc. 8 ** See COPYING for distribution information. 9 */ 10 11 #if HAVE_CONFIG_H 12 #include "rfc822/config.h" 13 #endif 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 /* 20 ** Implement REFERENCES threading. 21 */ 22 23 /* The data structures */ 24 25 struct imap_refmsg { 26 struct imap_refmsg *next, *last; /* Link list of all msgs */ 27 struct imap_refmsg *parent; /* my parent */ 28 struct imap_refmsg *firstchild, *lastchild; /* Children link list */ 29 struct imap_refmsg *prevsib, *nextsib; /* Link list of siblings */ 30 31 char isdummy; /* this is a dummy node (for now) */ 32 char flag2; /* Additional flag */ 33 34 char *msgid; /* msgid of this message */ 35 36 char *subj; /* dynalloced subject of this msg */ 37 time_t timestamp; /* Timestamp */ 38 unsigned long seqnum; /* Sequence number */ 39 } ; 40 41 struct imap_refmsgtable { 42 struct imap_refmsg *firstmsg, *lastmsg; /* Link list of all msgs */ 43 44 /* hash table message id lookup */ 45 46 struct imap_refmsghash *hashtable[512]; 47 48 struct imap_subjlookup *subjtable[512]; 49 50 struct imap_refmsg *rootptr; /* The root */ 51 } ; 52 53 struct imap_refmsgtable *rfc822_threadalloc(void); 54 void rfc822_threadfree(struct imap_refmsgtable *); 55 struct imap_refmsg *rfc822_threadmsg(struct imap_refmsgtable *mt, 56 const char *msgidhdr, 57 const char *refhdr, 58 const char *subjheader, 59 60 const char *dateheader, 61 time_t dateheader_tm, 62 /* Set one or other */ 63 64 unsigned long seqnum); 65 66 struct imap_refmsg *rfc822_threadmsgrefs(struct imap_refmsgtable *mt, 67 const char *msgid_s, 68 const char * const * msgidList, 69 const char *subjheader, 70 const char *dateheader, 71 time_t dateheader_tm, 72 unsigned long seqnum); 73 74 struct imap_refmsg *rfc822_thread(struct imap_refmsgtable *mt); 75 76 /* INTERNAL FUNCTIONS FOLLOW */ 77 78 79 struct imap_refmsghash { 80 struct imap_refmsghash *nexthash; 81 struct imap_refmsg *msg; 82 } ; 83 84 struct imap_subjlookup { 85 struct imap_subjlookup *nextsubj; 86 char *subj; 87 struct imap_refmsg *msg; 88 int msgisrefwd; 89 } ; 90 91 struct imap_refmsg *rfc822_threadallocmsg(struct imap_refmsgtable *mt, 92 const char *msgid); 93 void rfc822_threadprune(struct imap_refmsgtable *mt); 94 struct imap_refmsg *rfc822_threadgetroot(struct imap_refmsgtable *mt); 95 struct imap_refmsg *rfc822_threadsearchmsg(struct imap_refmsgtable *mt, 96 const char *msgid); 97 int rfc822_threadsortsubj(struct imap_refmsg *root); 98 int rfc822_threadgathersubj(struct imap_refmsgtable *mt, 99 struct imap_refmsg *root); 100 int rfc822_threadmergesubj(struct imap_refmsgtable *mt, 101 struct imap_refmsg *root); 102 int rfc822_threadsortbydate(struct imap_refmsgtable *mt); 103 104 105 #ifdef __cplusplus 106 } 107 #endif 108 109 #endif 110