Mailbox Searching void mail_search (MAILSTREAM *stream,char *criteria); void mail_search_full (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm, long flags); stream stream to search charset MIME character set to use when searching strings pgm search program flags option flags This function causes a mailbox search, using the given MIME charset (NIL means the default, US-ASCII) and the given search program. A search program is a structure that holds the following data: SEARCHSET *msgno; a set of message sequence numbers SEARCHSET *uid; a set of unique identifiers SEARCHOR *or; OR result of two search programs SEARCHPGMLIST *not; AND result of list of NOT'ed search programs SEARCHHEADER *header; message headers STRINGLIST *bcc; string(s) appear in bcc list STRINGLIST *body; string(s) appear in message body text STRINGLIST *cc; string(s) appear in cc list STRINGLIST *from; string(s) appear in from STRINGLIST *keyword; user flag string(s) set STRINGLIST *unkeyword; user flag strings() not set STRINGLIST *subject; string(s) appear in subject STRINGLIST *text; string(s) appear in message header or body STRINGLIST *to; string(s) appear in to list unsigned long larger; larger than this many octets unsigned long smaller; smaller than this many octes The following dates are in form: ((year - BASEYEAR) << 9) + (month << 5) + day unsigned short sentbefore; sent before this date unsigned short senton; sent on this date unsigned short sentsince; sent since this date unsigned short before; received before this date unsigned short on; received on this date unsigned short since; received since this date unsigned int answered : 1; message answered unsigned int unanswered : 1; message not answered unsigned int deleted : 1; message deleted unsigned int undeleted : 1; message not deleted unsigned int draft : 1; message is a draft unsigned int undraft : 1; message is not a draft unsigned int flagged : 1; message flagged as urgent unsigned int unflagged : 1; message not flagged as urgent unsigned int recent : 1; message recent since last parse of mailbox unsigned int old : 1; message not recent since last parse of mailbox unsigned int seen : 1; message read unsigned int unseen : 1; message not read The following auxillary structures are used by search programs: SEARCHHEADER: header line searching char *line; header line field name char *text; text header line SEARCHHEADER *next; next SEARCHHEADER in list (AND'ed) SEARCHSET: message number set unsigned long first; first number in set unsigned long last; if non-zero, last number in set SEARCHSET *next; next SEARCHSET in list (AND'ed) SEARCHOR: two search programs, OR'ed together SEARCHPGM *first; first program SEARCHPGM *second; second program SEARCHOR *next; next SEARCHOR in list SEARCHPGMLIST: list of search programs SEARCHPGM *pgm; search program (AND'd with others in list) SEARCHPGMLIST *next; next SEARCHPGM in list mail_search(), the older interface, accepts a search criteria argument as a character string in IMAP2 (RFC-1176) format. Do not try to use any IMAP4 search criteria with this interface. The application's mm_searched() function is called for each message that matches the search criteria. In addition, after the search is completed, the "fast" information (see mail_fetchfast_full() and envelopes of the searched messages are fetched (this is called pre-fetching). If there is any problem in searching, a message will be passed to the application via the mm_log() facility. The flags for mail_search_full() are a bit mask with one or more of the following: SE_UID Return UIDs instead of sequence numbers SE_FREE Return the search program to free storage after finishing SE_NOPREFETCH Don't prefetch searched messages. unsigned long *mail_sort (MAILSTREAM *stream,char *charset,SEARCHPGM *spg, SORTPGM *pgm,long flags); stream stream to sort charset MIME character set to use when sorting strings spg search program pgm sort program flags option flags This function is a variant of mail_search_full(). It accepts an additional argument, a sort program, which specifies one or more sort rules to be applied to the result. If the searching and sorting are successful, it returns a 0-terminated vector of message sequence numbers (or UIDs if SE_UID is set). This vector is created out of free storage, and must be freed with fs_give() when finished with it. A sort program is a structure that holds the following data: unsigned int reverse : 1; reverse sorting of this key short function; sort rule, one of the following: SORTDATE message Date SORTARRIVAL arrival date SORTFROM mailbox in first From address SORTSUBJECT message Subject SORTTO mailbox in first To address SORTCC mailbox in first cc address SORTSIZE size of message in octets SORTPGM *next; next sort program to be applied if two or more messages collate identically with this rule The flags for mail_search_full() are a bit mask with one or more of the following: SE_UID Return UIDs instead of sequence numbers SE_FREE Return the search program to free storage after finishing SE_NOPREFETCH Don't prefetch searched messages. SO_FREE Return the sort program to free storage after finishing