1 %{ 2 3 #define YYPARSE_PARAM param 4 5 #include "headers.h" 6 #include "cfgvar.h" 7 #include "csparse.h" 8 9 int yylex(); 10 int yyerror(); 11 12 void *CS_scan_string(char *); 13 14 %} 15 16 /* 17 * Token value definition 18 */ 19 %union { 20 int tv_int; 21 char *tv_char; 22 } 23 24 /* 25 * Token types returned by scanner 26 */ 27 %token <tv_char> TOK_STRING 28 29 %token ERROR 30 %token C_DUMP 31 %token C_IMPORT 32 %token C_RESTORE 33 %token C_IP 34 %token C_ACCOUNTING 35 %token C_SHOW 36 %token C_CHECKPOINT 37 %token C_CLEAR 38 %token C_STAT 39 %token C_HELP 40 %token C_SHUTDOWN 41 %token C_INTERFACE 42 %token C_VERSION 43 %token C_CACHE 44 %token C_FLOW 45 46 %type <tv_int> block 47 48 %% 49 50 operation: 51 block { 52 return $1; 53 }; 54 55 block: 56 C_HELP { $$ = CS_HELP; } 57 58 | C_STAT { $$ = CS_STAT; } 59 60 | C_DUMP { $$ = CS_DUMP; } 61 | C_IMPORT { $$ = CS_IMPT; } 62 | C_RESTORE { $$ = CS_REST; } 63 | C_SHUTDOWN { $$ = CS_SHUT; } 64 | C_DUMP TOK_STRING { $$ = CS_DUMP; *(char **)param = $2; } 65 | C_IMPORT TOK_STRING { $$ = CS_IMPT; *(char **)param = $2; } 66 | C_RESTORE TOK_STRING { $$ = CS_REST; *(char **)param = $2; } 67 68 | C_SHOW C_VERSION { $$ = CS_SVER; } 69 | C_SHOW C_IP C_ACCOUNTING { $$ = CS_SIA; } 70 | C_SHOW C_IP C_ACCOUNTING C_CHECKPOINT { $$ = CS_SIAC; } 71 | C_SHOW C_INTERFACE TOK_STRING { $$ = CS_SIN; *(char **)param = $3; } 72 | C_SHOW C_IP C_CACHE C_FLOW { $$ = CS_SICF; } 73 74 | C_CLEAR C_IP C_ACCOUNTING { $$ = CS_CIA; } 75 | C_CLEAR C_IP C_ACCOUNTING C_CHECKPOINT { $$ = CS_CIAC; } 76 ; 77 78 %% 79 80 int 81 yyerror(char *s) { 82 (void)s; 83 84 return 0; 85 }; 86 87 88