aboutsummaryrefslogtreecommitdiffstats
path: root/src/cfg_file.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2008-11-01 18:01:05 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2008-11-01 18:01:05 +0300
commit2aa9c74f1c449da92f6faf870f8cc801a83bb08b (patch)
tree33f0f941f08583fd0c4c3653cadde8d6ce8426c2 /src/cfg_file.h
parentcc5343692b448c27485a24ea7f1b24d714bb82f6 (diff)
downloadrspamd-2aa9c74f1c449da92f6faf870f8cc801a83bb08b.tar.gz
rspamd-2aa9c74f1c449da92f6faf870f8cc801a83bb08b.zip
* Reorganize structure of source files
* Adopt build system for new structure --HG-- rename : cfg_file.h => src/cfg_file.h rename : cfg_file.l => src/cfg_file.l rename : cfg_file.y => src/cfg_file.y rename : cfg_utils.c => src/cfg_utils.c rename : controller.c => src/controller.c rename : filter.c => src/filter.c rename : filter.h => src/filter.h rename : fstring.c => src/fstring.c rename : fstring.h => src/fstring.h rename : main.c => src/main.c rename : main.h => src/main.h rename : mem_pool.c => src/mem_pool.c rename : mem_pool.h => src/mem_pool.h rename : memcached-test.c => src/memcached-test.c rename : memcached.c => src/memcached.c rename : memcached.h => src/memcached.h rename : perl.c => src/perl.c rename : perl.h => src/perl.h rename : plugins/regexp.c => src/plugins/regexp.c rename : plugins/surbl.c => src/plugins/surbl.c rename : protocol.c => src/protocol.c rename : protocol.h => src/protocol.h rename : upstream.c => src/upstream.c rename : upstream.h => src/upstream.h rename : url.c => src/url.c rename : url.h => src/url.h rename : util.c => src/util.c rename : util.h => src/util.h rename : worker.c => src/worker.c
Diffstat (limited to 'src/cfg_file.h')
-rw-r--r--src/cfg_file.h167
1 files changed, 167 insertions, 0 deletions
diff --git a/src/cfg_file.h b/src/cfg_file.h
new file mode 100644
index 000000000..1eb71476d
--- /dev/null
+++ b/src/cfg_file.h
@@ -0,0 +1,167 @@
+/*
+ * $Id$
+ */
+
+
+#ifndef CFG_FILE_H
+#define CFG_FILE_H
+
+#include "config.h"
+#include <sys/types.h>
+#ifndef HAVE_OWN_QUEUE_H
+#include <sys/queue.h>
+#else
+#include "queue.h"
+#endif
+#include <netinet/in.h>
+#include <sys/un.h>
+#include <event.h>
+#include <glib.h>
+#include "mem_pool.h"
+#include "upstream.h"
+#include "memcached.h"
+#include "filter.h"
+
+#define DEFAULT_BIND_PORT 768
+#define DEFAULT_CONTROL_PORT 7608
+#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
+
+/* 1 worker by default */
+#define DEFAULT_WORKERS_NUM 1
+
+#define yyerror(fmt, ...) \
+ fprintf (stderr, "Config file parse error!\non line: %d\n", yylineno); \
+ fprintf (stderr, "while reading text: %s\nreason: ", yytext); \
+ fprintf (stderr, fmt, ##__VA_ARGS__); \
+ fprintf (stderr, "\n")
+#define yywarn(fmt, ...) \
+ fprintf (stderr, "Config file parse warning!\non line %d\n", yylineno); \
+ fprintf (stderr, "while reading text: %s\nreason: ", yytext); \
+ fprintf (stderr, fmt, ##__VA_ARGS__); \
+ fprintf (stderr, "\n")
+
+struct expression;
+
+enum { VAL_UNDEF=0, VAL_TRUE, VAL_FALSE };
+
+enum rspamd_regexp_type {
+ REGEXP_NONE = 0,
+ REGEXP_HEADER,
+ REGEXP_MIME,
+ REGEXP_MESSAGE,
+ REGEXP_URL,
+};
+
+enum rspamd_log_type {
+ RSPAMD_LOG_CONSOLE,
+ RSPAMD_LOG_SYSLOG,
+ RSPAMD_LOG_FILE,
+};
+
+struct rspamd_regexp {
+ enum rspamd_regexp_type type;
+ char *regexp_text;
+ GRegex *regexp;
+ char *header;
+};
+
+struct memcached_server {
+ struct upstream up;
+ struct in_addr addr;
+ uint16_t port;
+ short alive;
+ short int num;
+};
+
+struct perl_module {
+ char *path;
+ LIST_ENTRY (perl_module) next;
+};
+
+struct module_opt {
+ char *param;
+ char *value;
+ LIST_ENTRY (module_opt) next;
+};
+
+struct config_file {
+ memory_pool_t *cfg_pool;
+ char *cfg_name;
+ char *pid_file;
+ char *temp_dir;
+
+ char *bind_host;
+ struct in_addr bind_addr;
+ uint16_t bind_port;
+ uint16_t bind_family;
+
+ char *control_host;
+ struct in_addr control_addr;
+ uint16_t control_port;
+ uint16_t control_family;
+ int controller_enabled;
+ char *control_password;
+
+ int no_fork;
+ unsigned int workers_number;
+
+ enum rspamd_log_type log_type;
+ int log_facility;
+ int log_level;
+ char *log_file;
+ int log_fd;
+
+ struct memcached_server memcached_servers[MAX_MEMCACHED_SERVERS];
+ size_t memcached_servers_num;
+ memc_proto_t memcached_protocol;
+ unsigned int memcached_error_time;
+ unsigned int memcached_dead_time;
+ unsigned int memcached_maxerrors;
+ unsigned int memcached_connect_timeout;
+
+ LIST_HEAD (modulesq, perl_module) perl_modules;
+ LIST_HEAD (headersq, filter) header_filters;
+ LIST_HEAD (mimesq, filter) mime_filters;
+ LIST_HEAD (messagesq, filter) message_filters;
+ LIST_HEAD (urlsq, filter) url_filters;
+ char *header_filters_str;
+ char *mime_filters_str;
+ char *message_filters_str;
+ char *url_filters_str;
+ GHashTable* modules_opts;
+ GHashTable* variables;
+ GHashTable* metrics;
+ GHashTable* factors;
+ GHashTable* c_modules;
+ GHashTable* composite_symbols;
+};
+
+int add_memcached_server (struct config_file *cf, char *str);
+int parse_bind_line (struct config_file *cf, char *str, char is_control);
+void init_defaults (struct config_file *cfg);
+void free_config (struct config_file *cfg);
+char* get_module_opt (struct config_file *cfg, char *module_name, char *opt_name);
+size_t parse_limit (const char *limit);
+unsigned int parse_seconds (const char *t);
+char parse_flag (const char *str);
+char* substitute_variable (struct config_file *cfg, char *str, u_char recursive);
+void post_load_config (struct config_file *cfg);
+struct rspamd_regexp* parse_regexp (memory_pool_t *pool, char *line);
+struct expression* parse_expression (memory_pool_t *pool, char *line);
+
+int yylex (void);
+int yyparse (void);
+void yyrestart (FILE *);
+
+#endif /* ifdef CFG_FILE_H */
+/*
+ * vi:ts=4
+ */