4 * We exploit the fact that we are dealing only with headers here, and
5 * headers are limited to the ASCII characters by RFC822. It is barely
6 * possible that we might be dealing with a translation into another
7 * character set, but in particular it's very unlikely for a header
8 * character to be outside -128..255.
10 * Life would be a whole lot simpler if tolower() could safely and portably
11 * be applied to any char.
17 /* note that case.h knows the value of OFFSET */
18 #define OFFSET 128 /* avoid trouble with negative chars */
19 #define MAPSIZE (256+OFFSET)
20 char casemap
[MAPSIZE
]; /* relies on init to '\0' */
21 static int primed
= 0; /* has casemap been set up? */
24 - prime - set up case-mapping stuff
33 static char lower
[] = "abcdefghijklmnopqrstuvwxyz";
34 static char upper
[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
36 for (lp
= lower
, up
= upper
; *lp
!= '\0'; lp
++, up
++) {
38 casemap
[c
+OFFSET
] = c
;
39 casemap
[*up
+OFFSET
] = c
;
41 for (i
= 0; i
< MAPSIZE
; i
++)
42 if (casemap
[i
] == '\0')
43 casemap
[i
] = (char)(i
-OFFSET
);
48 - cistrncmp - case-independent strncmp
51 cistrncmp(s1
, s2
, len
)
66 while (--n
>= 0 && *p1
!= '\0' && TOLOW(*p1
) == TOLOW(*p2
)) {
74 * The following case analysis is necessary so that characters
75 * which look negative collate low against normal characters but
76 * high against the end-of-string NUL.
78 if (*p1
== '\0' && *p2
== '\0')
85 return(TOLOW(*p1
) - TOLOW(*p2
));
89 - rfc822ize - do the bizarre case conversion needed for rfc822 message-ids
91 * Actually, this is not quite complete. Absolute, total, full RFC822
92 * compliance requires a horrible parsing job, because of the arcane
93 * quoting conventions -- abc"def"ghi is not equivalent to abc"DEF"ghi,
94 * for example. There are three or four things that might occur in the
95 * domain part of a message-id that are case-sensitive. They don't seem
96 * to ever occur in real news, thank Cthulhu. (What? You were expecting
97 * a merciful and forgiving deity to be invoked in connection with RFC822?
98 * Forget it; none of them would come near it.)
100 char * /* returns the argument */
105 static char post
[] = "postmaster";
106 static int postlen
= sizeof(post
)-1;
112 if (p
== NULL
) /* no local/domain split */
113 p
= ""; /* assume all local */
114 else if (p
- (s
+1) == postlen
&& CISTREQN(s
+1, post
, postlen
)) {
115 /* crazy special case -- "postmaster" is case-insensitive */
120 #ifdef B_2_11_MISTAKE
121 p
= s
; /* all case-insensitive */
125 for (; *p
!= '\0'; p
++)