File: field.c

package info (click to toggle)
sn 0.3.8-10
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 924 kB
  • ctags: 852
  • sloc: ansic: 9,262; sh: 466; makefile: 208
file content (37 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * This file is part of the sn package.
 * Distribution of sn is covered by the GNU GPL. See file COPYING.
 * Copyright  1998-2000 Harold Tay.
 * Copyright  2000- Patrik Rdman.
 */

/*
 * Check the field name of a header line.
 */

static const char ver_ctrl_id[] = "$Id: field.c 52 2004-07-26 16:12:16Z patrik $";

int check_field (char *field, int len)
{
   int i;

   for (i = 0; i < len; i++)
   {
      /* Allow printable US-ASCII characters, except colon */
      if (field[i] >= '!' && field[i] <= '9')
         continue;
      if (field[i] >= ';' && field[i] <= '~')
         continue;
      if (field[i] == ':')
         return i;
      if (field[i] == ' ' || field[i] == '\t')
         break;
      return 0;
   }
   do
      i++;
   while (field[i] == ' ' || field[i] == '\t');
   if (field[i] != ':')
      return 0;
   return i;
}