Changeset View
Changeset View
Standalone View
Standalone View
sbin/dhclient/conflex.c
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
#include "dhcpd.h" | #include "dhcpd.h" | ||||
#include "dhctoken.h" | #include "dhctoken.h" | ||||
int lexline; | int lexline; | ||||
int lexchar; | int lexchar; | ||||
char *token_line; | char *token_line; | ||||
char *prev_line; | char *prev_line; | ||||
char *cur_line; | char *cur_line; | ||||
char *tlname; | const char *tlname; | ||||
int eol_token; | int eol_token; | ||||
static char line1[81]; | static char line1[81]; | ||||
static char line2[81]; | static char line2[81]; | ||||
static unsigned lpos; | static unsigned lpos; | ||||
static unsigned line; | static unsigned line; | ||||
static int tlpos; | static int tlpos; | ||||
static int tline; | static int tline; | ||||
static int token; | static int token; | ||||
static int ugflag; | static int ugflag; | ||||
static char *tval; | static char *tval; | ||||
static char tokbuf[1500]; | static char tokbuf[1500]; | ||||
static int get_char(FILE *); | static int get_char(FILE *); | ||||
static int get_token(FILE *); | static int get_token(FILE *); | ||||
static void skip_to_eol(FILE *); | static void skip_to_eol(FILE *); | ||||
static int read_string(FILE *); | static int read_string(FILE *); | ||||
static int read_number(int, FILE *); | static int read_number(int, FILE *); | ||||
static int read_num_or_name(int, FILE *); | static int read_num_or_name(int, FILE *); | ||||
static int intern(char *, int); | static int intern(char *, int); | ||||
void | void | ||||
new_parse(char *name) | new_parse(const char *name) | ||||
{ | { | ||||
tlname = name; | tlname = name; | ||||
lpos = line = 1; | lpos = line = 1; | ||||
cur_line = line1; | cur_line = line1; | ||||
prev_line = line2; | prev_line = line2; | ||||
token_line = cur_line; | token_line = cur_line; | ||||
cur_line[0] = prev_line[0] = 0; | cur_line[0] = prev_line[0] = 0; | ||||
warnings_occurred = 0; | warnings_occurred = 0; | ||||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | read_string(FILE *cfile) | ||||
tokbuf[i] = 0; | tokbuf[i] = 0; | ||||
tval = tokbuf; | tval = tokbuf; | ||||
return (STRING); | return (STRING); | ||||
} | } | ||||
static int | static int | ||||
read_number(int c, FILE *cfile) | read_number(int c, FILE *cfile) | ||||
{ | { | ||||
int seenx = 0, token = NUMBER; | int seenx = 0, _token = NUMBER; | ||||
unsigned i = 0; | unsigned i = 0; | ||||
tokbuf[i++] = c; | tokbuf[i++] = c; | ||||
for (; i < sizeof(tokbuf); i++) { | for (; i < sizeof(tokbuf); i++) { | ||||
c = get_char(cfile); | c = get_char(cfile); | ||||
if (!seenx && c == 'x') | if (!seenx && c == 'x') | ||||
seenx = 1; | seenx = 1; | ||||
else if (!isascii(c) || !isxdigit(c)) { | else if (!isascii(c) || !isxdigit(c)) { | ||||
ungetc(c, cfile); | ungetc(c, cfile); | ||||
ugflag = 1; | ugflag = 1; | ||||
break; | break; | ||||
} | } | ||||
tokbuf[i] = c; | tokbuf[i] = c; | ||||
} | } | ||||
if (i == sizeof(tokbuf)) { | if (i == sizeof(tokbuf)) { | ||||
parse_warn("numeric token larger than internal buffer"); | parse_warn("numeric token larger than internal buffer"); | ||||
i--; | i--; | ||||
} | } | ||||
tokbuf[i] = 0; | tokbuf[i] = 0; | ||||
tval = tokbuf; | tval = tokbuf; | ||||
return (token); | return (_token); | ||||
} | } | ||||
static int | static int | ||||
read_num_or_name(int c, FILE *cfile) | read_num_or_name(int c, FILE *cfile) | ||||
{ | { | ||||
unsigned i = 0; | unsigned i = 0; | ||||
int rv = NUMBER_OR_NAME; | int rv = NUMBER_OR_NAME; | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |