aboutsummaryrefslogtreecommitdiffstats
path: root/src/config-ini.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-03-24 16:34:15 +0100
committerMattias Andrée <m@maandree.se>2025-03-24 16:34:15 +0100
commit11f89cf7a9a7375b74a239311e394db3c952fbd9 (patch)
tree8cdd850a991dd9fcac9ad663454750427425edd7 /src/config-ini.c
parentCleanup (diff)
downloadredshift-ng-11f89cf7a9a7375b74a239311e394db3c952fbd9.tar.gz
redshift-ng-11f89cf7a9a7375b74a239311e394db3c952fbd9.tar.bz2
redshift-ng-11f89cf7a9a7375b74a239311e394db3c952fbd9.tar.xz
Add support for specifying hook file
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'src/config-ini.c')
-rw-r--r--src/config-ini.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/config-ini.c b/src/config-ini.c
index d5056dc..13aaa57 100644
--- a/src/config-ini.c
+++ b/src/config-ini.c
@@ -146,12 +146,12 @@ open_config_file(const char *path, const char **path_out, char **pathbuf_out, in
}
-void
-config_ini_init(struct config_ini_state *state, const char *path)
+const char *
+config_ini_init(struct config_ini_state *state, const char *path, char **pathbuf_out)
{
struct config_ini_section *section = NULL;
struct config_ini_setting *setting;
- char *line = NULL, *s, *p, *value, *end, *pathbuf;
+ char *line = NULL, *s, *p, *value, *end;
char *next_line = NULL, *name;
size_t size = 0;
ssize_t len = 0; /* initialised to silence false warning from clang */
@@ -159,10 +159,11 @@ config_ini_init(struct config_ini_state *state, const char *path)
int should_close;
state->sections = NULL;
+ *pathbuf_out = NULL;
- f = open_config_file(path, &path, &pathbuf, &should_close);
+ f = open_config_file(path, &path, pathbuf_out, &should_close);
if (!f)
- return;
+ return NULL;
#ifndef WINDOWS
again:
@@ -227,10 +228,11 @@ again:
eprintf("getline %s:", path);
}
- free(pathbuf);
free(line);
if (should_close)
fclose(f);
+
+ return path;
}