From 0449bc82bec13a5f9e9ea237e360993723c4b502 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Tue, 8 Jun 2021 19:47:03 -0400 Subject: Added the `init_config()` function. This function reads the config file supplied by `config_file`, and initialize the `config *` supplied by `cfg` accordingly. `init_config()` returns true if the config file was successfully read, otherwise, it returns false. --- pullreqd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pullreqd.c') diff --git a/pullreqd.c b/pullreqd.c index 406af10..2df8809 100644 --- a/pullreqd.c +++ b/pullreqd.c @@ -63,6 +63,21 @@ void init_daemon(int change_dir, char *path) { openlog("pullreqd", LOG_PID, LOG_DAEMON); } +int init_config(char *config_file, config **cfg) { + syslog(LOG_INFO, "Reading config file %s.", config_file); + + *cfg = parse_config(config_file); + + /* Did the config file parser succeed? */ + if (*cfg != NULL) { + syslog(LOG_INFO, "Successfully read %s.", config_file); + } else { + syslog(LOG_ERROR, "Error reading %s.", config_file); + } + + return (*cfg != NULL); +} + int main(int argc, char **argv) { int done = 0; init_daemon(1, "/"); -- cgit v1.2.3-13-gbd6f