1 %{ 2 #include <stdio.h> 3 #include <string.h> 4 #include <errno.h> 5 #include <assert.h> 6 #include <crm/crm.h> 7 #include <stonithd-config.h> 8 #include <standalone_config.h> 9 10 /* Some distributions can't use the output from flex without help */ 11 #ifndef ECHO 12 # define ECHO if(fwrite( yytext, yyleng, 1, yyout )) 13 #endif 14 15 int _line_count = 1; 16 17 static void _unescape(char * val)18_unescape(char *val) 19 { 20 size_t x,y; 21 int e = 0; 22 23 y = strlen(val); 24 for (x = 0; x < y; x++) { 25 if (e == 1) { 26 if (val[x] == '"') { 27 memmove(&val[x-1], &val[x], y-x); 28 --y; 29 --x; 30 } 31 e = 0; 32 } 33 if (val[x] == '\\') { 34 e = 1; 35 } 36 } 37 val[y] = 0; 38 } 39 40 %} 41 %% 42 "\\\n" { 43 ++_line_count; 44 } 45 46 [\n] { 47 ++_line_count; 48 return T_ENDL; 49 } 50 51 [ \t]* {} 52 53 \#[^\n]* {} 54 55 ^"device" { 56 return T_DEVICE; 57 } 58 59 ^"options" { 60 return T_OPTIONS; 61 } 62 63 ^"priority" { 64 return T_PRIO; 65 } 66 67 ^"ports" { 68 return T_PORTMAP; 69 } 70 71 ^"unfence" { 72 return T_UNFENCE; 73 } 74 75 "=" { 76 return T_EQ; 77 } 78 79 [^ &\|!\t\(\){},;=\"\n\[\]]+ { 80 yylval.sval = crm_strdup(yytext); 81 return T_VAL; 82 } 83 84 \"(\\\"|[^\"])+\" { 85 yylval.sval = crm_strdup(yytext+1); 86 yylval.sval[strlen(yytext)-2] = 0; 87 /* unescape backslash-quote to be quotes */ 88 _unescape(yylval.sval); 89 return T_VAL; 90 } 91 92 \"\" { 93 yylval.sval = NULL; 94 return T_VAL; 95 } 96 97 %% 98 99 int 100 yywrap(void) 101 { 102 /* This if block that is never executed is here to 103 * get rid of some compile warnings about 104 * unused autogenerated functions. Probably 105 * not the best solution... but a solution... 106 * unless the compiler optimizes it away and complains 107 * again. It may be possible to execute some sed 108 * magic to remove the code from the autogenerated .c 109 * file before compile time if this doesn't hold up.*/ 110 if (0) { 111 yyunput(1, NULL); 112 input(); 113 } 114 115 return 1; 116 } 117 118