/[imapfilter]/imapfilter/filter.c
ViewVC logotype

Diff of /imapfilter/filter.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3.2.4 by lefcha, Sat Dec 6 20:51:33 2003 UTC revision 1.11 by lefcha, Sat Feb 14 19:14:43 2004 UTC
# Line 19  extern mboxgrp_t *mboxgrps; Line 19  extern mboxgrp_t *mboxgrps;
19    
20  filter_t *filters = NULL;       /* First node of filters tree. */  filter_t *filters = NULL;       /* First node of filters tree. */
21    
22  filter_t *cur_fltr = NULL;      /* Current filter. */  filter_t *curfltr = NULL;       /* Current filter. */
23    
24    
25  void init_filter(filter_t * node);  void init_filter(filter_t * f);
26    
27  void init_mask(mask_t * node);  void init_mask(mask_t * m);
28    
29  void link_mbox_filter(filter_t * cf, mboxgrp_t * cg);  void link_mbox_filter(filter_t * cf, mboxgrp_t * cg);
30    
# Line 35  void string_upper(char *str, size_t size Line 35  void string_upper(char *str, size_t size
35   * Set new filter's variables to safe values.   * Set new filter's variables to safe values.
36   */   */
37  void  void
38  init_filter(filter_t * node)  init_filter(filter_t * f)
39  {  {
40          node->left = node->right = NULL;  
41          node->key[0] = '\0';          f->left = f->right = NULL;
42          node->mode = FILTER_MODE_AND;          f->key[0] = '\0';
43          node->action.type = node->action.msgflags = 0;          f->mode = FILTER_MODE_AND;
44          node->action.raccount = NULL;          f->action.type = 0;
45          node->action.destmbox[0] = node->action.args[0] = '\0';          f->action.msgflags = 0;
46          node->masks = NULL;          f->action.raccount = NULL;
47          node->masknum = node->masklen = 0;          f->action.destmbox[0] = '\0';
48            f->action.args[0] = '\0';
49            f->masks = NULL;
50            f->masknum = 0;
51            f->masklen = 0;
52  }  }
53    
54    
# Line 54  init_filter(filter_t * node) Line 58  init_filter(filter_t * node)
58  int  int
59  set_filter(char *line, regmatch_t * m)  set_filter(char *line, regmatch_t * m)
60  {  {
61          filter_t *node;          filter_t *f;
62    
63          if (cur_fltr != NULL && cur_fltr->action.type == 0)          if (curfltr != NULL && curfltr->action.type == 0)
64                  return ERROR_CONFIG_PARSE;                  return ERROR_PARSER;
65    
66          node = (filter_t *) xmalloc(sizeof(filter_t));          f = (filter_t *) xmalloc(sizeof(filter_t));
67    
68          init_filter(node);          init_filter(f);
69    
70          strncat(node->key, line + m[1].rm_so,          strncat(f->key, line + m[1].rm_so, min(m[1].rm_eo - m[1].rm_so,
71              min(m[1].rm_eo - m[1].rm_so, KEY_LEN - 1));              KEY_LEN - 1));
72    
73          if (m[2].rm_so != -1) {          if (m[2].rm_so != -1) {
74                  if (!strncasecmp(line + m[2].rm_so + 1, "or", 2))                  if (!strncasecmp(line + m[2].rm_so + 1, "or", 2))
75                          node->mode = FILTER_MODE_OR;                          f->mode = FILTER_MODE_OR;
76                  else                  else
77                          node->mode = FILTER_MODE_AND;                          f->mode = FILTER_MODE_AND;
78          }          }
79  #ifdef DEBUG          debug("filter: '%s' %s\n", f->key,
80          fprintf(stderr, "debug: FILTER: '%s' %s\n", node->key,              (f->mode == FILTER_MODE_OR ? "or" : "and"));
             (node->mode == FILTER_MODE_OR ? "OR" : "AND"));  
 #endif  
81    
82          INSERT_TREE(filters, node, filter);          INSERT_TREE(filters, f, filter);
83    
84          cur_fltr = node;          curfltr = f;
85    
86          return 0;          return 0;
87  }  }
# Line 94  set_action(char *line, regmatch_t * m) Line 96  set_action(char *line, regmatch_t * m)
96          char *c, *cp, *t;          char *c, *cp, *t;
97          account_t *a;          account_t *a;
98    
99          if (cur_fltr == NULL)          if (curfltr == NULL)
100                  return ERROR_CONFIG_PARSE;                  return ERROR_PARSER;
101    
102          if (!strncasecmp(line + m[1].rm_so, "delete", 6))          if (!strncasecmp(line + m[1].rm_so, "delete", 6))
103                  cur_fltr->action.type = FILTER_ACTION_DELETE;                  curfltr->action.type = ACTION_DELETE;
104          else if (!strncasecmp(line + m[1].rm_so, "copy", 4)) {          else if (!strncasecmp(line + m[1].rm_so, "copy", 4)) {
105                  cur_fltr->action.type = FILTER_ACTION_COPY;                  curfltr->action.type = ACTION_COPY;
106                  if (*(line + m[2].rm_so) == '"' &&                  if (*(line + m[2].rm_so) == '"' &&
107                      *(line + m[2].rm_eo - 1) == '"')                      *(line + m[2].rm_eo - 1) == '"')
108                          strncat(cur_fltr->action.destmbox,                          strncat(curfltr->action.destmbox,
109                              line + m[2].rm_so + 1,                              line + m[2].rm_so + 1,
110                              min(m[2].rm_eo - m[2].rm_so - 2,                              min(m[2].rm_eo - m[2].rm_so - 2,
111                                  MBOX_NAME_LEN - 1));                              MBOX_LEN - 1));
112                  else                  else
113                          strncat(cur_fltr->action.destmbox, line + m[2].rm_so,                          strncat(curfltr->action.destmbox, line + m[2].rm_so,
114                              min(m[2].rm_eo - m[2].rm_so, MBOX_NAME_LEN - 1));                              min(m[2].rm_eo - m[2].rm_so, MBOX_LEN - 1));
115          } else if (!strncasecmp(line + m[1].rm_so, "move", 4)) {          } else if (!strncasecmp(line + m[1].rm_so, "move", 4)) {
116                  cur_fltr->action.type = FILTER_ACTION_MOVE;                  curfltr->action.type = ACTION_MOVE;
117                  if (*(line + m[3].rm_so) == '"' &&                  if (*(line + m[3].rm_so) == '"' &&
118                      *(line + m[3].rm_eo - 1) == '"')                      *(line + m[3].rm_eo - 1) == '"')
119                          strncat(cur_fltr->action.destmbox,                          strncat(curfltr->action.destmbox,
120                              line + m[3].rm_so + 1,                              line + m[3].rm_so + 1,
121                              min(m[3].rm_eo - m[3].rm_so - 2,                              min(m[3].rm_eo - m[3].rm_so - 2,
122                                  MBOX_NAME_LEN - 1));                              MBOX_LEN - 1));
123                  else                  else
124                          strncat(cur_fltr->action.destmbox, line + m[3].rm_so,                          strncat(curfltr->action.destmbox, line + m[3].rm_so,
125                              min(m[3].rm_eo - m[3].rm_so, MBOX_NAME_LEN - 1));                              min(m[3].rm_eo - m[3].rm_so, MBOX_LEN - 1));
126          } else if (!strncasecmp(line + m[1].rm_so, "rcopy", 5)) {          } else if (!strncasecmp(line + m[1].rm_so, "rcopy", 5)) {
127                  cur_fltr->action.type = FILTER_ACTION_RCOPY;                  curfltr->action.type = ACTION_RCOPY;
128                  for (a = accounts; a; a = a->next)                  for (a = accounts; a; a = a->next)
129                          if (!strncasecmp(line + m[4].rm_so, a->key,                          if (!strncasecmp(line + m[4].rm_so, a->key,
130                                  strlen(a->key)))                              strlen(a->key)))
131                                  cur_fltr->action.raccount = a;                                  curfltr->action.raccount = a;
132                  if (!cur_fltr->action.raccount)                  if (!curfltr->action.raccount)
133                          return ERROR_CONFIG_PARSE;                          return ERROR_PARSER;
134    
135                  if (*(line + m[5].rm_so) == '"' &&                  if (*(line + m[5].rm_so) == '"' &&
136                      *(line + m[5].rm_eo - 1) == '"')                      *(line + m[5].rm_eo - 1) == '"')
137                          strncat(cur_fltr->action.destmbox,                          strncat(curfltr->action.destmbox,
138                              line + m[5].rm_so + 1,                              line + m[5].rm_so + 1,
139                              min(m[5].rm_eo - m[5].rm_so - 2,                              min(m[5].rm_eo - m[5].rm_so - 2,
140                                  MBOX_NAME_LEN - 1));                              MBOX_LEN - 1));
141                  else                  else
142                          strncat(cur_fltr->action.destmbox, line + m[5].rm_so,                          strncat(curfltr->action.destmbox, line + m[5].rm_so,
143                              min(m[5].rm_eo - m[5].rm_so, MBOX_NAME_LEN - 1));                              min(m[5].rm_eo - m[5].rm_so, MBOX_LEN - 1));
144          } else if (!strncasecmp(line + m[1].rm_so, "rmove", 5)) {          } else if (!strncasecmp(line + m[1].rm_so, "rmove", 5)) {
145                  cur_fltr->action.type = FILTER_ACTION_RMOVE;                  curfltr->action.type = ACTION_RMOVE;
146                  for (a = accounts; a; a = a->next)                  for (a = accounts; a; a = a->next)
147                          if (!strncasecmp(line + m[6].rm_so, a->key,                          if (!strncasecmp(line + m[6].rm_so, a->key,
148                                  strlen(a->key)))                              strlen(a->key)))
149                                  cur_fltr->action.raccount = a;                                  curfltr->action.raccount = a;
150                  if (!cur_fltr->action.raccount)                  if (!curfltr->action.raccount)
151                          return ERROR_CONFIG_PARSE;                          return ERROR_PARSER;
152    
153                  if (*(line + m[7].rm_so) == '"' &&                  if (*(line + m[7].rm_so) == '"' &&
154                      *(line + m[7].rm_eo - 1) == '"')                      *(line + m[7].rm_eo - 1) == '"')
155                          strncat(cur_fltr->action.destmbox,                          strncat(curfltr->action.destmbox,
156                              line + m[7].rm_so + 1,                              line + m[7].rm_so + 1,
157                              min(m[7].rm_eo - m[7].rm_so - 2,                              min(m[7].rm_eo - m[7].rm_so - 2,
158                                  MBOX_NAME_LEN - 1));                              MBOX_LEN - 1));
159                  else                  else
160                          strncat(cur_fltr->action.destmbox, line + m[7].rm_so,                          strncat(curfltr->action.destmbox, line + m[7].rm_so,
161                              min(m[7].rm_eo - m[7].rm_so, MBOX_NAME_LEN - 1));                              min(m[7].rm_eo - m[7].rm_so, MBOX_LEN - 1));
162          } else if (!strncasecmp(line + m[1].rm_so, "flag", 4)) {          } else if (!strncasecmp(line + m[1].rm_so, "flag", 4)) {
163                  if (!strncasecmp(line + m[8].rm_so, "replace", 7))                  if (!strncasecmp(line + m[8].rm_so, "replace", 7))
164                          cur_fltr->action.type = FILTER_ACTION_FLAG_REPLACE;                          curfltr->action.type = ACTION_FLAG_REPLACE;
165                  else if (!strncasecmp(line + m[8].rm_so, "add", 3))                  else if (!strncasecmp(line + m[8].rm_so, "add", 3))
166                          cur_fltr->action.type = FILTER_ACTION_FLAG_ADD;                          curfltr->action.type = ACTION_FLAG_ADD;
167                  else                  else
168                          cur_fltr->action.type = FILTER_ACTION_FLAG_REMOVE;                          curfltr->action.type = ACTION_FLAG_REMOVE;
169    
170                  c = cp = (char *)malloc(m[9].rm_eo - m[9].rm_so + 1);                  c = cp = (char *)malloc(m[9].rm_eo - m[9].rm_so + 1);
171                  xstrncpy(c, line + m[9].rm_so, m[9].rm_eo - m[9].rm_so);                  xstrncpy(c, line + m[9].rm_so, m[9].rm_eo - m[9].rm_so);
# Line 172  set_action(char *line, regmatch_t * m) Line 174  set_action(char *line, regmatch_t * m)
174                  while (t) {                  while (t) {
175                          if (!strcasecmp(t, "none")) {                          if (!strcasecmp(t, "none")) {
176                                  if (m[9].rm_eo - m[9].rm_so != strlen("none"))                                  if (m[9].rm_eo - m[9].rm_so != strlen("none"))
177                                          return ERROR_CONFIG_PARSE;                                          return ERROR_PARSER;
178                          } else if (!strcasecmp(t, "seen"))                          } else if (!strcasecmp(t, "seen"))
179                                  cur_fltr->action.msgflags |= MESSAGE_FLAG_SEEN;                                  curfltr->action.msgflags |= MSG_FLAG_SEEN;
180                          else if (!strcasecmp(t, "answered"))                          else if (!strcasecmp(t, "answered"))
181                                  cur_fltr->action.msgflags |=                                  curfltr->action.msgflags |= MSG_FLAG_ANSWERED;
                                     MESSAGE_FLAG_ANSWERED;  
182                          else if (!strcasecmp(t, "flagged"))                          else if (!strcasecmp(t, "flagged"))
183                                  cur_fltr->action.msgflags |=                                  curfltr->action.msgflags |= MSG_FLAG_FLAGGED;
                                     MESSAGE_FLAG_FLAGGED;  
184                          else if (!strcasecmp(t, "deleted"))                          else if (!strcasecmp(t, "deleted"))
185                                  cur_fltr->action.msgflags |=                                  curfltr->action.msgflags |= MSG_FLAG_DELETED;
                                     MESSAGE_FLAG_DELETED;  
186                          else if (!strcasecmp(t, "draft"))                          else if (!strcasecmp(t, "draft"))
187                                  cur_fltr->action.msgflags |= MESSAGE_FLAG_DRAFT;                                  curfltr->action.msgflags |= MSG_FLAG_DRAFT;
188                          else                          else
189                                  return ERROR_CONFIG_PARSE;                                  return ERROR_PARSER;
190    
191                          t = strtok_r(NULL, ",", &c);                          t = strtok_r(NULL, ",", &c);
192                  }                  }
193                  xfree(cp);                  xfree(cp);
194          } else if (!strncasecmp(line + m[1].rm_so, "list", 4)) {          } else if (!strncasecmp(line + m[1].rm_so, "list", 4)) {
195                  cur_fltr->action.type = FILTER_ACTION_LIST;                  curfltr->action.type = ACTION_LIST;
196          }          }
197          if (m[10].rm_so != -1) {          if (m[10].rm_so != -1) {
198                  strncat(cur_fltr->action.args, line + m[10].rm_so,                  strncat(curfltr->action.args, line + m[10].rm_so,
199                      min(m[10].rm_eo - m[10].rm_so, ARGS_LEN - 2));                      min(m[10].rm_eo - m[10].rm_so, ARGS_LEN - 2));
200                  while ((c = strchr(cur_fltr->action.args, ',')))                  while ((c = strchr(curfltr->action.args, ',')))
201                          *c = ' ';                          *c = ' ';
202          }          }
203  #ifdef DEBUG          debug("action: %d '%s' '%s' %d '%s'\n",
204          fprintf(stderr, "debug: ACTION: %d '%s' '%s' %d '%s'\n",              curfltr->action.type,
205              cur_fltr->action.type,              (curfltr->action.raccount ? curfltr->action.raccount->key : ""),
206              (cur_fltr->action.raccount ? cur_fltr->action.raccount->key : ""),              curfltr->action.destmbox,
207              cur_fltr->action.destmbox,              curfltr->action.msgflags,
208              cur_fltr->action.msgflags,              curfltr->action.args);
             cur_fltr->action.args);  
 #endif  
