/** * @file cfg_file.h * Config file parser and config routines API */ #ifndef CFG_FILE_H #define CFG_FILE_H #include "config.h" #include "mem_pool.h" #include "upstream.h" #include "memcached.h" #define DEFAULT_BIND_PORT 768 #define DEFAULT_CONTROL_PORT 7608 #define DEFAULT_LMTP_PORT 7609 #define MAX_MEMCACHED_SERVERS 48 #define DEFAULT_MEMCACHED_PORT 11211 /* Memcached timeouts */ #define DEFAULT_MEMCACHED_CONNECT_TIMEOUT 1000 /* Upstream timeouts */ #define DEFAULT_UPSTREAM_ERROR_TIME 10 #define DEFAULT_UPSTREAM_ERROR_TIME 10 #define DEFAULT_UPSTREAM_DEAD_TIME 300 #define DEFAULT_UPSTREAM_MAXERRORS 10 /* Statfile pool size, 50Mb */ #define DEFAULT_STATFILE_SIZE 52428800L /* 1 worker by default */ #define DEFAULT_WORKERS_NUM 1 #define DEFAULT_SCORE 10.0 #define DEFAULT_REJECT_SCORE 999.0 #define yyerror parse_err #define yywarn parse_warn struct expression; struct tokenizer; struct classifier; enum { VAL_UNDEF=0, VAL_TRUE, VAL_FALSE }; /** * Types of rspamd bind lines */ enum rspamd_cred_type { CRED_NORMAL, CRED_CONTROL, CRED_LMTP, CRED_DELIVERY, }; /** * Regexp type: /H - header, /M - mime, /U - url /X - raw header */ enum rspamd_regexp_type { REGEXP_NONE = 0, REGEXP_HEADER, REGEXP_MIME, REGEXP_MESSAGE, REGEXP_URL, REGEXP_RAW_HEADER, }; /** * Logging type */ enum rspamd_log_type { RSPAMD_LOG_CONSOLE, RSPAMD_LOG_SYSLOG, RSPAMD_LOG_FILE, }; /** * Regexp structure */ struct rspamd_regexp { enum rspamd_regexp_type type; /**< regexp type */ gchar *regexp_text; /**< regexp text representation */ GRegex *regexp; /**< glib regexp structure */ GRegex *raw_regexp; /**< glib regexp structure for raw matching */ gchar *header; /**< header name for header regexps */ }; /** * Memcached server object */ struct memcached_server { struct upstream up; /**< common upstream base */ struct in_addr addr; /**< address of server */ uint16_t port; /**< port to connect */ short alive; /**< is this server alive */ short int num; /**< number of servers in case of mirror */ }; /** * script module list item */ struct script_module { gchar *name; /**< name of module */ gchar *path; /**< path to module */ }; /** * Type of lua variable */ enum lua_var_type { LUA_VAR_NUM, LUA_VAR_BOOLEAN, LUA_VAR_STRING, LUA_VAR_FUNCTION, LUA_VAR_UNKNOWN }; /** * Module option */ struct module_opt { gchar *param; /**< parameter name */ gchar *value; /**< paramater value */ gpointer actual_data; /**< parsed data */ gboolean is_lua; /**< actually this is lua variable */ enum lua_var_type lua_type; /**< type of lua variable */ }; /** * Statfile section definition */ struct statfile_section { uint32_t code; /**< section's code */ uint64_t size; /**< size of section */ double weight; /**< weight coefficient for section */ }; /** * Statfile autolearn parameters */ struct statfile_autolearn_params { const gchar *metric; /**< metric name for autolearn triggering */ double threshold_min; /**< threshold mark */ double threshold_max; /**< threshold mark */ GList *symbols; /**< list of symbols */ }; /** * Sync affinity */ enum sync_affinity { AFFINITY_NONE = 0, AFFINITY_MASTER, AFFINITY_SLAVE }; /** * Binlog params */ struct statfile_binlog_params { enum sync_affinity affinity; time_
<script>
<!--
ok( true, "script within html comments executed" );
-->
</script>
<script>
<![CDATA[
ok( true, "script within CDATA executed" );
]]>
</script>
ion of clock used */ double grow_factor; /**< grow factor for consolidation callback */ GList *views; /**< views */ GHashTable* domain_settings; /**< settings per-domains */ GHashTable* user_settings; /**< settings per-user */ gchar* checksum; /**< real checksum of config file */ gchar* dump_checksum; /**< dump checksum of config file */ gpointer lua_state; /**< pointer to lua state */ }; /** * Add memcached server to config * @param cf config file to use * @param str line that describes server's credits * @return 1 if line was successfully parsed and 0 in case of error */ int add_memcached_server (struct config_file *cf, gchar *str); /** * Parse host:port line * @param ina host address * @param port port * @return TRUE if string was parsed */ gboolean parse_host_port (const gchar *str, struct in_addr *ina, uint16_t *port); /** * Parse bind credits * @param cf config file to use * @param str line that presents bind line * @param type type of credits * @return 1 if line was successfully parsed and 0 in case of error */ int parse_bind_line (struct config_file *cfg, struct worker_conf *cf, gchar *str); /** * Init default values * @param cfg config file */ void init_defaults (struct config_file *cfg); /** * Free memory used by config structure * @param cfg config file */ void free_config (struct config_file *cfg); /** * Gets module option with specified name * @param cfg config file * @param module_name name of module * @param opt_name name of option to get * @return module value or NULL if option does not defined */ gchar* get_module_opt (struct config_file *cfg, gchar *module_name, gchar *opt_name); /** * Parse limit * @param limit string representation of limit (eg. 1M) * @return numeric value of limit */ gsize parse_limit (const gchar *limit); /** * Parse seconds * @param t string representation of seconds (eg. 1D) * @return numeric value of string */ unsigned int parse_seconds (const gchar *t); /** * Parse flag * @param str string representation of flag (eg. 'on') * @return numeric value of flag (0 or 1) */ gchar parse_flag (const gchar *str); /** * Substitutes variable in specified string, may be recursive (eg. ${var1${var2}}) * @param cfg config file * @param name variable's name * @param str incoming string * @param recursive whether do recursive scanning * @return new string with substituted variables (uses cfg memory pool for allocating) */ gchar* substitute_variable (struct config_file *cfg, gchar *name, gchar *str, guchar recursive); /** * Do post load actions for config * @param cfg config file */ void post_load_config (struct config_file *cfg); /** * Calculate checksum for config file * @param cfg config file */ gboolean get_config_checksum (struct config_file *cfg); /** * Replace all \" with a single " in given string * @param line input string */ void unescape_quotes (gchar *line); GList* parse_comma_list (memory_pool_t *pool, gchar *line); struct classifier_config* check_classifier_cfg (struct config_file *cfg, struct classifier_config *c); struct worker_conf* check_worker_conf (struct config_file *cfg, struct worker_conf *c); gboolean parse_normalizer (struct config_file *cfg, struct statfile *st, const gchar *line); gboolean read_xml_config (struct config_file *cfg, const gchar *filename); int yylex (void); int yyparse (void); void yyrestart (FILE *); void parse_err (const gchar *fmt, ...); void parse_warn (const gchar *fmt, ...); #endif /* ifdef CFG_FILE_H */ /* * vi:ts=4 */