added missing <message set> condition
Showing
1 changed file
with
37 additions
and
8 deletions
... | @@ -44,6 +44,7 @@ static void cond_or __P((struct parsebuf *pb)); | ... | @@ -44,6 +44,7 @@ static void cond_or __P((struct parsebuf *pb)); |
44 | static void cond_not __P((struct parsebuf *pb)); | 44 | static void cond_not __P((struct parsebuf *pb)); |
45 | 45 | ||
46 | static void cond_all __P((struct parsebuf *pb)); | 46 | static void cond_all __P((struct parsebuf *pb)); |
47 | static void cond_msgset __P((struct parsebuf *pb)); | ||
47 | static void cond_bcc __P((struct parsebuf *pb)); | 48 | static void cond_bcc __P((struct parsebuf *pb)); |
48 | static void cond_before __P((struct parsebuf *pb)); | 49 | static void cond_before __P((struct parsebuf *pb)); |
49 | static void cond_body __P((struct parsebuf *pb)); | 50 | static void cond_body __P((struct parsebuf *pb)); |
... | @@ -77,7 +78,7 @@ struct cond | ... | @@ -77,7 +78,7 @@ struct cond |
77 | m -- message set | 78 | m -- message set |
78 | */ | 79 | */ |
79 | 80 | ||
80 | /* List of basic conditions */ | 81 | /* List of basic conditions. <message set> is handled separately */ |
81 | struct cond condlist[] = | 82 | struct cond condlist[] = |
82 | { | 83 | { |
83 | "ALL", NULL, cond_all, | 84 | "ALL", NULL, cond_all, |
... | @@ -170,7 +171,9 @@ struct parsebuf | ... | @@ -170,7 +171,9 @@ struct parsebuf |
170 | int *stack; /* Stack buffer. */ | 171 | int *stack; /* Stack buffer. */ |
171 | int tos; /* Top of stack */ | 172 | int tos; /* Top of stack */ |
172 | 173 | ||
173 | message_t msg; /* Execution time only: current message */ | 174 | /* Execution time only: */ |
175 | size_t msgno; /* Number of current message */ | ||
176 | message_t msg; /* Current message */ | ||
174 | }; | 177 | }; |
175 | 178 | ||
176 | static void put_code __P((struct parsebuf *pb, inst_t inst)); | 179 | static void put_code __P((struct parsebuf *pb, inst_t inst)); |
... | @@ -237,18 +240,18 @@ imap4d_search (struct imap4d_command *command, char *arg) | ... | @@ -237,18 +240,18 @@ imap4d_search (struct imap4d_command *command, char *arg) |
237 | void | 240 | void |
238 | do_search (struct parsebuf *pb) | 241 | do_search (struct parsebuf *pb) |
239 | { | 242 | { |
240 | size_t i, count = 0; | 243 | size_t count = 0; |
241 | size_t *set = NULL; | 244 | size_t *set = NULL; |
242 | int n = 0; | 245 | int n = 0; |
243 | 246 | ||
244 | mailbox_messages_count (mbox, &count); | 247 | mailbox_messages_count (mbox, &count); |
245 | 248 | ||
246 | util_send ("* SEARCH"); | 249 | util_send ("* SEARCH"); |
247 | for (i = 1; i <= count; i++) | 250 | for (pb->msgno = 1; pb->msgno <= count; pb->msgno++) |
248 | { | 251 | { |
249 | if (mailbox_get_message (mbox, i, &pb->msg) == 0 | 252 | if (mailbox_get_message (mbox, pb->msgno, &pb->msg) == 0 |
250 | && search_run (pb)) | 253 | && search_run (pb)) |
251 | util_send (" %d", i); | 254 | util_send (" %d", pb->msgno); |
252 | } | 255 | } |
253 | util_send ("\r\n"); | 256 | util_send ("\r\n"); |
254 | } | 257 | } |
... | @@ -452,6 +455,8 @@ parse_simple_key (struct parsebuf *pb) | ... | @@ -452,6 +455,8 @@ parse_simple_key (struct parsebuf *pb) |
452 | struct cond *condp; | 455 | struct cond *condp; |
453 | char *t; | 456 | char *t; |
454 | time_t time; | 457 | time_t time; |
458 | size_t *set = NULL; | ||
459 | int n = 0; | ||
455 | 460 | ||
456 | for (condp = condlist; condp->name && strcasecmp (condp->name, pb->token); | 461 | for (condp = condlist; condp->name && strcasecmp (condp->name, pb->token); |
457 | condp++) | 462 | condp++) |
... | @@ -459,8 +464,19 @@ parse_simple_key (struct parsebuf *pb) | ... | @@ -459,8 +464,19 @@ parse_simple_key (struct parsebuf *pb) |
459 | 464 | ||
460 | if (!condp->name) | 465 | if (!condp->name) |
461 | { | 466 | { |
462 | pb->err_mesg = "Unknown search criterion"; | 467 | if (util_msgset (pb->token, &set, &n, 0) == 0) /*FIXME: isuid? */ |
463 | return 1; | 468 | { |
469 | put_code (pb, cond_msgset); | ||
470 | put_code (pb, (inst_t) n); | ||
471 | put_code (pb, (inst_t) parse_regmem (pb, set)); | ||
472 | parse_gettoken (pb, 0); | ||
473 | return 0; | ||
474 | } | ||
475 | else | ||
476 | { | ||
477 | pb->err_mesg = "Unknown search criterion"; | ||
478 | return 1; | ||
479 | } | ||
464 | } | 480 | } |
465 | 481 | ||
466 | put_code (pb, condp->inst); | 482 | put_code (pb, condp->inst); |
... | @@ -707,6 +723,19 @@ cond_all (struct parsebuf *pb) | ... | @@ -707,6 +723,19 @@ cond_all (struct parsebuf *pb) |
707 | } | 723 | } |
708 | 724 | ||
709 | void | 725 | void |
726 | cond_msgset (struct parsebuf *pb) | ||
727 | { | ||
728 | int n = (int)_search_arg (pb); | ||
729 | size_t *set = (size_t*)_search_arg (pb); | ||
730 | int i, rc; | ||
731 | |||
732 | for (i = rc = 0; rc == 0 && i < n; i++) | ||
733 | rc = set[i] == pb->msgno; | ||
734 | |||
735 | _search_push (pb, rc); | ||
736 | } | ||
737 | |||
738 | void | ||
710 | cond_bcc (struct parsebuf *pb) | 739 | cond_bcc (struct parsebuf *pb) |
711 | { | 740 | { |
712 | _search_push (pb, _scan_header (pb, "bcc", _search_arg (pb))); | 741 | _search_push (pb, _scan_header (pb, "bcc", _search_arg (pb))); | ... | ... |
-
Please register or sign in to post a comment