209          return 0;          return 0;
210  }  }
211    
# Line 217  set_action(char *line, regmatch_t * m) Line 214  set_action(char *line, regmatch_t * m)
214   * Set new mask's variables to safe values.   * Set new mask's variables to safe values.
215   */   */
216  void  void
217  init_mask(mask_t * node)  init_mask(mask_t * m)
218  {  {
219          node->next = NULL;  
220          node->body[0] = '\0';          m->next = NULL;
221          node->type = 0;          m->body[0] = '\0';
222            m->type = 0;
223  }  }
224    
225    
226  /*  /*
227   * A new mask entry was declared, create it and set it's   * A new mask entry was declared, create it and set it's variables accordingly.
  * variables accordingly.  
228   */   */
229  int  int
230  set_mask(char *line, regmatch_t * m, int mmt)  set_mask(char *line, regmatch_t * m, int mmt)
231  {  {
232          int n, len;          int n, len;
233          mask_t *node;          mask_t *k;
234          char *bp;          char *bp;
235    
236          len = 0;          len = 0;
237    
238          if (cur_fltr == NULL)          if (curfltr == NULL)
239                  return ERROR_CONFIG_PARSE;                  return ERROR_PARSER;
240    
241          node = (mask_t *) xmalloc(sizeof(mask_t));          k = (mask_t *) xmalloc(sizeof(mask_t));
242    
243          init_mask(node);          init_mask(k);
244    
245          bp = node->body;          bp = k->body;
246    
247          /* If specified set mask's type. */          /* If specified set mask's type. */
248          if (m[2].rm_so != -1 && cur_fltr->masks) {          if (m[2].rm_so != -1 && curfltr->masks) {
249                  if (!strncasecmp(line + m[2].rm_so, "or", 2)) {                  if (!strncasecmp(line + m[2].rm_so, "or", 2)) {
250                          node->type = MASK_TYPE_OR;                          k->type = MASK_TYPE_OR;
251                  } else                  } else
252                          node->type = MASK_TYPE_AND;                          k->type = MASK_TYPE_AND;
253          }          }
254          /* Add NOT if specified. */          /* Add NOT if specified. */
255          if (m[3].rm_so != -1) {          if (m[3].rm_so != -1) {
256                  n = min(m[3].rm_eo - m[3].rm_so,                  n = min(m[3].rm_eo - m[3].rm_so,
257                      MASK_BODY_LEN - (bp - node->body) - 1);                      MASK_BODY_LEN - (bp - k->body) - 1);
258                  xstrncpy(bp, line + m[3].rm_so, n);                  xstrncpy(bp, line + m[3].rm_so, n);
259                  string_upper(bp, n);                  string_upper(bp, n);
260                  *(bp + n - 1) = ' ';    /* In case it's '\t'. */                  *(bp + n - 1) = ' ';    /* In case it's '\t'. */
# Line 266  set_mask(char *line, regmatch_t * m, int Line 263  set_mask(char *line, regmatch_t * m, int
263          }          }
264          /* Keyword of the search key. */          /* Keyword of the search key. */
265          n = min(m[4].rm_eo - m[4].rm_so,          n = min(m[4].rm_eo - m[4].rm_so,
266              MASK_BODY_LEN - (bp - node->body) - 3);              MASK_BODY_LEN - (bp - k->body) - 3);
267          xstrncpy(bp, line + m[4].rm_so, n);          xstrncpy(bp, line + m[4].rm_so, n);
268          string_upper(bp, n);          string_upper(bp, n);
269          *(bp + n) = '\0';          *(bp + n) = '\0';
# Line 276  set_mask(char *line, regmatch_t * m, int Line 273  set_mask(char *line, regmatch_t * m, int
273          case MASK_MATCH_1:          case MASK_MATCH_1:
274                  /* Mask is ANSWERED, DELETED, DRAFT, FLAGGED, NEW, OLD, etc. */                  /* Mask is ANSWERED, DELETED, DRAFT, FLAGGED, NEW, OLD, etc. */
275    
276                  len = bp - node->body;                  len = bp - k->body;
277    
278                  break;                  break;
279    
# Line 290  set_mask(char *line, regmatch_t * m, int Line 287  set_mask(char *line, regmatch_t * m, int
287                  *bp = '\0';                  *bp = '\0';
288    
289                  n = min(m[5].rm_eo - m[5].rm_so,                  n = min(m[5].rm_eo - m[5].rm_so,
290                      MASK_BODY_LEN - (bp - node->body) - 2);                      MASK_BODY_LEN - (bp - k->body) - 2);
291                  xstrncpy(bp, line + m[5].rm_so, n);                  xstrncpy(bp, line + m[5].rm_so, n);
292                  *(bp + n) = '\0';                  *(bp + n) = '\0';
293                  bp += n;                  bp += n;
# Line 299  set_mask(char *line, regmatch_t * m, int Line 296  set_mask(char *line, regmatch_t * m, int
296                          *(bp++) = '"';                          *(bp++) = '"';
297                  *bp = '\0';                  *bp = '\0';
298    
299                  len = bp - node->body;                  len = bp - k->body;
300    
301                  break;                  break;
302    
# Line 313  set_mask(char *line, regmatch_t * m, int Line 310  set_mask(char *line, regmatch_t * m, int
310                  *bp = '\0';                  *bp = '\0';
311    
312                  n = min(m[5].rm_eo - m[5].rm_so,                  n = min(m[5].rm_eo - m[5].rm_so,
313                      MASK_BODY_LEN - (bp - node->body) - 2);                      MASK_BODY_LEN - (bp - k->body) - 2);
314                  xstrncpy(bp, line + m[5].rm_so, n);                  xstrncpy(bp, line + m[5].rm_so, n);
315                  *(bp + n) = '\0';                  *(bp + n) = '\0';
316                  bp += n;                  bp += n;
# Line 329  set_mask(char *line, regmatch_t * m, int Line 326  set_mask(char *line, regmatch_t * m, int
326                  *bp = '\0';                  *bp = '\0';
327    
328                  n = min(m[6].rm_eo - m[6].rm_so,                  n = min(m[6].rm_eo - m[6].rm_so,
329                      MASK_BODY_LEN - (bp - node->body) - 2);                      MASK_BODY_LEN - (bp - k->body) - 2);
330                  xstrncpy(bp, line + m[6].rm_so, n);                  xstrncpy(bp, line + m[6].rm_so, n);
331                  *(bp + n) = '\0';                  *(bp + n) = '\0';
332                  bp += n;                  bp += n;
# Line 338  set_mask(char *line, regmatch_t * m, int Line 335  set_mask(char *line, regmatch_t * m, int
335                          *(bp++) = '"';                          *(bp++) = '"';
336                  *bp = '\0';                  *bp = '\0';
337    
338                  len = bp - node->body;                  len = bp - k->body;
339    
340                  break;                  break;
341    
# Line 348  set_mask(char *line, regmatch_t * m, int Line 345  set_mask(char *line, regmatch_t * m, int
345                  *(bp++) = ' ';                  *(bp++) = ' ';
346    
347                  n = min(m[5].rm_eo - m[5].rm_so,                  n = min(m[5].rm_eo - m[5].rm_so,
348                      MASK_BODY_LEN - (bp - node->body) - 2);                      MASK_BODY_LEN - (bp - k->body) - 2);
349                  xstrncpy(bp, line + m[5].rm_so, n);                  xstrncpy(bp, line + m[5].rm_so, n);
350                  *(bp + n) = '\0';                  *(bp + n) = '\0';
351                  bp += n;                  bp += n;
352                  *bp = '\0';                  *bp = '\0';
353    
354                  /* Mask length after conversion to IMAP4rev1 date format. */                  /* Mask length after conversion to IMAP4rev1 date format. */
355                  if (strstr(node->body, "OLDER"))                  if (strstr(k->body, "OLDER"))
356                          len = strlen("NOT BEFORE DD-MMM-YYYY");                          len = strlen("NOT BEFORE DD-MMM-YYYY");
357                  else if (strstr(node->body, "NEWER"))                  else if (strstr(k->body, "NEWER"))
358                          len = strlen("NOT SINCE DD-MMM-YYYY");                          len = strlen("NOT SINCE DD-MMM-YYYY");
359                  else                  else
360                          len = bp - node->body;                          len = bp - k->body;
361    
362                  break;                  break;
363          default:          default:
364                  break;                  break;
365          }          }
366    
367          APPEND_LINKED_LIST(cur_fltr->masks, node, mask);          APPEND_LINKED_LIST(curfltr->masks, k, mask);
368    
369          cur_fltr->masknum++;          curfltr->masknum++;
370          cur_fltr->masklen += len;          curfltr->masklen += len;
371    
372  #ifdef DEBUG          debug("mask: '%s'\n", k->body);
         fprintf(stderr, "debug: MASK: '%s'\n", node->body);  
 #endif  
