You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cfg_file.l 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. %x incl
  2. %x module
  3. %{
  4. #define NO_GMIME
  5. #include "config.h"
  6. #include "cfg_file.h"
  7. #include "cfg_yacc.h"
  8. #define MAX_INCLUDE_DEPTH 10
  9. YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
  10. int include_stack_ptr = 0;
  11. extern struct config_file *cfg;
  12. %}
  13. %option noyywrap
  14. %option yylineno
  15. %%
  16. ^[ \t]*#.* /* ignore comments */;
  17. .include BEGIN(incl);
  18. .module BEGIN(module);
  19. composites return COMPOSITES;
  20. tempdir return TEMPDIR;
  21. pidfile return PIDFILE;
  22. workers return WORKERS;
  23. error_time return ERROR_TIME;
  24. dead_time return DEAD_TIME;
  25. maxerrors return MAXERRORS;
  26. reconnect_timeout return RECONNECT_TIMEOUT;
  27. connect_timeout return CONNECT_TIMEOUT;
  28. protocol return PROTOCOL;
  29. memcached return MEMCACHED;
  30. bind_socket return BINDSOCK;
  31. servers return SERVERS;
  32. require return REQUIRE;
  33. header_filters return HEADER_FILTERS;
  34. mime_filters return MIME_FILTERS;
  35. message_filters return MESSAGE_FILTERS;
  36. url_filters return URL_FILTERS;
  37. factors return FACTORS;
  38. metric return METRIC;
  39. name return NAME;
  40. required_score return REQUIRED_SCORE;
  41. function return FUNCTION;
  42. control return CONTROL;
  43. password return PASSWORD;
  44. statfile return STATFILE;
  45. alias return ALIAS;
  46. pattern return PATTERN;
  47. weight return WEIGHT;
  48. size return SIZE;
  49. tokenizer return TOKENIZER;
  50. classifier return CLASSIFIER;
  51. logging return LOGGING;
  52. log_type return LOG_TYPE;
  53. console return LOG_TYPE_CONSOLE;
  54. syslog return LOG_TYPE_SYSLOG;
  55. file return LOG_TYPE_FILE;
  56. log_level return LOG_LEVEL;
  57. DEBUG return LOG_LEVEL_DEBUG;
  58. INFO return LOG_LEVEL_INFO;
  59. WARNING return LOG_LEVEL_WARNING;
  60. ERROR return LOG_LEVEL_ERROR;
  61. log_facility return LOG_FACILITY;
  62. log_file return LOG_FILENAME;
  63. statfile_pool_size return STATFILE_POOL_SIZE;
  64. \{ return OBRACE;
  65. \} return EBRACE;
  66. ; return SEMICOLON;
  67. , return COMMA;
  68. = return EQSIGN;
  69. yes|YES|no|NO|[yY]|[nN] yylval.flag=parse_flag(yytext); return FLAG;
  70. \n /* ignore EOL */;
  71. [ \t]+ /* ignore whitespace */;
  72. \"[^"]+\" yylval.string=strdup(yytext + 1); yylval.string[strlen(yylval.string) - 1] = '\0'; return QUOTEDSTRING;
  73. \" return QUOTE;
  74. \$[a-zA-Z_][a-zA-Z0-9_]+ yylval.string=strdup(yytext + 1); return VARIABLE;
  75. [0-9]+ yylval.number=strtol(yytext, NULL, 10); return NUMBER;
  76. -?[0-9]+\.?[0-9]* yylval.fract=strtod(yytext, NULL); return FRACT;
  77. [0-9]+[kKmMgG]? yylval.limit=parse_limit(yytext); return SIZELIMIT;
  78. [0-9]+[sS]|[0-9]+[mM][sS] yylval.seconds=parse_seconds(yytext); return SECONDS;
  79. [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} yylval.string=strdup(yytext); return IPADDR;
  80. [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/[0-9]{1,2} yylval.string=strdup(yytext); return IPNETWORK;
  81. [a-zA-Z0-9.-]+:[0-9]{1,5} yylval.string=strdup(yytext); return HOSTPORT;
  82. [a-zA-Z<][a-zA-Z@+>_-]* yylval.string=strdup(yytext); return STRING;
  83. \/[^/\n]+\/ yylval.string=strdup(yytext); return REGEXP;
  84. [a-zA-Z0-9].[a-zA-Z0-9\/.-]+ yylval.string=strdup(yytext); return DOMAINNAME;
  85. <incl>[ \t]* /* eat the whitespace */
  86. <incl>[^ \t\n]+ { /* got the include file name */
  87. if (include_stack_ptr >= MAX_INCLUDE_DEPTH) {
  88. yyerror ("yylex: includes nested too deeply");
  89. return -1;
  90. }
  91. include_stack[include_stack_ptr++] =
  92. YY_CURRENT_BUFFER;
  93. yyin = fopen (yytext, "r");
  94. if (! yyin) {
  95. yyerror ("yylex: cannot open include file");
  96. return -1;
  97. }
  98. yy_switch_to_buffer (yy_create_buffer (yyin, YY_BUF_SIZE));
  99. BEGIN(INITIAL);
  100. }
  101. <<EOF>> {
  102. if ( --include_stack_ptr < 0 ) {
  103. post_load_config (cfg);
  104. yyterminate ();
  105. }
  106. else {
  107. yy_delete_buffer (YY_CURRENT_BUFFER);
  108. yy_switch_to_buffer (include_stack[include_stack_ptr]);
  109. }
  110. }
  111. <module>\n /* ignore EOL */;
  112. <module>[ \t]+ /* ignore whitespace */;
  113. <module>\'[a-zA-Z0-9_-]\' yylval.string=strdup(yytext + 1); yylval.string[strlen(yylval.string) - 1] = '\0'; return MODULE_OPT;
  114. <module>\{ return OBRACE;
  115. <module>\} return EBRACE;
  116. <module>\; return SEMICOLON;
  117. <module>[a-zA-Z0-9_-] yylval.string=strdup(yytext); return PARAM;
  118. <module>\$[a-zA-Z_][a-zA-Z0-9_]+ yylval.string=strdup(yytext + 1); return VARIABLE;
  119. <module>\"[^"]+\" yylval.string=strdup(yytext + 1); yylval.string[strlen(yylval.string) - 1] = '\0'; return QUOTEDSTRING;
  120. %%
  121. /*
  122. * vi:ts=4
  123. */