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>
This commit is contained in:
parent
e8462a4f88
commit
0bbf9ddf9d
2 changed files with 10 additions and 4 deletions
|
@ -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.
|
/** Parse a configuration file.
|
||||||
* @param file path to the config file
|
* @param file path to the config file
|
||||||
* @return 0 on success, non-zero on error
|
* @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 parseconfig(const char *file)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct section_t section;
|
if((ret = parseconfigfile(file))) {
|
||||||
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))) {
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
pm_printf(ALPM_LOG_DEBUG, "config: finished parsing %s\n", file);
|
pm_printf(ALPM_LOG_DEBUG, "config: finished parsing %s\n", file);
|
||||||
|
|
|
@ -242,6 +242,7 @@ void config_repo_free(config_repo_t *repo);
|
||||||
|
|
||||||
int config_set_arch(const char *arch);
|
int config_set_arch(const char *arch);
|
||||||
int parseconfig(const char *file);
|
int parseconfig(const char *file);
|
||||||
|
int parseconfigfile(const char *file);
|
||||||
#endif /* PM_CONF_H */
|
#endif /* PM_CONF_H */
|
||||||
|
|
||||||
/* vim: set noet: */
|
/* vim: set noet: */
|
||||||
|
|
Loading…
Add table
Reference in a new issue