From: Dave Hart Date: Sun, 11 Oct 2009 19:27:05 +0000 (+0000) Subject: Construct ntpd keyword scanner finite state machine at compile time X-Git-Tag: NTP_4_2_5P232_RC~5^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcebce26eee3b090930fdd3305f7302681ef9a71;p=thirdparty%2Fntp.git Construct ntpd keyword scanner finite state machine at compile time rather than at runtime, shrink entries from 40+ to 8 bytes. bk: 4ad23189nGazo1D22dNTn1fM2bc2lQ --- diff --git a/ChangeLog b/ChangeLog index f86a5be54..371a9be99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +* Construct ntpd keyword scanner finite state machine at compile time + rather than at runtime, shrink entries from 40+ to 8 bytes. (4.2.5p231-RC) 2009/10/10 Released by Harlan Stenn * [Bug 1335] Broadcast client degraded by wildcard default change. (4.2.5p230-RC) 2009/10/09 Released by Harlan Stenn diff --git a/bootstrap b/bootstrap index 1acabd4c6..f5a14533d 100755 --- a/bootstrap +++ b/bootstrap @@ -110,6 +110,10 @@ done touch ntpd/ntp_parser.[ch] +# generated by ntpd/keyword-gen.c + +touch ntpd/ntp_keyword.h + ## HMS: Danger, Will Robinson. # If we remove files that used to be there, the old .Po files will bite us. # If we remove the .deps file, we *must* run config.status to generate new diff --git a/include/ntp_filegen.h b/include/ntp_filegen.h index 8ebcd4df6..2b90db29d 100644 --- a/include/ntp_filegen.h +++ b/include/ntp_filegen.h @@ -35,20 +35,20 @@ /* without this, open is suppressed */ typedef struct FILEGEN - { - FILE *fp; /* file referring to current generation */ - char *prefix; /* filename prefix and basename to be used*/ - char *basename; /* for constructing filename of generation file */ +{ + FILE * fp; /* file referring to current generation */ + const char * prefix; /* filename prefix and basename to be used*/ + char * basename; /* for constructing filename of generation file */ /* WARNING: must be malloced !!! will be fed to free()*/ - u_long id; /* id of current generation */ - u_char type; /* type of file generation */ - u_char flag; /* flags modifying processing of file generation */ - } FILEGEN; + u_long id; /* id of current generation */ + u_char type; /* type of file generation */ + u_char flag; /* flags modifying processing of file generation */ +} FILEGEN; extern void filegen_setup (FILEGEN *, u_long); -extern void filegen_config (FILEGEN *, char *, u_int, u_int); -extern FILEGEN *filegen_get (char *); -extern void filegen_register (char *, const char *, FILEGEN *); +extern void filegen_config (FILEGEN *, const char *, u_int, u_int); +extern FILEGEN *filegen_get (const char *); +extern void filegen_register (const char *, const char *, FILEGEN *); #ifdef DEBUG extern void filegen_unregister(char *); #endif diff --git a/ntpd/Makefile.am b/ntpd/Makefile.am index 74819341c..56e9ac43a 100644 --- a/ntpd/Makefile.am +++ b/ntpd/Makefile.am @@ -58,7 +58,8 @@ vphack_after: ) BUILT_SOURCES= $(VPHACK) ntp_parser.c ntp_parser.h $(VPHACK_AFTER) \ - ntpd-opts.c ntpd-opts.h ntpd.1 ntpd-opts.texi ntpd-opts.menu + ntp_keyword.h ntpd-opts.c ntpd-opts.h ntpd.1 ntpd-opts.texi \ + ntpd-opts.menu man_MANS= ntpd.1 @@ -71,16 +72,18 @@ man_MANS= ntpd.1 # sqrt ntp_control.o # floor refclock_wwv.o # which are (usually) provided by -lm. +keyword_gen_LDADD = ../libntp/libntp.a ntpd_LDADD = $(LDADD) -lm @LCRYPTO@ @LSCF@ $(LIBOPTS_LDADD) ../libntp/libntp.a ntpdsim_LDADD = $(LDADD) -lm @LCRYPTO@ @LSCF@ $(LIBOPTS_LDADD) ../libntp/libntpsim.a ntpdsim_CFLAGS = $(CFLAGS) -DSIM check_y2k_LDADD = $(LDADD) ../libntp/libntp.a -DISTCLEANFILES = .version version.c -CLEANFILES = check-saveconfig compsave.conf +DISTCLEANFILES = keyword-gen .version version.c +CLEANFILES = check-saveconfig compsave.conf ntp_keyword.out EXTRA_DIST = \ complete.conf \ ntpd-opts.def \ ntpdbase-opts.def \ + ntp_keyword.h \ refclock_msfees.c \ refclock_trak.c \ $(BUILT_SOURCES) \ @@ -88,7 +91,7 @@ EXTRA_DIST = \ ETAGS_ARGS = Makefile.am ### Y2Kfixes check_PROGRAMS = @MAKE_CHECK_Y2K@ -EXTRA_PROGRAMS = check_y2k ntpdsim +EXTRA_PROGRAMS = check_y2k ntpdsim keyword-gen run_ag= cd $(srcdir) && autogen -L ../include --writable std_def_list= $(top_srcdir)/include/autogen-version.def \ $(top_srcdir)/include/copyright.def \ @@ -176,6 +179,16 @@ libntpd_a_SOURCES = \ refclock_zyfer.c \ $(NULL) +ntp_keyword.out: keyword-gen + ./keyword-gen $(srcdir)/ntp_parser.h > $@ + grep -F -v diff_ignore_line < $(srcdir)/ntp_keyword.h > cmp1 + grep -F -v diff_ignore_line < $@ > cmp2 + cmp cmp1 cmp2 > /dev/null || cp $@ $(srcdir)/ntp_keyword.h + rm cmp1 cmp2 + +$(srcdir)/ntp_keyword.h: ntp_keyword.out + echo $(srcdir)/ntp_keyword.h is unchanged > /dev/null + $(srcdir)/ntpd-opts.h: $(srcdir)/ntpd-opts.c $(srcdir)/ntpd-opts.c: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list) $(run_ag) ntpd-opts.def diff --git a/ntpd/keyword-gen.c b/ntpd/keyword-gen.c new file mode 100644 index 000000000..5ef118908 --- /dev/null +++ b/ntpd/keyword-gen.c @@ -0,0 +1,546 @@ +/* + * keyword-gen.c -- generate keyword scanner finite state machine and + * keyword_text array. + * This program is run to generate ntp_keyword.h + */ +#include +#include +#include +#include + +#include +#include +#include "../libntp/lib_strbuf.h" +#include "ntp_scanner.h" +#include "ntp_parser.h" + + +#ifdef QSORT_USES_VOID_P +typedef const void * QSORTP; +#else +typedef char * QSORTP; +#endif + +/* Define a structure to hold a (keyword, token) pair */ +struct key_tok { + char * key; /* Keyword */ + int token; /* Associated Token */ + follby followedby; /* nonzero indicates the next token(s) + forced to be string(s) */ +}; + +struct key_tok ntp_keywords[] = { +{ "automax", T_Automax, FOLLBY_TOKEN }, +{ "broadcast", T_Broadcast, FOLLBY_STRING }, +{ "broadcastclient", T_Broadcastclient, FOLLBY_TOKEN }, +{ "broadcastdelay", T_Broadcastdelay, FOLLBY_TOKEN }, +{ "calldelay", T_Calldelay, FOLLBY_TOKEN }, +{ "disable", T_Disable, FOLLBY_TOKEN }, +{ "driftfile", T_Driftfile, FOLLBY_STRING }, +{ "enable", T_Enable, FOLLBY_TOKEN }, +{ "end", T_End, FOLLBY_TOKEN }, +{ "filegen", T_Filegen, FOLLBY_TOKEN }, +{ "fudge", T_Fudge, FOLLBY_STRING }, +{ "includefile", T_Includefile, FOLLBY_STRING }, +{ "leapfile", T_Leapfile, FOLLBY_STRING }, +{ "logconfig", T_Logconfig, FOLLBY_STRINGS_TO_EOC }, +{ "logfile", T_Logfile, FOLLBY_STRING }, +{ "manycastclient", T_Manycastclient, FOLLBY_STRING }, +{ "manycastserver", T_Manycastserver, FOLLBY_STRINGS_TO_EOC }, +{ "multicastclient", T_Multicastclient, FOLLBY_STRINGS_TO_EOC }, +{ "peer", T_Peer, FOLLBY_STRING }, +{ "phone", T_Phone, FOLLBY_STRINGS_TO_EOC }, +{ "pidfile", T_Pidfile, FOLLBY_STRING }, +{ "pool", T_Pool, FOLLBY_STRING }, +{ "discard", T_Discard, FOLLBY_TOKEN }, +{ "restrict", T_Restrict, FOLLBY_TOKEN }, +{ "server", T_Server, FOLLBY_STRING }, +{ "setvar", T_Setvar, FOLLBY_STRING }, +{ "statistics", T_Statistics, FOLLBY_TOKEN }, +{ "statsdir", T_Statsdir, FOLLBY_STRING }, +{ "tick", T_Tick, FOLLBY_TOKEN }, +{ "tinker", T_Tinker, FOLLBY_TOKEN }, +{ "tos", T_Tos, FOLLBY_TOKEN }, +{ "trap", T_Trap, FOLLBY_STRING }, +{ "unconfig", T_Unconfig, FOLLBY_STRING }, +{ "unpeer", T_Unpeer, FOLLBY_STRING }, +/* authentication_command */ +{ "controlkey", T_ControlKey, FOLLBY_TOKEN }, +{ "crypto", T_Crypto, FOLLBY_TOKEN }, +{ "keys", T_Keys, FOLLBY_STRING }, +{ "keysdir", T_Keysdir, FOLLBY_STRING }, +{ "ntpsigndsocket", T_NtpSignDsocket, FOLLBY_STRING }, +{ "requestkey", T_Requestkey, FOLLBY_TOKEN }, +{ "revoke", T_Revoke, FOLLBY_TOKEN }, +{ "trustedkey", T_Trustedkey, FOLLBY_TOKEN }, +/* IPv4/IPv6 protocol override flag */ +{ "-4", T_Ipv4_flag, FOLLBY_TOKEN }, +{ "-6", T_Ipv6_flag, FOLLBY_TOKEN }, +/* option */ +{ "autokey", T_Autokey, FOLLBY_TOKEN }, +{ "bias", T_Bias, FOLLBY_TOKEN }, +{ "burst", T_Burst, FOLLBY_TOKEN }, +{ "iburst", T_Iburst, FOLLBY_TOKEN }, +{ "key", T_Key, FOLLBY_TOKEN }, +{ "maxpoll", T_Maxpoll, FOLLBY_TOKEN }, +{ "minpoll", T_Minpoll, FOLLBY_TOKEN }, +{ "mode", T_Mode, FOLLBY_TOKEN }, +{ "noselect", T_Noselect, FOLLBY_TOKEN }, +{ "preempt", T_Preempt, FOLLBY_TOKEN }, +{ "true", T_True, FOLLBY_TOKEN }, +{ "prefer", T_Prefer, FOLLBY_TOKEN }, +{ "ttl", T_Ttl, FOLLBY_TOKEN }, +{ "version", T_Version, FOLLBY_TOKEN }, +{ "xleave", T_Xleave, FOLLBY_TOKEN }, +/* crypto_command */ +{ "host", T_Host, FOLLBY_STRING }, +{ "ident", T_Ident, FOLLBY_STRING }, +{ "pw", T_Pw, FOLLBY_STRING }, +{ "randfile", T_Randfile, FOLLBY_STRING }, +{ "sign", T_Sign, FOLLBY_STRING }, +/*** MONITORING COMMANDS ***/ +/* stat */ +{ "clockstats", T_Clockstats, FOLLBY_TOKEN }, +{ "cryptostats", T_Cryptostats, FOLLBY_TOKEN }, +{ "loopstats", T_Loopstats, FOLLBY_TOKEN }, +{ "peerstats", T_Peerstats, FOLLBY_TOKEN }, +{ "rawstats", T_Rawstats, FOLLBY_TOKEN }, +{ "sysstats", T_Sysstats, FOLLBY_TOKEN }, +{ "protostats", T_Protostats, FOLLBY_TOKEN }, +{ "timingstats", T_Timingstats, FOLLBY_TOKEN }, +/* filegen_option */ +{ "file", T_File, FOLLBY_STRING }, +{ "link", T_Link, FOLLBY_TOKEN }, +{ "nolink", T_Nolink, FOLLBY_TOKEN }, +{ "type", T_Type, FOLLBY_TOKEN }, +/* filegen_type */ +{ "age", T_Age, FOLLBY_TOKEN }, +{ "day", T_Day, FOLLBY_TOKEN }, +{ "month", T_Month, FOLLBY_TOKEN }, +{ "none", T_None, FOLLBY_TOKEN }, +{ "pid", T_Pid, FOLLBY_TOKEN }, +{ "week", T_Week, FOLLBY_TOKEN }, +{ "year", T_Year, FOLLBY_TOKEN }, +/*** ORPHAN MODE COMMANDS ***/ +/* tos_option */ +{ "minclock", T_Minclock, FOLLBY_TOKEN }, +{ "maxclock", T_Maxclock, FOLLBY_TOKEN }, +{ "minsane", T_Minsane, FOLLBY_TOKEN }, +{ "floor", T_Floor, FOLLBY_TOKEN }, +{ "ceiling", T_Ceiling, FOLLBY_TOKEN }, +{ "cohort", T_Cohort, FOLLBY_TOKEN }, +{ "mindist", T_Mindist, FOLLBY_TOKEN }, +{ "maxdist", T_Maxdist, FOLLBY_TOKEN }, +{ "beacon", T_Beacon, FOLLBY_TOKEN }, +{ "orphan", T_Orphan, FOLLBY_TOKEN }, +/* access_control_flag */ +{ "default", T_Default, FOLLBY_TOKEN }, +{ "flake", T_Flake, FOLLBY_TOKEN }, +{ "ignore", T_Ignore, FOLLBY_TOKEN }, +{ "limited", T_Limited, FOLLBY_TOKEN }, +{ "mssntp", T_Mssntp, FOLLBY_TOKEN }, +{ "kod", T_Kod, FOLLBY_TOKEN }, +{ "lowpriotrap", T_Lowpriotrap, FOLLBY_TOKEN }, +{ "mask", T_Mask, FOLLBY_TOKEN }, +{ "nomodify", T_Nomodify, FOLLBY_TOKEN }, +{ "nopeer", T_Nopeer, FOLLBY_TOKEN }, +{ "noquery", T_Noquery, FOLLBY_TOKEN }, +{ "noserve", T_Noserve, FOLLBY_TOKEN }, +{ "notrap", T_Notrap, FOLLBY_TOKEN }, +{ "notrust", T_Notrust, FOLLBY_TOKEN }, +{ "ntpport", T_Ntpport, FOLLBY_TOKEN }, +/* discard_option */ +{ "average", T_Average, FOLLBY_TOKEN }, +{ "minimum", T_Minimum, FOLLBY_TOKEN }, +{ "monitor", T_Monitor, FOLLBY_TOKEN }, +/* fudge_factor */ +{ "flag1", T_Flag1, FOLLBY_TOKEN }, +{ "flag2", T_Flag2, FOLLBY_TOKEN }, +{ "flag3", T_Flag3, FOLLBY_TOKEN }, +{ "flag4", T_Flag4, FOLLBY_TOKEN }, +{ "refid", T_Refid, FOLLBY_STRING }, +{ "stratum", T_Stratum, FOLLBY_TOKEN }, +{ "time1", T_Time1, FOLLBY_TOKEN }, +{ "time2", T_Time2, FOLLBY_TOKEN }, +/* system_option */ +{ "auth", T_Auth, FOLLBY_TOKEN }, +{ "bclient", T_Bclient, FOLLBY_TOKEN }, +{ "calibrate", T_Calibrate, FOLLBY_TOKEN }, +{ "kernel", T_Kernel, FOLLBY_TOKEN }, +{ "ntp", T_Ntp, FOLLBY_TOKEN }, +{ "stats", T_Stats, FOLLBY_TOKEN }, +/* tinker_option */ +{ "step", T_Step, FOLLBY_TOKEN }, +{ "panic", T_Panic, FOLLBY_TOKEN }, +{ "dispersion", T_Dispersion, FOLLBY_TOKEN }, +{ "stepout", T_Stepout, FOLLBY_TOKEN }, +{ "allan", T_Allan, FOLLBY_TOKEN }, +{ "huffpuff", T_Huffpuff, FOLLBY_TOKEN }, +{ "freq", T_Freq, FOLLBY_TOKEN }, +/* miscellaneous_command */ +{ "port", T_Port, FOLLBY_TOKEN }, +{ "interface", T_Interface, FOLLBY_TOKEN }, +{ "qos", T_Qos, FOLLBY_TOKEN }, +{ "saveconfigdir", T_Saveconfigdir, FOLLBY_STRING }, +/* interface_command (ignore and interface already defined) */ +{ "nic", T_Nic, FOLLBY_TOKEN }, +{ "all", T_All, FOLLBY_TOKEN }, +{ "ipv4", T_Ipv4, FOLLBY_TOKEN }, +{ "ipv6", T_Ipv6, FOLLBY_TOKEN }, +{ "wildcard", T_Wildcard, FOLLBY_TOKEN }, +{ "listen", T_Listen, FOLLBY_TOKEN }, +{ "drop", T_Drop, FOLLBY_TOKEN }, +/* simulator commands */ +{ "simulate", T_Simulate, FOLLBY_TOKEN }, +{ "simulation_duration",T_Sim_Duration, FOLLBY_TOKEN }, +{ "beep_delay", T_Beep_Delay, FOLLBY_TOKEN }, +{ "duration", T_Duration, FOLLBY_TOKEN }, +{ "server_offset", T_Server_Offset, FOLLBY_TOKEN }, +{ "freq_offset", T_Freq_Offset, FOLLBY_TOKEN }, +{ "wander", T_Wander, FOLLBY_TOKEN }, +{ "jitter", T_Jitter, FOLLBY_TOKEN }, +{ "prop_delay", T_Prop_Delay, FOLLBY_TOKEN }, +{ "proc_delay", T_Proc_Delay, FOLLBY_TOKEN }, +}; + +const char * current_keyword;/* for error reporting */ +int sst_free; /* next unused entry index */ +scan_state sst[2048]; /* scanner FSM state entries */ +char * symb[1024]; /* map token ID to symbolic name */ + +/* for libntp */ +const char * progname = "keyword-gen"; +volatile int debug = 1; + +int main (int, char **); +static void generate_preamble (void); +static void generate_fsm (void); +static void generate_token_text (void); +static int create_keyword_scanner (void); +static int create_scan_states (char *, int, follby, int); +int compare_key_tok_id (QSORTP, QSORTP); +int compare_key_tok_text (QSORTP, QSORTP); +void populate_symb (char *); +const char * symbname (int); + + +int main(int argc, char **argv) +{ + if (argc < 2) { + fprintf(stderr, "Usage:\n%s t_header.h\n", argv[0]); + exit(1); + } + populate_symb(argv[1]); + + generate_preamble(); + generate_token_text(); + generate_fsm(); + + return 0; +} + + +static void +generate_preamble(void) +{ + time_t now; + char timestamp[128]; + char preamble[] = +"/*\n" +" * ntp_keyword.h\n" +" * \n" +" * NOTE: edit this file with caution, it is generated by keyword-gen.c\n" +" *\t Generated %s UTC diff_ignore_line\n" +" *\n" +" */\n" +"#include \"ntp_scanner.h\"\n" +"#include \"ntp_parser.h\"\n" +"\n"; + + time(&now); + if (!strftime(timestamp, sizeof(timestamp), + "%Y-%m-%d %H:%M:%S", gmtime(&now))) + timestamp[0] = '\0'; + + printf(preamble, timestamp); +} + + +static void +generate_fsm(void) +{ + int initial_state; + int i; + + /* + * Sort ntp_keywords in alphabetical keyword order. This is + * not necessary, but minimizes nonfunctional changes in the + * generated finite state machine when keywords are modified. + */ + qsort(ntp_keywords, COUNTOF(ntp_keywords), + sizeof(ntp_keywords[0]), compare_key_tok_text); + + initial_state = create_keyword_scanner(); + + fprintf(stderr, + "%d keywords consumed %d states of %d max.\n", + (int)COUNTOF(ntp_keywords), + sst_free - 1, + (int)COUNTOF(sst) - 1); + + printf("#define SCANNER_INIT_S %d\n\n", initial_state); + + printf("const scan_state sst[%d] = {\n" + "/*\t\t{ ch,\tf-by,\t\t token,\tmatch,\tother\t}\t*/\n" + "/* %-5d */\t{ 0 },", + sst_free, + 0); + + for (i = 1; i < sst_free; i++) { + printf("\n/* %-5d */\t{ '%c',\t%d,%20s,\t%5u,\t%5u\t}", + i, + sst[i].ch, + sst[i].followedby, + symbname(sst[i].finishes_token), + sst[i].match_next_s, + sst[i].other_next_s); + if (i + 1 < sst_free) + printf(","); + } + + printf("\n};\n\n"); +} + + +/* Define a function to create the states of the scanner. This function + * is used by the create_keyword_scanner function below. + * + * This function takes a suffix of a keyword, the token to be returned on + * recognizing the complete keyword, and any pre-existing state that exists + * for some other keyword that has the same prefix as the current one. + */ +static int +create_scan_states( + char * text, + int token, + follby followedby, + int prev_state + ) +{ + int my_state; + int return_state; + int prev_char_s; + int curr_char_s; + + return_state = prev_state; + curr_char_s = prev_state; + prev_char_s = 0; + + /* Find the correct position to insert the state. + * All states should be in alphabetical order + */ + while (curr_char_s && (text[0] < sst[curr_char_s].ch)) { + prev_char_s = curr_char_s; + curr_char_s = sst[curr_char_s].other_next_s; + } + + /* + * Check if a previously seen keyword has the same prefix as + * the current keyword. If so, simply use the state for that + * keyword as my_state, otherwise, allocate a new state. + */ + if (curr_char_s && (text[0] == sst[curr_char_s].ch)) { + my_state = curr_char_s; + if ('\0' == text[1]) { + fprintf(stderr, + "Duplicate entries for keyword '%s' in" + " keyword_gen.c ntp_keywords[].\n", + current_keyword); + exit(2); + } + } else { + my_state = sst_free++; + if (my_state >= COUNTOF(sst)) { + fprintf(stderr, + "fatal, keyword scanner state array " + "sst[%d] is too small, modify\n" + "keyword-gen.c to increase.\n", + (int)COUNTOF(sst)); + exit(3); + } + /* Store the next character of the keyword */ + sst[my_state].ch = text[0]; + sst[my_state].other_next_s = curr_char_s; + + if (prev_char_s) + sst[prev_char_s].other_next_s = my_state; + else + return_state = my_state; + } + + /* Check if the next character is '\0'. + * If yes, we are done with the recognition and this is an accepting + * state. + * If not, we need to continue scanning + */ + if ('\0' == text[1]) { + sst[my_state].finishes_token = (u_short)token; + sst[my_state].followedby = (char)followedby; + } else + sst[my_state].match_next_s = + create_scan_states( + &text[1], + token, + followedby, + sst[my_state].match_next_s); + + return return_state; +} + + +/* Define a function that takes a list of (keyword, token) values and + * creates a keywords scanner out of it. + */ + +static int +create_keyword_scanner(void) +{ + int scanner; + int i; + + sst_free = 1; /* index 0 invalid, unused */ + scanner = 0; + + for (i = 0; i < COUNTOF(ntp_keywords); i++) { + current_keyword = ntp_keywords[i].key; + scanner = + create_scan_states( + ntp_keywords[i].key, + ntp_keywords[i].token, + ntp_keywords[i].followedby, + scanner); + } + + return scanner; +} + + +static void +generate_token_text(void) +{ + int lowest_id; + int highest_id; + int id_count; + int id; + int i; + + /* sort ntp_keywords in token ID order */ + qsort(ntp_keywords, COUNTOF(ntp_keywords), + sizeof(ntp_keywords[0]), compare_key_tok_id); + + lowest_id = ntp_keywords[0].token; + highest_id = ntp_keywords[COUNTOF(ntp_keywords) - 1].token; + id_count = highest_id - lowest_id + 1; + + printf("#define LOWEST_KEYWORD_ID %d\n\n", lowest_id); + + printf("const char * const keyword_text[%d] = {", id_count); + + id = lowest_id; + i = 0; + while (i < COUNTOF(ntp_keywords)) { + while (id < ntp_keywords[i].token) { + printf(",\n\t/* %-5d %5d %20s */\tNULL", + id - lowest_id, id, symbname(id)); + id++; + } + if (i > 0) + printf(","); + printf("\n\t/* %-5d %5d %20s */\t\"%s\"", + id - lowest_id, id, symbname(id), + ntp_keywords[i].key); + i++; + id++; + } + + printf("\n};\n\n"); +} + + +int +compare_key_tok_id( + QSORTP a1, + QSORTP a2 + ) +{ + const struct key_tok *p1 = (const void *)a1; + const struct key_tok *p2 = (const void *)a2; + + if (p1->token == p2->token) + return 0; + + if (p1->token < p2->token) + return -1; + else + return 1; +} + + +int +compare_key_tok_text( + QSORTP a1, + QSORTP a2 + ) +{ + const struct key_tok *p1 = (const void *)a1; + const struct key_tok *p2 = (const void *)a2; + + return strcmp(p1->key, p2->key); +} + + +/* + * populate_symb() - populate symb[] lookup array with symbolic token + * names such that symb[T_Age] == "T_Age", etc. + */ +void +populate_symb( + char *header_file + ) +{ + FILE * yh; + char line[128]; + char name[128]; + int token; + + yh = fopen(header_file, "r"); + if (NULL == yh) { + perror("unable to open yacc/bison header file"); + exit(4); + } + + while (NULL != fgets(line, sizeof(line), yh)) + if (2 == sscanf(line, "#define %s %d", name, &token) + && 'T' == name[0] && '_' == name[1] && token >= 0 + && token < COUNTOF(symb)) + + symb[token] = estrdup(name); + + fclose(yh); +} + + +const char * +symbname( + int token + ) +{ + char *name; + + if (token >= 0 && token < COUNTOF(symb) && symb[token] != NULL) + return symb[token]; + + LIB_GETBUF(name); + snprintf(name, LIB_BUFLENGTH, "%d", token); + return name; +} diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index a031a9146..ddad85c07 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -1948,12 +1948,11 @@ config_monitor( ) { int *pfilegen_token; - char *filegen_string; + const char *filegen_string; + const char *filegen_file; FILEGEN *filegen; struct filegen_node *my_node; struct attr_val *my_opts; - - char *filegen_file; int filegen_type; int filegen_flag; @@ -3728,10 +3727,7 @@ config_remotely( input_from_file = 0; init_syntax_tree(&cfgt); - key_scanner = create_keyword_scanner(); yyparse(); - delete_keyword_scanner(key_scanner); - key_scanner = NULL; cfgt.source.attr = CONF_SOURCE_NTPQ; cfgt.timestamp = time(NULL); cfgt.source.value.s = estrdup(stoa(remote_addr)); @@ -3839,12 +3835,8 @@ getconfig( yydebug = !!(debug >= 5); #endif ip_file = fp[curr_include_level]; - key_scanner = create_keyword_scanner(); yyparse(); - delete_keyword_scanner(key_scanner); - key_scanner = NULL; - DPRINTF(1, ("Finished Parsing!!\n")); cfgt.source.attr = CONF_SOURCE_FILE; diff --git a/ntpd/ntp_filegen.c b/ntpd/ntp_filegen.c index 5730ce841..3ba3906cd 100644 --- a/ntpd/ntp_filegen.c +++ b/ntpd/ntp_filegen.c @@ -45,8 +45,8 @@ #define SUFFIX_SEP '.' static void filegen_open (FILEGEN *, u_long); -static int valid_fileref (char *, char *); -static void filegen_init (char *, const char *, FILEGEN *); +static int valid_fileref (const char *, const char *); +static void filegen_init (const char *, const char *, FILEGEN *); #ifdef DEBUG static void filegen_uninit (FILEGEN *); #endif /* DEBUG */ @@ -58,15 +58,14 @@ static void filegen_uninit (FILEGEN *); static void filegen_init( - char * prefix, + const char * prefix, const char * basename, FILEGEN * fgp ) { fgp->fp = NULL; fgp->prefix = prefix; /* Yes, this is TOTALLY lame! */ - fgp->basename = emalloc(strlen(basename) + 1); - strcpy(fgp->basename, basename); + fgp->basename = estrdup(basename); fgp->id = 0; fgp->type = FILEGEN_DAY; fgp->flag = FGEN_FLAG_LINK; /* not yet enabled !!*/ @@ -410,7 +409,7 @@ filegen_setup( void filegen_config( FILEGEN * gen, - char * basename, + const char * basename, u_int type, u_int flag ) @@ -421,8 +420,7 @@ filegen_config( /* * if nothing would be changed... */ - if ((basename == gen->basename || strcmp(basename, gen->basename) == 0) - && type == gen->type + if ((strcmp(basename, gen->basename) == 0) && type == gen->type && flag == gen->flag) return; @@ -448,7 +446,7 @@ filegen_config( gen->type, type, gen->flag, flag)); - if (gen->basename != basename || strcmp(gen->basename, basename) != 0) { + if (strcmp(gen->basename, basename) != 0) { octets = strlen(basename) + 1; gen->basename = erealloc(gen->basename, octets); memcpy(gen->basename, basename, octets); @@ -477,8 +475,8 @@ filegen_config( */ static int valid_fileref( - char * prefix, - char * basename + const char * prefix, + const char * basename ) { /* @@ -494,7 +492,7 @@ valid_fileref( * has to be ensured by other means * (however, it would be possible to perform some checks here...) */ - register char *p = basename; + register const char *p = basename; /* * Just to catch, dumb errors opening up the world... @@ -528,7 +526,7 @@ static struct filegen_entry { FILEGEN * filegen_get( - char * name + const char * name ) { struct filegen_entry *f = filegen_registry; @@ -548,7 +546,7 @@ filegen_get( void filegen_register( - char * prefix, + const char * prefix, const char * name, FILEGEN * filegen ) diff --git a/ntpd/ntp_keyword.h b/ntpd/ntp_keyword.h new file mode 100644 index 000000000..be3bbf899 --- /dev/null +++ b/ntpd/ntp_keyword.h @@ -0,0 +1,920 @@ +/* + * ntp_keyword.h + * + * NOTE: edit this file with caution, it is generated by keyword-gen.c + * Generated 2009-10-11 08:55:52 UTC diff_ignore_line + * + */ +#include "ntp_scanner.h" +#include "ntp_parser.h" + +#define LOWEST_KEYWORD_ID 258 + +const char * const keyword_text[161] = { + /* 0 258 T_Age */ "age", + /* 1 259 T_All */ "all", + /* 2 260 T_Allan */ "allan", + /* 3 261 T_Auth */ "auth", + /* 4 262 T_Autokey */ "autokey", + /* 5 263 T_Automax */ "automax", + /* 6 264 T_Average */ "average", + /* 7 265 T_Bclient */ "bclient", + /* 8 266 T_Beacon */ "beacon", + /* 9 267 T_Bias */ "bias", + /* 10 268 T_Broadcast */ "broadcast", + /* 11 269 T_Broadcastclient */ "broadcastclient", + /* 12 270 T_Broadcastdelay */ "broadcastdelay", + /* 13 271 T_Burst */ "burst", + /* 14 272 T_Calibrate */ "calibrate", + /* 15 273 T_Calldelay */ "calldelay", + /* 16 274 T_Ceiling */ "ceiling", + /* 17 275 T_Clockstats */ "clockstats", + /* 18 276 T_Cohort */ "cohort", + /* 19 277 T_ControlKey */ "controlkey", + /* 20 278 T_Crypto */ "crypto", + /* 21 279 T_Cryptostats */ "cryptostats", + /* 22 280 T_Day */ "day", + /* 23 281 T_Default */ "default", + /* 24 282 T_Disable */ "disable", + /* 25 283 T_Discard */ "discard", + /* 26 284 T_Dispersion */ "dispersion", + /* 27 285 T_Double */ NULL, + /* 28 286 T_Driftfile */ "driftfile", + /* 29 287 T_Drop */ "drop", + /* 30 288 T_Enable */ "enable", + /* 31 289 T_End */ "end", + /* 32 290 T_False */ NULL, + /* 33 291 T_File */ "file", + /* 34 292 T_Filegen */ "filegen", + /* 35 293 T_Flag1 */ "flag1", + /* 36 294 T_Flag2 */ "flag2", + /* 37 295 T_Flag3 */ "flag3", + /* 38 296 T_Flag4 */ "flag4", + /* 39 297 T_Flake */ "flake", + /* 40 298 T_Floor */ "floor", + /* 41 299 T_Freq */ "freq", + /* 42 300 T_Fudge */ "fudge", + /* 43 301 T_Host */ "host", + /* 44 302 T_Huffpuff */ "huffpuff", + /* 45 303 T_Iburst */ "iburst", + /* 46 304 T_Ident */ "ident", + /* 47 305 T_Ignore */ "ignore", + /* 48 306 T_Includefile */ "includefile", + /* 49 307 T_Integer */ NULL, + /* 50 308 T_Interface */ "interface", + /* 51 309 T_Ipv4 */ "ipv4", + /* 52 310 T_Ipv4_flag */ "-4", + /* 53 311 T_Ipv6 */ "ipv6", + /* 54 312 T_Ipv6_flag */ "-6", + /* 55 313 T_Kernel */ "kernel", + /* 56 314 T_Key */ "key", + /* 57 315 T_Keys */ "keys", + /* 58 316 T_Keysdir */ "keysdir", + /* 59 317 T_Kod */ "kod", + /* 60 318 T_Mssntp */ "mssntp", + /* 61 319 T_Leapfile */ "leapfile", + /* 62 320 T_Limited */ "limited", + /* 63 321 T_Link */ "link", + /* 64 322 T_Listen */ "listen", + /* 65 323 T_Logconfig */ "logconfig", + /* 66 324 T_Logfile */ "logfile", + /* 67 325 T_Loopstats */ "loopstats", + /* 68 326 T_Lowpriotrap */ "lowpriotrap", + /* 69 327 T_Manycastclient */ "manycastclient", + /* 70 328 T_Manycastserver */ "manycastserver", + /* 71 329 T_Mask */ "mask", + /* 72 330 T_Maxclock */ "maxclock", + /* 73 331 T_Maxdist */ "maxdist", + /* 74 332 T_Maxpoll */ "maxpoll", + /* 75 333 T_Minclock */ "minclock", + /* 76 334 T_Mindist */ "mindist", + /* 77 335 T_Minimum */ "minimum", + /* 78 336 T_Minpoll */ "minpoll", + /* 79 337 T_Minsane */ "minsane", + /* 80 338 T_Mode */ "mode", + /* 81 339 T_Monitor */ "monitor", + /* 82 340 T_Month */ "month", + /* 83 341 T_Multicastclient */ "multicastclient", + /* 84 342 T_Nic */ "nic", + /* 85 343 T_Nolink */ "nolink", + /* 86 344 T_Nomodify */ "nomodify", + /* 87 345 T_None */ "none", + /* 88 346 T_Nopeer */ "nopeer", + /* 89 347 T_Noquery */ "noquery", + /* 90 348 T_Noselect */ "noselect", + /* 91 349 T_Noserve */ "noserve", + /* 92 350 T_Notrap */ "notrap", + /* 93 351 T_Notrust */ "notrust", + /* 94 352 T_Ntp */ "ntp", + /* 95 353 T_Ntpport */ "ntpport", + /* 96 354 T_NtpSignDsocket */ "ntpsigndsocket", + /* 97 355 T_Orphan */ "orphan", + /* 98 356 T_Panic */ "panic", + /* 99 357 T_Peer */ "peer", + /* 100 358 T_Peerstats */ "peerstats", + /* 101 359 T_Phone */ "phone", + /* 102 360 T_Pid */ "pid", + /* 103 361 T_Pidfile */ "pidfile", + /* 104 362 T_Pool */ "pool", + /* 105 363 T_Port */ "port", + /* 106 364 T_Preempt */ "preempt", + /* 107 365 T_Prefer */ "prefer", + /* 108 366 T_Protostats */ "protostats", + /* 109 367 T_Pw */ "pw", + /* 110 368 T_Qos */ "qos", + /* 111 369 T_Randfile */ "randfile", + /* 112 370 T_Rawstats */ "rawstats", + /* 113 371 T_Refid */ "refid", + /* 114 372 T_Requestkey */ "requestkey", + /* 115 373 T_Restrict */ "restrict", + /* 116 374 T_Revoke */ "revoke", + /* 117 375 T_Saveconfigdir */ "saveconfigdir", + /* 118 376 T_Server */ "server", + /* 119 377 T_Setvar */ "setvar", + /* 120 378 T_Sign */ "sign", + /* 121 379 T_Statistics */ "statistics", + /* 122 380 T_Stats */ "stats", + /* 123 381 T_Statsdir */ "statsdir", + /* 124 382 T_Step */ "step", + /* 125 383 T_Stepout */ "stepout", + /* 126 384 T_Stratum */ "stratum", + /* 127 385 T_String */ NULL, + /* 128 386 T_Sysstats */ "sysstats", + /* 129 387 T_Tick */ "tick", + /* 130 388 T_Time1 */ "time1", + /* 131 389 T_Time2 */ "time2", + /* 132 390 T_Timingstats */ "timingstats", + /* 133 391 T_Tinker */ "tinker", + /* 134 392 T_Tos */ "tos", + /* 135 393 T_Trap */ "trap", + /* 136 394 T_True */ "true", + /* 137 395 T_Trustedkey */ "trustedkey", + /* 138 396 T_Ttl */ "ttl", + /* 139 397 T_Type */ "type", + /* 140 398 T_Unconfig */ "unconfig", + /* 141 399 T_Unpeer */ "unpeer", + /* 142 400 T_Version */ "version", + /* 143 401 T_WanderThreshold */ NULL, + /* 144 402 T_Week */ "week", + /* 145 403 T_Wildcard */ "wildcard", + /* 146 404 T_Xleave */ "xleave", + /* 147 405 T_Year */ "year", + /* 148 406 T_Flag */ NULL, + /* 149 407 T_Void */ NULL, + /* 150 408 T_EOC */ NULL, + /* 151 409 T_Simulate */ "simulate", + /* 152 410 T_Beep_Delay */ "beep_delay", + /* 153 411 T_Sim_Duration */ "simulation_duration", + /* 154 412 T_Server_Offset */ "server_offset", + /* 155 413 T_Duration */ "duration", + /* 156 414 T_Freq_Offset */ "freq_offset", + /* 157 415 T_Wander */ "wander", + /* 158 416 T_Jitter */ "jitter", + /* 159 417 T_Prop_Delay */ "prop_delay", + /* 160 418 T_Proc_Delay */ "proc_delay" +}; + +#define SCANNER_INIT_S 734 + +const scan_state sst[738] = { +/* { ch, f-by, token, match, other } */ +/* 0 */ { 0 }, +/* 1 */ { '-', 0, 0, 3, 0 }, +/* 2 */ { '4', 0, T_Ipv4_flag, 0, 0 }, +/* 3 */ { '6', 0, T_Ipv6_flag, 0, 2 }, +/* 4 */ { 'a', 0, 0, 21, 1 }, +/* 5 */ { 'g', 0, 0, 6, 0 }, +/* 6 */ { 'e', 0, T_Age, 0, 0 }, +/* 7 */ { 'l', 0, 0, 8, 5 }, +/* 8 */ { 'l', 0, T_All, 9, 0 }, +/* 9 */ { 'a', 0, 0, 10, 0 }, +/* 10 */ { 'n', 0, T_Allan, 0, 0 }, +/* 11 */ { 'u', 0, 0, 12, 7 }, +/* 12 */ { 't', 0, 0, 14, 0 }, +/* 13 */ { 'h', 0, T_Auth, 0, 0 }, +/* 14 */ { 'o', 0, 0, 18, 13 }, +/* 15 */ { 'k', 0, 0, 16, 0 }, +/* 16 */ { 'e', 0, 0, 17, 0 }, +/* 17 */ { 'y', 0, T_Autokey, 0, 0 }, +/* 18 */ { 'm', 0, 0, 19, 15 }, +/* 19 */ { 'a', 0, 0, 20, 0 }, +/* 20 */ { 'x', 0, T_Automax, 0, 0 }, +/* 21 */ { 'v', 0, 0, 22, 11 }, +/* 22 */ { 'e', 0, 0, 23, 0 }, +/* 23 */ { 'r', 0, 0, 24, 0 }, +/* 24 */ { 'a', 0, 0, 25, 0 }, +/* 25 */ { 'g', 0, 0, 26, 0 }, +/* 26 */ { 'e', 0, T_Average, 0, 0 }, +/* 27 */ { 'b', 0, 0, 69, 4 }, +/* 28 */ { 'c', 0, 0, 29, 0 }, +/* 29 */ { 'l', 0, 0, 30, 0 }, +/* 30 */ { 'i', 0, 0, 31, 0 }, +/* 31 */ { 'e', 0, 0, 32, 0 }, +/* 32 */ { 'n', 0, 0, 33, 0 }, +/* 33 */ { 't', 0, T_Bclient, 0, 0 }, +/* 34 */ { 'e', 0, 0, 39, 28 }, +/* 35 */ { 'a', 0, 0, 36, 0 }, +/* 36 */ { 'c', 0, 0, 37, 0 }, +/* 37 */ { 'o', 0, 0, 38, 0 }, +/* 38 */ { 'n', 0, T_Beacon, 0, 0 }, +/* 39 */ { 'e', 0, 0, 40, 35 }, +/* 40 */ { 'p', 0, 0, 41, 0 }, +/* 41 */ { '_', 0, 0, 42, 0 }, +/* 42 */ { 'd', 0, 0, 43, 0 }, +/* 43 */ { 'e', 0, 0, 44, 0 }, +/* 44 */ { 'l', 0, 0, 45, 0 }, +/* 45 */ { 'a', 0, 0, 46, 0 }, +/* 46 */ { 'y', 0, T_Beep_Delay, 0, 0 }, +/* 47 */ { 'i', 0, 0, 48, 34 }, +/* 48 */ { 'a', 0, 0, 49, 0 }, +/* 49 */ { 's', 0, T_Bias, 0, 0 }, +/* 50 */ { 'r', 0, 0, 51, 47 }, +/* 51 */ { 'o', 0, 0, 52, 0 }, +/* 52 */ { 'a', 0, 0, 53, 0 }, +/* 53 */ { 'd', 0, 0, 54, 0 }, +/* 54 */ { 'c', 0, 0, 55, 0 }, +/* 55 */ { 'a', 0, 0, 56, 0 }, +/* 56 */ { 's', 0, 0, 57, 0 }, +/* 57 */ { 't', 1, T_Broadcast, 64, 0 }, +/* 58 */ { 'c', 0, 0, 59, 0 }, +/* 59 */ { 'l', 0, 0, 60, 0 }, +/* 60 */ { 'i', 0, 0, 61, 0 }, +/* 61 */ { 'e', 0, 0, 62, 0 }, +/* 62 */ { 'n', 0, 0, 63, 0 }, +/* 63 */ { 't', 0, T_Broadcastclient, 0, 0 }, +/* 64 */ { 'd', 0, 0, 65, 58 }, +/* 65 */ { 'e', 0, 0, 66, 0 }, +/* 66 */ { 'l', 0, 0, 67, 0 }, +/* 67 */ { 'a', 0, 0, 68, 0 }, +/* 68 */ { 'y', 0, T_Broadcastdelay, 0, 0 }, +/* 69 */ { 'u', 0, 0, 70, 50 }, +/* 70 */ { 'r', 0, 0, 71, 0 }, +/* 71 */ { 's', 0, 0, 72, 0 }, +/* 72 */ { 't', 0, T_Burst, 0, 0 }, +/* 73 */ { 'c', 0, 0, 116, 27 }, +/* 74 */ { 'a', 0, 0, 75, 0 }, +/* 75 */ { 'l', 0, 0, 82, 0 }, +/* 76 */ { 'i', 0, 0, 77, 0 }, +/* 77 */ { 'b', 0, 0, 78, 0 }, +/* 78 */ { 'r', 0, 0, 79, 0 }, +/* 79 */ { 'a', 0, 0, 80, 0 }, +/* 80 */ { 't', 0, 0, 81, 0 }, +/* 81 */ { 'e', 0, T_Calibrate, 0, 0 }, +/* 82 */ { 'l', 0, 0, 83, 76 }, +/* 83 */ { 'd', 0, 0, 84, 0 }, +/* 84 */ { 'e', 0, 0, 85, 0 }, +/* 85 */ { 'l', 0, 0, 86, 0 }, +/* 86 */ { 'a', 0, 0, 87, 0 }, +/* 87 */ { 'y', 0, T_Calldelay, 0, 0 }, +/* 88 */ { 'e', 0, 0, 89, 74 }, +/* 89 */ { 'i', 0, 0, 90, 0 }, +/* 90 */ { 'l', 0, 0, 91, 0 }, +/* 91 */ { 'i', 0, 0, 92, 0 }, +/* 92 */ { 'n', 0, 0, 93, 0 }, +/* 93 */ { 'g', 0, T_Ceiling, 0, 0 }, +/* 94 */ { 'l', 0, 0, 95, 88 }, +/* 95 */ { 'o', 0, 0, 96, 0 }, +/* 96 */ { 'c', 0, 0, 97, 0 }, +/* 97 */ { 'k', 0, 0, 98, 0 }, +/* 98 */ { 's', 0, 0, 99, 0 }, +/* 99 */ { 't', 0, 0, 100, 0 }, +/* 100 */ { 'a', 0, 0, 101, 0 }, +/* 101 */ { 't', 0, 0, 102, 0 }, +/* 102 */ { 's', 0, T_Clockstats, 0, 0 }, +/* 103 */ { 'o', 0, 0, 108, 94 }, +/* 104 */ { 'h', 0, 0, 105, 0 }, +/* 105 */ { 'o', 0, 0, 106, 0 }, +/* 106 */ { 'r', 0, 0, 107, 0 }, +/* 107 */ { 't', 0, T_Cohort, 0, 0 }, +/* 108 */ { 'n', 0, 0, 109, 104 }, +/* 109 */ { 't', 0, 0, 110, 0 }, +/* 110 */ { 'r', 0, 0, 111, 0 }, +/* 111 */ { 'o', 0, 0, 112, 0 }, +/* 112 */ { 'l', 0, 0, 113, 0 }, +/* 113 */ { 'k', 0, 0, 114, 0 }, +/* 114 */ { 'e', 0, 0, 115, 0 }, +/* 115 */ { 'y', 0, T_ControlKey, 0, 0 }, +/* 116 */ { 'r', 0, 0, 117, 103 }, +/* 117 */ { 'y', 0, 0, 118, 0 }, +/* 118 */ { 'p', 0, 0, 119, 0 }, +/* 119 */ { 't', 0, 0, 120, 0 }, +/* 120 */ { 'o', 0, T_Crypto, 121, 0 }, +/* 121 */ { 's', 0, 0, 122, 0 }, +/* 122 */ { 't', 0, 0, 123, 0 }, +/* 123 */ { 'a', 0, 0, 124, 0 }, +/* 124 */ { 't', 0, 0, 125, 0 }, +/* 125 */ { 's', 0, T_Cryptostats, 0, 0 }, +/* 126 */ { 'd', 0, 0, 162, 73 }, +/* 127 */ { 'a', 0, 0, 128, 0 }, +/* 128 */ { 'y', 0, T_Day, 0, 0 }, +/* 129 */ { 'e', 0, 0, 130, 127 }, +/* 130 */ { 'f', 0, 0, 131, 0 }, +/* 131 */ { 'a', 0, 0, 132, 0 }, +/* 132 */ { 'u', 0, 0, 133, 0 }, +/* 133 */ { 'l', 0, 0, 134, 0 }, +/* 134 */ { 't', 0, T_Default, 0, 0 }, +/* 135 */ { 'i', 0, 0, 136, 129 }, +/* 136 */ { 's', 0, 0, 145, 0 }, +/* 137 */ { 'a', 0, 0, 138, 0 }, +/* 138 */ { 'b', 0, 0, 139, 0 }, +/* 139 */ { 'l', 0, 0, 140, 0 }, +/* 140 */ { 'e', 0, T_Disable, 0, 0 }, +/* 141 */ { 'c', 0, 0, 142, 137 }, +/* 142 */ { 'a', 0, 0, 143, 0 }, +/* 143 */ { 'r', 0, 0, 144, 0 }, +/* 144 */ { 'd', 0, T_Discard, 0, 0 }, +/* 145 */ { 'p', 0, 0, 146, 141 }, +/* 146 */ { 'e', 0, 0, 147, 0 }, +/* 147 */ { 'r', 0, 0, 148, 0 }, +/* 148 */ { 's', 0, 0, 149, 0 }, +/* 149 */ { 'i', 0, 0, 150, 0 }, +/* 150 */ { 'o', 0, 0, 151, 0 }, +/* 151 */ { 'n', 0, T_Dispersion, 0, 0 }, +/* 152 */ { 'r', 0, 0, 160, 135 }, +/* 153 */ { 'i', 0, 0, 154, 0 }, +/* 154 */ { 'f', 0, 0, 155, 0 }, +/* 155 */ { 't', 0, 0, 156, 0 }, +/* 156 */ { 'f', 0, 0, 157, 0 }, +/* 157 */ { 'i', 0, 0, 158, 0 }, +/* 158 */ { 'l', 0, 0, 159, 0 }, +/* 159 */ { 'e', 1, T_Driftfile, 0, 0 }, +/* 160 */ { 'o', 0, 0, 161, 153 }, +/* 161 */ { 'p', 0, T_Drop, 0, 0 }, +/* 162 */ { 'u', 0, 0, 163, 152 }, +/* 163 */ { 'r', 0, 0, 164, 0 }, +/* 164 */ { 'a', 0, 0, 165, 0 }, +/* 165 */ { 't', 0, 0, 166, 0 }, +/* 166 */ { 'i', 0, 0, 167, 0 }, +/* 167 */ { 'o', 0, 0, 168, 0 }, +/* 168 */ { 'n', 0, T_Duration, 0, 0 }, +/* 169 */ { 'e', 0, 0, 170, 126 }, +/* 170 */ { 'n', 0, 0, 175, 0 }, +/* 171 */ { 'a', 0, 0, 172, 0 }, +/* 172 */ { 'b', 0, 0, 173, 0 }, +/* 173 */ { 'l', 0, 0, 174, 0 }, +/* 174 */ { 'e', 0, T_Enable, 0, 0 }, +/* 175 */ { 'd', 0, T_End, 0, 171 }, +/* 176 */ { 'f', 0, 0, 205, 169 }, +/* 177 */ { 'i', 0, 0, 178, 0 }, +/* 178 */ { 'l', 0, 0, 179, 0 }, +/* 179 */ { 'e', 1, T_File, 180, 0 }, +/* 180 */ { 'g', 0, 0, 181, 0 }, +/* 181 */ { 'e', 0, 0, 182, 0 }, +/* 182 */ { 'n', 0, T_Filegen, 0, 0 }, +/* 183 */ { 'l', 0, 0, 192, 177 }, +/* 184 */ { 'a', 0, 0, 190, 0 }, +/* 185 */ { 'g', 0, 0, 189, 0 }, +/* 186 */ { '1', 0, T_Flag1, 0, 0 }, +/* 187 */ { '2', 0, T_Flag2, 0, 186 }, +/* 188 */ { '3', 0, T_Flag3, 0, 187 }, +/* 189 */ { '4', 0, T_Flag4, 0, 188 }, +/* 190 */ { 'k', 0, 0, 191, 185 }, +/* 191 */ { 'e', 0, T_Flake, 0, 0 }, +/* 192 */ { 'o', 0, 0, 193, 184 }, +/* 193 */ { 'o', 0, 0, 194, 0 }, +/* 194 */ { 'r', 0, T_Floor, 0, 0 }, +/* 195 */ { 'r', 0, 0, 196, 183 }, +/* 196 */ { 'e', 0, 0, 197, 0 }, +/* 197 */ { 'q', 0, T_Freq, 198, 0 }, +/* 198 */ { '_', 0, 0, 199, 0 }, +/* 199 */ { 'o', 0, 0, 200, 0 }, +/* 200 */ { 'f', 0, 0, 201, 0 }, +/* 201 */ { 'f', 0, 0, 202, 0 }, +/* 202 */ { 's', 0, 0, 203, 0 }, +/* 203 */ { 'e', 0, 0, 204, 0 }, +/* 204 */ { 't', 0, T_Freq_Offset, 0, 0 }, +/* 205 */ { 'u', 0, 0, 206, 195 }, +/* 206 */ { 'd', 0, 0, 207, 0 }, +/* 207 */ { 'g', 0, 0, 208, 0 }, +/* 208 */ { 'e', 1, T_Fudge, 0, 0 }, +/* 209 */ { 'h', 0, 0, 213, 176 }, +/* 210 */ { 'o', 0, 0, 211, 0 }, +/* 211 */ { 's', 0, 0, 212, 0 }, +/* 212 */ { 't', 1, T_Host, 0, 0 }, +/* 213 */ { 'u', 0, 0, 214, 210 }, +/* 214 */ { 'f', 0, 0, 215, 0 }, +/* 215 */ { 'f', 0, 0, 216, 0 }, +/* 216 */ { 'p', 0, 0, 217, 0 }, +/* 217 */ { 'u', 0, 0, 218, 0 }, +/* 218 */ { 'f', 0, 0, 219, 0 }, +/* 219 */ { 'f', 0, T_Huffpuff, 0, 0 }, +/* 220 */ { 'i', 0, 0, 252, 209 }, +/* 221 */ { 'b', 0, 0, 222, 0 }, +/* 222 */ { 'u', 0, 0, 223, 0 }, +/* 223 */ { 'r', 0, 0, 224, 0 }, +/* 224 */ { 's', 0, 0, 225, 0 }, +/* 225 */ { 't', 0, T_Iburst, 0, 0 }, +/* 226 */ { 'd', 0, 0, 227, 221 }, +/* 227 */ { 'e', 0, 0, 228, 0 }, +/* 228 */ { 'n', 0, 0, 229, 0 }, +/* 229 */ { 't', 1, T_Ident, 0, 0 }, +/* 230 */ { 'g', 0, 0, 231, 226 }, +/* 231 */ { 'n', 0, 0, 232, 0 }, +/* 232 */ { 'o', 0, 0, 233, 0 }, +/* 233 */ { 'r', 0, 0, 234, 0 }, +/* 234 */ { 'e', 0, T_Ignore, 0, 0 }, +/* 235 */ { 'n', 0, 0, 245, 230 }, +/* 236 */ { 'c', 0, 0, 237, 0 }, +/* 237 */ { 'l', 0, 0, 238, 0 }, +/* 238 */ { 'u', 0, 0, 239, 0 }, +/* 239 */ { 'd', 0, 0, 240, 0 }, +/* 240 */ { 'e', 0, 0, 241, 0 }, +/* 241 */ { 'f', 0, 0, 242, 0 }, +/* 242 */ { 'i', 0, 0, 243, 0 }, +/* 243 */ { 'l', 0, 0, 244, 0 }, +/* 244 */ { 'e', 1, T_Includefile, 0, 0 }, +/* 245 */ { 't', 0, 0, 246, 236 }, +/* 246 */ { 'e', 0, 0, 247, 0 }, +/* 247 */ { 'r', 0, 0, 248, 0 }, +/* 248 */ { 'f', 0, 0, 249, 0 }, +/* 249 */ { 'a', 0, 0, 250, 0 }, +/* 250 */ { 'c', 0, 0, 251, 0 }, +/* 251 */ { 'e', 0, T_Interface, 0, 0 }, +/* 252 */ { 'p', 0, 0, 253, 235 }, +/* 253 */ { 'v', 0, 0, 255, 0 }, +/* 254 */ { '4', 0, T_Ipv4, 0, 0 }, +/* 255 */ { '6', 0, T_Ipv6, 0, 254 }, +/* 256 */ { 'j', 0, 0, 257, 220 }, +/* 257 */ { 'i', 0, 0, 258, 0 }, +/* 258 */ { 't', 0, 0, 259, 0 }, +/* 259 */ { 't', 0, 0, 260, 0 }, +/* 260 */ { 'e', 0, 0, 261, 0 }, +/* 261 */ { 'r', 0, T_Jitter, 0, 0 }, +/* 262 */ { 'k', 0, 0, 273, 256 }, +/* 263 */ { 'e', 0, 0, 268, 0 }, +/* 264 */ { 'r', 0, 0, 265, 0 }, +/* 265 */ { 'n', 0, 0, 266, 0 }, +/* 266 */ { 'e', 0, 0, 267, 0 }, +/* 267 */ { 'l', 0, T_Kernel, 0, 0 }, +/* 268 */ { 'y', 0, T_Key, 269, 264 }, +/* 269 */ { 's', 1, T_Keys, 270, 0 }, +/* 270 */ { 'd', 0, 0, 271, 0 }, +/* 271 */ { 'i', 0, 0, 272, 0 }, +/* 272 */ { 'r', 1, T_Keysdir, 0, 0 }, +/* 273 */ { 'o', 0, 0, 274, 263 }, +/* 274 */ { 'd', 0, T_Kod, 0, 0 }, +/* 275 */ { 'l', 0, 0, 295, 262 }, +/* 276 */ { 'e', 0, 0, 277, 0 }, +/* 277 */ { 'a', 0, 0, 278, 0 }, +/* 278 */ { 'p', 0, 0, 279, 0 }, +/* 279 */ { 'f', 0, 0, 280, 0 }, +/* 280 */ { 'i', 0, 0, 281, 0 }, +/* 281 */ { 'l', 0, 0, 282, 0 }, +/* 282 */ { 'e', 1, T_Leapfile, 0, 0 }, +/* 283 */ { 'i', 0, 0, 291, 276 }, +/* 284 */ { 'm', 0, 0, 285, 0 }, +/* 285 */ { 'i', 0, 0, 286, 0 }, +/* 286 */ { 't', 0, 0, 287, 0 }, +/* 287 */ { 'e', 0, 0, 288, 0 }, +/* 288 */ { 'd', 0, T_Limited, 0, 0 }, +/* 289 */ { 'n', 0, 0, 290, 284 }, +/* 290 */ { 'k', 0, T_Link, 0, 0 }, +/* 291 */ { 's', 0, 0, 292, 289 }, +/* 292 */ { 't', 0, 0, 293, 0 }, +/* 293 */ { 'e', 0, 0, 294, 0 }, +/* 294 */ { 'n', 0, T_Listen, 0, 0 }, +/* 295 */ { 'o', 0, 0, 314, 283 }, +/* 296 */ { 'g', 0, 0, 303, 0 }, +/* 297 */ { 'c', 0, 0, 298, 0 }, +/* 298 */ { 'o', 0, 0, 299, 0 }, +/* 299 */ { 'n', 0, 0, 300, 0 }, +/* 300 */ { 'f', 0, 0, 301, 0 }, +/* 301 */ { 'i', 0, 0, 302, 0 }, +/* 302 */ { 'g', 2, T_Logconfig, 0, 0 }, +/* 303 */ { 'f', 0, 0, 304, 297 }, +/* 304 */ { 'i', 0, 0, 305, 0 }, +/* 305 */ { 'l', 0, 0, 306, 0 }, +/* 306 */ { 'e', 1, T_Logfile, 0, 0 }, +/* 307 */ { 'o', 0, 0, 308, 296 }, +/* 308 */ { 'p', 0, 0, 309, 0 }, +/* 309 */ { 's', 0, 0, 310, 0 }, +/* 310 */ { 't', 0, 0, 311, 0 }, +/* 311 */ { 'a', 0, 0, 312, 0 }, +/* 312 */ { 't', 0, 0, 313, 0 }, +/* 313 */ { 's', 0, T_Loopstats, 0, 0 }, +/* 314 */ { 'w', 0, 0, 315, 307 }, +/* 315 */ { 'p', 0, 0, 316, 0 }, +/* 316 */ { 'r', 0, 0, 317, 0 }, +/* 317 */ { 'i', 0, 0, 318, 0 }, +/* 318 */ { 'o', 0, 0, 319, 0 }, +/* 319 */ { 't', 0, 0, 320, 0 }, +/* 320 */ { 'r', 0, 0, 321, 0 }, +/* 321 */ { 'a', 0, 0, 322, 0 }, +/* 322 */ { 'p', 0, T_Lowpriotrap, 0, 0 }, +/* 323 */ { 'm', 0, 0, 397, 275 }, +/* 324 */ { 'a', 0, 0, 345, 0 }, +/* 325 */ { 'n', 0, 0, 326, 0 }, +/* 326 */ { 'y', 0, 0, 327, 0 }, +/* 327 */ { 'c', 0, 0, 328, 0 }, +/* 328 */ { 'a', 0, 0, 329, 0 }, +/* 329 */ { 's', 0, 0, 330, 0 }, +/* 330 */ { 't', 0, 0, 337, 0 }, +/* 331 */ { 'c', 0, 0, 332, 0 }, +/* 332 */ { 'l', 0, 0, 333, 0 }, +/* 333 */ { 'i', 0, 0, 334, 0 }, +/* 334 */ { 'e', 0, 0, 335, 0 }, +/* 335 */ { 'n', 0, 0, 336, 0 }, +/* 336 */ { 't', 1, T_Manycastclient, 0, 0 }, +/* 337 */ { 's', 0, 0, 338, 331 }, +/* 338 */ { 'e', 0, 0, 339, 0 }, +/* 339 */ { 'r', 0, 0, 340, 0 }, +/* 340 */ { 'v', 0, 0, 341, 0 }, +/* 341 */ { 'e', 0, 0, 342, 0 }, +/* 342 */ { 'r', 2, T_Manycastserver, 0, 0 }, +/* 343 */ { 's', 0, 0, 344, 325 }, +/* 344 */ { 'k', 0, T_Mask, 0, 0 }, +/* 345 */ { 'x', 0, 0, 355, 343 }, +/* 346 */ { 'c', 0, 0, 347, 0 }, +/* 347 */ { 'l', 0, 0, 348, 0 }, +/* 348 */ { 'o', 0, 0, 349, 0 }, +/* 349 */ { 'c', 0, 0, 350, 0 }, +/* 350 */ { 'k', 0, T_Maxclock, 0, 0 }, +/* 351 */ { 'd', 0, 0, 352, 346 }, +/* 352 */ { 'i', 0, 0, 353, 0 }, +/* 353 */ { 's', 0, 0, 354, 0 }, +/* 354 */ { 't', 0, T_Maxdist, 0, 0 }, +/* 355 */ { 'p', 0, 0, 356, 351 }, +/* 356 */ { 'o', 0, 0, 357, 0 }, +/* 357 */ { 'l', 0, 0, 358, 0 }, +/* 358 */ { 'l', 0, T_Maxpoll, 0, 0 }, +/* 359 */ { 'i', 0, 0, 360, 324 }, +/* 360 */ { 'n', 0, 0, 378, 0 }, +/* 361 */ { 'c', 0, 0, 362, 0 }, +/* 362 */ { 'l', 0, 0, 363, 0 }, +/* 363 */ { 'o', 0, 0, 364, 0 }, +/* 364 */ { 'c', 0, 0, 365, 0 }, +/* 365 */ { 'k', 0, T_Minclock, 0, 0 }, +/* 366 */ { 'd', 0, 0, 367, 361 }, +/* 367 */ { 'i', 0, 0, 368, 0 }, +/* 368 */ { 's', 0, 0, 369, 0 }, +/* 369 */ { 't', 0, T_Mindist, 0, 0 }, +/* 370 */ { 'i', 0, 0, 371, 366 }, +/* 371 */ { 'm', 0, 0, 372, 0 }, +/* 372 */ { 'u', 0, 0, 373, 0 }, +/* 373 */ { 'm', 0, T_Minimum, 0, 0 }, +/* 374 */ { 'p', 0, 0, 375, 370 }, +/* 375 */ { 'o', 0, 0, 376, 0 }, +/* 376 */ { 'l', 0, 0, 377, 0 }, +/* 377 */ { 'l', 0, T_Minpoll, 0, 0 }, +/* 378 */ { 's', 0, 0, 379, 374 }, +/* 379 */ { 'a', 0, 0, 380, 0 }, +/* 380 */ { 'n', 0, 0, 381, 0 }, +/* 381 */ { 'e', 0, T_Minsane, 0, 0 }, +/* 382 */ { 'o', 0, 0, 385, 359 }, +/* 383 */ { 'd', 0, 0, 384, 0 }, +/* 384 */ { 'e', 0, T_Mode, 0, 0 }, +/* 385 */ { 'n', 0, 0, 390, 383 }, +/* 386 */ { 'i', 0, 0, 387, 0 }, +/* 387 */ { 't', 0, 0, 388, 0 }, +/* 388 */ { 'o', 0, 0, 389, 0 }, +/* 389 */ { 'r', 0, T_Monitor, 0, 0 }, +/* 390 */ { 't', 0, 0, 391, 386 }, +/* 391 */ { 'h', 0, T_Month, 0, 0 }, +/* 392 */ { 's', 0, 0, 393, 382 }, +/* 393 */ { 's', 0, 0, 394, 0 }, +/* 394 */ { 'n', 0, 0, 395, 0 }, +/* 395 */ { 't', 0, 0, 396, 0 }, +/* 396 */ { 'p', 0, T_Mssntp, 0, 0 }, +/* 397 */ { 'u', 0, 0, 398, 392 }, +/* 398 */ { 'l', 0, 0, 399, 0 }, +/* 399 */ { 't', 0, 0, 400, 0 }, +/* 400 */ { 'i', 0, 0, 401, 0 }, +/* 401 */ { 'c', 0, 0, 402, 0 }, +/* 402 */ { 'a', 0, 0, 403, 0 }, +/* 403 */ { 's', 0, 0, 404, 0 }, +/* 404 */ { 't', 0, 0, 405, 0 }, +/* 405 */ { 'c', 0, 0, 406, 0 }, +/* 406 */ { 'l', 0, 0, 407, 0 }, +/* 407 */ { 'i', 0, 0, 408, 0 }, +/* 408 */ { 'e', 0, 0, 409, 0 }, +/* 409 */ { 'n', 0, 0, 410, 0 }, +/* 410 */ { 't', 2, T_Multicastclient, 0, 0 }, +/* 411 */ { 'n', 0, 0, 452, 323 }, +/* 412 */ { 'i', 0, 0, 413, 0 }, +/* 413 */ { 'c', 0, T_Nic, 0, 0 }, +/* 414 */ { 'o', 0, 0, 445, 412 }, +/* 415 */ { 'l', 0, 0, 416, 0 }, +/* 416 */ { 'i', 0, 0, 417, 0 }, +/* 417 */ { 'n', 0, 0, 418, 0 }, +/* 418 */ { 'k', 0, T_Nolink, 0, 0 }, +/* 419 */ { 'm', 0, 0, 420, 415 }, +/* 420 */ { 'o', 0, 0, 421, 0 }, +/* 421 */ { 'd', 0, 0, 422, 0 }, +/* 422 */ { 'i', 0, 0, 423, 0 }, +/* 423 */ { 'f', 0, 0, 424, 0 }, +/* 424 */ { 'y', 0, T_Nomodify, 0, 0 }, +/* 425 */ { 'n', 0, 0, 426, 419 }, +/* 426 */ { 'e', 0, T_None, 0, 0 }, +/* 427 */ { 'p', 0, 0, 428, 425 }, +/* 428 */ { 'e', 0, 0, 429, 0 }, +/* 429 */ { 'e', 0, 0, 430, 0 }, +/* 430 */ { 'r', 0, T_Nopeer, 0, 0 }, +/* 431 */ { 'q', 0, 0, 432, 427 }, +/* 432 */ { 'u', 0, 0, 433, 0 }, +/* 433 */ { 'e', 0, 0, 434, 0 }, +/* 434 */ { 'r', 0, 0, 435, 0 }, +/* 435 */ { 'y', 0, T_Noquery, 0, 0 }, +/* 436 */ { 's', 0, 0, 437, 431 }, +/* 437 */ { 'e', 0, 0, 442, 0 }, +/* 438 */ { 'l', 0, 0, 439, 0 }, +/* 439 */ { 'e', 0, 0, 440, 0 }, +/* 440 */ { 'c', 0, 0, 441, 0 }, +/* 441 */ { 't', 0, T_Noselect, 0, 0 }, +/* 442 */ { 'r', 0, 0, 443, 438 }, +/* 443 */ { 'v', 0, 0, 444, 0 }, +/* 444 */ { 'e', 0, T_Noserve, 0, 0 }, +/* 445 */ { 't', 0, 0, 446, 436 }, +/* 446 */ { 'r', 0, 0, 449, 0 }, +/* 447 */ { 'a', 0, 0, 448, 0 }, +/* 448 */ { 'p', 0, T_Notrap, 0, 0 }, +/* 449 */ { 'u', 0, 0, 450, 447 }, +/* 450 */ { 's', 0, 0, 451, 0 }, +/* 451 */ { 't', 0, T_Notrust, 0, 0 }, +/* 452 */ { 't', 0, 0, 453, 414 }, +/* 453 */ { 'p', 0, T_Ntp, 458, 0 }, +/* 454 */ { 'p', 0, 0, 455, 0 }, +/* 455 */ { 'o', 0, 0, 456, 0 }, +/* 456 */ { 'r', 0, 0, 457, 0 }, +/* 457 */ { 't', 0, T_Ntpport, 0, 0 }, +/* 458 */ { 's', 0, 0, 459, 454 }, +/* 459 */ { 'i', 0, 0, 460, 0 }, +/* 460 */ { 'g', 0, 0, 461, 0 }, +/* 461 */ { 'n', 0, 0, 462, 0 }, +/* 462 */ { 'd', 0, 0, 463, 0 }, +/* 463 */ { 's', 0, 0, 464, 0 }, +/* 464 */ { 'o', 0, 0, 465, 0 }, +/* 465 */ { 'c', 0, 0, 466, 0 }, +/* 466 */ { 'k', 0, 0, 467, 0 }, +/* 467 */ { 'e', 0, 0, 468, 0 }, +/* 468 */ { 't', 1, T_NtpSignDsocket, 0, 0 }, +/* 469 */ { 'o', 0, 0, 470, 411 }, +/* 470 */ { 'r', 0, 0, 471, 0 }, +/* 471 */ { 'p', 0, 0, 472, 0 }, +/* 472 */ { 'h', 0, 0, 473, 0 }, +/* 473 */ { 'a', 0, 0, 474, 0 }, +/* 474 */ { 'n', 0, T_Orphan, 0, 0 }, +/* 475 */ { 'p', 0, 0, 534, 469 }, +/* 476 */ { 'a', 0, 0, 477, 0 }, +/* 477 */ { 'n', 0, 0, 478, 0 }, +/* 478 */ { 'i', 0, 0, 479, 0 }, +/* 479 */ { 'c', 0, T_Panic, 0, 0 }, +/* 480 */ { 'e', 0, 0, 481, 476 }, +/* 481 */ { 'e', 0, 0, 482, 0 }, +/* 482 */ { 'r', 1, T_Peer, 483, 0 }, +/* 483 */ { 's', 0, 0, 484, 0 }, +/* 484 */ { 't', 0, 0, 485, 0 }, +/* 485 */ { 'a', 0, 0, 486, 0 }, +/* 486 */ { 't', 0, 0, 487, 0 }, +/* 487 */ { 's', 0, T_Peerstats, 0, 0 }, +/* 488 */ { 'h', 0, 0, 489, 480 }, +/* 489 */ { 'o', 0, 0, 490, 0 }, +/* 490 */ { 'n', 0, 0, 491, 0 }, +/* 491 */ { 'e', 2, T_Phone, 0, 0 }, +/* 492 */ { 'i', 0, 0, 493, 488 }, +/* 493 */ { 'd', 0, T_Pid, 494, 0 }, +/* 494 */ { 'f', 0, 0, 495, 0 }, +/* 495 */ { 'i', 0, 0, 496, 0 }, +/* 496 */ { 'l', 0, 0, 497, 0 }, +/* 497 */ { 'e', 1, T_Pidfile, 0, 0 }, +/* 498 */ { 'o', 0, 0, 501, 492 }, +/* 499 */ { 'o', 0, 0, 500, 0 }, +/* 500 */ { 'l', 1, T_Pool, 0, 0 }, +/* 501 */ { 'r', 0, 0, 502, 499 }, +/* 502 */ { 't', 0, T_Port, 0, 0 }, +/* 503 */ { 'r', 0, 0, 512, 498 }, +/* 504 */ { 'e', 0, 0, 509, 0 }, +/* 505 */ { 'e', 0, 0, 506, 0 }, +/* 506 */ { 'm', 0, 0, 507, 0 }, +/* 507 */ { 'p', 0, 0, 508, 0 }, +/* 508 */ { 't', 0, T_Preempt, 0, 0 }, +/* 509 */ { 'f', 0, 0, 510, 505 }, +/* 510 */ { 'e', 0, 0, 511, 0 }, +/* 511 */ { 'r', 0, T_Prefer, 0, 0 }, +/* 512 */ { 'o', 0, 0, 527, 504 }, +/* 513 */ { 'c', 0, 0, 514, 0 }, +/* 514 */ { '_', 0, 0, 515, 0 }, +/* 515 */ { 'd', 0, 0, 516, 0 }, +/* 516 */ { 'e', 0, 0, 517, 0 }, +/* 517 */ { 'l', 0, 0, 518, 0 }, +/* 518 */ { 'a', 0, 0, 519, 0 }, +/* 519 */ { 'y', 0, T_Proc_Delay, 0, 0 }, +/* 520 */ { 'p', 0, 0, 521, 513 }, +/* 521 */ { '_', 0, 0, 522, 0 }, +/* 522 */ { 'd', 0, 0, 523, 0 }, +/* 523 */ { 'e', 0, 0, 524, 0 }, +/* 524 */ { 'l', 0, 0, 525, 0 }, +/* 525 */ { 'a', 0, 0, 526, 0 }, +/* 526 */ { 'y', 0, T_Prop_Delay, 0, 0 }, +/* 527 */ { 't', 0, 0, 528, 520 }, +/* 528 */ { 'o', 0, 0, 529, 0 }, +/* 529 */ { 's', 0, 0, 530, 0 }, +/* 530 */ { 't', 0, 0, 531, 0 }, +/* 531 */ { 'a', 0, 0, 532, 0 }, +/* 532 */ { 't', 0, 0, 533, 0 }, +/* 533 */ { 's', 0, T_Protostats, 0, 0 }, +/* 534 */ { 'w', 1, T_Pw, 0, 503 }, +/* 535 */ { 'q', 0, 0, 536, 475 }, +/* 536 */ { 'o', 0, 0, 537, 0 }, +/* 537 */ { 's', 0, T_Qos, 0, 0 }, +/* 538 */ { 'r', 0, 0, 552, 535 }, +/* 539 */ { 'a', 0, 0, 546, 0 }, +/* 540 */ { 'n', 0, 0, 541, 0 }, +/* 541 */ { 'd', 0, 0, 542, 0 }, +/* 542 */ { 'f', 0, 0, 543, 0 }, +/* 543 */ { 'i', 0, 0, 544, 0 }, +/* 544 */ { 'l', 0, 0, 545, 0 }, +/* 545 */ { 'e', 1, T_Randfile, 0, 0 }, +/* 546 */ { 'w', 0, 0, 547, 540 }, +/* 547 */ { 's', 0, 0, 548, 0 }, +/* 548 */ { 't', 0, 0, 549, 0 }, +/* 549 */ { 'a', 0, 0, 550, 0 }, +/* 550 */ { 't', 0, 0, 551, 0 }, +/* 551 */ { 's', 0, T_Rawstats, 0, 0 }, +/* 552 */ { 'e', 0, 0, 570, 539 }, +/* 553 */ { 'f', 0, 0, 554, 0 }, +/* 554 */ { 'i', 0, 0, 555, 0 }, +/* 555 */ { 'd', 1, T_Refid, 0, 0 }, +/* 556 */ { 'q', 0, 0, 557, 553 }, +/* 557 */ { 'u', 0, 0, 558, 0 }, +/* 558 */ { 'e', 0, 0, 559, 0 }, +/* 559 */ { 's', 0, 0, 560, 0 }, +/* 560 */ { 't', 0, 0, 561, 0 }, +/* 561 */ { 'k', 0, 0, 562, 0 }, +/* 562 */ { 'e', 0, 0, 563, 0 }, +/* 563 */ { 'y', 0, T_Requestkey, 0, 0 }, +/* 564 */ { 's', 0, 0, 565, 556 }, +/* 565 */ { 't', 0, 0, 566, 0 }, +/* 566 */ { 'r', 0, 0, 567, 0 }, +/* 567 */ { 'i', 0, 0, 568, 0 }, +/* 568 */ { 'c', 0, 0, 569, 0 }, +/* 569 */ { 't', 0, T_Restrict, 0, 0 }, +/* 570 */ { 'v', 0, 0, 571, 564 }, +/* 571 */ { 'o', 0, 0, 572, 0 }, +/* 572 */ { 'k', 0, 0, 573, 0 }, +/* 573 */ { 'e', 0, T_Revoke, 0, 0 }, +/* 574 */ { 's', 0, 0, 647, 538 }, +/* 575 */ { 'a', 0, 0, 576, 0 }, +/* 576 */ { 'v', 0, 0, 577, 0 }, +/* 577 */ { 'e', 0, 0, 578, 0 }, +/* 578 */ { 'c', 0, 0, 579, 0 }, +/* 579 */ { 'o', 0, 0, 580, 0 }, +/* 580 */ { 'n', 0, 0, 581, 0 }, +/* 581 */ { 'f', 0, 0, 582, 0 }, +/* 582 */ { 'i', 0, 0, 583, 0 }, +/* 583 */ { 'g', 0, 0, 584, 0 }, +/* 584 */ { 'd', 0, 0, 585, 0 }, +/* 585 */ { 'i', 0, 0, 586, 0 }, +/* 586 */ { 'r', 1, T_Saveconfigdir, 0, 0 }, +/* 587 */ { 'e', 0, 0, 599, 575 }, +/* 588 */ { 'r', 0, 0, 589, 0 }, +/* 589 */ { 'v', 0, 0, 590, 0 }, +/* 590 */ { 'e', 0, 0, 591, 0 }, +/* 591 */ { 'r', 1, T_Server, 592, 0 }, +/* 592 */ { '_', 0, 0, 593, 0 }, +/* 593 */ { 'o', 0, 0, 594, 0 }, +/* 594 */ { 'f', 0, 0, 595, 0 }, +/* 595 */ { 'f', 0, 0, 596, 0 }, +/* 596 */ { 's', 0, 0, 597, 0 }, +/* 597 */ { 'e', 0, 0, 598, 0 }, +/* 598 */ { 't', 0, T_Server_Offset, 0, 0 }, +/* 599 */ { 't', 0, 0, 600, 588 }, +/* 600 */ { 'v', 0, 0, 601, 0 }, +/* 601 */ { 'a', 0, 0, 602, 0 }, +/* 602 */ { 'r', 1, T_Setvar, 0, 0 }, +/* 603 */ { 'i', 0, 0, 606, 587 }, +/* 604 */ { 'g', 0, 0, 605, 0 }, +/* 605 */ { 'n', 1, T_Sign, 0, 0 }, +/* 606 */ { 'm', 0, 0, 607, 604 }, +/* 607 */ { 'u', 0, 0, 608, 0 }, +/* 608 */ { 'l', 0, 0, 609, 0 }, +/* 609 */ { 'a', 0, 0, 610, 0 }, +/* 610 */ { 't', 0, 0, 612, 0 }, +/* 611 */ { 'e', 0, T_Simulate, 0, 0 }, +/* 612 */ { 'i', 0, 0, 613, 611 }, +/* 613 */ { 'o', 0, 0, 614, 0 }, +/* 614 */ { 'n', 0, 0, 615, 0 }, +/* 615 */ { '_', 0, 0, 616, 0 }, +/* 616 */ { 'd', 0, 0, 617, 0 }, +/* 617 */ { 'u', 0, 0, 618, 0 }, +/* 618 */ { 'r', 0, 0, 619, 0 }, +/* 619 */ { 'a', 0, 0, 620, 0 }, +/* 620 */ { 't', 0, 0, 621, 0 }, +/* 621 */ { 'i', 0, 0, 622, 0 }, +/* 622 */ { 'o', 0, 0, 623, 0 }, +/* 623 */ { 'n', 0, T_Sim_Duration, 0, 0 }, +/* 624 */ { 't', 0, 0, 642, 603 }, +/* 625 */ { 'a', 0, 0, 626, 0 }, +/* 626 */ { 't', 0, 0, 633, 0 }, +/* 627 */ { 'i', 0, 0, 628, 0 }, +/* 628 */ { 's', 0, 0, 629, 0 }, +/* 629 */ { 't', 0, 0, 630, 0 }, +/* 630 */ { 'i', 0, 0, 631, 0 }, +/* 631 */ { 'c', 0, 0, 632, 0 }, +/* 632 */ { 's', 0, T_Statistics, 0, 0 }, +/* 633 */ { 's', 0, T_Stats, 634, 627 }, +/* 634 */ { 'd', 0, 0, 635, 0 }, +/* 635 */ { 'i', 0, 0, 636, 0 }, +/* 636 */ { 'r', 1, T_Statsdir, 0, 0 }, +/* 637 */ { 'e', 0, 0, 638, 625 }, +/* 638 */ { 'p', 0, T_Step, 639, 0 }, +/* 639 */ { 'o', 0, 0, 640, 0 }, +/* 640 */ { 'u', 0, 0, 641, 0 }, +/* 641 */ { 't', 0, T_Stepout, 0, 0 }, +/* 642 */ { 'r', 0, 0, 643, 637 }, +/* 643 */ { 'a', 0, 0, 644, 0 }, +/* 644 */ { 't', 0, 0, 645, 0 }, +/* 645 */ { 'u', 0, 0, 646, 0 }, +/* 646 */ { 'm', 0, T_Stratum, 0, 0 }, +/* 647 */ { 'y', 0, 0, 648, 624 }, +/* 648 */ { 's', 0, 0, 649, 0 }, +/* 649 */ { 's', 0, 0, 650, 0 }, +/* 650 */ { 't', 0, 0, 651, 0 }, +/* 651 */ { 'a', 0, 0, 652, 0 }, +/* 652 */ { 't', 0, 0, 653, 0 }, +/* 653 */ { 's', 0, T_Sysstats, 0, 0 }, +/* 654 */ { 't', 0, 0, 690, 574 }, +/* 655 */ { 'i', 0, 0, 670, 0 }, +/* 656 */ { 'c', 0, 0, 657, 0 }, +/* 657 */ { 'k', 0, T_Tick, 0, 0 }, +/* 658 */ { 'm', 0, 0, 662, 656 }, +/* 659 */ { 'e', 0, 0, 661, 0 }, +/* 660 */ { '1', 0, T_Time1, 0, 0 }, +/* 661 */ { '2', 0, T_Time2, 0, 660 }, +/* 662 */ { 'i', 0, 0, 663, 659 }, +/* 663 */ { 'n', 0, 0, 664, 0 }, +/* 664 */ { 'g', 0, 0, 665, 0 }, +/* 665 */ { 's', 0, 0, 666, 0 }, +/* 666 */ { 't', 0, 0, 667, 0 }, +/* 667 */ { 'a', 0, 0, 668, 0 }, +/* 668 */ { 't', 0, 0, 669, 0 }, +/* 669 */ { 's', 0, T_Timingstats, 0, 0 }, +/* 670 */ { 'n', 0, 0, 671, 658 }, +/* 671 */ { 'k', 0, 0, 672, 0 }, +/* 672 */ { 'e', 0, 0, 673, 0 }, +/* 673 */ { 'r', 0, T_Tinker, 0, 0 }, +/* 674 */ { 'o', 0, 0, 675, 655 }, +/* 675 */ { 's', 0, T_Tos, 0, 0 }, +/* 676 */ { 'r', 0, 0, 679, 674 }, +/* 677 */ { 'a', 0, 0, 678, 0 }, +/* 678 */ { 'p', 1, T_Trap, 0, 0 }, +/* 679 */ { 'u', 0, 0, 681, 677 }, +/* 680 */ { 'e', 0, T_True, 0, 0 }, +/* 681 */ { 's', 0, 0, 682, 680 }, +/* 682 */ { 't', 0, 0, 683, 0 }, +/* 683 */ { 'e', 0, 0, 684, 0 }, +/* 684 */ { 'd', 0, 0, 685, 0 }, +/* 685 */ { 'k', 0, 0, 686, 0 }, +/* 686 */ { 'e', 0, 0, 687, 0 }, +/* 687 */ { 'y', 0, T_Trustedkey, 0, 0 }, +/* 688 */ { 't', 0, 0, 689, 676 }, +/* 689 */ { 'l', 0, T_Ttl, 0, 0 }, +/* 690 */ { 'y', 0, 0, 691, 688 }, +/* 691 */ { 'p', 0, 0, 692, 0 }, +/* 692 */ { 'e', 0, T_Type, 0, 0 }, +/* 693 */ { 'u', 0, 0, 694, 654 }, +/* 694 */ { 'n', 0, 0, 701, 0 }, +/* 695 */ { 'c', 0, 0, 696, 0 }, +/* 696 */ { 'o', 0, 0, 697, 0 }, +/* 697 */ { 'n', 0, 0, 698, 0 }, +/* 698 */ { 'f', 0, 0, 699, 0 }, +/* 699 */ { 'i', 0, 0, 700, 0 }, +/* 700 */ { 'g', 1, T_Unconfig, 0, 0 }, +/* 701 */ { 'p', 0, 0, 702, 695 }, +/* 702 */ { 'e', 0, 0, 703, 0 }, +/* 703 */ { 'e', 0, 0, 704, 0 }, +/* 704 */ { 'r', 1, T_Unpeer, 0, 0 }, +/* 705 */ { 'v', 0, 0, 706, 693 }, +/* 706 */ { 'e', 0, 0, 707, 0 }, +/* 707 */ { 'r', 0, 0, 708, 0 }, +/* 708 */ { 's', 0, 0, 709, 0 }, +/* 709 */ { 'i', 0, 0, 710, 0 }, +/* 710 */ { 'o', 0, 0, 711, 0 }, +/* 711 */ { 'n', 0, T_Version, 0, 0 }, +/* 712 */ { 'w', 0, 0, 721, 705 }, +/* 713 */ { 'a', 0, 0, 714, 0 }, +/* 714 */ { 'n', 0, 0, 715, 0 }, +/* 715 */ { 'd', 0, 0, 716, 0 }, +/* 716 */ { 'e', 0, 0, 717, 0 }, +/* 717 */ { 'r', 0, T_Wander, 0, 0 }, +/* 718 */ { 'e', 0, 0, 719, 713 }, +/* 719 */ { 'e', 0, 0, 720, 0 }, +/* 720 */ { 'k', 0, T_Week, 0, 0 }, +/* 721 */ { 'i', 0, 0, 722, 718 }, +/* 722 */ { 'l', 0, 0, 723, 0 }, +/* 723 */ { 'd', 0, 0, 724, 0 }, +/* 724 */ { 'c', 0, 0, 725, 0 }, +/* 725 */ { 'a', 0, 0, 726, 0 }, +/* 726 */ { 'r', 0, 0, 727, 0 }, +/* 727 */ { 'd', 0, T_Wildcard, 0, 0 }, +/* 728 */ { 'x', 0, 0, 729, 712 }, +/* 729 */ { 'l', 0, 0, 730, 0 }, +/* 730 */ { 'e', 0, 0, 731, 0 }, +/* 731 */ { 'a', 0, 0, 732, 0 }, +/* 732 */ { 'v', 0, 0, 733, 0 }, +/* 733 */ { 'e', 0, T_Xleave, 0, 0 }, +/* 734 */ { 'y', 0, 0, 735, 728 }, +/* 735 */ { 'e', 0, 0, 736, 0 }, +/* 736 */ { 'a', 0, 0, 737, 0 }, +/* 737 */ { 'r', 0, T_Year, 0, 0 } +}; + diff --git a/ntpd/ntp_scanner.c b/ntpd/ntp_scanner.c index 940fa5b09..d424e0e81 100644 --- a/ntpd/ntp_scanner.c +++ b/ntpd/ntp_scanner.c @@ -25,18 +25,9 @@ #include "ntp_parser.h" #include "ntp_debug.h" +/* ntp_keyword.h declares finite state machine and token text */ +#include "ntp_keyword.h" -/* Define a structure to hold the FSA for the keywords. - * The structure is actually a trie - */ - -struct state { - char ch; /* Input character associated with the state */ - struct state *next_state; /* Next state to advance to on reading ch */ - struct state *next_char_s;/* State to check having read any other */ - int token; /* Token to be returned on successful parse */ - follby followedby; /* Forces the next token(s) to T_String */ -}; /* SCANNER GLOBAL VARIABLES @@ -45,187 +36,9 @@ struct state { #define MAX_LEXEME (1024 + 1) /* The maximum size of a lexeme */ char yytext[MAX_LEXEME]; /* Buffer for storing the input text/lexeme */ -struct state *key_scanner; /* A FSA for recognizing keywords */ extern int input_from_file; -struct key_tok ntp_keyword_list[] = { -{ "automax", T_Automax, FOLLBY_TOKEN }, -{ "broadcast", T_Broadcast, FOLLBY_STRING }, -{ "broadcastclient", T_Broadcastclient, FOLLBY_TOKEN }, -{ "broadcastdelay", T_Broadcastdelay, FOLLBY_TOKEN }, -{ "calldelay", T_Calldelay, FOLLBY_TOKEN }, -{ "disable", T_Disable, FOLLBY_TOKEN }, -{ "driftfile", T_Driftfile, FOLLBY_STRING }, -{ "enable", T_Enable, FOLLBY_TOKEN }, -{ "end", T_End, FOLLBY_TOKEN }, -{ "filegen", T_Filegen, FOLLBY_TOKEN }, -{ "fudge", T_Fudge, FOLLBY_STRING }, -{ "includefile", T_Includefile, FOLLBY_STRING }, -{ "leapfile", T_Leapfile, FOLLBY_STRING }, -{ "logconfig", T_Logconfig, FOLLBY_STRINGS_TO_EOC }, -{ "logfile", T_Logfile, FOLLBY_STRING }, -{ "manycastclient", T_Manycastclient, FOLLBY_STRING }, -{ "manycastserver", T_Manycastserver, FOLLBY_STRINGS_TO_EOC }, -{ "multicastclient", T_Multicastclient, FOLLBY_STRINGS_TO_EOC }, -{ "peer", T_Peer, FOLLBY_STRING }, -{ "phone", T_Phone, FOLLBY_STRINGS_TO_EOC }, -{ "pidfile", T_Pidfile, FOLLBY_STRING }, -{ "pool", T_Pool, FOLLBY_STRING }, -{ "discard", T_Discard, FOLLBY_TOKEN }, -{ "restrict", T_Restrict, FOLLBY_TOKEN }, -{ "server", T_Server, FOLLBY_STRING }, -{ "setvar", T_Setvar, FOLLBY_STRING }, -{ "statistics", T_Statistics, FOLLBY_TOKEN }, -{ "statsdir", T_Statsdir, FOLLBY_STRING }, -{ "tick", T_Tick, FOLLBY_TOKEN }, -{ "tinker", T_Tinker, FOLLBY_TOKEN }, -{ "tos", T_Tos, FOLLBY_TOKEN }, -{ "trap", T_Trap, FOLLBY_STRING }, -{ "unconfig", T_Unconfig, FOLLBY_STRING }, -{ "unpeer", T_Unpeer, FOLLBY_STRING }, -/* authentication_command */ -{ "controlkey", T_ControlKey, FOLLBY_TOKEN }, -{ "crypto", T_Crypto, FOLLBY_TOKEN }, -{ "keys", T_Keys, FOLLBY_STRING }, -{ "keysdir", T_Keysdir, FOLLBY_STRING }, -{ "ntpsigndsocket", T_NtpSignDsocket, FOLLBY_STRING }, -{ "requestkey", T_Requestkey, FOLLBY_TOKEN }, -{ "revoke", T_Revoke, FOLLBY_TOKEN }, -{ "trustedkey", T_Trustedkey, FOLLBY_TOKEN }, -/* IPv4/IPv6 protocol override flag */ -{ "-4", T_Ipv4_flag, FOLLBY_TOKEN }, -{ "-6", T_Ipv6_flag, FOLLBY_TOKEN }, -/* option */ -{ "autokey", T_Autokey, FOLLBY_TOKEN }, -{ "bias", T_Bias, FOLLBY_TOKEN }, -{ "burst", T_Burst, FOLLBY_TOKEN }, -{ "iburst", T_Iburst, FOLLBY_TOKEN }, -{ "key", T_Key, FOLLBY_TOKEN }, -{ "maxpoll", T_Maxpoll, FOLLBY_TOKEN }, -{ "minpoll", T_Minpoll, FOLLBY_TOKEN }, -{ "mode", T_Mode, FOLLBY_TOKEN }, -{ "noselect", T_Noselect, FOLLBY_TOKEN }, -{ "preempt", T_Preempt, FOLLBY_TOKEN }, -{ "true", T_True, FOLLBY_TOKEN }, -{ "prefer", T_Prefer, FOLLBY_TOKEN }, -{ "ttl", T_Ttl, FOLLBY_TOKEN }, -{ "version", T_Version, FOLLBY_TOKEN }, -{ "xleave", T_Xleave, FOLLBY_TOKEN }, -/* crypto_command */ -{ "host", T_Host, FOLLBY_STRING }, -{ "ident", T_Ident, FOLLBY_STRING }, -{ "pw", T_Pw, FOLLBY_STRING }, -{ "randfile", T_Randfile, FOLLBY_STRING }, -{ "sign", T_Sign, FOLLBY_STRING }, -/*** MONITORING COMMANDS ***/ -/* stat */ -{ "clockstats", T_Clockstats, FOLLBY_TOKEN }, -{ "cryptostats", T_Cryptostats, FOLLBY_TOKEN }, -{ "loopstats", T_Loopstats, FOLLBY_TOKEN }, -{ "peerstats", T_Peerstats, FOLLBY_TOKEN }, -{ "rawstats", T_Rawstats, FOLLBY_TOKEN }, -{ "sysstats", T_Sysstats, FOLLBY_TOKEN }, -{ "protostats", T_Protostats, FOLLBY_TOKEN }, -{ "timingstats", T_Timingstats, FOLLBY_TOKEN }, -/* filegen_option */ -{ "disable", T_Disable, FOLLBY_TOKEN }, -{ "enable", T_Enable, FOLLBY_TOKEN }, -{ "file", T_File, FOLLBY_STRING }, -{ "link", T_Link, FOLLBY_TOKEN }, -{ "nolink", T_Nolink, FOLLBY_TOKEN }, -{ "type", T_Type, FOLLBY_TOKEN }, -/* filegen_type */ -{ "age", T_Age, FOLLBY_TOKEN }, -{ "day", T_Day, FOLLBY_TOKEN }, -{ "month", T_Month, FOLLBY_TOKEN }, -{ "none", T_None, FOLLBY_TOKEN }, -{ "pid", T_Pid, FOLLBY_TOKEN }, -{ "week", T_Week, FOLLBY_TOKEN }, -{ "year", T_Year, FOLLBY_TOKEN }, -/*** ORPHAN MODE COMMANDS ***/ -/* tos_option */ -{ "minclock", T_Minclock, FOLLBY_TOKEN }, -{ "maxclock", T_Maxclock, FOLLBY_TOKEN }, -{ "minsane", T_Minsane, FOLLBY_TOKEN }, -{ "floor", T_Floor, FOLLBY_TOKEN }, -{ "ceiling", T_Ceiling, FOLLBY_TOKEN }, -{ "cohort", T_Cohort, FOLLBY_TOKEN }, -{ "mindist", T_Mindist, FOLLBY_TOKEN }, -{ "maxdist", T_Maxdist, FOLLBY_TOKEN }, -{ "beacon", T_Beacon, FOLLBY_TOKEN }, -{ "orphan", T_Orphan, FOLLBY_TOKEN }, -/* access_control_flag */ -{ "default", T_Default, FOLLBY_TOKEN }, -{ "flake", T_Flake, FOLLBY_TOKEN }, -{ "ignore", T_Ignore, FOLLBY_TOKEN }, -{ "limited", T_Limited, FOLLBY_TOKEN }, -{ "mssntp", T_Mssntp, FOLLBY_TOKEN }, -{ "kod", T_Kod, FOLLBY_TOKEN }, -{ "lowpriotrap", T_Lowpriotrap, FOLLBY_TOKEN }, -{ "mask", T_Mask, FOLLBY_TOKEN }, -{ "nomodify", T_Nomodify, FOLLBY_TOKEN }, -{ "nopeer", T_Nopeer, FOLLBY_TOKEN }, -{ "noquery", T_Noquery, FOLLBY_TOKEN }, -{ "noserve", T_Noserve, FOLLBY_TOKEN }, -{ "notrap", T_Notrap, FOLLBY_TOKEN }, -{ "notrust", T_Notrust, FOLLBY_TOKEN }, -{ "ntpport", T_Ntpport, FOLLBY_TOKEN }, -{ "version", T_Version, FOLLBY_TOKEN }, -/* discard_option */ -{ "average", T_Average, FOLLBY_TOKEN }, -{ "minimum", T_Minimum, FOLLBY_TOKEN }, -{ "monitor", T_Monitor, FOLLBY_TOKEN }, -/* fudge_factor */ -{ "flag1", T_Flag1, FOLLBY_TOKEN }, -{ "flag2", T_Flag2, FOLLBY_TOKEN }, -{ "flag3", T_Flag3, FOLLBY_TOKEN }, -{ "flag4", T_Flag4, FOLLBY_TOKEN }, -{ "refid", T_Refid, FOLLBY_STRING }, -{ "stratum", T_Stratum, FOLLBY_TOKEN }, -{ "time1", T_Time1, FOLLBY_TOKEN }, -{ "time2", T_Time2, FOLLBY_TOKEN }, -/* system_option */ -{ "auth", T_Auth, FOLLBY_TOKEN }, -{ "bclient", T_Bclient, FOLLBY_TOKEN }, -{ "calibrate", T_Calibrate, FOLLBY_TOKEN }, -{ "kernel", T_Kernel, FOLLBY_TOKEN }, -{ "monitor", T_Monitor, FOLLBY_TOKEN }, -{ "ntp", T_Ntp, FOLLBY_TOKEN }, -{ "stats", T_Stats, FOLLBY_TOKEN }, -/* tinker_option */ -{ "step", T_Step, FOLLBY_TOKEN }, -{ "panic", T_Panic, FOLLBY_TOKEN }, -{ "dispersion", T_Dispersion, FOLLBY_TOKEN }, -{ "stepout", T_Stepout, FOLLBY_TOKEN }, -{ "allan", T_Allan, FOLLBY_TOKEN }, -{ "huffpuff", T_Huffpuff, FOLLBY_TOKEN }, -{ "freq", T_Freq, FOLLBY_TOKEN }, -/* miscellaneous_command */ -{ "port", T_Port, FOLLBY_TOKEN }, -{ "interface", T_Interface, FOLLBY_TOKEN }, -{ "qos", T_Qos, FOLLBY_TOKEN }, -{ "saveconfigdir", T_Saveconfigdir, FOLLBY_STRING }, -/* interface_command (ignore and interface already defined) */ -{ "nic", T_Nic, FOLLBY_TOKEN }, -{ "all", T_All, FOLLBY_TOKEN }, -{ "ipv4", T_Ipv4, FOLLBY_TOKEN }, -{ "ipv6", T_Ipv6, FOLLBY_TOKEN }, -{ "wildcard", T_Wildcard, FOLLBY_TOKEN }, -{ "listen", T_Listen, FOLLBY_TOKEN }, -{ "drop", T_Drop, FOLLBY_TOKEN }, -/* simulator commands */ -{ "simulate", T_Simulate, FOLLBY_TOKEN }, -{ "simulation_duration",T_Sim_Duration, FOLLBY_TOKEN }, -{ "beep_delay", T_Beep_Delay, FOLLBY_TOKEN }, -{ "duration", T_Duration, FOLLBY_TOKEN }, -{ "server_offset", T_Server_Offset, FOLLBY_TOKEN }, -{ "freq_offset", T_Freq_Offset, FOLLBY_TOKEN }, -{ "wander", T_Wander, FOLLBY_TOKEN }, -{ "jitter", T_Jitter, FOLLBY_TOKEN }, -{ "prop_delay", T_Prop_Delay, FOLLBY_TOKEN }, -{ "proc_delay", T_Proc_Delay, FOLLBY_TOKEN }, -{ NULL, 0, 0 } }; /* CONSTANTS @@ -248,160 +61,28 @@ char get_next_char(void); static int is_keyword(char *lexeme, follby *pfollowedby); -/* Define a function to create the states of the scanner. This function - * is used by the create_keyword_scanner function below. - * - * This function takes a suffix of a keyword, the token to be returned on - * recognizing the complete keyword, and any pre-existing state that exists - * for some other keyword that has the same prefix as the current one. - */ -struct state * -create_states( - char * text, - int token, - follby followedby, - struct state *pre_state - ) -{ - struct state *my_state; - struct state *return_state; - struct state *prev_char_s; - struct state *curr_char_s; - - return_state = pre_state; - curr_char_s = pre_state; - prev_char_s = NULL; - - /* Find the correct position to insert the state. - * All states should be in alphabetical order - */ - while (curr_char_s != NULL && (text[0] < curr_char_s->ch)) { - prev_char_s = curr_char_s; - curr_char_s = curr_char_s->next_char_s; - } - - /* Check if a previously seen keyword has the same prefix as the - * current keyword. If yes, simply use the state for that keyword - * as my_state - */ - if (curr_char_s && (text[0] == curr_char_s->ch)) - my_state = curr_char_s; - else { - my_state = emalloc(sizeof(*my_state)); - /* Store the first character of the keyword */ - my_state->ch = text[0]; - my_state->next_state = NULL; - my_state->next_char_s = curr_char_s; - /* Not an accepting state */ - my_state->token = NON_ACCEPTING; - my_state->followedby = FOLLBY_TOKEN; - - if (prev_char_s) - prev_char_s->next_char_s = my_state; - else - return_state = my_state; - } - - /* Check if the next character is '\0'. - * If yes, we are done with the recognition and this is an accepting - * state. - * If not, we need to continue scanning - */ - if ('\0' == text[1]) { - my_state->token = token; - my_state->followedby = followedby; - } else - my_state->next_state = - create_states(&text[1], token, followedby, - my_state->next_state); - - return return_state; -} - - -/* Define a function that takes a list of (keyword, token) values and - * creates a keywords scanner out of it. - */ - -struct state * -create_keyword_scanner(void) -{ - struct state *scanner; - struct key_tok *keyword_list; - - keyword_list = ntp_keyword_list; - scanner = NULL; - while (keyword_list->key != NULL) { - scanner = create_states(keyword_list->key, - keyword_list->token, - keyword_list->followedby, - scanner); - ++keyword_list; - } - return scanner; -} - - -/* Define a function to delete the keyword scanner, freeing all the allocated - * memory - */ -void -delete_keyword_scanner( - struct state *my_key_scanner - ) -{ - if (my_key_scanner) { - delete_keyword_scanner(my_key_scanner->next_char_s); - delete_keyword_scanner(my_key_scanner->next_state); - free(my_key_scanner); - } -} - - -/* Define a function to print the keyword scanner built using the - * above functions. - */ - -void -print_keyword_scanner( - struct state *my_key_scanner, - int pos - ) -{ - static char lexeme[MAX_LEXEME]; - struct state *curr_state = my_key_scanner; - while (curr_state != NULL) { - lexeme[pos] = curr_state->ch; - if (curr_state->token != NON_ACCEPTING) { - lexeme[pos + 1] = '\0'; - printf("%s\n", lexeme); - } - if (curr_state->next_state != NULL) - print_keyword_scanner(curr_state->next_state, pos + 1); - curr_state = curr_state->next_char_s; - } -} - /* * keyword() - Return the keyword associated with token T_ identifier */ -char * +const char * keyword( int token ) { - struct key_tok *keyword_list; + int i; + const char *text; - + i = token - LOWEST_KEYWORD_ID; - for (keyword_list = ntp_keyword_list; - keyword_list->key != NULL; - keyword_list++) - if (keyword_list->token == token) - return keyword_list->key; + if (i >= 0 && i < COUNTOF(keyword_text)) + text = keyword_text[i]; + else + text = NULL; - return "(keyword not found)"; + return (text != NULL) + ? text + : "(keyword not found)"; } @@ -552,20 +233,22 @@ is_keyword( follby *pfollowedby ) { - struct state *curr_state = key_scanner; - int token = NON_ACCEPTING; + int curr_state; + int token; int i; + curr_state = SCANNER_INIT_S; + token = NON_ACCEPTING; + for (i = 0; lexeme[i]; ++i) { - while (curr_state && (lexeme[i] != curr_state->ch)) - curr_state = curr_state->next_char_s; + while (curr_state && (lexeme[i] != sst[curr_state].ch)) + curr_state = sst[curr_state].other_next_s; - if (curr_state && (lexeme[i] == curr_state->ch)) { - *pfollowedby = curr_state->followedby; - token = curr_state->token; - curr_state = curr_state->next_state; - } - else { + if (curr_state && (lexeme[i] == sst[curr_state].ch)) { + *pfollowedby = sst[curr_state].followedby; + token = sst[curr_state].finishes_token; + curr_state = sst[curr_state].match_next_s; + } else { *pfollowedby = FOLLBY_TOKEN; token = NON_ACCEPTING; break; diff --git a/ntpd/ntp_scanner.h b/ntpd/ntp_scanner.h index 7ad43279a..8e53e13fc 100644 --- a/ntpd/ntp_scanner.h +++ b/ntpd/ntp_scanner.h @@ -8,6 +8,9 @@ * Copyright (c) 2006 */ +#ifndef NTP_SCANNER_H +#define NTP_SCANNER_H + /* * ntp.conf syntax is slightly irregular in that some tokens such as * hostnames do not require quoting even if they might otherwise be @@ -39,13 +42,18 @@ typedef enum { * ---------- */ -/* Define a structure to hold a (keyword, token) pair */ -struct key_tok { - char * key; /* Keyword */ - int token; /* Associated Token */ - follby followedby; /* nonzero indicates the next token - should be a string */ -}; +/* Define a structure to hold the FSA for the keywords. + * The structure is actually a trie + */ + +typedef struct scan_state_tag { + char ch; /* Character this state matches on */ + char followedby; /* Forces next token(s) to T_String */ + u_short finishes_token; /* nonzero ID if last keyword char */ + u_short match_next_s; /* next state to check matching ch */ + u_short other_next_s; /* next state to check if not ch */ +} scan_state; + /* Structure to hold a filename, file pointer and positional info */ struct FILE_INFO { @@ -85,14 +93,8 @@ extern struct FILE_INFO *fp[]; /* VARIOUS SUBROUTINE DECLARATIONS * ------------------------------- */ -extern char * keyword(int token); -extern char * quote_if_needed(char *str); -struct state * create_states(char *text, - int token, - follby followedby, - struct state *pre_state); -struct state * create_keyword_scanner(void); -void delete_keyword_scanner(struct state *my_key_scanner); +extern const char *keyword(int token); +extern char *quote_if_needed(char *str); int yylex(void); struct FILE_INFO *F_OPEN(const char *path, const char *mode); @@ -100,5 +102,6 @@ int FGETC(struct FILE_INFO *stream); int UNGETC(int ch, struct FILE_INFO *stream); int FCLOSE(struct FILE_INFO *stream); -void print_keyword_scanner(struct state *, int); void push_back_char(int ch); + +#endif /* NTP_SCANNER_H */ diff --git a/ports/winnt/vs2008/ntpd/ntpd.vcproj b/ports/winnt/vs2008/ntpd/ntpd.vcproj index 2a6215dad..6d6f73e85 100644 --- a/ports/winnt/vs2008/ntpd/ntpd.vcproj +++ b/ports/winnt/vs2008/ntpd/ntpd.vcproj @@ -852,6 +852,10 @@ RelativePath="..\..\include\ntp_iocompletionport.h" > + +