projects
/
apps
/
pfixtools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow user-defined fd in events.
[apps/pfixtools.git]
/
postlicyd
/
config.c
diff --git
a/postlicyd/config.c
b/postlicyd/config.c
index
d1e4d83
..
672faca
100644
(file)
--- a/
postlicyd/config.c
+++ b/
postlicyd/config.c
@@
-77,9
+77,13
@@
config_param_register("verify_filter");
*/
config_param_register("port");
*/
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);
static inline config_t *config_new(void)
{
config_t *config = p_new(config_t, 1);
+ global_config = config;
return config;
}
return config;
}
@@
-97,9
+101,17
@@
void config_delete(config_t **config)
if (*config) {
config_close(*config);
p_delete(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)
{
static bool config_second_pass(config_t *config)
{
@@
-176,7
+188,7
@@
static bool config_load(config_t *config)
char key[BUFSIZ];
char value[BUFSIZ];
char key[BUFSIZ];
char value[BUFSIZ];
-
ssize_
t key_len, value_len;
+
in
t key_len, value_len;
if (!file_map_open(&map, config->filename, false)) {
return false;
if (!file_map_open(&map, config->filename, false)) {
return false;
@@
-188,7
+200,7
@@
static bool config_load(config_t *config)
#define READ_LOG(Lev, Fmt, ...) \
__log(LOG_ ## Lev, "config file %s:%d:%d: " Fmt, config->filename, \
#define READ_LOG(Lev, Fmt, ...) \
__log(LOG_ ## Lev, "config file %s:%d:%d: " Fmt, config->filename, \
- line + 1,
p - linep + 1
, ##__VA_ARGS__)
+ line + 1,
(int)(p - linep + 1)
, ##__VA_ARGS__)
#define READ_ERROR(Fmt, ...) \
do { \
READ_LOG(ERR, Fmt, ##__VA_ARGS__); \
#define READ_ERROR(Fmt, ...) \
do { \
READ_LOG(ERR, Fmt, ##__VA_ARGS__); \
@@
-411,7
+423,7
@@
config_t *config_read(const char *file)
config_t *config = config_new();
config->filename = file;
if (!config_reload(config)) {
config_t *config = config_new();
config->filename = file;
if (!config_reload(config)) {
-
p
_delete(&config);
+
config
_delete(&config);
return NULL;
}
return config;
return NULL;
}
return config;