98 |
int apply_filters(filter_t ** filters) |
int apply_filters(filter_t ** filters) |
99 |
{ |
{ |
100 |
int i; |
int i; |
101 |
char mesgs[SEARCH_MESSAGES_BUF]; |
char *mesgs; |
102 |
|
|
103 |
for (i = 0; filters[i]; i++) { |
for (i = 0; filters[i]; i++) { |
104 |
|
|
105 |
mesgs[0] = 0; |
if (match_filter(filters[i], &mesgs)) |
|
|
|
|
if (match_filter(filters[i], mesgs)) |
|
106 |
continue; |
continue; |
107 |
|
|
108 |
log_info(LOG_FILTER, filters[i]->key); |
log_info(LOG_FILTER, filters[i]->key); |
109 |
|
|
110 |
|
|
111 |
apply_action(mesgs, &(filters[i]->action.type), |
apply_action(mesgs, &(filters[i]->action.type), |
112 |
filters[i]->action.destmbox, filters[i]->action.args); |
filters[i]->action.destmbox, filters[i]->action.args); |
113 |
|
|
114 |
|
free(mesgs); |
115 |
} |
} |
116 |
|
|
117 |
return 0; |
return 0; |
122 |
* Generate the search request by the masks of the filter and try to |
* Generate the search request by the masks of the filter and try to |
123 |
* match the generated filter. |
* match the generated filter. |
124 |
*/ |
*/ |
125 |
int match_filter(filter_t * filter, char *mesgs) |
int match_filter(filter_t * filter, char **mesgs) |
126 |
{ |
{ |
127 |
char *search; |
char *search; |
128 |
|
|
137 |
|
|
138 |
free(search); |
free(search); |
139 |
|
|
140 |
if (!*mesgs) |
if (!**mesgs) |
141 |
return 1; |
return 1; |
142 |
|
|
143 |
return 0; |
return 0; |
209 |
len += 4; |
len += 4; |
210 |
} else |
} else |
211 |
while ((tmp = tmp->next)) { |
while ((tmp = tmp->next)) { |
212 |
if (tmp->type != MASK_TYPE_OR) { |
if (tmp->type != MASK_TYPE_OR) { |
213 |
strncat(search, "ALL ", searchbuf - len - 1); |
strncat(search, "ALL ", searchbuf - len - 1); |
214 |
len += 4; |
len += 4; |
215 |
break; |
break; |
216 |
|
} |
217 |
} |
} |
|
} |
|
218 |
|
|
219 |
tmp = NULL; |
tmp = NULL; |
220 |
while (mask) { |
while (mask) { |
500 |
end++; |
end++; |
501 |
else { |
else { |
502 |
if (start == end) |
if (start == end) |
503 |
snprintf(mesgs + len, SEARCH_MESSAGES_BUF - len - 1, "%d ", |
snprintf(mesgs + len, strlen(mesgs) - len - 1, "%d ", |
504 |
start); |
start); |
505 |
else |
else |
506 |
snprintf(mesgs + len, SEARCH_MESSAGES_BUF - len - 1, |
snprintf(mesgs + len, strlen(mesgs) - len - 1, |
507 |
"%d:%d ", start, end); |
"%d:%d ", start, end); |
508 |
|
|
509 |
len = strlen(mesgs); |
len = strlen(mesgs); |