X-Git-Url: http://git.jankratochvil.net/?a=blobdiff_plain;f=parse.c;h=b9f33605b98fdb61d2709be4a421bef6647a95ab;hb=b911161616bef05d332b0631aece5b807e592e91;hp=6ac6908a5169b4f08ba51df5d26e9581fb799753;hpb=a4d53c2fe3dc1952c7c7d8a4283545389ba5aa64;p=tac_plus.git diff --git a/parse.c b/parse.c index 6ac6908..b9f3360 100644 --- a/parse.c +++ b/parse.c @@ -19,8 +19,15 @@ /* Keywords of the configuration language */ + #include "tac_plus.h" +#include "parse.h" +#include "utils.h" +#include "report.h" +#include "hash.h" + + static void *wordtable[HASH_TAB_SIZE]; /* Table of keyword declarations */ struct keyword { @@ -31,6 +38,8 @@ struct keyword { typedef struct keyword KEYWORD; +static void declare TAC_ARGS((char *name, int value)); + static void declare(name, value) char *name; @@ -53,7 +62,9 @@ declare(name, value) /* Declare keywords of the "configuration language". */ -void +void parser_init TAC_ARGS((void)); + +void parser_init() { bzero(wordtable, sizeof(wordtable)); @@ -85,7 +96,6 @@ parser_init() declare("group", S_group); declare("global", S_global); declare("host", S_host); - declare("type", S_type); declare("ip", S_ip); declare("ipx", S_ipx); declare("key", S_key); @@ -115,12 +125,23 @@ parser_init() declare("service", S_svc); declare("user", S_user); declare("time", S_time); + declare("and", S_and); + declare("closeparen", S_closeparen); + declare("enlist", S_enlist); + declare("first", S_first); + declare("not", S_not); + declare("openparen", S_openparen); + declare("or", S_or); + declare("recursive", S_recursive); + declare("when", S_when); } +int keycode TAC_ARGS((const char *keyword)); + /* Return a keyword code if a keyword is recognized. 0 otherwise */ int keycode(keyword) -char *keyword; +const char *keyword; { KEYWORD *k = hash_lookup(wordtable, keyword); @@ -129,7 +150,9 @@ char *keyword; return (S_unknown); } -char * +const char *codestring TAC_ARGS((int type)); + +const char * codestring(type) int type; { @@ -156,8 +179,6 @@ int type; return ("group"); case S_host: return ("host"); - case S_type: - return ("type"); case S_file: return ("file"); case S_skey: @@ -205,7 +226,7 @@ int type; #ifdef USE_PAM case S_pam: return ("pam"); -#endif /*USE_PAM */ +#endif /*USE_PAM */ case S_nopasswd: return("nopassword"); case S_des: @@ -250,5 +271,23 @@ int type; return("lcp"); case S_time: return("time"); + case S_and: + return("and"); + case S_closeparen: + return(")"); + case S_enlist: + return("enlist"); + case S_first: + return("first"); + case S_not: + return("not"); + case S_openparen: + return("("); + case S_or: + return("or"); + case S_recursive: + return("recursive"); + case S_when: + return("when"); } }