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.h 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * $Id$
  3. */
  4. #ifndef CFG_FILE_H
  5. #define CFG_FILE_H
  6. #include "config.h"
  7. #include <sys/types.h>
  8. #ifndef OWN_QUEUE_H
  9. #include <sys/queue.h>
  10. #else
  11. #include "queue.h"
  12. #endif
  13. #include <netinet/in.h>
  14. #include <sys/un.h>
  15. #include <event.h>
  16. #include <glib.h>
  17. #include "mem_pool.h"
  18. #include "upstream.h"
  19. #include "memcached.h"
  20. #include "filter.h"
  21. #define DEFAULT_BIND_PORT 768
  22. #define MAX_MEMCACHED_SERVERS 48
  23. #define DEFAULT_MEMCACHED_PORT 11211
  24. /* Memcached timeouts */
  25. #define DEFAULT_MEMCACHED_CONNECT_TIMEOUT 1000
  26. /* Upstream timeouts */
  27. #define DEFAULT_UPSTREAM_ERROR_TIME 10
  28. #define DEFAULT_UPSTREAM_ERROR_TIME 10
  29. #define DEFAULT_UPSTREAM_DEAD_TIME 300
  30. #define DEFAULT_UPSTREAM_MAXERRORS 10
  31. /* 1 worker by default */
  32. #define DEFAULT_WORKERS_NUM 1
  33. #define yyerror(fmt, ...) \
  34. fprintf (stderr, "Config file parse error!\non line: %d\n", yylineno); \
  35. fprintf (stderr, "while reading text: %s\nreason: ", yytext); \
  36. fprintf (stderr, fmt, ##__VA_ARGS__); \
  37. fprintf (stderr, "\n")
  38. #define yywarn(fmt, ...) \
  39. fprintf (stderr, "Config file parse warning!\non line %d\n", yylineno); \
  40. fprintf (stderr, "while reading text: %s\nreason: ", yytext); \
  41. fprintf (stderr, fmt, ##__VA_ARGS__); \
  42. fprintf (stderr, "\n")
  43. enum { VAL_UNDEF=0, VAL_TRUE, VAL_FALSE };
  44. enum script_type {
  45. SCRIPT_HEADER,
  46. SCRIPT_MIME,
  47. SCRIPT_URL,
  48. SCRIPT_MESSAGE,
  49. };
  50. struct memcached_server {
  51. struct upstream up;
  52. struct in_addr addr;
  53. uint16_t port;
  54. short alive;
  55. short int num;
  56. };
  57. struct perl_module {
  58. char *path;
  59. LIST_ENTRY (perl_module) next;
  60. };
  61. struct module_opt {
  62. char *param;
  63. char *value;
  64. LIST_ENTRY (module_opt) next;
  65. };
  66. struct config_file {
  67. memory_pool_t *cfg_pool;
  68. char *cfg_name;
  69. char *pid_file;
  70. char *temp_dir;
  71. char *bind_host;
  72. struct in_addr bind_addr;
  73. uint16_t bind_port;
  74. uint16_t bind_family;
  75. char no_fork;
  76. unsigned int workers_number;
  77. struct memcached_server memcached_servers[MAX_MEMCACHED_SERVERS];
  78. size_t memcached_servers_num;
  79. memc_proto_t memcached_protocol;
  80. unsigned int memcached_error_time;
  81. unsigned int memcached_dead_time;
  82. unsigned int memcached_maxerrors;
  83. unsigned int memcached_connect_timeout;
  84. LIST_HEAD (modulesq, perl_module) perl_modules;
  85. LIST_HEAD (headersq, filter) header_filters;
  86. LIST_HEAD (mimesq, filter) mime_filters;
  87. LIST_HEAD (messagesq, filter) message_filters;
  88. LIST_HEAD (urlsq, filter) url_filters;
  89. char *header_filters_str;
  90. char *mime_filters_str;
  91. char *message_filters_str;
  92. char *url_filters_str;
  93. GHashTable* modules_opts;
  94. GHashTable* variables;
  95. GHashTable* metrics;
  96. GHashTable* factors;
  97. GHashTable* c_modules;
  98. };
  99. int add_memcached_server (struct config_file *cf, char *str);
  100. int parse_bind_line (struct config_file *cf, char *str);
  101. void init_defaults (struct config_file *cfg);
  102. void free_config (struct config_file *cfg);
  103. char* get_module_opt (struct config_file *cfg, char *module_name, char *opt_name);
  104. size_t parse_limit (const char *limit);
  105. unsigned int parse_seconds (const char *t);
  106. char parse_flag (const char *str);
  107. char* substitute_variable (struct config_file *cfg, char *str, u_char recursive);
  108. void post_load_config (struct config_file *cfg);
  109. int yylex (void);
  110. int yyparse (void);
  111. void yyrestart (FILE *);
  112. #endif /* ifdef CFG_FILE_H */
  113. /*
  114. * vi:ts=4
  115. */