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

Diff of /imapfilter/data.c

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

revision 1.1 by lefcha, Mon Sep 10 23:43:29 2001 UTC revision 1.2 by lefcha, Tue Sep 11 16:12:42 2001 UTC
# Line 6  Line 6 
6  #include <stdlib.h>  #include <stdlib.h>
7  #include <limits.h>  #include <limits.h>
8  #include <sys/stat.h>  #include <sys/stat.h>
9    #include <ctype.h>
10    
11  #include "config.h"  #include "config.h"
12  #include "imapfilter.h"  #include "imapfilter.h"
# Line 309  int set_filter(char *line, regmatch_t * Line 310  int set_filter(char *line, regmatch_t *
310      node->key[s] = 0;      node->key[s] = 0;
311    
312      if (match[2].rm_eo - match[2].rm_so) {      if (match[2].rm_eo - match[2].rm_so) {
313          if (!strncmp(line + match[2].rm_so + 1, "OR", 2))          if (*(line + match[2].rm_so + 1) == 'o' || *(line + match[2].rm_so + 1) == 'O')
314              node->mode = FILTER_MODE_OR;              node->mode = FILTER_MODE_OR;
315          else          else
316              node->mode = FILTER_MODE_AND;              node->mode = FILTER_MODE_AND;
# Line 405  int set_mask(char *line, regmatch_t * ma Line 406  int set_mask(char *line, regmatch_t * ma
406      init_mask(node);      init_mask(node);
407    
408      if ((match[2].rm_eo - match[2].rm_so) && cur_fltr->masks) {      if ((match[2].rm_eo - match[2].rm_so) && cur_fltr->masks) {
409          if (!strncmp(line + match[2].rm_so, "OR", 2))          if (*(line + match[2].rm_so) == 'o' || *(line + match[2].rm_so) == 'O')
410              node->type = MASK_TYPE_OR;              node->type = MASK_TYPE_OR;
411          else          else
412              node->type = MASK_TYPE_AND;              node->type = MASK_TYPE_AND;
# Line 414  int set_mask(char *line, regmatch_t * ma Line 415  int set_mask(char *line, regmatch_t * ma
415      if (match[3].rm_eo - match[3].rm_so) {      if (match[3].rm_eo - match[3].rm_so) {
416          s = min(match[3].rm_eo - match[3].rm_so, MASK_BODY_LEN - len - 1);          s = min(match[3].rm_eo - match[3].rm_so, MASK_BODY_LEN - len - 1);
417          strncpy(node->body + len, line + match[3].rm_so, s);          strncpy(node->body + len, line + match[3].rm_so, s);
418            upper_case(node->body + len, s);                /* XXX */
419          node->body[len + s - 1] = ' ';  /* In case it's '\t'. */          node->body[len + s - 1] = ' ';  /* In case it's '\t'. */
420          node->body[len + s] = 0;          node->body[len + s] = 0;
421          len = strlen(node->body);          len = strlen(node->body);
# Line 421  int set_mask(char *line, regmatch_t * ma Line 423  int set_mask(char *line, regmatch_t * ma
423    
424      s = min(match[4].rm_eo - match[4].rm_so, MASK_BODY_LEN - len - 1);      s = min(match[4].rm_eo - match[4].rm_so, MASK_BODY_LEN - len - 1);
425      strncpy(node->body + len, line + match[4].rm_so, s);      strncpy(node->body + len, line + match[4].rm_so, s);
426        upper_case(node->body + len, s);
427      node->body[len + s] = 0;      node->body[len + s] = 0;
428      len = strlen(node->body);      len = strlen(node->body);
429    
# Line 514  int link_mbox_filter(filter_t * cf, mbox Line 517  int link_mbox_filter(filter_t * cf, mbox
517          while (cmg->mboxes[i]->filters[j]) {          while (cmg->mboxes[i]->filters[j]) {
518              if (i == MBOX_FILTERS_MAX)              if (i == MBOX_FILTERS_MAX)
519                  return 1;                  return 1;
520                if (!strncmp(cf->key, cmg->mboxes[i]->filters[j]->key, KEY_LEN))
521                    return 0;
522              j++;              j++;
523          }          }
524    
# Line 558  void destroy_mboxgrp(mboxgrp_t * node) Line 563  void destroy_mboxgrp(mboxgrp_t * node)
563    
564      delete_mboxgrp(node);      delete_mboxgrp(node);
565  }  }
566    
567    
568    /*
569     * Convert a string of specified size to upper case.
570     */
571    void upper_case(char *str, size_t size)
572    {
573        int i;
574    
575        for (i = 0; i < size; i++)
576            *(str + i) = toupper(*(str + i));
577    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26