100
100
arg->value.mailbox_glob =
101
101
imap_match_init(default_pool, arg->value.str,
102
TRUE, mail_namespace_get_sep(ns));
105
105
case SEARCH_INTHREAD:
110
110
struct mail_search_args, 1);
111
111
thread_args->pool = args->pool;
112
112
thread_args->args = arg->value.subargs;
113
thread_args->charset = args->charset;
114
113
thread_args->simplified = TRUE;
115
114
/* simplification should have unnested all
116
115
inthreads, so we'll assume that
158
157
case SEARCH_KEYWORDS:
159
158
if (arg->value.keywords == NULL)
161
mailbox_keywords_unref(args->box, &arg->value.keywords);
160
mailbox_keywords_unref(&arg->value.keywords);
163
162
case SEARCH_MAILBOX_GLOB:
164
163
if (arg->value.mailbox_glob == NULL)
267
266
new_arg = p_new(pool, struct mail_search_arg, 1);
268
267
new_arg->type = arg->type;
269
new_arg->not = arg->not;
268
new_arg->match_not = arg->match_not;
270
269
new_arg->match_always = arg->match_always;
271
270
new_arg->nonmatch_always = arg->nonmatch_always;
272
271
new_arg->value.search_flags = arg->value.search_flags;
344
341
struct mail_search_args *new_args;
346
343
new_args = mail_search_build_init();
347
new_args->charset = p_strdup(new_args->pool, args->charset);
348
344
new_args->simplified = args->simplified;
349
345
new_args->have_inthreads = args->have_inthreads;
350
346
new_args->args = mail_search_arg_dup(new_args->pool, args->args);
409
405
subarg = subarg->next;
411
if (arg->not && arg->result != -1)
407
if (arg->match_not && arg->result != -1)
412
408
arg->result = !arg->result;
413
409
} else if (arg->type == SEARCH_OR) {
414
410
/* OR-list of conditions */
561
555
case SEARCH_MAILBOX:
562
556
ret = strcmp(arg->value.str, vname) == 0;
563
return ret != arg->not;
557
return ret != arg->match_not;
564
558
case SEARCH_MAILBOX_GLOB: {
566
560
struct imap_match_glob *glob;
569
563
arg->value.str, TRUE, sep);
570
564
ret = imap_match(glob, vname) == IMAP_MATCH_YES;
572
return ret != arg->not;
566
return ret != arg->match_not;
619
613
new_kw = mailbox_keywords_create_from_indexes(box,
622
mailbox_keywords_unref(box, _kw1);
623
mailbox_keywords_unref(box, _kw2);
616
mailbox_keywords_unref(_kw1);
617
mailbox_keywords_unref(_kw2);
635
629
prev_flags_arg = prev_not_flags_arg = NULL;
636
630
prev_kw_arg = prev_not_kw_arg = NULL;
637
631
while (args != NULL) {
638
if (args->not && (args->type == SEARCH_SUB ||
639
args->type == SEARCH_OR)) {
632
if (args->match_not && (args->type == SEARCH_SUB ||
633
args->type == SEARCH_OR)) {
640
634
/* neg(p and q and ..) == neg(p) or neg(q) or ..
641
635
neg(p or q or ..) == neg(p) and neg(q) and .. */
642
636
args->type = args->type == SEARCH_SUB ?
643
637
SEARCH_OR : SEARCH_SUB;
638
args->match_not = FALSE;
645
639
sub = args->value.subargs;
647
sub->not = !sub->not;
641
sub->match_not = !sub->match_not;
649
643
} while (sub != NULL);
673
667
/* merge all flags arguments */
674
if (args->type == SEARCH_FLAGS && !args->not && parent_and) {
668
if (args->type == SEARCH_FLAGS &&
669
!args->match_not && parent_and) {
675
670
if (prev_flags_arg == NULL)
676
671
prev_flags_arg = args;
895
889
i_assert(args1->simplified == args2->simplified);
896
890
i_assert(args1->box == args2->box);
898
if (null_strcmp(args1->charset, args2->charset) != 0)
901
892
return mail_search_arg_equals(args1->args, args2->args);
896
mail_search_args_result_serialize_arg(const struct mail_search_arg *arg,
899
const struct mail_search_arg *subarg;
901
buffer_append_c(dest, arg->result < 0 ? 0xff : arg->result);
906
case SEARCH_INTHREAD:
907
subarg = arg->value.subargs;
908
for (; subarg != NULL; subarg = subarg->next)
909
mail_search_args_result_serialize_arg(subarg, dest);
915
void mail_search_args_result_serialize(const struct mail_search_args *args,
918
mail_search_args_result_serialize_arg(args->args, dest);
922
mail_search_args_result_deserialize_arg(struct mail_search_arg *arg,
923
const unsigned char **data,
926
struct mail_search_arg *subarg;
929
arg->result = **data == 0xff ? -1 : **data;
930
*data += 1; *size -= 1;
935
case SEARCH_INTHREAD:
936
subarg = arg->value.subargs;
937
for (; subarg != NULL; subarg = subarg->next) {
938
mail_search_args_result_deserialize_arg(subarg,
946
void mail_search_args_result_deserialize(struct mail_search_args *args,
947
const unsigned char *data, size_t size)
949
mail_search_args_result_deserialize_arg(args->args, &data, &size);