summaryrefslogtreecommitdiff
path: root/pullreqd.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-06-08 19:47:03 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-06-08 19:47:03 -0400
commit0449bc82bec13a5f9e9ea237e360993723c4b502 (patch)
tree5b1b72b5839d99dc95719df68a5ed07a7303b703 /pullreqd.c
parentbf6b94116fd0f55df94a846a69778f948182edbb (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.c15
1 files changed, 15 insertions, 0 deletions
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, "/");