6 |
#include <stdlib.h> |
#include <stdlib.h> |
7 |
#include <limits.h> |
#include <limits.h> |
8 |
#include <sys/stat.h> |
#include <sys/stat.h> |
9 |
|
#include <ctype.h> |
10 |
|
|
11 |
#include "config.h" |
#include "config.h" |
12 |
#include "imapfilter.h" |
#include "imapfilter.h" |
310 |
node->key[s] = 0; |
node->key[s] = 0; |
311 |
|
|
312 |
if (match[2].rm_eo - match[2].rm_so) { |
if (match[2].rm_eo - match[2].rm_so) { |
313 |
if (!strncmp(line + match[2].rm_so + 1, "OR", 2)) |
if (*(line + match[2].rm_so + 1) == 'o' || *(line + match[2].rm_so + 1) == 'O') |
314 |
node->mode = FILTER_MODE_OR; |
node->mode = FILTER_MODE_OR; |
315 |
else |
else |
316 |
node->mode = FILTER_MODE_AND; |
node->mode = FILTER_MODE_AND; |
406 |
init_mask(node); |
init_mask(node); |
407 |
|
|
408 |
if ((match[2].rm_eo - match[2].rm_so) && cur_fltr->masks) { |
if ((match[2].rm_eo - match[2].rm_so) && cur_fltr->masks) { |
409 |
if (!strncmp(line + match[2].rm_so, "OR", 2)) |
if (*(line + match[2].rm_so) == 'o' || *(line + match[2].rm_so) == 'O') |
410 |
node->type = MASK_TYPE_OR; |
node->type = MASK_TYPE_OR; |
411 |
else |
else |
412 |
node->type = MASK_TYPE_AND; |
node->type = MASK_TYPE_AND; |
415 |
if (match[3].rm_eo - match[3].rm_so) { |
if (match[3].rm_eo - match[3].rm_so) { |
416 |
s = min(match[3].rm_eo - match[3].rm_so, MASK_BODY_LEN - len - 1); |
s = min(match[3].rm_eo - match[3].rm_so, MASK_BODY_LEN - len - 1); |
417 |
strncpy(node->body + len, line + match[3].rm_so, s); |
strncpy(node->body + len, line + match[3].rm_so, s); |
418 |
|
upper_case(node->body + len, s); /* XXX */ |
419 |
node->body[len + s - 1] = ' '; /* In case it's '\t'. */ |
node->body[len + s - 1] = ' '; /* In case it's '\t'. */ |
420 |
node->body[len + s] = 0; |
node->body[len + s] = 0; |
421 |
len = strlen(node->body); |
len = strlen(node->body); |
423 |
|
|
424 |
s = min(match[4].rm_eo - match[4].rm_so, MASK_BODY_LEN - len - 1); |
s = min(match[4].rm_eo - match[4].rm_so, MASK_BODY_LEN - len - 1); |
425 |
strncpy(node->body + len, line + match[4].rm_so, s); |
strncpy(node->body + len, line + match[4].rm_so, s); |
426 |
|
upper_case(node->body + len, s); |
427 |
node->body[len + s] = 0; |
node->body[len + s] = 0; |
428 |
len = strlen(node->body); |
len = strlen(node->body); |
429 |
|
|
517 |
while (cmg->mboxes[i]->filters[j]) { |
while (cmg->mboxes[i]->filters[j]) { |
518 |
if (i == MBOX_FILTERS_MAX) |
if (i == MBOX_FILTERS_MAX) |
519 |
return 1; |
return 1; |
520 |
|
if (!strncmp(cf->key, cmg->mboxes[i]->filters[j]->key, KEY_LEN)) |
521 |
|
return 0; |
522 |
j++; |
j++; |
523 |
} |
} |
524 |
|
|
563 |
|
|
564 |
delete_mboxgrp(node); |
delete_mboxgrp(node); |
565 |
} |
} |
566 |
|
|
567 |
|
|
568 |
|
/* |
569 |
|
* Convert a string of specified size to upper case. |
570 |
|
*/ |
571 |
|
void upper_case(char *str, size_t size) |
572 |
|
{ |
573 |
|
int i; |
574 |
|
|
575 |
|
for (i = 0; i < size; i++) |
576 |
|
*(str + i) = toupper(*(str + i)); |
577 |
|
} |