5
/* message header classification
7
/* #include <is_header.h>
9
/* int is_header(string)
10
/* const char *string;
12
/* is_header() examines the given string and returns non-zero (true)
13
/* when it begins with a mail header name + optional space + colon.
14
/* The result is the length of the mail header name.
16
/* RFC 822 (ARPA Internet Text Messages)
20
/* The Secure Mailer license must be distributed with this software.
23
/* IBM T.J. Watson Research
25
/* Yorktown Heights, NY 10598, USA
35
#include "is_header.h"
37
/* is_header - determine if this can be a header line */
39
int is_header(const char *str)
41
const unsigned char *cp;
48
#define IN_CHAR_SPACE 2
49
#define CU_CHAR_PTR(x) ((const unsigned char *) (x))
52
* XXX RFC 2822 Section 4.5, Obsolete header fields: whitespace may
53
* appear between header label and ":" (see: RFC 822, Section 3.4.2.).
55
for (len = 0, state = INIT, cp = CU_CHAR_PTR(str); (c = *cp) != 0; cp++) {
58
if (!ISASCII(c) || ISCNTRL(c))
62
if (state == IN_CHAR) {
70
state = IN_CHAR_SPACE;
71
if (state == IN_CHAR_SPACE)
75
return ((state == IN_CHAR || state == IN_CHAR_SPACE) ? len : 0);