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

Diff of /imapfilter/data.c

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

revision 1.30 by lefcha, Thu Jul 25 21:27:48 2002 UTC revision 1.30.2.4 by lefcha, Sun May 25 00:42:17 2003 UTC
# Line 221  void process_mboxgrp(mboxgrp_t * node, c Line 221  void process_mboxgrp(mboxgrp_t * node, c
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    
# Line 298  void init_filter(filter_t * node) Line 301  void init_filter(filter_t * node)
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;
# Line 434  int set_action(char *line, regmatch_t * Line 437  int set_action(char *line, regmatch_t *
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;
# Line 450  int set_action(char *line, regmatch_t * Line 455  int set_action(char *line, regmatch_t *
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)) {
# Line 463  int set_action(char *line, regmatch_t * Line 470  int set_action(char *line, regmatch_t *
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    
# Line 578  int set_mask(char *line, regmatch_t * ma Line 585  int set_mask(char *line, regmatch_t * ma
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++;
# Line 680  int set_job(char *line, regmatch_t * mat Line 657  int set_job(char *line, regmatch_t * mat
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;
# Line 689  int set_job(char *line, regmatch_t * mat Line 667  int set_job(char *line, regmatch_t * mat
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);
# Line 746  void destroy_data(void) Line 729  void destroy_data(void)
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;
# Line 788  int string_decode(char *str) Line 774  int string_decode(char *str)
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++;

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.30.2.4

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26