diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-04-18 19:18:33 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2006-04-18 19:18:33 +0000 |
commit | cce7a5f92295794cf2cc572026a946410be92948 (patch) | |
tree | dd5bd22d5babbd33c181f640c3901be846f82370 /usr.sbin/dhcpd/parse.c | |
parent | b645a40eb61bfbe27f5c44b15e6e62e629f197b2 (diff) |
cleanup keyword lookup for the lexer, and remove keywords not valid in
either dhclient or dhcpd context; tested by many
Diffstat (limited to 'usr.sbin/dhcpd/parse.c')
-rw-r--r-- | usr.sbin/dhcpd/parse.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/usr.sbin/dhcpd/parse.c b/usr.sbin/dhcpd/parse.c index 3dc693835e8..3cab5da4345 100644 --- a/usr.sbin/dhcpd/parse.c +++ b/usr.sbin/dhcpd/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.7 2004/09/16 18:35:43 deraadt Exp $ */ +/* $OpenBSD: parse.c,v 1.8 2006/04/18 19:18:32 deraadt Exp $ */ /* Common parser code for dhcpd and dhclient. */ @@ -67,16 +67,16 @@ skip_to_semi(FILE *cfile) do { token = peek_token(&val, cfile); - if (token == RBRACE) { + if (token == '}') { if (brace_count) { token = next_token(&val, cfile); if (!--brace_count) return; } else return; - } else if (token == LBRACE) { + } else if (token == '{') { brace_count++; - } else if (token == SEMI && !brace_count) { + } else if (token == ';' && !brace_count) { token = next_token(&val, cfile); return; } else if (token == '\n') { @@ -100,7 +100,7 @@ parse_semi(FILE *cfile) char *val; token = next_token(&val, cfile); - if (token != SEMI) { + if (token != ';') { parse_warn("semicolon expected."); skip_to_semi(cfile); return (0); @@ -118,7 +118,7 @@ parse_string(FILE *cfile) int token; token = next_token(&val, cfile); - if (token != STRING) { + if (token != TOK_STRING) { parse_warn("filename must be a string"); skip_to_semi(cfile); return (NULL); @@ -147,7 +147,7 @@ parse_host_name(FILE *cfile) do { /* Read a token, which should be an identifier. */ token = next_token(&val, cfile); - if (!is_identifier(token) && token != NUMBER) { + if (!is_identifier(token) && token != TOK_NUMBER) { parse_warn("expecting an identifier in hostname"); skip_to_semi(cfile); return (NULL); @@ -163,9 +163,9 @@ parse_host_name(FILE *cfile) * we're done. */ token = peek_token(&val, cfile); - if (token == DOT) + if (token == '.') token = next_token(&val, cfile); - } while (token == DOT); + } while (token == '.'); /* Assemble the hostname together into a string. */ if (!(s = malloc(len))) @@ -201,13 +201,13 @@ parse_hardware_param(FILE *cfile, struct hardware *hardware) token = next_token(&val, cfile); switch (token) { - case ETHERNET: + case TOK_ETHERNET: hardware->htype = HTYPE_ETHER; break; - case TOKEN_RING: + case TOK_TOKEN_RING: hardware->htype = HTYPE_IEEE802; break; - case FDDI: + case TOK_FDDI: hardware->htype = HTYPE_FDDI; break; default: @@ -226,7 +226,7 @@ parse_hardware_param(FILE *cfile, struct hardware *hardware) * on such clients. Yuck. */ hlen = 0; - t = parse_numeric_aggregate(cfile, NULL, &hlen, COLON, 16, 8); + t = parse_numeric_aggregate(cfile, NULL, &hlen, ':', 16, 8); if (!t) return; if (hlen > sizeof(hardware->haddr)) { @@ -242,7 +242,7 @@ parse_hardware_param(FILE *cfile, struct hardware *hardware) } token = next_token(&val, cfile); - if (token != SEMI) { + if (token != ';') { parse_warn("expecting semicolon."); skip_to_semi(cfile); } @@ -258,7 +258,7 @@ parse_lease_time(FILE *cfile, time_t *timep) int token; token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("Expecting numeric lease time"); skip_to_semi(cfile); return; @@ -300,10 +300,10 @@ parse_numeric_aggregate(FILE *cfile, unsigned char *buf, int *max, if (token != separator) { if (!*max) break; - if (token != RBRACE && token != LBRACE) + if (token != '{' && token != '}') token = next_token(&val, cfile); parse_warn("too few numbers."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } @@ -316,8 +316,8 @@ parse_numeric_aggregate(FILE *cfile, unsigned char *buf, int *max, break; } /* Allow NUMBER_OR_NAME if base is 16. */ - if (token != NUMBER && - (base != 16 || token != NUMBER_OR_NAME)) { + if (token != TOK_NUMBER && + (base != 16 || token != TOK_NUMBER_OR_NAME)) { parse_warn("expecting numeric value."); skip_to_semi(cfile); return (NULL); @@ -476,9 +476,9 @@ parse_date(FILE * cfile) /* Day of week... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric day of week expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } @@ -486,9 +486,9 @@ parse_date(FILE * cfile) /* Year... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric year expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } @@ -498,17 +498,17 @@ parse_date(FILE * cfile) /* Slash separating year from month... */ token = next_token(&val, cfile); - if (token != SLASH) { + if (token != '/') { parse_warn("expected slash separating year from month."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } /* Month... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric month expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } @@ -516,17 +516,17 @@ parse_date(FILE * cfile) /* Slash separating month from day... */ token = next_token(&val, cfile); - if (token != SLASH) { + if (token != '/') { parse_warn("expected slash separating month from day."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } /* Month... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric day of month expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } @@ -534,9 +534,9 @@ parse_date(FILE * cfile) /* Hour... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric hour expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } @@ -544,17 +544,17 @@ parse_date(FILE * cfile) /* Colon separating hour from minute... */ token = next_token(&val, cfile); - if (token != COLON) { + if (token != ':') { parse_warn("expected colon separating hour from minute."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } /* Minute... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric minute expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } @@ -562,17 +562,17 @@ parse_date(FILE * cfile) /* Colon separating minute from second... */ token = next_token(&val, cfile); - if (token != COLON) { + if (token != ':') { parse_warn("expected colon separating hour from minute."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } /* Minute... */ token = next_token(&val, cfile); - if (token != NUMBER) { + if (token != TOK_NUMBER) { parse_warn("numeric minute expected."); - if (token != SEMI) + if (token != ';') skip_to_semi(cfile); return (NULL); } @@ -584,7 +584,7 @@ parse_date(FILE * cfile) /* Make sure the date ends in a semicolon... */ token = next_token(&val, cfile); - if (token != SEMI) { + if (token != ';') { parse_warn("semicolon expected."); skip_to_semi(cfile); return (NULL); |