int is_not = 0;
int is_or = 0;
int pos = 0;
+ int i;
+ char *fieldptr;
if (num_items == 0) return(0);
}
else if (!strcasecmp(itemlist[pos], "ANSWERED")) {
- /* FIXME */
+ if (IMAP->flags[seq-1] & IMAP_ANSWERED) {
+ match = 1;
+ }
++pos;
}
else if (!strcasecmp(itemlist[pos], "BCC")) {
- /* FIXME */
+ fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Bcc");
+ if (fieldptr != NULL) {
+ if (bmstrstr(fieldptr, itemlist[pos+1], strncasecmp)) {
+ match = 1;
+ }
+ free(fieldptr);
+ }
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "BEFORE")) {
- /* FIXME */
+ if (msg->cm_fields['T'] != NULL) {
+ if (imap_datecmp(itemlist[pos+1],
+ atol(msg->cm_fields['T'])) < 0) {
+ match = 1;
+ }
+ }
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "BODY")) {
- if (bmstrcasestr(msg->cm_fields['M'], itemlist[pos+1])) {
+ if (bmstrstr(msg->cm_fields['M'], itemlist[pos+1], strncasecmp)) {
match = 1;
}
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "CC")) {
- /* FIXME */
+ fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Cc");
+ if (fieldptr != NULL) {
+ if (bmstrstr(fieldptr, itemlist[pos+1], strncasecmp)) {
+ match = 1;
+ }
+ free(fieldptr);
+ }
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "DELETED")) {
- /* FIXME */
+ if (IMAP->flags[seq-1] & IMAP_DELETED) {
+ match = 1;
+ }
++pos;
}
else if (!strcasecmp(itemlist[pos], "DRAFT")) {
- /* FIXME */
+ if (IMAP->flags[seq-1] & IMAP_DRAFT) {
+ match = 1;
+ }
++pos;
}
else if (!strcasecmp(itemlist[pos], "FLAGGED")) {
- /* FIXME */
+ if (IMAP->flags[seq-1] & IMAP_FLAGGED) {
+ match = 1;
+ }
++pos;
}
else if (!strcasecmp(itemlist[pos], "FROM")) {
- /* FIXME */
+ if (bmstrstr(msg->cm_fields['A'], itemlist[pos+1], strncasecmp)) {
+ match = 1;
+ }
pos += 2;
}
}
else if (!strcasecmp(itemlist[pos], "LARGER")) {
- /* FIXME */
+ if (strlen(msg->cm_fields['M']) > atoi(itemlist[pos+1])) {
+ match = 1;
+ }
pos += 2;
}
}
else if (!strcasecmp(itemlist[pos], "ON")) {
- /* FIXME */
+ if (msg->cm_fields['T'] != NULL) {
+ if (imap_datecmp(itemlist[pos+1],
+ atol(msg->cm_fields['T'])) == 0) {
+ match = 1;
+ }
+ }
pos += 2;
}
}
else if (!strcasecmp(itemlist[pos], "SEEN")) {
- /* FIXME */
+ if (IMAP->flags[seq-1] & IMAP_SEEN) {
+ match = 1;
+ }
++pos;
}
else if (!strcasecmp(itemlist[pos], "SENTBEFORE")) {
- /* FIXME */
+ if (msg->cm_fields['T'] != NULL) {
+ if (imap_datecmp(itemlist[pos+1],
+ atol(msg->cm_fields['T'])) < 0) {
+ match = 1;
+ }
+ }
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "SENTON")) {
- /* FIXME */
+ if (msg->cm_fields['T'] != NULL) {
+ if (imap_datecmp(itemlist[pos+1],
+ atol(msg->cm_fields['T'])) == 0) {
+ match = 1;
+ }
+ }
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "SENTSINCE")) {
- /* FIXME */
+ if (msg->cm_fields['T'] != NULL) {
+ if (imap_datecmp(itemlist[pos+1],
+ atol(msg->cm_fields['T'])) >= 0) {
+ match = 1;
+ }
+ }
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "SINCE")) {
- /* FIXME */
+ if (msg->cm_fields['T'] != NULL) {
+ if (imap_datecmp(itemlist[pos+1],
+ atol(msg->cm_fields['T'])) >= 0) {
+ match = 1;
+ }
+ }
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "SMALLER")) {
- /* FIXME */
+ if (strlen(msg->cm_fields['M']) < atoi(itemlist[pos+1])) {
+ match = 1;
+ }
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "SUBJECT")) {
- /* FIXME */
+ if (bmstrstr(msg->cm_fields['U'], itemlist[pos+1], strncasecmp)) {
+ match = 1;
+ }
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "TEXT")) {
- /* FIXME */
+ for (i='A'; i<='Z'; ++i) {
+ if (bmstrstr(msg->cm_fields[i], itemlist[pos+1], strncasecmp)) {
+ match = 1;
+ }
+ }
pos += 2;
}
else if (!strcasecmp(itemlist[pos], "TO")) {
- /* FIXME */
+ if (bmstrstr(msg->cm_fields['R'], itemlist[pos+1], strncasecmp)) {
+ match = 1;
+ }
pos += 2;
}
*/
else if (!strcasecmp(itemlist[pos], "UNANSWERED")) {
- /* FIXME */
+ if ((IMAP->flags[seq-1] & IMAP_ANSWERED) == 0) {
+ match = 1;
+ }
++pos;
}
else if (!strcasecmp(itemlist[pos], "UNDELETED")) {
- /* FIXME */
+ if ((IMAP->flags[seq-1] & IMAP_DELETED) == 0) {
+ match = 1;
+ }
++pos;
}
else if (!strcasecmp(itemlist[pos], "UNDRAFT")) {
- /* FIXME */
+ if ((IMAP->flags[seq-1] & IMAP_DRAFT) == 0) {
+ match = 1;
+ }
++pos;
}
else if (!strcasecmp(itemlist[pos], "UNFLAGGED")) {
- /* FIXME */
+ if ((IMAP->flags[seq-1] & IMAP_FLAGGED) == 0) {
+ match = 1;
+ }
++pos;
}
}
else if (!strcasecmp(itemlist[pos], "UNSEEN")) {
- /* FIXME */
+ if ((IMAP->flags[seq-1] & IMAP_SEEN) == 0) {
+ match = 1;
+ }
++pos;
}
CtdlFreeMessage(msg);
}
else {
- lprintf(1, "SEARCH internal error\n");
+ lprintf(CTDL_ERR, "SEARCH internal error\n");
}
}
cprintf("\r\n");