diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2013-07-22 02:46:46 -0400 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2013-08-21 11:06:41 +1000 |
commit | 36f702ba826f2d3bebb4df3232c1b2b64a03f8a5 (patch) | |
tree | a13e396dc236afcd4e96fb5017eb4f1a8529fbe6 | |
parent | 74c8943682829329eaafa1e76482ca31877725fa (diff) | |
download | pacman-36f702ba826f2d3bebb4df3232c1b2b64a03f8a5.tar.xz |
conf.c: move repo parsing out of _parseconfig
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | src/pacman/conf.c | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/src/pacman/conf.c b/src/pacman/conf.c index e9a29e37..ca49749d 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -752,6 +752,43 @@ struct section_t { alpm_list_t *servers; }; +static int _parse_repo(const char *key, char *value, const char *file, + int line, struct section_t *section) +{ + int ret = 0; + + if(strcmp(key, "Server") == 0) { + if(!value) { + pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"), + file, line, key); + ret = 1; + } else { + section->servers = alpm_list_add(section->servers, strdup(value)); + } + } else if(strcmp(key, "SigLevel") == 0) { + if(!value) { + pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"), + file, line, key); + } else { + alpm_list_t *values = NULL; + setrepeatingoption(value, "SigLevel", &values); + if(values) { + if(section->siglevel == ALPM_SIG_USE_DEFAULT) { + section->siglevel = config->siglevel; + } + ret = process_siglevel(values, §ion->siglevel, file, line); + FREELIST(values); + } + } + } else { + pm_printf(ALPM_LOG_WARNING, + _("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"), + file, line, key, section->name); + } + + return ret; +} + /** * Wrap up a section once we have reached the end of it. This should be called * when a subsequent section is encountered, or when we have reached the end of @@ -946,32 +983,8 @@ static int _parseconfig(const char *file, struct section_t *section, int depth) } } else if(!section->parse_options && !section->is_options) { /* ... or in a repo section */ - if(strcmp(key, "Server") == 0) { - if(value == NULL) { - pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value\n"), - file, linenum, key); - ret = 1; - goto cleanup; - } - section->servers = alpm_list_add(section->servers, strdup(value)); - } else if(strcmp(key, "SigLevel") == 0) { - alpm_list_t *values = NULL; - setrepeatingoption(value, "SigLevel", &values); - if(values) { - if(section->siglevel == ALPM_SIG_USE_DEFAULT) { - section->siglevel = config->siglevel; - } - if(process_siglevel(values, §ion->siglevel, file, linenum)) { - FREELIST(values); - ret = 1; - goto cleanup; - } - FREELIST(values); - } - } else { - pm_printf(ALPM_LOG_WARNING, - _("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"), - file, linenum, key, section->name); + if((ret = _parse_repo(key, value, file, linenum, section)) != 0) { + goto cleanup; } } } |