From 11f89cf7a9a7375b74a239311e394db3c952fbd9 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 24 Mar 2025 16:34:15 +0100 Subject: Add support for specifying hook file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/config-ini.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/config-ini.c') 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; } -- cgit v1.2.3-70-g09d2