2 CTDB event daemon - config handling
4 Copyright (C) Amitay Isaacs 2018
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
24 #include "common/path.h"
26 #include "conf/conf.h"
27 #include "conf/logging_conf.h"
28 #include "conf/event_conf.h"
30 #include "event/event_private.h"
34 struct conf_context
*conf
;
36 const char *logging_location
;
37 const char *logging_loglevel
;
38 const char *debug_script
;
41 int event_config_init(TALLOC_CTX
*mem_ctx
, struct event_config
**result
)
43 struct event_config
*config
;
47 config
= talloc_zero(mem_ctx
, struct event_config
);
52 config
->config_file
= path_config(config
);
53 if (config
->config_file
== NULL
) {
58 ret
= conf_init(config
, &config
->conf
);
64 logging_conf_init(config
->conf
, NULL
);
66 conf_assign_string_pointer(config
->conf
,
68 LOGGING_CONF_LOCATION
,
69 &config
->logging_location
);
70 conf_assign_string_pointer(config
->conf
,
72 LOGGING_CONF_LOG_LEVEL
,
73 &config
->logging_loglevel
);
75 event_conf_init(config
->conf
);
77 conf_assign_string_pointer(config
->conf
,
79 EVENT_CONF_DEBUG_SCRIPT
,
80 &config
->debug_script
);
82 ok
= conf_valid(config
->conf
);
88 ret
= conf_load(config
->conf
, config
->config_file
, true, true);
89 if (ret
!= 0 && ret
!= ENOENT
) {
98 const char *event_config_log_location(struct event_config
*config
)
100 return config
->logging_location
;
103 const char *event_config_log_level(struct event_config
*config
)
105 return config
->logging_loglevel
;
108 const char *event_config_debug_script(struct event_config
*config
)
110 return config
->debug_script
;
113 int event_config_reload(struct event_config
*config
)
117 ret
= conf_reload(config
->conf
);
118 if (ret
!= 0 && ret
!= ENOENT
) {