summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2018-01-13 17:49:57 +0100
committerAllan McRae <allan@archlinux.org>2018-01-18 04:42:57 +0100
commit0bbf9ddf9dff45346fb95bc6b6f1db8320551b6a (patch)
tree3363f4820c0578105740917974e9bc0c51d05853
parente8462a4f88335b200ad0a1c5d96e05a44af7e67c (diff)
downloadpacman-0bbf9ddf9dff45346fb95bc6b6f1db8320551b6a.tar.gz
pacman-0bbf9ddf9dff45346fb95bc6b6f1db8320551b6a.tar.xz
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 <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--src/pacman/conf.c13
-rw-r--r--src/pacman/conf.h1
2 files changed, 10 insertions, 4 deletions
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(&section, 0, sizeof(struct section_t));
+ pm_printf(ALPM_LOG_DEBUG, "config: attempting to read file %s\n", file);
+ return parse_ini(file, _parse_directive, &section);
+}
+
/** 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(&section, 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, &section))) {
+ if((ret = parseconfigfile(file))) {
return ret;
}
pm_printf(ALPM_LOG_DEBUG, "config: finished parsing %s\n", file);
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 53b44be6..e937051b 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -242,6 +242,7 @@ void config_repo_free(config_repo_t *repo);
int config_set_arch(const char *arch);
int parseconfig(const char *file);
+int parseconfigfile(const char *file);
#endif /* PM_CONF_H */
/* vim: set noet: */