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

Diff of /imapfilter/file.c

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

revision 1.42 by lefcha, Thu Jul 25 21:24:53 2002 UTC revision 1.43 by lefcha, Fri Jul 26 18:17:28 2002 UTC
# Line 132  int parse_config(FILE * fd) Line 132  int parse_config(FILE * fd)
132          "[[:blank:]]*=[[:blank:]]*([[:print:]]+)\n$",          "[[:blank:]]*=[[:blank:]]*([[:print:]]+)\n$",
133    
134          "^[[:blank:]]*(SET[[:blank:]])?[[:blank:]]*(EXPUNGE|HEADERS|NAMESPACE|"          "^[[:blank:]]*(SET[[:blank:]])?[[:blank:]]*(EXPUNGE|HEADERS|NAMESPACE|"
135          "SUBSCRIBE)[[:blank:]]*=[[:blank:]]*(YES|NO)[[:blank:]]*\n$",          "SUBSCRIBE|WARNING)[[:blank:]]*=[[:blank:]]*(YES|NO)[[:blank:]]*\n$",
136    
137          "^[[:blank:]]*(SET[[:blank:]])?[[:blank:]]*(DAEMON|TIMEOUT)"          "^[[:blank:]]*(SET[[:blank:]])?[[:blank:]]*(DAEMON|TIMEOUT)"
138          "[[:blank:]]*=[[:blank:]]*([[:digit:]]+)\n$"          "[[:blank:]]*=[[:blank:]]*([[:digit:]]+)\n$"
# Line 141  int parse_config(FILE * fd) Line 141  int parse_config(FILE * fd)
141      for (i = 0; i < 13; i++)      for (i = 0; i < 13; i++)
142          regcomp(&creg[i], reg[i], REG_EXTENDED | REG_ICASE);          regcomp(&creg[i], reg[i], REG_EXTENDED | REG_ICASE);
143    
144        /* First process all the variables.  This is done because some variables'
145           arguments are used before the other commands are processed. */
146        while (fgets(line, LINE_MAX - 1, fd))
147            if (!regexec(&creg[10], line, 4, match, 0) ||
148                !regexec(&creg[11], line, 4, match, 0) ||
149                !regexec(&creg[12], line, 4, match, 0))
150                set_options(line, match);
151    
152        /* Then rewind and process everything else. */
153        fseek(fd, 0L, SEEK_SET);
154      while (fgets(line, LINE_MAX - 1, fd)) {      while (fgets(line, LINE_MAX - 1, fd)) {
155          row++;          row++;
156          if (!regexec(&creg[0], line, 0, match, 0))          if (!regexec(&creg[0], line, 0, match, 0))
# Line 163  int parse_config(FILE * fd) Line 173  int parse_config(FILE * fd)
173              r = set_mask(line, match, MASK_MATCH_4);              r = set_mask(line, match, MASK_MATCH_4);
174          else if (!regexec(&creg[9], line, 3, match, 0))          else if (!regexec(&creg[9], line, 3, match, 0))
175              r = set_job(line, match);              r = set_job(line, match);
176            /* Skip variable processing. */
177          else if (!regexec(&creg[10], line, 4, match, 0) ||          else if (!regexec(&creg[10], line, 4, match, 0) ||
178                   !regexec(&creg[11], line, 4, match, 0) ||                   !regexec(&creg[11], line, 4, match, 0) ||
179                   !regexec(&creg[12], line, 4, match, 0))                   !regexec(&creg[12], line, 4, match, 0));
             set_options(line, match);  
180          else          else
181              return row;              return row;
182    
# Line 208  void set_options(char *line, regmatch_t Line 218  void set_options(char *line, regmatch_t
218          else          else
219              options &= ~(OPTION_NAMESPACE);              options &= ~(OPTION_NAMESPACE);
220      } else if (!strncasecmp(line + match[2].rm_so, "subscribe", 9)) {      } else if (!strncasecmp(line + match[2].rm_so, "subscribe", 9)) {
221          if (!strncasecmp(line + match[2].rm_so, "yes", 3))          if (!strncasecmp(line + match[3].rm_so, "yes", 3))
222              options |= OPTION_SUBSCRIBE;              options |= OPTION_SUBSCRIBE;
223          else          else
224              options &= ~(OPTION_SUBSCRIBE);              options &= ~(OPTION_SUBSCRIBE);
225        } else if (!strncasecmp(line + match[2].rm_so, "warning", 7)) {
226            if (!strncasecmp(line + match[3].rm_so, "yes", 3))
227                options |= OPTION_WARNING;
228            else
229                options &= ~(OPTION_WARNING);
230      } else if (!strncasecmp(line + match[2].rm_so, "timeout", 7)) {      } else if (!strncasecmp(line + match[2].rm_so, "timeout", 7)) {
231          errno = 0;          errno = 0;
232          timeout = strtol(line + match[3].rm_so, NULL, 10);          timeout = strtol(line + match[3].rm_so, NULL, 10);

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26