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

Diff of /imapfilter/filter.c

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

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

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26