diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-08 19:47:03 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-08 19:47:03 -0400 |
commit | 0449bc82bec13a5f9e9ea237e360993723c4b502 (patch) | |
tree | 5b1b72b5839d99dc95719df68a5ed07a7303b703 /pullreqd.c | |
parent | bf6b94116fd0f55df94a846a69778f948182edbb (diff) |
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.
Diffstat (limited to 'pullreqd.c')
-rw-r--r-- | pullreqd.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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, "/"); |