From 0bbf9ddf9dff45346fb95bc6b6f1db8320551b6a Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Sat, 13 Jan 2018 11:49:57 -0500 Subject: extract raw config file parser To allow pacman-conf to parse the configuration file without having to also setup alpm. Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- src/pacman/conf.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/pacman/conf.c') diff --git a/src/pacman/conf.c b/src/pacman/conf.c index a283d7f4..e4980ed2 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -1036,6 +1036,14 @@ static int _parse_directive(const char *file, int linenum, const char *name, } } +int parseconfigfile(const char *file) +{ + struct section_t section; + memset(§ion, 0, sizeof(struct section_t)); + pm_printf(ALPM_LOG_DEBUG, "config: attempting to read file %s\n", file); + return parse_ini(file, _parse_directive, §ion); +} + /** Parse a configuration file. * @param file path to the config file * @return 0 on success, non-zero on error @@ -1043,10 +1051,7 @@ static int _parse_directive(const char *file, int linenum, const char *name, int parseconfig(const char *file) { int ret; - struct section_t section; - memset(§ion, 0, sizeof(struct section_t)); - pm_printf(ALPM_LOG_DEBUG, "config: attempting to read file %s\n", file); - if((ret = parse_ini(file, _parse_directive, §ion))) { + if((ret = parseconfigfile(file))) { return ret; } pm_printf(ALPM_LOG_DEBUG, "config: finished parsing %s\n", file); -- cgit v1.2.3-54-g00ecf