]>
Commit | Line | Data |
---|---|---|
d7837182 TL |
1 | /* conflex.c |
2 | ||
3 | Lexical scanner for dhcpd config file... */ | |
4 | ||
5 | /* | |
88cd8aca | 6 | * Copyright (c) 2004-2006 by Internet Systems Consortium, Inc. ("ISC") |
98311e4b | 7 | * Copyright (c) 1995-2003 by Internet Software Consortium |
d7837182 | 8 | * |
98311e4b DH |
9 | * Permission to use, copy, modify, and distribute this software for any |
10 | * purpose with or without fee is hereby granted, provided that the above | |
11 | * copyright notice and this permission notice appear in all copies. | |
d7837182 | 12 | * |
98311e4b DH |
13 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES |
14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | |
16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
19 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
d7837182 | 20 | * |
98311e4b DH |
21 | * Internet Systems Consortium, Inc. |
22 | * 950 Charter Street | |
23 | * Redwood City, CA 94063 | |
24 | * <info@isc.org> | |
25 | * http://www.isc.org/ | |
49733f31 | 26 | * |
98311e4b | 27 | * This software has been written for Internet Systems Consortium |
49733f31 | 28 | * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. |
98311e4b | 29 | * To learn more about Internet Systems Consortium, see |
49733f31 TL |
30 | * ``http://www.isc.org/''. To learn more about Vixie Enterprises, |
31 | * see ``http://www.vix.com''. To learn more about Nominum, Inc., see | |
32 | * ``http://www.nominum.com''. | |
d7837182 TL |
33 | */ |
34 | ||
35 | #ifndef lint | |
36 | static char copyright[] = | |
dba5803b | 37 | "$Id: conflex.c,v 1.101 2006/07/22 02:24:16 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n"; |
d7837182 TL |
38 | #endif /* not lint */ |
39 | ||
40 | #include "dhcpd.h" | |
d7837182 TL |
41 | #include <ctype.h> |
42 | ||
6f4b5b31 TL |
43 | static int get_char PROTO ((struct parse *)); |
44 | static enum dhcp_token get_token PROTO ((struct parse *)); | |
45 | static void skip_to_eol PROTO ((struct parse *)); | |
46 | static enum dhcp_token read_string PROTO ((struct parse *)); | |
47 | static enum dhcp_token read_number PROTO ((int, struct parse *)); | |
48 | static enum dhcp_token read_num_or_name PROTO ((int, struct parse *)); | |
49 | static enum dhcp_token intern PROTO ((char *, enum dhcp_token)); | |
d7837182 | 50 | |
24f9d67e | 51 | isc_result_t new_parse (cfile, file, inbuf, buflen, name, eolp) |
6f4b5b31 TL |
52 | struct parse **cfile; |
53 | int file; | |
54 | char *inbuf; | |
b1b7b521 TL |
55 | unsigned buflen; |
56 | const char *name; | |
24f9d67e | 57 | int eolp; |
6f4b5b31 TL |
58 | { |
59 | struct parse *tmp; | |
512994ed | 60 | |
4bd8800e | 61 | tmp = dmalloc (sizeof (struct parse), MDL); |
6f4b5b31 TL |
62 | if (!tmp) |
63 | return ISC_R_NOMEMORY; | |
64 | memset (tmp, 0, sizeof *tmp); | |
512994ed | 65 | |
a6d79ad7 | 66 | tmp -> token = 0; |
6f4b5b31 TL |
67 | tmp -> tlname = name; |
68 | tmp -> lpos = tmp -> line = 1; | |
69 | tmp -> cur_line = tmp -> line1; | |
70 | tmp -> prev_line = tmp -> line2; | |
71 | tmp -> token_line = tmp -> cur_line; | |
72 | tmp -> cur_line [0] = tmp -> prev_line [0] = 0; | |
73 | tmp -> warnings_occurred = 0; | |
74 | tmp -> file = file; | |
24f9d67e | 75 | tmp -> eol_token = eolp; |
d7837182 | 76 | |
6f4b5b31 TL |
77 | tmp -> bufix = 0; |
78 | tmp -> buflen = buflen; | |
79 | if (inbuf) { | |
80 | tmp -> bufsiz = 0; | |
81 | tmp -> inbuf = inbuf; | |
82 | } else { | |
4bd8800e | 83 | tmp -> inbuf = dmalloc (8192, MDL); |
6f4b5b31 | 84 | if (!tmp -> inbuf) { |
4bd8800e | 85 | dfree (tmp, MDL); |
6f4b5b31 TL |
86 | return ISC_R_NOMEMORY; |
87 | } | |
88 | tmp -> bufsiz = 8192; | |
89 | } | |
90 | ||
91 | *cfile = tmp; | |
92 | return ISC_R_SUCCESS; | |
93 | } | |
94 | ||
95 | isc_result_t end_parse (cfile) | |
96 | struct parse **cfile; | |
58304e8e | 97 | { |
88cd8aca DH |
98 | /* "Memory" config files have no file. */ |
99 | if ((*cfile)->file != -1) | |
100 | close((*cfile)->file); | |
101 | ||
102 | if ((*cfile)->bufsiz) | |
103 | dfree((*cfile)->inbuf, MDL); | |
104 | dfree(*cfile, MDL); | |
105 | *cfile = NULL; | |
6f4b5b31 | 106 | return ISC_R_SUCCESS; |
58304e8e TL |
107 | } |
108 | ||
d7837182 | 109 | static int get_char (cfile) |
6f4b5b31 | 110 | struct parse *cfile; |
d7837182 | 111 | { |
6f4b5b31 TL |
112 | /* My kingdom for WITH... */ |
113 | int c; | |
114 | ||
115 | if (cfile -> bufix == cfile -> buflen) { | |
116 | if (cfile -> file != -1) { | |
117 | cfile -> buflen = | |
118 | read (cfile -> file, | |
119 | cfile -> inbuf, cfile -> bufsiz); | |
120 | if (cfile -> buflen == 0) { | |
121 | c = EOF; | |
122 | cfile -> bufix = 0; | |
123 | } else if (cfile -> buflen < 0) { | |
124 | c = EOF; | |
125 | cfile -> bufix = cfile -> buflen = 0; | |
126 | } else { | |
127 | c = cfile -> inbuf [0]; | |
128 | cfile -> bufix = 1; | |
129 | } | |
130 | } else | |
131 | c = EOF; | |
132 | } else { | |
133 | c = cfile -> inbuf [cfile -> bufix]; | |
134 | cfile -> bufix++; | |
135 | } | |
136 | ||
137 | if (!cfile -> ugflag) { | |
d7837182 | 138 | if (c == EOL) { |
6f4b5b31 TL |
139 | if (cfile -> cur_line == cfile -> line1) { |
140 | cfile -> cur_line = cfile -> line2; | |
141 | cfile -> prev_line = cfile -> line1; | |
512994ed | 142 | } else { |
6f4b5b31 TL |
143 | cfile -> cur_line = cfile -> line1; |
144 | cfile -> prev_line = cfile -> line2; | |
512994ed | 145 | } |
6f4b5b31 TL |
146 | cfile -> line++; |
147 | cfile -> lpos = 1; | |
148 | cfile -> cur_line [0] = 0; | |
512994ed | 149 | } else if (c != EOF) { |
6f4b5b31 TL |
150 | if (cfile -> lpos <= 80) { |
151 | cfile -> cur_line [cfile -> lpos - 1] = c; | |
152 | cfile -> cur_line [cfile -> lpos] = 0; | |
512994ed | 153 | } |
6f4b5b31 | 154 | cfile -> lpos++; |
d7837182 TL |
155 | } |
156 | } else | |
6f4b5b31 | 157 | cfile -> ugflag = 0; |
d7837182 TL |
158 | return c; |
159 | } | |
160 | ||
104c88cd | 161 | static enum dhcp_token get_token (cfile) |
6f4b5b31 | 162 | struct parse *cfile; |
d7837182 TL |
163 | { |
164 | int c; | |
104c88cd | 165 | enum dhcp_token ttok; |
089fb364 | 166 | static char tb [2]; |
512994ed | 167 | int l, p, u; |
d7837182 TL |
168 | |
169 | do { | |
6f4b5b31 TL |
170 | l = cfile -> line; |
171 | p = cfile -> lpos; | |
172 | u = cfile -> ugflag; | |
58304e8e | 173 | |
d7837182 | 174 | c = get_char (cfile); |
512994ed TL |
175 | #ifdef OLD_LEXER |
176 | if (c == '\n' && p == 1 && !u | |
6f4b5b31 TL |
177 | && cfile -> comment_index < sizeof cfile -> comments) |
178 | cfile -> comments [cfile -> comment_index++] = '\n'; | |
512994ed TL |
179 | #endif |
180 | ||
6f4b5b31 TL |
181 | if (!(c == '\n' && cfile -> eol_token) |
182 | && isascii (c) && isspace (c)) | |
d7837182 TL |
183 | continue; |
184 | if (c == '#') { | |
512994ed | 185 | #ifdef OLD_LEXER |
6f4b5b31 TL |
186 | if (cfile -> comment_index < sizeof cfile -> comments) |
187 | cfile -> comments [cfile -> comment_index++] = '#'; | |
512994ed | 188 | #endif |
d7837182 TL |
189 | skip_to_eol (cfile); |
190 | continue; | |
191 | } | |
d7837182 | 192 | if (c == '"') { |
6f4b5b31 TL |
193 | cfile -> lexline = l; |
194 | cfile -> lexchar = p; | |
d7837182 TL |
195 | ttok = read_string (cfile); |
196 | break; | |
197 | } | |
a8b53b42 | 198 | if ((isascii (c) && isdigit (c)) || c == '-') { |
6f4b5b31 TL |
199 | cfile -> lexline = l; |
200 | cfile -> lexchar = p; | |
d7837182 TL |
201 | ttok = read_number (c, cfile); |
202 | break; | |
203 | } else if (isascii (c) && isalpha (c)) { | |
6f4b5b31 TL |
204 | cfile -> lexline = l; |
205 | cfile -> lexchar = p; | |
50b025a3 | 206 | ttok = read_num_or_name (c, cfile); |
d7837182 | 207 | break; |
0b69dcc8 TL |
208 | } else if (c == EOF) { |
209 | ttok = END_OF_FILE; | |
b3519f23 | 210 | cfile -> tlen = 0; |
0b69dcc8 | 211 | break; |
d7837182 | 212 | } else { |
6f4b5b31 TL |
213 | cfile -> lexline = l; |
214 | cfile -> lexchar = p; | |
089fb364 TL |
215 | tb [0] = c; |
216 | tb [1] = 0; | |
6f4b5b31 | 217 | cfile -> tval = tb; |
b3519f23 | 218 | cfile -> tlen = 1; |
d7837182 TL |
219 | ttok = c; |
220 | break; | |
221 | } | |
222 | } while (1); | |
223 | return ttok; | |
224 | } | |
225 | ||
b3519f23 | 226 | enum dhcp_token next_token (rval, rlen, cfile) |
b1b7b521 | 227 | const char **rval; |
b3519f23 | 228 | unsigned *rlen; |
6f4b5b31 | 229 | struct parse *cfile; |
d7837182 TL |
230 | { |
231 | int rv; | |
232 | ||
6f4b5b31 TL |
233 | if (cfile -> token) { |
234 | if (cfile -> lexline != cfile -> tline) | |
235 | cfile -> token_line = cfile -> cur_line; | |
236 | cfile -> lexchar = cfile -> tlpos; | |
237 | cfile -> lexline = cfile -> tline; | |
238 | rv = cfile -> token; | |
239 | cfile -> token = 0; | |
d7837182 TL |
240 | } else { |
241 | rv = get_token (cfile); | |
6f4b5b31 | 242 | cfile -> token_line = cfile -> cur_line; |
d7837182 TL |
243 | } |
244 | if (rval) | |
6f4b5b31 | 245 | *rval = cfile -> tval; |
b3519f23 TL |
246 | if (rlen) |
247 | *rlen = cfile -> tlen; | |
089fb364 | 248 | #ifdef DEBUG_TOKENS |
6f4b5b31 | 249 | fprintf (stderr, "%s:%d ", cfile -> tval, rv); |
089fb364 | 250 | #endif |
d7837182 TL |
251 | return rv; |
252 | } | |
253 | ||
b3519f23 | 254 | enum dhcp_token peek_token (rval, rlen, cfile) |
b1b7b521 | 255 | const char **rval; |
b3519f23 | 256 | unsigned int *rlen; |
6f4b5b31 | 257 | struct parse *cfile; |
d7837182 | 258 | { |
58304e8e TL |
259 | int x; |
260 | ||
6f4b5b31 TL |
261 | if (!cfile -> token) { |
262 | cfile -> tlpos = cfile -> lexchar; | |
263 | cfile -> tline = cfile -> lexline; | |
264 | cfile -> token = get_token (cfile); | |
265 | if (cfile -> lexline != cfile -> tline) | |
266 | cfile -> token_line = cfile -> prev_line; | |
267 | ||
268 | x = cfile -> lexchar; | |
269 | cfile -> lexchar = cfile -> tlpos; | |
270 | cfile -> tlpos = x; | |
271 | ||
272 | x = cfile -> lexline; | |
273 | cfile -> lexline = cfile -> tline; | |
274 | cfile -> tline = x; | |
58304e8e | 275 | } |
d7837182 | 276 | if (rval) |
6f4b5b31 | 277 | *rval = cfile -> tval; |
b3519f23 TL |
278 | if (rlen) |
279 | *rlen = cfile -> tlen; | |
089fb364 | 280 | #ifdef DEBUG_TOKENS |
6f4b5b31 | 281 | fprintf (stderr, "(%s:%d) ", cfile -> tval, cfile -> token); |
089fb364 | 282 | #endif |
6f4b5b31 | 283 | return cfile -> token; |
d7837182 TL |
284 | } |
285 | ||
286 | static void skip_to_eol (cfile) | |
6f4b5b31 | 287 | struct parse *cfile; |
d7837182 TL |
288 | { |
289 | int c; | |
290 | do { | |
291 | c = get_char (cfile); | |
292 | if (c == EOF) | |
293 | return; | |
512994ed | 294 | #ifdef OLD_LEXER |
6f4b5b31 TL |
295 | if (cfile -> comment_index < sizeof (cfile -> comments)) |
296 | comments [cfile -> comment_index++] = c; | |
512994ed | 297 | #endif |
d7837182 | 298 | if (c == EOL) { |
d7837182 TL |
299 | return; |
300 | } | |
301 | } while (1); | |
302 | } | |
303 | ||
104c88cd | 304 | static enum dhcp_token read_string (cfile) |
6f4b5b31 | 305 | struct parse *cfile; |
d7837182 TL |
306 | { |
307 | int i; | |
308 | int bs = 0; | |
309 | int c; | |
98311e4b DH |
310 | int value = 0; |
311 | int hex = 0; | |
d7837182 | 312 | |
6f4b5b31 | 313 | for (i = 0; i < sizeof cfile -> tokbuf; i++) { |
2b6e0559 | 314 | again: |
d7837182 TL |
315 | c = get_char (cfile); |
316 | if (c == EOF) { | |
6f4b5b31 | 317 | parse_warn (cfile, "eof in string constant"); |
d7837182 TL |
318 | break; |
319 | } | |
2b6e0559 TL |
320 | if (bs == 1) { |
321 | switch (c) { | |
322 | case 't': | |
323 | cfile -> tokbuf [i] = '\t'; | |
324 | break; | |
325 | case 'r': | |
326 | cfile -> tokbuf [i] = '\r'; | |
327 | break; | |
328 | case 'n': | |
329 | cfile -> tokbuf [i] = '\n'; | |
330 | break; | |
331 | case 'b': | |
332 | cfile -> tokbuf [i] = '\b'; | |
333 | break; | |
334 | case '0': | |
335 | case '1': | |
336 | case '2': | |
337 | case '3': | |
338 | hex = 0; | |
339 | value = c - '0'; | |
340 | ++bs; | |
341 | goto again; | |
342 | case 'x': | |
343 | hex = 1; | |
344 | value = 0; | |
345 | ++bs; | |
346 | goto again; | |
347 | default: | |
348 | cfile -> tokbuf [i] = c; | |
349 | bs = 0; | |
350 | break; | |
351 | } | |
d7837182 | 352 | bs = 0; |
2b6e0559 TL |
353 | } else if (bs > 1) { |
354 | if (hex) { | |
355 | if (c >= '0' && c <= '9') { | |
356 | value = value * 16 + (c - '0'); | |
357 | } else if (c >= 'a' && c <= 'f') { | |
358 | value = value * 16 + (c - 'a' + 10); | |
359 | } else if (c >= 'A' && c <= 'F') { | |
360 | value = value * 16 + (c - 'A' + 10); | |
361 | } else { | |
362 | parse_warn (cfile, | |
363 | "invalid hex digit: %x", | |
364 | c); | |
365 | bs = 0; | |
366 | continue; | |
367 | } | |
368 | if (++bs == 4) { | |
369 | cfile -> tokbuf [i] = value; | |
370 | bs = 0; | |
371 | } else | |
372 | goto again; | |
373 | } else { | |
374 | if (c >= '0' && c <= '9') { | |
375 | value = value * 8 + (c - '0'); | |
376 | } else { | |
377 | if (value != 0) { | |
378 | parse_warn (cfile, | |
379 | "invalid octal digit %x", | |
380 | c); | |
381 | continue; | |
382 | } else | |
383 | cfile -> tokbuf [i] = 0; | |
384 | bs = 0; | |
385 | } | |
386 | if (++bs == 4) { | |
387 | cfile -> tokbuf [i] = value; | |
388 | bs = 0; | |
389 | } else | |
390 | goto again; | |
391 | } | |
392 | } else if (c == '\\') { | |
d7837182 | 393 | bs = 1; |
2b6e0559 TL |
394 | goto again; |
395 | } else if (c == '"') | |
d7837182 TL |
396 | break; |
397 | else | |
6f4b5b31 | 398 | cfile -> tokbuf [i] = c; |
d7837182 TL |
399 | } |
400 | /* Normally, I'd feel guilty about this, but we're talking about | |
401 | strings that'll fit in a DHCP packet here... */ | |
6f4b5b31 TL |
402 | if (i == sizeof cfile -> tokbuf) { |
403 | parse_warn (cfile, | |
404 | "string constant larger than internal buffer"); | |
d7837182 TL |
405 | --i; |
406 | } | |
6f4b5b31 | 407 | cfile -> tokbuf [i] = 0; |
b3519f23 | 408 | cfile -> tlen = i; |
6f4b5b31 | 409 | cfile -> tval = cfile -> tokbuf; |
d7837182 TL |
410 | return STRING; |
411 | } | |
412 | ||
104c88cd | 413 | static enum dhcp_token read_number (c, cfile) |
d7837182 | 414 | int c; |
6f4b5b31 | 415 | struct parse *cfile; |
d7837182 | 416 | { |
98311e4b | 417 | #ifdef OLD_LEXER |
d7837182 | 418 | int seenx = 0; |
98311e4b | 419 | #endif |
d7837182 | 420 | int i = 0; |
512994ed TL |
421 | int token = NUMBER; |
422 | ||
6f4b5b31 TL |
423 | cfile -> tokbuf [i++] = c; |
424 | for (; i < sizeof cfile -> tokbuf; i++) { | |
d7837182 | 425 | c = get_char (cfile); |
98311e4b | 426 | |
512994ed | 427 | #ifndef OLD_LEXER |
98311e4b DH |
428 | /* Promote NUMBER -> NUMBER_OR_NAME -> NAME, never demote. |
429 | * Except in the case of '0x' syntax hex, which gets called | |
430 | * a NAME at '0x', and returned to NUMBER_OR_NAME once it's | |
431 | * verified to be at least 0xf or less. | |
432 | */ | |
433 | switch(isascii(c) ? token : BREAK) { | |
434 | case NUMBER: | |
435 | if(isdigit(c)) | |
436 | break; | |
437 | /* FALLTHROUGH */ | |
438 | case NUMBER_OR_NAME: | |
439 | if(isxdigit(c)) { | |
440 | token = NUMBER_OR_NAME; | |
441 | break; | |
442 | } | |
443 | /* FALLTHROUGH */ | |
444 | case NAME: | |
445 | if((i == 2) && isxdigit(c) && | |
446 | (cfile->tokbuf[0] == '0') && | |
447 | ((cfile->tokbuf[1] == 'x') || | |
448 | (cfile->tokbuf[1] == 'X'))) { | |
449 | token = NUMBER_OR_NAME; | |
450 | break; | |
451 | } else if(((c == '-') || (c == '_') || isalnum(c))) { | |
452 | token = NAME; | |
453 | break; | |
454 | } | |
455 | /* FALLTHROUGH */ | |
456 | case BREAK: | |
457 | /* At this point c is either EOF or part of the next | |
458 | * token. If not EOF, rewind the file one byte so | |
459 | * the next token is read from there. | |
460 | */ | |
461 | if(c != EOF) { | |
462 | cfile->bufix--; | |
463 | cfile->ugflag = 1; | |
464 | } | |
465 | goto end_read; | |
466 | ||
467 | default: | |
468 | log_fatal("read_number():%s:%d: impossible case", MDL); | |
469 | } | |
470 | #else /* OLD_LEXER */ | |
88cd8aca | 471 | if (!seenx && (c == 'x')) { |
98311e4b | 472 | seenx = 1; |
512994ed | 473 | } else if (!isascii (c) || !isxdigit (c)) { |
98311e4b DH |
474 | if (c != EOF) { |
475 | cfile -> bufix--; | |
476 | cfile -> ugflag = 1; | |
477 | } | |
d7837182 TL |
478 | break; |
479 | } | |
98311e4b DH |
480 | #endif /* OLD_LEXER */ |
481 | ||
6f4b5b31 | 482 | cfile -> tokbuf [i] = c; |
d7837182 | 483 | } |
98311e4b | 484 | |
6f4b5b31 TL |
485 | if (i == sizeof cfile -> tokbuf) { |
486 | parse_warn (cfile, | |
487 | "numeric token larger than internal buffer"); | |
d7837182 TL |
488 | --i; |
489 | } | |
98311e4b DH |
490 | |
491 | end_read: | |
6f4b5b31 | 492 | cfile -> tokbuf [i] = 0; |
b3519f23 | 493 | cfile -> tlen = i; |
6f4b5b31 | 494 | cfile -> tval = cfile -> tokbuf; |
98311e4b | 495 | |
512994ed | 496 | return token; |
d7837182 TL |
497 | } |
498 | ||
104c88cd | 499 | static enum dhcp_token read_num_or_name (c, cfile) |
d7837182 | 500 | int c; |
6f4b5b31 | 501 | struct parse *cfile; |
d7837182 TL |
502 | { |
503 | int i = 0; | |
104c88cd | 504 | enum dhcp_token rv = NUMBER_OR_NAME; |
6f4b5b31 TL |
505 | cfile -> tokbuf [i++] = c; |
506 | for (; i < sizeof cfile -> tokbuf; i++) { | |
d7837182 TL |
507 | c = get_char (cfile); |
508 | if (!isascii (c) || | |
509 | (c != '-' && c != '_' && !isalnum (c))) { | |
98311e4b DH |
510 | if (c != EOF) { |
511 | cfile -> bufix--; | |
512 | cfile -> ugflag = 1; | |
513 | } | |
d7837182 TL |
514 | break; |
515 | } | |
516 | if (!isxdigit (c)) | |
50b025a3 | 517 | rv = NAME; |
6f4b5b31 | 518 | cfile -> tokbuf [i] = c; |
d7837182 | 519 | } |
6f4b5b31 TL |
520 | if (i == sizeof cfile -> tokbuf) { |
521 | parse_warn (cfile, "token larger than internal buffer"); | |
d7837182 TL |
522 | --i; |
523 | } | |
6f4b5b31 | 524 | cfile -> tokbuf [i] = 0; |
b3519f23 | 525 | cfile -> tlen = i; |
6f4b5b31 TL |
526 | cfile -> tval = cfile -> tokbuf; |
527 | return intern (cfile -> tval, rv); | |
d7837182 TL |
528 | } |
529 | ||
104c88cd | 530 | static enum dhcp_token intern (atom, dfv) |
d7837182 | 531 | char *atom; |
104c88cd | 532 | enum dhcp_token dfv; |
d7837182 | 533 | { |
54d9cf28 TL |
534 | if (!isascii (atom [0])) |
535 | return dfv; | |
536 | ||
537 | switch (tolower (atom [0])) { | |
33d7b01a TL |
538 | case '-': |
539 | if (atom [1] == 0) | |
540 | return MINUS; | |
541 | break; | |
542 | ||
4660b519 | 543 | case 'a': |
551d1bc4 TL |
544 | if (!strncasecmp (atom + 1, "uth", 3)) { |
545 | if (!strncasecmp (atom + 3, "uthenticat", 10)) { | |
546 | if (!strcasecmp (atom + 13, "ed")) | |
547 | return AUTHENTICATED; | |
548 | if (!strcasecmp (atom + 13, "ion")) | |
549 | return AUTHENTICATION; | |
550 | break; | |
551 | } | |
552 | if (!strcasecmp (atom + 1, "uthoritative")) | |
553 | return AUTHORITATIVE; | |
551d1bc4 TL |
554 | break; |
555 | } | |
80fcef91 TL |
556 | if (!strcasecmp (atom + 1, "nd")) |
557 | return AND; | |
89500b31 TL |
558 | if (!strcasecmp (atom + 1, "ppend")) |
559 | return APPEND; | |
4660b519 TL |
560 | if (!strcasecmp (atom + 1, "llow")) |
561 | return ALLOW; | |
f79e49f3 TL |
562 | if (!strcasecmp (atom + 1, "lias")) |
563 | return ALIAS; | |
e6a480f0 TL |
564 | if (!strcasecmp (atom + 1, "lgorithm")) |
565 | return ALGORITHM; | |
f4fb257d | 566 | if (!strcasecmp (atom + 1, "bandoned")) |
007e3ee4 | 567 | return TOKEN_ABANDONED; |
52cdb300 | 568 | if (!strcasecmp (atom + 1, "dd")) |
8a04c615 | 569 | return TOKEN_ADD; |
f197003d TL |
570 | if (!strcasecmp (atom + 1, "ll")) |
571 | return ALL; | |
2b6e0559 TL |
572 | if (!strcasecmp (atom + 1, "t")) |
573 | return AT; | |
f8b21a3d TL |
574 | if (!strcasecmp (atom + 1, "rray")) |
575 | return ARRAY; | |
ff56f1d9 TL |
576 | if (!strcasecmp (atom + 1, "ddress")) |
577 | return ADDRESS; | |
007e3ee4 TL |
578 | if (!strcasecmp (atom + 1, "ctive")) |
579 | return TOKEN_ACTIVE; | |
88cd8aca DH |
580 | if (!strcasecmp (atom + 1, "tsfp")) |
581 | return ATSFP; | |
4660b519 | 582 | break; |
58304e8e | 583 | case 'b': |
007e3ee4 TL |
584 | if (!strcasecmp (atom + 1, "ackup")) |
585 | return TOKEN_BACKUP; | |
586 | if (!strcasecmp (atom + 1, "ootp")) | |
587 | return TOKEN_BOOTP; | |
588 | if (!strcasecmp (atom + 1, "inding")) | |
589 | return BINDING; | |
6df38ab2 TL |
590 | if (!strcasecmp (atom + 1, "inary-to-ascii")) |
591 | return BINARY_TO_ASCII; | |
3951e13c TL |
592 | if (!strcasecmp (atom + 1, "ackoff-cutoff")) |
593 | return BACKOFF_CUTOFF; | |
4660b519 TL |
594 | if (!strcasecmp (atom + 1, "ooting")) |
595 | return BOOTING; | |
58304e8e TL |
596 | if (!strcasecmp (atom + 1, "oot-unknown-clients")) |
597 | return BOOT_UNKNOWN_CLIENTS; | |
52cdb300 TL |
598 | if (!strcasecmp (atom + 1, "reak")) |
599 | return BREAK; | |
bcc73737 TL |
600 | if (!strcasecmp (atom + 1, "illing")) |
601 | return BILLING; | |
f8b21a3d TL |
602 | if (!strcasecmp (atom + 1, "oolean")) |
603 | return BOOLEAN; | |
ff56f1d9 TL |
604 | if (!strcasecmp (atom + 1, "alance")) |
605 | return BALANCE; | |
cf199463 TL |
606 | if (!strcasecmp (atom + 1, "ound")) |
607 | return BOUND; | |
52cdb300 | 608 | break; |
089fb364 | 609 | case 'c': |
14a2c383 TL |
610 | if (!strcasecmp (atom + 1, "ase")) |
611 | return CASE; | |
79a65726 TL |
612 | if (!strcasecmp (atom + 1, "ommit")) |
613 | return COMMIT; | |
f8b21a3d TL |
614 | if (!strcasecmp (atom + 1, "ode")) |
615 | return CODE; | |
79a65726 TL |
616 | if (!strcasecmp (atom + 1, "onfig-option")) |
617 | return CONFIG_OPTION; | |
80fcef91 TL |
618 | if (!strcasecmp (atom + 1, "heck")) |
619 | return CHECK; | |
089fb364 TL |
620 | if (!strcasecmp (atom + 1, "lass")) |
621 | return CLASS; | |
9345f3cc DN |
622 | if (!strcasecmp (atom + 1, "lose")) |
623 | return TOKEN_CLOSE; | |
624 | if (!strcasecmp (atom + 1, "reate")) | |
625 | return TOKEN_CREATE; | |
97ca1699 TL |
626 | if (!strcasecmp (atom + 1, "iaddr")) |
627 | return CIADDR; | |
74f45f96 TL |
628 | if (!strncasecmp (atom + 1, "lient", 5)) { |
629 | if (!strcasecmp (atom + 6, "-identifier")) | |
630 | return CLIENT_IDENTIFIER; | |
631 | if (!strcasecmp (atom + 6, "-hostname")) | |
632 | return CLIENT_HOSTNAME; | |
adccf916 TL |
633 | if (!strcasecmp (atom + 6, "-state")) |
634 | return CLIENT_STATE; | |
5a2bee23 TL |
635 | if (!strcasecmp (atom + 6, "-updates")) |
636 | return CLIENT_UPDATES; | |
74f45f96 TL |
637 | if (!strcasecmp (atom + 6, "s")) |
638 | return CLIENTS; | |
639 | } | |
24f9d67e | 640 | if (!strcasecmp (atom + 1, "oncat")) |
e25ff257 | 641 | return CONCAT; |
24f9d67e TL |
642 | if (!strcasecmp (atom + 1, "onnect")) |
643 | return CONNECT; | |
a167f312 TL |
644 | if (!strcasecmp (atom + 1, "ommunications-interrupted")) |
645 | return COMMUNICATIONS_INTERRUPTED; | |
8c8e27c5 TL |
646 | if (!strcasecmp (atom + 1, "ltt")) |
647 | return CLTT; | |
089fb364 | 648 | break; |
685963dc | 649 | case 'd': |
5e864416 DH |
650 | if (!strcasecmp(atom + 1, "b-time-format")) |
651 | return DB_TIME_FORMAT; | |
069e9f4c TL |
652 | if (!strcasecmp (atom + 1, "ns-update")) |
653 | return DNS_UPDATE; | |
88886e12 TL |
654 | if (!strcasecmp (atom + 1, "ns-delete")) |
655 | return DNS_DELETE; | |
89500b31 TL |
656 | if (!strcasecmp (atom + 1, "omain")) |
657 | return DOMAIN; | |
dba5803b DH |
658 | if (!strncasecmp (atom + 1, "omain-", 6)) { |
659 | if (!strcasecmp(atom + 7, "name")) | |
660 | return DOMAIN_NAME; | |
661 | if (!strcasecmp(atom + 7, "list")) | |
662 | return DOMAIN_LIST; | |
663 | } | |
98311e4b DH |
664 | if (!strcasecmp (atom + 1, "o-forward-update")) |
665 | return DO_FORWARD_UPDATE; | |
e7a9c293 DN |
666 | if (!strcasecmp (atom + 1, "ebug")) |
667 | return TOKEN_DEBUG; | |
4660b519 TL |
668 | if (!strcasecmp (atom + 1, "eny")) |
669 | return DENY; | |
07dc11f8 | 670 | if (!strcasecmp (atom + 1, "eleted")) |
007e3ee4 | 671 | return TOKEN_DELETED; |
2b6e0559 TL |
672 | if (!strcasecmp (atom + 1, "elete")) |
673 | return TOKEN_DELETE; | |
4660b519 TL |
674 | if (!strncasecmp (atom + 1, "efault", 6)) { |
675 | if (!atom [7]) | |
676 | return DEFAULT; | |
677 | if (!strcasecmp (atom + 7, "-lease-time")) | |
678 | return DEFAULT_LEASE_TIME; | |
679 | break; | |
680 | } | |
f197003d TL |
681 | if (!strncasecmp (atom + 1, "ynamic", 6)) { |
682 | if (!atom [7]) | |
683 | return DYNAMIC; | |
684 | if (!strncasecmp (atom + 7, "-bootp", 6)) { | |
685 | if (!atom [13]) | |
686 | return DYNAMIC_BOOTP; | |
687 | if (!strcasecmp (atom + 13, "-lease-cutoff")) | |
688 | return DYNAMIC_BOOTP_LEASE_CUTOFF; | |
689 | if (!strcasecmp (atom + 13, "-lease-length")) | |
690 | return DYNAMIC_BOOTP_LEASE_LENGTH; | |
691 | break; | |
692 | } | |
58304e8e | 693 | } |
337b3e52 TL |
694 | if (!strcasecmp (atom + 1, "uplicates")) |
695 | return DUPLICATES; | |
1038f739 TL |
696 | if (!strcasecmp (atom + 1, "eclines")) |
697 | return DECLINES; | |
33d7b01a TL |
698 | if (!strncasecmp (atom + 1, "efine", 5)) { |
699 | if (!strcasecmp (atom + 6, "d")) | |
700 | return DEFINED; | |
701 | if (!atom [6]) | |
702 | return DEFINE; | |
703 | } | |
685963dc | 704 | break; |
089fb364 | 705 | case 'e': |
0c6a64b2 TL |
706 | if (isascii (atom [1]) && tolower (atom [1]) == 'x') { |
707 | if (!strcasecmp (atom + 2, "tract-int")) | |
708 | return EXTRACT_INT; | |
709 | if (!strcasecmp (atom + 2, "ists")) | |
710 | return EXISTS; | |
a6d79ad7 TL |
711 | if (!strcasecmp (atom + 2, "piry")) |
712 | return EXPIRY; | |
713 | if (!strcasecmp (atom + 2, "pire")) | |
714 | return EXPIRE; | |
007e3ee4 TL |
715 | if (!strcasecmp (atom + 2, "pired")) |
716 | return TOKEN_EXPIRED; | |
0c6a64b2 | 717 | } |
337b3e52 | 718 | if (!strcasecmp (atom + 1, "ncode-int")) |
a6d79ad7 | 719 | return ENCODE_INT; |
5e864416 DH |
720 | if (!strcasecmp(atom + 1, "poch")) |
721 | return EPOCH; | |
089fb364 TL |
722 | if (!strcasecmp (atom + 1, "thernet")) |
723 | return ETHERNET; | |
724 | if (!strcasecmp (atom + 1, "nds")) | |
725 | return ENDS; | |
52cdb300 TL |
726 | if (!strncasecmp (atom + 1, "ls", 2)) { |
727 | if (!strcasecmp (atom + 3, "e")) | |
728 | return ELSE; | |
729 | if (!strcasecmp (atom + 3, "if")) | |
730 | return ELSIF; | |
731 | break; | |
732 | } | |
e7a9c293 DN |
733 | if (!strcasecmp (atom + 1, "rror")) |
734 | return ERROR; | |
34731eed TL |
735 | if (!strcasecmp (atom + 1, "val")) |
736 | return EVAL; | |
eebf58bc TL |
737 | if (!strcasecmp (atom + 1, "ncapsulate")) |
738 | return ENCAPSULATE; | |
d7837182 TL |
739 | break; |
740 | case 'f': | |
e7a9c293 DN |
741 | if (!strcasecmp (atom + 1, "atal")) |
742 | return FATAL; | |
d7837182 TL |
743 | if (!strcasecmp (atom + 1, "ilename")) |
744 | return FILENAME; | |
745 | if (!strcasecmp (atom + 1, "ixed-address")) | |
746 | return FIXED_ADDR; | |
a167f312 TL |
747 | if (!strcasecmp (atom + 1, "ddi")) |
748 | return FDDI; | |
14a2c383 TL |
749 | if (!strcasecmp (atom + 1, "ormerr")) |
750 | return NS_FORMERR; | |
33d7b01a TL |
751 | if (!strcasecmp (atom + 1, "unction")) |
752 | return FUNCTION; | |
ff56f1d9 TL |
753 | if (!strcasecmp (atom + 1, "ailover")) |
754 | return FAILOVER; | |
007e3ee4 TL |
755 | if (!strcasecmp (atom + 1, "ree")) |
756 | return TOKEN_FREE; | |
d7837182 | 757 | break; |
97ca1699 TL |
758 | case 'g': |
759 | if (!strcasecmp (atom + 1, "iaddr")) | |
760 | return GIADDR; | |
58304e8e TL |
761 | if (!strcasecmp (atom + 1, "roup")) |
762 | return GROUP; | |
5fea7b10 TL |
763 | if (!strcasecmp (atom + 1, "et-lease-hostnames")) |
764 | return GET_LEASE_HOSTNAMES; | |
97ca1699 | 765 | break; |
089fb364 | 766 | case 'h': |
f7fdb216 DH |
767 | if (!strcasecmp(atom + 1, "ash")) |
768 | return HASH; | |
2b6e0559 TL |
769 | if (!strcasecmp (atom + 1, "ba")) |
770 | return HBA; | |
089fb364 TL |
771 | if (!strcasecmp (atom + 1, "ost")) |
772 | return HOST; | |
79a65726 TL |
773 | if (!strcasecmp (atom + 1, "ost-decl-name")) |
774 | return HOST_DECL_NAME; | |
089fb364 TL |
775 | if (!strcasecmp (atom + 1, "ardware")) |
776 | return HARDWARE; | |
7e0f16d0 TL |
777 | if (!strcasecmp (atom + 1, "ostname")) |
778 | return HOSTNAME; | |
9345f3cc DN |
779 | if (!strcasecmp (atom + 1, "elp")) |
780 | return TOKEN_HELP; | |
089fb364 | 781 | break; |
f71f026a | 782 | case 'i': |
20916cae TL |
783 | if (!strcasecmp (atom + 1, "nclude")) |
784 | return INCLUDE; | |
f8b21a3d TL |
785 | if (!strcasecmp (atom + 1, "nteger")) |
786 | return INTEGER; | |
be1ee858 TL |
787 | if (!strcasecmp (atom + 1, "nfinite")) |
788 | return INFINITE; | |
e7a9c293 DN |
789 | if (!strcasecmp (atom + 1, "nfo")) |
790 | return INFO; | |
f8b21a3d TL |
791 | if (!strcasecmp (atom + 1, "p-address")) |
792 | return IP_ADDRESS; | |
3951e13c TL |
793 | if (!strcasecmp (atom + 1, "nitial-interval")) |
794 | return INITIAL_INTERVAL; | |
f71f026a TL |
795 | if (!strcasecmp (atom + 1, "nterface")) |
796 | return INTERFACE; | |
a167f312 TL |
797 | if (!strcasecmp (atom + 1, "dentifier")) |
798 | return IDENTIFIER; | |
52cdb300 TL |
799 | if (!strcasecmp (atom + 1, "f")) |
800 | return IF; | |
2b6e0559 TL |
801 | if (!strcasecmp (atom + 1, "s")) |
802 | return IS; | |
bd8734b5 TL |
803 | if (!strcasecmp (atom + 1, "gnore")) |
804 | return IGNORE; | |
f71f026a | 805 | break; |
f197003d | 806 | case 'k': |
98311e4b DH |
807 | if (!strncasecmp (atom + 1, "nown", 4)) { |
808 | if (!strcasecmp (atom + 5, "-clients")) | |
809 | return KNOWN_CLIENTS; | |
810 | if (!atom[5]) | |
811 | return KNOWN; | |
812 | break; | |
813 | } | |
e6a480f0 TL |
814 | if (!strcasecmp (atom + 1, "ey")) |
815 | return KEY; | |
f197003d | 816 | break; |
089fb364 | 817 | case 'l': |
2727c1cf DH |
818 | if (!strcasecmp (atom + 1, "case")) |
819 | return LCASE; | |
089fb364 TL |
820 | if (!strcasecmp (atom + 1, "ease")) |
821 | return LEASE; | |
6df38ab2 TL |
822 | if (!strcasecmp (atom + 1, "eased-address")) |
823 | return LEASED_ADDRESS; | |
71a34477 | 824 | if (!strcasecmp (atom + 1, "ease-time")) |
069e9f4c | 825 | return LEASE_TIME; |
f7fdb216 DH |
826 | if (!strcasecmp(atom + 1, "ength")) |
827 | return LENGTH; | |
bcc73737 TL |
828 | if (!strcasecmp (atom + 1, "imit")) |
829 | return LIMIT; | |
34731eed TL |
830 | if (!strcasecmp (atom + 1, "et")) |
831 | return LET; | |
ff56f1d9 TL |
832 | if (!strcasecmp (atom + 1, "oad")) |
833 | return LOAD; | |
5e864416 DH |
834 | if (!strcasecmp(atom + 1, "ocal")) |
835 | return LOCAL; | |
e7a9c293 DN |
836 | if (!strcasecmp (atom + 1, "og")) |
837 | return LOG; | |
d7837182 | 838 | break; |
685963dc | 839 | case 'm': |
ff56f1d9 TL |
840 | if (!strncasecmp (atom + 1, "ax", 2)) { |
841 | if (!atom [3]) | |
842 | return TOKEN_MAX; | |
2426234f DH |
843 | if (!strcasecmp (atom + 3, "-balance")) |
844 | return MAX_BALANCE; | |
845 | if (!strcasecmp (atom + 3, "-lease-")) { | |
846 | if (!strcasecmp(atom + 10, "misbalance")) | |
847 | return MAX_LEASE_MISBALANCE; | |
848 | if (!strcasecmp(atom + 10, "ownership")) | |
849 | return MAX_LEASE_OWNERSHIP; | |
850 | if (!strcasecmp(atom + 10, "time")) | |
851 | return MAX_LEASE_TIME; | |
852 | } | |
ff56f1d9 | 853 | if (!strcasecmp (atom + 3, "-transmit-idle")) |
a167f312 | 854 | return MAX_TRANSMIT_IDLE; |
ff56f1d9 | 855 | if (!strcasecmp (atom + 3, "-response-delay")) |
a167f312 | 856 | return MAX_RESPONSE_DELAY; |
ff56f1d9 | 857 | if (!strcasecmp (atom + 3, "-unacked-updates")) |
2b6e0559 | 858 | return MAX_UNACKED_UPDATES; |
a167f312 | 859 | } |
8028ab1d | 860 | if (!strncasecmp (atom + 1, "in-", 3)) { |
2426234f DH |
861 | if (!strcasecmp (atom + 4, "balance")) |
862 | return MIN_BALANCE; | |
8028ab1d TL |
863 | if (!strcasecmp (atom + 4, "lease-time")) |
864 | return MIN_LEASE_TIME; | |
865 | if (!strcasecmp (atom + 4, "secs")) | |
866 | return MIN_SECS; | |
867 | break; | |
868 | } | |
4660b519 TL |
869 | if (!strncasecmp (atom + 1, "edi", 3)) { |
870 | if (!strcasecmp (atom + 4, "a")) | |
871 | return MEDIA; | |
872 | if (!strcasecmp (atom + 4, "um")) | |
873 | return MEDIUM; | |
874 | break; | |
875 | } | |
52cdb300 TL |
876 | if (!strcasecmp (atom + 1, "atch")) |
877 | return MATCH; | |
f197003d TL |
878 | if (!strcasecmp (atom + 1, "embers")) |
879 | return MEMBERS; | |
a167f312 TL |
880 | if (!strcasecmp (atom + 1, "y")) |
881 | return MY; | |
2b6e0559 TL |
882 | if (!strcasecmp (atom + 1, "clt")) |
883 | return MCLT; | |
685963dc TL |
884 | break; |
885 | case 'n': | |
a167f312 TL |
886 | if (!strcasecmp (atom + 1, "ormal")) |
887 | return NORMAL; | |
89500b31 TL |
888 | if (!strcasecmp (atom + 1, "ameserver")) |
889 | return NAMESERVER; | |
685963dc TL |
890 | if (!strcasecmp (atom + 1, "etmask")) |
891 | return NETMASK; | |
be1ee858 TL |
892 | if (!strcasecmp (atom + 1, "ever")) |
893 | return NEVER; | |
58304e8e TL |
894 | if (!strcasecmp (atom + 1, "ext-server")) |
895 | return NEXT_SERVER; | |
a167f312 TL |
896 | if (!strcasecmp (atom + 1, "ot")) |
897 | return TOKEN_NOT; | |
2b6e0559 TL |
898 | if (!strcasecmp (atom + 1, "o")) |
899 | return NO; | |
900 | if (!strcasecmp (atom + 1, "s-update")) | |
901 | return NS_UPDATE; | |
14a2c383 TL |
902 | if (!strcasecmp (atom + 1, "oerror")) |
903 | return NS_NOERROR; | |
904 | if (!strcasecmp (atom + 1, "otauth")) | |
905 | return NS_NOTAUTH; | |
906 | if (!strcasecmp (atom + 1, "otimp")) | |
907 | return NS_NOTIMP; | |
908 | if (!strcasecmp (atom + 1, "otzone")) | |
909 | return NS_NOTZONE; | |
910 | if (!strcasecmp (atom + 1, "xdomain")) | |
911 | return NS_NXDOMAIN; | |
912 | if (!strcasecmp (atom + 1, "xrrset")) | |
913 | return NS_NXRRSET; | |
914 | if (!strcasecmp (atom + 1, "ull")) | |
915 | return TOKEN_NULL; | |
007e3ee4 TL |
916 | if (!strcasecmp (atom + 1, "ext")) |
917 | return TOKEN_NEXT; | |
5ec697e6 TL |
918 | if (!strcasecmp (atom + 1, "ew")) |
919 | return TOKEN_NEW; | |
685963dc | 920 | break; |
d7837182 | 921 | case 'o': |
9ea249af TL |
922 | if (!strcasecmp (atom + 1, "mapi")) |
923 | return OMAPI; | |
80fcef91 TL |
924 | if (!strcasecmp (atom + 1, "r")) |
925 | return OR; | |
79a65726 TL |
926 | if (!strcasecmp (atom + 1, "n")) |
927 | return ON; | |
9345f3cc DN |
928 | if (!strcasecmp (atom + 1, "pen")) |
929 | return TOKEN_OPEN; | |
d7837182 TL |
930 | if (!strcasecmp (atom + 1, "ption")) |
931 | return OPTION; | |
512994ed TL |
932 | if (!strcasecmp (atom + 1, "ne-lease-per-client")) |
933 | return ONE_LEASE_PER_CLIENT; | |
f197003d TL |
934 | if (!strcasecmp (atom + 1, "f")) |
935 | return OF; | |
2b6e0559 TL |
936 | if (!strcasecmp (atom + 1, "wner")) |
937 | return OWNER; | |
512994ed TL |
938 | break; |
939 | case 'p': | |
89500b31 TL |
940 | if (!strcasecmp (atom + 1, "repend")) |
941 | return PREPEND; | |
512994ed TL |
942 | if (!strcasecmp (atom + 1, "acket")) |
943 | return PACKET; | |
f197003d TL |
944 | if (!strcasecmp (atom + 1, "ool")) |
945 | return POOL; | |
946 | if (!strcasecmp (atom + 1, "seudo")) | |
947 | return PSEUDO; | |
a167f312 TL |
948 | if (!strcasecmp (atom + 1, "eer")) |
949 | return PEER; | |
950 | if (!strcasecmp (atom + 1, "rimary")) | |
951 | return PRIMARY; | |
952 | if (!strncasecmp (atom + 1, "artner", 6)) { | |
953 | if (!atom [7]) | |
954 | return PARTNER; | |
955 | if (!strcasecmp (atom + 7, "-down")) | |
956 | return PARTNER_DOWN; | |
957 | } | |
958 | if (!strcasecmp (atom + 1, "ort")) | |
959 | return PORT; | |
960 | if (!strcasecmp (atom + 1, "otential-conflict")) | |
961 | return POTENTIAL_CONFLICT; | |
34731eed TL |
962 | if (!strcasecmp (atom + 1, "ick-first-value") || |
963 | !strcasecmp (atom + 1, "ick")) | |
964 | return PICK; | |
05815916 TL |
965 | if (!strcasecmp (atom + 1, "aused")) |
966 | return PAUSED; | |
d7837182 | 967 | break; |
089fb364 | 968 | case 'r': |
732dc815 TL |
969 | if (!strcasecmp (atom + 1, "esolution-interrupted")) |
970 | return RESOLUTION_INTERRUPTED; | |
089fb364 TL |
971 | if (!strcasecmp (atom + 1, "ange")) |
972 | return RANGE; | |
a167f312 TL |
973 | if (!strcasecmp (atom + 1, "ecover")) |
974 | return RECOVER; | |
05815916 TL |
975 | if (!strcasecmp (atom + 1, "ecover-done")) |
976 | return RECOVER_DONE; | |
3417f5cf TL |
977 | if (!strcasecmp (atom + 1, "ecover-wait")) |
978 | return RECOVER_WAIT; | |
cf199463 TL |
979 | if (!strcasecmp (atom + 1, "econtact-interval")) |
980 | return RECONTACT_INTERVAL; | |
f71f026a TL |
981 | if (!strcasecmp (atom + 1, "equest")) |
982 | return REQUEST; | |
983 | if (!strcasecmp (atom + 1, "equire")) | |
984 | return REQUIRE; | |
a167f312 TL |
985 | if (!strcasecmp (atom + 1, "equire")) |
986 | return REQUIRE; | |
f71f026a TL |
987 | if (!strcasecmp (atom + 1, "etry")) |
988 | return RETRY; | |
1b234d44 DN |
989 | if (!strcasecmp (atom + 1, "eturn")) |
990 | return RETURN; | |
f71f026a TL |
991 | if (!strcasecmp (atom + 1, "enew")) |
992 | return RENEW; | |
993 | if (!strcasecmp (atom + 1, "ebind")) | |
994 | return REBIND; | |
296af24c TL |
995 | if (!strcasecmp (atom + 1, "eboot")) |
996 | return REBOOT; | |
36f5381c TL |
997 | if (!strcasecmp (atom + 1, "eject")) |
998 | return REJECT; | |
6df38ab2 TL |
999 | if (!strcasecmp (atom + 1, "everse")) |
1000 | return REVERSE; | |
79a65726 TL |
1001 | if (!strcasecmp (atom + 1, "elease")) |
1002 | return RELEASE; | |
14a2c383 TL |
1003 | if (!strcasecmp (atom + 1, "efused")) |
1004 | return NS_REFUSED; | |
007e3ee4 TL |
1005 | if (!strcasecmp (atom + 1, "eleased")) |
1006 | return TOKEN_RELEASED; | |
1007 | if (!strcasecmp (atom + 1, "eset")) | |
1008 | return TOKEN_RESET; | |
1009 | if (!strcasecmp (atom + 1, "eserved")) | |
1010 | return TOKEN_RESERVED; | |
31bbee78 TL |
1011 | if (!strcasecmp (atom + 1, "emove")) |
1012 | return REMOVE; | |
d758ad8c TL |
1013 | if (!strcasecmp (atom + 1, "efresh")) |
1014 | return REFRESH; | |
089fb364 TL |
1015 | break; |
1016 | case 's': | |
f7fdb216 DH |
1017 | if (!strcasecmp(atom + 1, "cript")) |
1018 | return SCRIPT; | |
1019 | if (tolower(atom[1]) == 'e') { | |
1020 | if (!strcasecmp(atom + 2, "arch")) | |
1021 | return SEARCH; | |
1022 | if (tolower(atom[2]) == 'c') { | |
1023 | if (!strcasecmp(atom + 3, "ond")) { | |
1024 | if (!strcasecmp(atom + 6, "ary")) | |
1025 | return SECONDARY; | |
1026 | if (!strcasecmp(atom + 6, "s")) | |
1027 | return SECONDS; | |
1028 | break; | |
1029 | } | |
1030 | if (!strcasecmp(atom + 3, "ret")) | |
1031 | return SECRET; | |
1032 | break; | |
1033 | } | |
1034 | if (!strncasecmp(atom + 2, "lect", 4)) { | |
1035 | if (atom[6] == '\0') | |
1036 | return SELECT; | |
1037 | if (!strcasecmp(atom + 6, "-timeout")) | |
1038 | return SELECT_TIMEOUT; | |
1039 | break; | |
1040 | } | |
1041 | if (!strcasecmp(atom + 2, "nd")) | |
1042 | return SEND; | |
1043 | if (!strncasecmp(atom + 2, "rv", 2)) { | |
1044 | if (!strncasecmp(atom + 4, "er", 2)) { | |
1045 | if (atom[6] == '\0') | |
1046 | return SERVER; | |
1047 | if (atom[6] == '-') { | |
1048 | if (!strcasecmp(atom + 7, | |
1049 | "name")) | |
1050 | return SERVER_NAME; | |
1051 | if (!strcasecmp(atom + 7, | |
1052 | "identifier")) | |
1053 | return SERVER_IDENTIFIER; | |
1054 | break; | |
1055 | } | |
1056 | break; | |
1057 | } | |
1058 | if (!strcasecmp(atom + 4, "fail")) | |
1059 | return NS_SERVFAIL; | |
1060 | break; | |
1061 | } | |
1062 | if (!strcasecmp(atom + 2, "t")) | |
1063 | return TOKEN_SET; | |
52cdb300 TL |
1064 | break; |
1065 | } | |
f7fdb216 DH |
1066 | if (tolower(atom[1]) == 'h') { |
1067 | if (!strcasecmp(atom + 2, "ared-network")) | |
1068 | return SHARED_NETWORK; | |
1069 | if (!strcasecmp(atom + 2, "utdown")) | |
1070 | return SHUTDOWN; | |
1071 | break; | |
1072 | } | |
1073 | if (tolower(atom[1]) == 'i') { | |
1074 | if (!strcasecmp(atom + 2, "addr")) | |
1075 | return SIADDR; | |
1076 | if (!strcasecmp(atom + 2, "gned")) | |
1077 | return SIGNED; | |
1078 | if (!strcasecmp(atom + 2, "ze")) | |
1079 | return SIZE; | |
1080 | break; | |
1081 | } | |
1082 | if (tolower(atom[1]) == 'p') { | |
1083 | if (tolower(atom[2]) == 'a') { | |
1084 | if (!strcasecmp(atom + 3, "ce")) | |
1085 | return SPACE; | |
1086 | if (!strcasecmp(atom + 3, "wn")) | |
1087 | return SPAWN; | |
1088 | break; | |
1089 | } | |
1090 | if (!strcasecmp(atom + 2, "lit")) | |
1091 | return SPLIT; | |
1092 | break; | |
1093 | } | |
1094 | if (tolower(atom[1]) == 't') { | |
1095 | if (tolower(atom[2]) == 'a') { | |
1096 | if(strncasecmp(atom + 3, "rt", 2)) { | |
1097 | if (!strcasecmp(atom + 5, "s")) | |
1098 | return STARTS; | |
1099 | if (!strcasecmp(atom + 5, "up")) | |
1100 | return STARTUP; | |
1101 | break; | |
1102 | } | |
1103 | if (tolower(atom[3]) == 't') { | |
1104 | if (!strcasecmp(atom + 4, "e")) | |
1105 | return STATE; | |
1106 | if (!strcasecmp(atom + 4, "ic")) | |
1107 | return STATIC; | |
1108 | break; | |
1109 | } | |
1110 | } | |
1111 | if (!strcasecmp(atom + 2, "ring")) | |
1112 | return STRING_TOKEN; | |
1113 | break; | |
1114 | } | |
1115 | if (!strncasecmp(atom + 1, "ub", 2)) { | |
1116 | if (!strcasecmp(atom + 3, "class")) | |
1117 | return SUBCLASS; | |
1118 | if (!strcasecmp(atom + 3, "net")) | |
1119 | return SUBNET; | |
1120 | if (!strcasecmp(atom + 3, "string")) | |
1121 | return SUBSTRING; | |
1122 | break; | |
1123 | } | |
1124 | if (tolower(atom[1]) == 'u') { | |
1125 | if (!strcasecmp(atom + 2, "ffix")) | |
1126 | return SUFFIX; | |
1127 | if (!strcasecmp(atom + 2, "persede")) | |
1128 | return SUPERSEDE; | |
1129 | } | |
1130 | if (!strcasecmp(atom + 1, "witch")) | |
1131 | return SWITCH; | |
089fb364 TL |
1132 | break; |
1133 | case 't': | |
54d9cf28 | 1134 | if (!strcasecmp (atom + 1, "imestamp")) |
089fb364 | 1135 | return TIMESTAMP; |
f71f026a TL |
1136 | if (!strcasecmp (atom + 1, "imeout")) |
1137 | return TIMEOUT; | |
58304e8e TL |
1138 | if (!strcasecmp (atom + 1, "oken-ring")) |
1139 | return TOKEN_RING; | |
f8b21a3d TL |
1140 | if (!strcasecmp (atom + 1, "ext")) |
1141 | return TEXT; | |
2b6e0559 TL |
1142 | if (!strcasecmp (atom + 1, "stp")) |
1143 | return TSTP; | |
1144 | if (!strcasecmp (atom + 1, "sfp")) | |
1145 | return TSFP; | |
1687c64b TL |
1146 | if (!strcasecmp (atom + 1, "ransmission")) |
1147 | return TRANSMISSION; | |
089fb364 TL |
1148 | break; |
1149 | case 'u': | |
2727c1cf DH |
1150 | if (!strcasecmp (atom + 1, "case")) |
1151 | return UCASE; | |
34731eed TL |
1152 | if (!strcasecmp (atom + 1, "nset")) |
1153 | return UNSET; | |
f8b21a3d TL |
1154 | if (!strcasecmp (atom + 1, "nsigned")) |
1155 | return UNSIGNED; | |
089fb364 TL |
1156 | if (!strcasecmp (atom + 1, "id")) |
1157 | return UID; | |
a167f312 TL |
1158 | if (!strncasecmp (atom + 1, "se", 2)) { |
1159 | if (!strcasecmp (atom + 3, "r-class")) | |
1160 | return USER_CLASS; | |
1161 | if (!strcasecmp (atom + 3, "-host-decl-names")) | |
1162 | return USE_HOST_DECL_NAMES; | |
1163 | if (!strcasecmp (atom + 3, | |
1164 | "-lease-addr-for-default-route")) | |
1165 | return USE_LEASE_ADDR_FOR_DEFAULT_ROUTE; | |
1166 | break; | |
1167 | } | |
f197003d TL |
1168 | if (!strncasecmp (atom + 1, "nknown", 6)) { |
1169 | if (!strcasecmp (atom + 7, "-clients")) | |
1170 | return UNKNOWN_CLIENTS; | |
822e866a TL |
1171 | if (!strcasecmp (atom + 7, "-state")) |
1172 | return UNKNOWN_STATE; | |
f197003d TL |
1173 | if (!atom [7]) |
1174 | return UNKNOWN; | |
1175 | break; | |
1176 | } | |
1177 | if (!strcasecmp (atom + 1, "nauthenticated")) | |
1178 | return AUTHENTICATED; | |
846d7d54 TL |
1179 | if (!strcasecmp (atom + 1, "pdated-dns-rr")) |
1180 | return UPDATED_DNS_RR; | |
2b6e0559 TL |
1181 | if (!strcasecmp (atom + 1, "pdate")) |
1182 | return UPDATE; | |
b0e3a220 TL |
1183 | break; |
1184 | case 'v': | |
1185 | if (!strcasecmp (atom + 1, "endor-class")) | |
1186 | return VENDOR_CLASS; | |
eebf58bc TL |
1187 | if (!strcasecmp (atom + 1, "endor")) |
1188 | return VENDOR; | |
089fb364 | 1189 | break; |
52cdb300 TL |
1190 | case 'w': |
1191 | if (!strcasecmp (atom + 1, "ith")) | |
1192 | return WITH; | |
f7fdb216 DH |
1193 | if (!strcasecmp(atom + 1, "idth")) |
1194 | return WIDTH; | |
52cdb300 | 1195 | break; |
97ca1699 TL |
1196 | case 'y': |
1197 | if (!strcasecmp (atom + 1, "iaddr")) | |
1198 | return YIADDR; | |
14a2c383 TL |
1199 | if (!strcasecmp (atom + 1, "xdomain")) |
1200 | return NS_YXDOMAIN; | |
1201 | if (!strcasecmp (atom + 1, "xrrset")) | |
1202 | return NS_YXRRSET; | |
97ca1699 | 1203 | break; |
cfc62a06 TL |
1204 | case 'z': |
1205 | if (!strcasecmp (atom + 1, "one")) | |
1206 | return ZONE; | |
1207 | break; | |
d7837182 TL |
1208 | } |
1209 | return dfv; | |
1210 | } |