X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd%2Fconfig.c;h=672faca0844a3e730bd01a25b2b053560847bee8;hb=59b8220d0227fe68537a563b3e5fa2e63e26bc0d;hp=848685867d962d3ee0f1dd16c55c67b3e4f22e9a;hpb=1dce100d387a16637d1e3062ada8346d896f4c3e;p=apps%2Fpfixtools.git diff --git a/postlicyd/config.c b/postlicyd/config.c index 8486858..672faca 100644 --- a/postlicyd/config.c +++ b/postlicyd/config.c @@ -77,9 +77,13 @@ config_param_register("verify_filter"); */ config_param_register("port"); + +static config_t *global_config = NULL; + static inline config_t *config_new(void) { config_t *config = p_new(config_t, 1); + global_config = config; return config; } @@ -97,9 +101,17 @@ void config_delete(config_t **config) if (*config) { config_close(*config); p_delete(config); + global_config = NULL; } } +static void config_exit() +{ + if (global_config) { + config_delete(&global_config); + } +} +module_exit(config_exit); static bool config_second_pass(config_t *config) { @@ -128,7 +140,7 @@ static bool config_second_pass(config_t *config) ok = false; #define PARSE_CHECK(Expr, Fmt, ...) \ if (!(Expr)) { \ - syslog(LOG_ERR, Fmt, ##__VA_ARGS__); \ + err(Fmt, ##__VA_ARGS__); \ return false; \ } foreach (filter_param_t *param, config->params) { @@ -158,7 +170,7 @@ static bool config_second_pass(config_t *config) array_deep_wipe(config->params, filter_params_wipe); if (!ok) { - syslog(LOG_ERR, "no entry point defined"); + err("no entry point defined"); } return ok; @@ -176,7 +188,7 @@ static bool config_load(config_t *config) char key[BUFSIZ]; char value[BUFSIZ]; - ssize_t key_len, value_len; + int key_len, value_len; if (!file_map_open(&map, config->filename, false)) { return false; @@ -187,8 +199,8 @@ static bool config_load(config_t *config) linep = p = map.map; #define READ_LOG(Lev, Fmt, ...) \ - syslog(LOG_ ## Lev, "config file %s:%d:%d: " Fmt, config->filename, \ - line + 1, p - linep + 1, ##__VA_ARGS__) + __log(LOG_ ## Lev, "config file %s:%d:%d: " Fmt, config->filename, \ + line + 1, (int)(p - linep + 1), ##__VA_ARGS__) #define READ_ERROR(Fmt, ...) \ do { \ READ_LOG(ERR, Fmt, ##__VA_ARGS__); \ @@ -391,7 +403,7 @@ ok: return true; badeof: - syslog(LOG_ERR, "Unexpected end of file"); + err("Unexpected end of file"); error: if (filter.name) { @@ -411,7 +423,7 @@ config_t *config_read(const char *file) config_t *config = config_new(); config->filename = file; if (!config_reload(config)) { - p_delete(&config); + config_delete(&config); return NULL; } return config;