~ubuntu-branches/ubuntu/hardy/dbacl/hardy

« back to all changes in this revision

Viewing changes to src/rfc2822.c

  • Committer: Bazaar Package Importer
  • Author(s): Zak B. Elep
  • Date: 2006-03-26 22:35:35 UTC
  • mto: (2.1.1 etch) (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060326223535-icwiulpkzesds4mq
ImportĀ upstreamĀ versionĀ 1.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
 
74
74
static __inline__
75
75
char *skip_twodigit(char *line) {
76
 
  if( !line || !isdigit(line[0]) || !isdigit(line[1]) ) { return NULL; }
 
76
  if( !line || !isdigit((int)line[0]) || !isdigit((int)line[1]) ) { return NULL; }
77
77
  line += 2;
78
78
  return line;
79
79
}
80
80
 
81
81
static __inline__
82
82
char *skip_onetwodigit(char *line) {
83
 
  if( !line || !isdigit(line[0]) ) { return NULL; }
 
83
  if( !line || !isdigit((int)line[0]) ) { return NULL; }
84
84
  line++;
85
 
  if( isdigit(line[0]) ) {
 
85
  if( isdigit((int)line[0]) ) {
86
86
    line++;
87
87
  }
88
88
  return line;
90
90
 
91
91
static __inline__
92
92
char *skip_fourdigit(char *line) {
93
 
  if( !line || !isdigit(line[0]) || !isdigit(line[1]) ||
94
 
      !isdigit(line[2]) || !isdigit(line[3]) ) { return NULL; }
 
93
  if( !line || !isdigit((int)line[0]) || !isdigit((int)line[1]) ||
 
94
      !isdigit((int)line[2]) || !isdigit((int)line[3]) ) { return NULL; }
95
95
  line += 4;
96
96
  return line;
97
97
}
124
124
static __inline__
125
125
char *skip_2822_fws(char *line) {
126
126
  if( !line ) { return NULL; }
127
 
  while( !isblank(*line) ) {
128
 
    if( !isspace(*line) ) { return NULL; }
 
127
  while( !isblank((int)*line) ) {
 
128
    if( !isspace((int)*line) ) { return NULL; }
129
129
    line++;
130
130
  }
131
131
  line++;
132
 
  while( isblank(*line) ) { line++; }
 
132
  while( isblank((int)*line) ) { line++; }
133
133
  return line;
134
134
}
135
135
 
142
142
 */
143
143
static __inline__
144
144
char *unskip_2822_fws(char *line) {
145
 
  while( line && isspace(line[-1]) ) {
 
145
  while( line && isspace((int)line[-1]) ) {
146
146
    line--;
147
147
  }
148
148
  return line;
153
153
  char *tmp;
154
154
  if( !line ) { return NULL; }
155
155
  while(min-- > 0) {
156
 
    if( isspace(*line ) ) {
 
156
    if( isspace((int)*line ) ) {
157
157
      line = skip_2822_fws(line);
158
158
    } else if( *line == '(' ) {
159
159
      line = skip_recursive(line, '(', ')', '\\');
163
163
  }
164
164
  /* below space is optional */
165
165
  while( line ) {
166
 
    if( isspace(*line ) ) {
 
166
    if( isspace((int)*line ) ) {
167
167
      tmp = skip_2822_fws(line);
168
168
      if( tmp ) { 
169
169
        line = tmp; 
211
211
}
212
212
 
213
213
char *skip_2822_seq(char *line, token_delim_t *tok, 
214
 
               char *(*skip)(char *,token_delim_t *, options_t), char delim, options_t opt) {
 
214
                    char *(*skip)(char *,token_delim_t *, options_t), 
 
215
                    char delim, options_t opt) {
215
216
  char *tmp;
216
217
  BOT;
217
218
  line = (*skip)(line, NULL, opt);
226
227
}
227
228
 
228
229
static char rfc2822_atom[256] = {
229
 
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
 
230
 -1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
230
231
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
231
232
  0, '!',   0, '#', '$', '%', '&','\'',   0,   0, '*', '+',   0, '-',   0, '/',
232
233
  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',   0,   0,   0, '=',   0, '?',
532
533
 
533
534
static __inline__
534
535
char *skip_2822_item_name(char *line, token_delim_t *tok) {
535
 
  if( !line || !isalpha(*line) ) { return NULL; }
 
536
  if( !line || !isalpha((int)*line) ) { return NULL; }
536
537
  BOT;
537
 
  while( isalnum(*line) || (*line == '-') ) {
 
538
  while( isalnum((int)*line) || (*line == '-') ) {
538
539
    line++;
539
540
  }
540
541
  EOT;
589
590
  if( !line ) { return NULL; }
590
591
  if( (opt & (1<<O_2822_OBS)) ) {
591
592
    line = skip_2822_cfws(line, 0);
592
 
  } else if( isblank(*line) ) {
 
593
  } else if( isblank((int)*line) ) {
593
594
    line = skip_2822_fws(line);
594
595
  }
595
596
  line = skip_string_list(line, day_name, sizeof(day_name)/sizeof(char*));
604
605
  if( !line ) { return NULL; }
605
606
  if( (opt & (1<<O_2822_OBS)) ) {
606
607
    line = skip_2822_cfws(line, 0);
607
 
  } else if( isblank(*line) ) {
 
608
  } else if( isblank((int)*line) ) {
608
609
    line = skip_2822_fws(line);
609
610
  }
610
611
  line = skip_onetwodigit(line);
717
718
static __inline__
718
719
char *skip_2822_obs_zone(char *line) {
719
720
  if( !line ) { return NULL; }
720
 
  if( isalpha(line[0]) ) {
721
 
    if( !isalpha(line[1]) ) {
 
721
  if( isalpha((int)line[0]) ) {
 
722
    if( !isalpha((int)line[1]) ) {
722
723
      line++;
723
724
    } else {
724
725
      line = skip_2822_obs_zone_name(line);
779
780
  if( !line ) { return NULL; }
780
781
  if( *line == '.') {
781
782
    tmp = line + 1;
782
 
  } else if( isspace(*line) ) {
 
783
  } else if( isspace((int)*line) ) {
783
784
    tmp = skip_2822_cfws(line, 1);
784
785
  } else {
785
786
    tmp = skip_2822_word(line, NULL, opt);
788
789
    line = tmp;
789
790
    if( *line == '.') {
790
791
      tmp = line + 1;
791
 
    } else if( isspace(*line) ) {
 
792
    } else if( isspace((int)*line) ) {
792
793
      tmp = skip_2822_cfws(line, 1);
793
794
    } else {
794
795
      tmp = skip_2822_word(line, NULL, opt);
991
992
char *skip_2822_end_of_line(char *line) {
992
993
  /* check for CRLF, but OS may have mangled/removed it */
993
994
  if( !line || (strlen(line) > 2) ) { return NULL; }
994
 
  while( isspace(*line) ) { line++; }
 
995
  while( isspace((int)*line) ) { line++; }
995
996
  return (*line) ? NULL : line;
996
997
}
997
998
 
1175
1176
 
1176
1177
static __inline__
1177
1178
char *skip_2821_sub_domain(char *line, token_delim_t *tok, options_t opt) {
1178
 
  if( !line || !isalnum(*line) ) { return NULL; }
 
1179
  if( !line || !isalnum((int)*line) ) { return NULL; }
1179
1180
  BOT;
1180
1181
  line++;
1181
 
  while( isalnum(*line) || (*line == '-') ) {
 
1182
  while( isalnum((int)*line) || (*line == '-') ) {
1182
1183
    line++;
1183
1184
  }
1184
1185
  EOT;