373    
374          return 0;          return 0;
375  }  }
# Line 391  set_job(char *line, regmatch_t * match) Line 386  set_job(char *line, regmatch_t * match)
386          filter_t *cf;          filter_t *cf;
387          mboxgrp_t *cg;          mboxgrp_t *cg;
388    
389          if (accounts == NULL || filters == NULL || cur_fltr->action.type == 0)          if (accounts == NULL || filters == NULL || curfltr->action.type == 0)
390                  return ERROR_CONFIG_PARSE;                  return ERROR_PARSER;
391    
392          n = match[1].rm_eo - match[1].rm_so;          n = match[1].rm_eo - match[1].rm_so;
393          fltr = (char *)xmalloc(n + 1);          fltr = (char *)xmalloc(n + 1);
# Line 408  set_job(char *line, regmatch_t * match) Line 403  set_job(char *line, regmatch_t * match)
403          while (ftok != NULL) {          while (ftok != NULL) {
404                  FIND_TREE(filters, ftok, cf);                  FIND_TREE(filters, ftok, cf);
405                  if (cf == NULL)                  if (cf == NULL)
406                          return ERROR_CONFIG_PARSE;                          return ERROR_PARSER;
407    
408                  g = xstrncpy(mbgrp, line + match[2].rm_so, n);                  g = xstrncpy(mbgrp, line + match[2].rm_so, n);
409                  g[n] = '\0';                  g[n] = '\0';
# Line 418  set_job(char *line, regmatch_t * match) Line 413  set_job(char *line, regmatch_t * match)
413                  while (gtok != NULL) {                  while (gtok != NULL) {
414                          FIND_TREE(mboxgrps, gtok, cg);                          FIND_TREE(mboxgrps, gtok, cg);
415                          if (cg == NULL)                          if (cg == NULL)
416                                  return ERROR_CONFIG_PARSE;                                  return ERROR_PARSER;
417                          link_mbox_filter(cf, cg);                          link_mbox_filter(cf, cg);
418    
419                          gtok = strtok_r(NULL, ",", &g);                          gtok = strtok_r(NULL, ",", &g);
# Line 456  link_mbox_filter(filter_t * cf, mboxgrp_ Line 451  link_mbox_filter(filter_t * cf, mboxgrp_
451    
452          }          }
453    
454  #ifdef DEBUG          debug("job: '%s' '%s'\n", cf->key, cg->key);
         fprintf(stderr, "debug: JOB: '%s' '%s'\n", cf->key, cg->key);  
 #endif  
455  }  }
456    
457    

Legend:
Removed from v.1.3.2.4  
changed lines
  Added in v.1.11

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26