221 |
unsigned int i = 0; |
unsigned int i = 0; |
222 |
char *tok; |
char *tok; |
223 |
|
|
224 |
while (i < MBOXGRP_MBOXES_MAX - 1 && (tok = strsep(&mboxs, ","))) { |
tok = strtok_r(mboxs, ",", &mboxs); |
225 |
|
while (i < MBOXGRP_MBOXES_MAX - 1 && tok) { |
226 |
node->mboxes[i] = (mbox_t *) set_mbox(tok); |
node->mboxes[i] = (mbox_t *) set_mbox(tok); |
227 |
node->mboxes[++i] = NULL; |
node->mboxes[++i] = NULL; |
228 |
|
|
229 |
|
tok = strtok_r(NULL, ",", &mboxs); |
230 |
} |
} |
231 |
} |
} |
232 |
|
|
301 |
node->left = node->right = NULL; |
node->left = node->right = NULL; |
302 |
node->key[0] = 0; |
node->key[0] = 0; |
303 |
node->mode = FILTER_MODE_AND; |
node->mode = FILTER_MODE_AND; |
304 |
node->action.type = 0; |
node->action.type = node->action.msgflags = 0; |
305 |
node->action.raccount = NULL; |
node->action.raccount = NULL; |
306 |
node->action.destmbox[0] = node->action.args[0] = 0; |
node->action.destmbox[0] = node->action.args[0] = 0; |
307 |
node->masks = NULL; |
node->masks = NULL; |
437 |
|
|
438 |
c = cp = (char *)malloc(match[9].rm_eo - match[9].rm_so + 1); |
c = cp = (char *)malloc(match[9].rm_eo - match[9].rm_so + 1); |
439 |
xstrncpy(c, line + match[9].rm_so, match[9].rm_eo - match[9].rm_so); |
xstrncpy(c, line + match[9].rm_so, match[9].rm_eo - match[9].rm_so); |
440 |
while ((t = strsep(&c, ","))) { |
|
441 |
|
t = strtok_r(c, ",", &c); |
442 |
|
while (t) { |
443 |
if (!strcasecmp(t, "none")) { |
if (!strcasecmp(t, "none")) { |
444 |
if (match[9].rm_eo - match[9].rm_so != strlen("none")) |
if (match[9].rm_eo - match[9].rm_so != strlen("none")) |
445 |
return ERROR_CONFIG_PARSE; |
return ERROR_CONFIG_PARSE; |
455 |
cur_fltr->action.msgflags |= MESSAGE_FLAG_DRAFT; |
cur_fltr->action.msgflags |= MESSAGE_FLAG_DRAFT; |
456 |
else |
else |
457 |
return ERROR_CONFIG_PARSE; |
return ERROR_CONFIG_PARSE; |
458 |
|
|
459 |
|
t = strtok_r(NULL, ",", &c); |
460 |
} |
} |
461 |
xfree(cp); |
xfree(cp); |
462 |
} else if (!strncasecmp(line + match[1].rm_so, "list", 4)) { |
} else if (!strncasecmp(line + match[1].rm_so, "list", 4)) { |
470 |
} |
} |
471 |
#ifdef DEBUG |
#ifdef DEBUG |
472 |
printf("debug: ACTION: %d '%s' '%s' %d '%s'\n", cur_fltr->action.type, |
printf("debug: ACTION: %d '%s' '%s' %d '%s'\n", cur_fltr->action.type, |
473 |
cur_fltr->action.raccount->key, cur_fltr->action.destmbox, |
(cur_fltr->action.raccount ? cur_fltr->action.raccount->key : ""), |
474 |
cur_fltr->action.msgflags, cur_fltr->action.args); |
cur_fltr->action.destmbox, cur_fltr->action.msgflags, |
475 |
|
cur_fltr->action.args); |
476 |
#endif |
#endif |
477 |
return 0; |
return 0; |
|
|
|
478 |
} |
} |
479 |
|
|
480 |
|
|
585 |
bp = node->body + strlen(node->body); |
bp = node->body + strlen(node->body); |
586 |
} |
} |
587 |
} |
} |
|
/* for (i = 5; i <= 6; i++) |
|
|
if (match[i].rm_so != -1) { |
|
|
*(bp++) = ' '; |
|
|
|
|
|
if (match[6].rm_so == -1 && |
|
|
(strstr(node->body, "LARGER") || |
|
|
strstr(node->body, "SMALLER") || |
|
|
strstr(node->body, "OLDER") || |
|
|
strstr(node->body, "NEWER"))) |
|
|
f = 1; |
|
|
else if (*(line + match[i].rm_so) != '"') |
|
|
*(bp++) = '"'; |
|
|
|
|
|
*bp = 0; |
|
|
|
|
|
n = min(match[i].rm_eo - match[i].rm_so, |
|
|
MASK_BODY_LEN - (bp - node->body) - 2); |
|
|
xstrncpy(bp, line + match[i].rm_so, n); |
|
|
*(bp + n) = 0; |
|
|
bp += n; |
|
|
|
|
|
if (*(line + match[i].rm_so) != '"' && !f) |
|
|
*(bp++) = '"'; |
|
|
*bp = 0; |
|
|
} |
|
|
if (f && (strstr(node->body, "OLDER") || strstr(node->body, "NEWER"))) { |
|
|
convert_date(node); |
|
|
bp = node->body + strlen(node->body); |
|
|
}*/ |
|
|
|
|
588 |
append_mask(node); |
append_mask(node); |
589 |
|
|
590 |
cur_fltr->masknum++; |
cur_fltr->masknum++; |
657 |
mbgrp = (char *)xmalloc(n + 1); |
mbgrp = (char *)xmalloc(n + 1); |
658 |
|
|
659 |
/* Go through filters. */ |
/* Go through filters. */ |
660 |
while ((ftok = strsep(&f, ","))) { |
ftok = strtok_r(f, ",", &f); |
661 |
|
while (ftok) { |
662 |
cf = (filter_t *) find_filter(ftok); |
cf = (filter_t *) find_filter(ftok); |
663 |
if (!cf) |
if (!cf) |
664 |
return ERROR_CONFIG_PARSE; |
return ERROR_CONFIG_PARSE; |
667 |
g[n] = 0; |
g[n] = 0; |
668 |
|
|
669 |
/* Go through mailbox groups. */ |
/* Go through mailbox groups. */ |
670 |
while ((gtok = strsep(&g, ","))) { |
gtok = strtok_r(g, ",", &g); |
671 |
|
while (gtok) { |
672 |
cg = (mboxgrp_t *) find_mboxgrp(gtok); |
cg = (mboxgrp_t *) find_mboxgrp(gtok); |
673 |
if (!cg) |
if (!cg) |
674 |
return ERROR_CONFIG_PARSE; |
return ERROR_CONFIG_PARSE; |
675 |
link_mbox_filter(cf, cg); |
link_mbox_filter(cf, cg); |
676 |
|
|
677 |
|
gtok = strtok_r(NULL, ",", &g); |
678 |
} |
} |
679 |
|
|
680 |
|
ftok = strtok_r(NULL, ",", &f); |
681 |
} |
} |
682 |
|
|
683 |
xfree(fltr); |
xfree(fltr); |
729 |
*/ |
*/ |
730 |
void destroy_mboxgrp(mboxgrp_t * node) |
void destroy_mboxgrp(mboxgrp_t * node) |
731 |
{ |
{ |
732 |
|
if (!node) |
733 |
|
return; |
734 |
|
|
735 |
if (node->left) { |
if (node->left) { |
736 |
destroy_mboxgrp(node->left); |
destroy_mboxgrp(node->left); |
737 |
node->left = NULL; |
node->left = NULL; |
774 |
|
|
775 |
while (*c) { |
while (*c) { |
776 |
if (*c == '%') { |
if (*c == '%') { |
777 |
if (!isxdigit(*(c + 1)) || !isxdigit(*(c + 2))) |
if (!isxdigit((unsigned char)(*(c + 1))) || |
778 |
|
!isxdigit((unsigned char)(*(c + 2)))) |
779 |
return ERROR_CONFIG_PARSE; |
return ERROR_CONFIG_PARSE; |
780 |
|
|
781 |
xstrncpy(hex, ++c, 2); |
xstrncpy(hex, ++c, 2); |
782 |
hex[2] = 0; |
hex[2] = 0; |
783 |
|
|
784 |
if (!isprint(*str = (char)strtoul(hex, NULL, 16))) |
if (!isprint((unsigned char)(*str = (char)strtoul(hex, NULL, 16)))) |
785 |
return ERROR_CONFIG_PARSE; |
return ERROR_CONFIG_PARSE; |
786 |
|
|
787 |
str++; |
str++; |