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/conf.h"
25 #include "common/logging_conf.h"
26 #include "common/path.h"
28 #include "event/event_private.h"
29 #include "event/event_conf.h"
33 struct conf_context
*conf
;
35 const char *logging_location
;
36 const char *logging_loglevel
;
37 const char *debug_script
;
40 int event_config_init(TALLOC_CTX
*mem_ctx
, struct event_config
**result
)
42 struct event_config
*config
;
46 config
= talloc_zero(mem_ctx
, struct event_config
);
51 config
->config_file
= path_config(config
);
52 if (config
->config_file
== NULL
) {
57 ret
= conf_init(config
, &config
->conf
);
63 logging_conf_init(config
->conf
, NULL
);
65 conf_assign_string_pointer(config
->conf
,
67 LOGGING_CONF_LOCATION
,
68 &config
->logging_location
);
69 conf_assign_string_pointer(config
->conf
,
71 LOGGING_CONF_LOG_LEVEL
,
72 &config
->logging_loglevel
);
74 event_conf_init(config
->conf
);
76 conf_assign_string_pointer(config
->conf
,
78 EVENT_CONF_DEBUG_SCRIPT
,
79 &config
->debug_script
);
81 ok
= conf_valid(config
->conf
);
87 ret
= conf_load(config
->conf
, config
->config_file
, true);
88 if (ret
!= 0 && ret
!= ENOENT
) {
97 const char *event_config_log_location(struct event_config
*config
)
99 return config
->logging_location
;
102 const char *event_config_log_level(struct event_config
*config
)
104 return config
->logging_loglevel
;
107 const char *event_config_debug_script(struct event_config
*config
)
109 return config
->debug_script
;
112 int event_config_reload(struct event_config
*config
)
116 ret
= conf_reload(config
->conf
);
117 if (ret
!= 0 && ret
!= ENOENT
) {