s/qmail 4.2.29a
Next generation secure email transport
Loading...
Searching...
No Matches
hfield.c
Go to the documentation of this file.
1#include "hfield.h"
2
3static char *(hname[]) = {
4 "unknown-header"
5, "sender"
6, "from"
7, "reply-to"
8, "to"
9, "cc"
10, "bcc"
11, "date"
12, "message-id"
13, "subject"
14, "resent-sender"
15, "resent-from"
16, "resent-reply-to"
17, "resent-to"
18, "resent-cc"
19, "resent-bcc"
20, "resent-date"
21, "resent-message-id"
22, "return-receipt-to"
23, "errors-to"
24, "apparently-to"
25, "received"
26, "return-path"
27, "delivered-to"
28, "content-length"
29, "content-type"
30, "content-transfer-encoding"
31, "notice-requested-upon-delivery-to"
32, "mail-followup-to"
33, 0
34};
35
36static int hmatch( char *s,int len,char *t)
37{
38 int i;
39 char ch;
40
41 for (i = 0; (ch = t[i]); ++i) {
42 if (i >= len) return 0;
43 if (ch != s[i]) {
44 if (ch == '-') return 0;
45 if (ch - 32 != s[i]) return 0;
46 }
47 }
48 for (;;) {
49 if (i >= len) return 0;
50 ch = s[i];
51 if (ch == ':') return 1;
52 if ((ch != ' ') && (ch != '\t')) return 0;
53 ++i;
54 }
55}
56
57int hfield_known(char *s,int len)
58{
59 int i;
60 char *t;
61
62 for (i = 1; (t = hname[i]); ++i)
63 if (hmatch(s,len,t))
64 return i;
65
66 return 0;
67}
68
69int hfield_valid(char *s,int len)
70{
71 int i;
72 int j;
73 char ch;
74
75 for (j = 0; j < len; ++j)
76 if (s[j] == ':') break;
77
78 if (j >= len) return 0;
79
80 while (j) {
81 ch = s[j - 1];
82 if ((ch != ' ') && (ch != '\t'))
83 break;
84 --j;
85 }
86 if (!j) return 0;
87
88 for (i = 0; i < j; ++i) {
89 ch = s[i];
90 if (ch <= 32) return 0;
91 if (ch >= 127) return 0;
92 }
93 return 1;
94}
95
96unsigned int hfield_skipname(char *s,int len)
97{
98 int i;
99 char ch;
100
101 for (i = 0; i < len; ++i)
102 if (s[i] == ':') break;
103
104 if (i < len) ++i;
105 while (i < len) {
106 ch = s[i];
107 if ((ch != '\t') && (ch != '\n') && (ch != '\r') && (ch != ' '))
108 break;
109 ++i;
110 }
111
112 return i;
113}
int hfield_known()
unsigned int hfield_skipname()
int hfield_valid()
int j
Definition: qmail-send.c:920