| 1 |
%{ |
| 2 |
/* gperf --struct-type --readonly-table --enum --global -K field_name -N header_entry --ignore-case */ |
| 3 |
/* Contributed by Bruce Lilly |
| 4 |
derived from http://users.erols.com/blilly/mailparse/fields.gperf */ |
| 5 |
|
| 6 |
#include <string.h> |
| 7 |
|
| 8 |
%} |
| 9 |
struct header_state { const char *field_name; }; |
| 10 |
%% |
| 11 |
Accept-Language |
| 12 |
Action |
| 13 |
Alternate-Recipient |
| 14 |
Approved |
| 15 |
Archive |
| 16 |
Arrival-Date |
| 17 |
Autoforwarded |
| 18 |
Autosubmitted |
| 19 |
Bcc |
| 20 |
Cc |
| 21 |
Comments |
| 22 |
Complaints-To |
| 23 |
Content-alternative |
| 24 |
Content-Base |
| 25 |
Content-Description |
| 26 |
Content-Disposition |
| 27 |
Content-Duration |
| 28 |
Content-Features |
| 29 |
Content-ID |
| 30 |
Content-Language |
| 31 |
Content-Location |
| 32 |
Content-MD5 |
| 33 |
Content-Transfer-Encoding |
| 34 |
Content-Type |
| 35 |
Control |
| 36 |
Conversion |
| 37 |
Conversion-With-Loss |
| 38 |
DL-Expansion-History |
| 39 |
DSN-Gateway |
| 40 |
Date |
| 41 |
Deferred-Delivery |
| 42 |
Delivery-Date |
| 43 |
Diagnostic-Code |
| 44 |
Discarded-X400-IPMS-Extensions |
| 45 |
Discarded-X400-MTS-Extensions |
| 46 |
Disclose-Recipients |
| 47 |
Disposition |
| 48 |
Disposition-Notification-Options |
| 49 |
Disposition-Notification-To |
| 50 |
Distribution |
| 51 |
Encrypted |
| 52 |
Error |
| 53 |
Expires |
| 54 |
Failure |
| 55 |
Final-Log-ID |
| 56 |
Final-Recipient |
| 57 |
Followup-To |
| 58 |
From |
| 59 |
Generate-Delivery-Report |
| 60 |
Importance |
| 61 |
In-Reply-To |
| 62 |
Incomplete-Copy |
| 63 |
Injector-Info |
| 64 |
Keywords |
| 65 |
Last-Attempt-Date |
| 66 |
Latest-Delivery-Time |
| 67 |
Lines |
| 68 |
List-Archive |
| 69 |
List-Help |
| 70 |
List-ID |
| 71 |
List-Post |
| 72 |
List-Owner |
| 73 |
List-Subscribe |
| 74 |
List-Unsubscribe |
| 75 |
MDN-Gateway |
| 76 |
Media-Accept-Features |
| 77 |
MIME-Version |
| 78 |
Mail-Copies-To |
| 79 |
Message-ID |
| 80 |
Message-Type |
| 81 |
Newsgroups |
| 82 |
Organization |
| 83 |
Original-Encoded-Information-Types |
| 84 |
Original-Envelope-ID |
| 85 |
Original-Message-ID |
| 86 |
Original-Recipient |
| 87 |
Originator-Return-Address |
| 88 |
Path |
| 89 |
Posted-And-Mailed |
| 90 |
Prevent-Nondelivery-Report |
| 91 |
Priority |
| 92 |
Received |
| 93 |
Received-content-MIC |
| 94 |
Received-From-MTA |
| 95 |
References |
| 96 |
Remote-MTA |
| 97 |
Reply-By |
| 98 |
Reply-To |
| 99 |
Reporting-MTA |
| 100 |
Reporting-UA |
| 101 |
Return-Path |
| 102 |
Sender |
| 103 |
Sensitivity |
| 104 |
Status |
| 105 |
Subject |
| 106 |
Summary |
| 107 |
Supersedes |
| 108 |
To |
| 109 |
User-Agent |
| 110 |
Warning |
| 111 |
Will-Retry-Until |
| 112 |
X400-Content-Identifier |
| 113 |
X400-Content-Return |
| 114 |
X400-Content-Type |
| 115 |
X400-MTS-Identifier |
| 116 |
X400-Originator |
| 117 |
X400-Received |
| 118 |
X400-Recipients |
| 119 |
Xref |
| 120 |
%% |
| 121 |
|
| 122 |
#include <stdio.h> |
| 123 |
#include <stdlib.h> |
| 124 |
#include <ctype.h> |
| 125 |
|
| 126 |
static int |
| 127 |
my_case_strcmp (const char *s1, const char *s2) |
| 128 |
{ |
| 129 |
for (;;) |
| 130 |
{ |
| 131 |
unsigned char c1 = *s1++; |
| 132 |
unsigned char c2 = *s2++; |
| 133 |
if (c1 >= 'A' && c1 <= 'Z') |
| 134 |
c1 += 'a' - 'A'; |
| 135 |
if (c2 >= 'A' && c2 <= 'Z') |
| 136 |
c2 += 'a' - 'A'; |
| 137 |
if (c1 != 0 && c1 == c2) |
| 138 |
continue; |
| 139 |
return (int)c1 - (int)c2; |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
int |
| 144 |
main (int argc, char *argv[]) |
| 145 |
{ |
| 146 |
int i, j, k, n, exitcode; |
| 147 |
size_t len; |
| 148 |
const struct header_state *hs; |
| 149 |
|
| 150 |
n = 1; |
| 151 |
if (argc > 1) |
| 152 |
n = atoi (argv[1]); |
| 153 |
if (n < 1) |
| 154 |
n = 1; |
| 155 |
|
| 156 |
exitcode = 0; |
| 157 |
for (i = 0; i < n; i++) |
| 158 |
{ |
| 159 |
for (j = 0; j <= MAX_HASH_VALUE; j++) |
| 160 |
{ |
| 161 |
const char *s = wordlist[j].field_name; |
| 162 |
len = strlen (s); |
| 163 |
if (len) |
| 164 |
{ |
| 165 |
hs = header_entry (s, len); |
| 166 |
if (!(hs && strcmp (hs->field_name, s) == 0)) |
| 167 |
{ |
| 168 |
fprintf (stderr, "%s != %s\n", s, hs ? hs->field_name : "(null)"); |
| 169 |
exitcode = 1; |
| 170 |
} |
| 171 |
} |
| 172 |
} |
| 173 |
for (j = 0; j <= MAX_HASH_VALUE; j++) |
| 174 |
{ |
| 175 |
char s[MAX_WORD_LENGTH+1]; |
| 176 |
/* expensive copy with case conversion (for testing) */ |
| 177 |
strcpy (s, wordlist[j].field_name); |
| 178 |
len = strlen (s); |
| 179 |
if (len) |
| 180 |
{ |
| 181 |
for (k = 0; k < len; k++) |
| 182 |
if (isupper ((unsigned char) s[k])) |
| 183 |
s[k] = tolower ((unsigned char) s[k]); |
| 184 |
else if (islower ((unsigned char) s[k])) |
| 185 |
s[k] = toupper ((unsigned char) s[k]); |
| 186 |
hs = header_entry (s, len); |
| 187 |
if (!(hs && my_case_strcmp (hs->field_name, s) == 0)) |
| 188 |
{ |
| 189 |
fprintf (stderr, "%s != %s\n", s, hs ? hs->field_name : "(null)"); |
| 190 |
exitcode = 1; |
| 191 |
} |
| 192 |
} |
| 193 |
} |
| 194 |
hs = header_entry ("Dave", 4); |
| 195 |
if (hs) |
| 196 |
{ |
| 197 |
fprintf (stderr, "Dave == %s\n", hs->field_name); |
| 198 |
exitcode = 1; |
| 199 |
} |
| 200 |
} |
| 201 |
return exitcode; |
| 202 |
} |