Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   Case insensitive configuration values (to allow both SigLevel = Never and SigLevel = never) (http://www.linux-archive.org/archlinux-pacman-development/621722-case-insensitive-configuration-values-allow-both-siglevel-never-siglevel-never.html)

Alexander Rødseth 01-16-2012 11:14 PM

Case insensitive configuration values (to allow both SigLevel = Never and SigLevel = never)
 
---
src/pacman/conf.c | 66 ++++++++++++++++++++++++++--------------------------
1 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 7ba2791..f114339 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -225,7 +225,7 @@ cleanup:

int config_set_arch(const char *arch)
{
- if(strcmp(arch, "auto") == 0) {
+ if(strcasecmp(arch, "auto") == 0) {
struct utsname un;
uname(&un);
config->arch = strdup(un.machine);
@@ -272,14 +272,14 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
}

/* now parse out and store actual flag if it is valid */
- if(strcmp(value, "Never") == 0) {
+ if(strcasecmp(value, "Never") == 0) {
if(package) {
level &= ~ALPM_SIG_PACKAGE;
}
if(database) {
level &= ~ALPM_SIG_DATABASE;
}
- } else if(strcmp(value, "Optional") == 0) {
+ } else if(strcasecmp(value, "Optional") == 0) {
if(package) {
level |= ALPM_SIG_PACKAGE;
level |= ALPM_SIG_PACKAGE_OPTIONAL;
@@ -288,7 +288,7 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
level |= ALPM_SIG_DATABASE;
level |= ALPM_SIG_DATABASE_OPTIONAL;
}
- } else if(strcmp(value, "Required") == 0) {
+ } else if(strcasecmp(value, "Required") == 0) {
if(package) {
level |= ALPM_SIG_PACKAGE;
level &= ~ALPM_SIG_PACKAGE_OPTIONAL;
@@ -297,7 +297,7 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
level |= ALPM_SIG_DATABASE;
level &= ~ALPM_SIG_DATABASE_OPTIONAL;
}
- } else if(strcmp(value, "TrustedOnly") == 0) {
+ } else if(strcasecmp(value, "TrustedOnly") == 0) {
if(package) {
level &= ~ALPM_SIG_PACKAGE_MARGINAL_OK;
level &= ~ALPM_SIG_PACKAGE_UNKNOWN_OK;
@@ -306,7 +306,7 @@ static int process_siglevel(alpm_list_t *values, alpm_siglevel_t *storage,
level &= ~ALPM_SIG_DATABASE_MARGINAL_OK;
level &= ~ALPM_SIG_DATABASE_UNKNOWN_OK;
}
- } else if(strcmp(value, "TrustAll") == 0) {
+ } else if(strcasecmp(value, "TrustAll") == 0) {
if(package) {
level |= ALPM_SIG_PACKAGE_MARGINAL_OK;
level |= ALPM_SIG_PACKAGE_UNKNOWN_OK;
@@ -345,9 +345,9 @@ static int process_cleanmethods(alpm_list_t *values,
alpm_list_t *i;
for(i = values; i; i = alpm_list_next(i)) {
const char *value = i->data;
- if(strcmp(value, "KeepInstalled") == 0) {
+ if(strcasecmp(value, "KeepInstalled") == 0) {
config->cleanmethod |= PM_CLEAN_KEEPINST;
- } else if(strcmp(value, "KeepCurrent") == 0) {
+ } else if(strcasecmp(value, "KeepCurrent") == 0) {
config->cleanmethod |= PM_CLEAN_KEEPCUR;
} else {
pm_printf(ALPM_LOG_ERROR,
@@ -387,22 +387,22 @@ static int _parse_options(const char *key, char *value,
{
if(value == NULL) {
/* options without settings */
- if(strcmp(key, "UseSyslog") == 0) {
+ if(strcasecmp(key, "UseSyslog") == 0) {
config->usesyslog = 1;
pm_printf(ALPM_LOG_DEBUG, "config: usesyslog
");
- } else if(strcmp(key, "ILoveCandy") == 0) {
+ } else if(strcasecmp(key, "ILoveCandy") == 0) {
config->chomp = 1;
pm_printf(ALPM_LOG_DEBUG, "config: chomp
");
- } else if(strcmp(key, "VerbosePkgLists") == 0) {
+ } else if(strcasecmp(key, "VerbosePkgLists") == 0) {
config->verbosepkglists = 1;
pm_printf(ALPM_LOG_DEBUG, "config: verbosepkglists
");
- } else if(strcmp(key, "UseDelta") == 0) {
+ } else if(strcasecmp(key, "UseDelta") == 0) {
config->usedelta = 1;
pm_printf(ALPM_LOG_DEBUG, "config: usedelta
");
- } else if(strcmp(key, "TotalDownload") == 0) {
+ } else if(strcasecmp(key, "TotalDownload") == 0) {
config->totaldownload = 1;
pm_printf(ALPM_LOG_DEBUG, "config: totaldownload
");
- } else if(strcmp(key, "CheckSpace") == 0) {
+ } else if(strcasecmp(key, "CheckSpace") == 0) {
config->checkspace = 1;
} else {
pm_printf(ALPM_LOG_WARNING,
@@ -411,50 +411,50 @@ static int _parse_options(const char *key, char *value,
}
} else {
/* options with settings */
- if(strcmp(key, "NoUpgrade") == 0) {
+ if(strcasecmp(key, "NoUpgrade") == 0) {
setrepeatingoption(value, "NoUpgrade", &(config->noupgrade));
- } else if(strcmp(key, "NoExtract") == 0) {
+ } else if(strcasecmp(key, "NoExtract") == 0) {
setrepeatingoption(value, "NoExtract", &(config->noextract));
- } else if(strcmp(key, "IgnorePkg") == 0) {
+ } else if(strcasecmp(key, "IgnorePkg") == 0) {
setrepeatingoption(value, "IgnorePkg", &(config->ignorepkg));
- } else if(strcmp(key, "IgnoreGroup") == 0) {
+ } else if(strcasecmp(key, "IgnoreGroup") == 0) {
setrepeatingoption(value, "IgnoreGroup", &(config->ignoregrp));
- } else if(strcmp(key, "HoldPkg") == 0) {
+ } else if(strcasecmp(key, "HoldPkg") == 0) {
setrepeatingoption(value, "HoldPkg", &(config->holdpkg));
- } else if(strcmp(key, "SyncFirst") == 0) {
+ } else if(strcasecmp(key, "SyncFirst") == 0) {
setrepeatingoption(value, "SyncFirst", &(config->syncfirst));
- } else if(strcmp(key, "CacheDir") == 0) {
+ } else if(strcasecmp(key, "CacheDir") == 0) {
setrepeatingoption(value, "CacheDir", &(config->cachedirs));
- } else if(strcmp(key, "Architecture") == 0) {
+ } else if(strcasecmp(key, "Architecture") == 0) {
if(!config->arch) {
config_set_arch(value);
}
- } else if(strcmp(key, "DBPath") == 0) {
+ } else if(strcasecmp(key, "DBPath") == 0) {
/* don't overwrite a path specified on the command line */
if(!config->dbpath) {
config->dbpath = strdup(value);
pm_printf(ALPM_LOG_DEBUG, "config: dbpath: %s
", value);
}
- } else if(strcmp(key, "RootDir") == 0) {
+ } else if(strcasecmp(key, "RootDir") == 0) {
/* don't overwrite a path specified on the command line */
if(!config->rootdir) {
config->rootdir = strdup(value);
pm_printf(ALPM_LOG_DEBUG, "config: rootdir: %s
", value);
}
- } else if(strcmp(key, "GPGDir") == 0) {
+ } else if(strcasecmp(key, "GPGDir") == 0) {
if(!config->gpgdir) {
config->gpgdir = strdup(value);
pm_printf(ALPM_LOG_DEBUG, "config: gpgdir: %s
", value);
}
- } else if(strcmp(key, "LogFile") == 0) {
+ } else if(strcasecmp(key, "LogFile") == 0) {
if(!config->logfile) {
config->logfile = strdup(value);
pm_printf(ALPM_LOG_DEBUG, "config: logfile: %s
", value);
}
- } else if(strcmp(key, "XferCommand") == 0) {
+ } else if(strcasecmp(key, "XferCommand") == 0) {
config->xfercommand = strdup(value);
pm_printf(ALPM_LOG_DEBUG, "config: xfercommand: %s
", value);
- } else if(strcmp(key, "CleanMethod") == 0) {
+ } else if(strcasecmp(key, "CleanMethod") == 0) {
alpm_list_t *methods = NULL;
setrepeatingoption(value, "CleanMethod", &methods);
if(process_cleanmethods(methods, file, linenum)) {
@@ -462,7 +462,7 @@ static int _parse_options(const char *key, char *value,
return 1;
}
FREELIST(methods);
- } else if(strcmp(key, "SigLevel") == 0) {
+ } else if(strcasecmp(key, "SigLevel") == 0) {
alpm_list_t *values = NULL;
setrepeatingoption(value, "SigLevel", &values);
if(process_siglevel(values, &config->siglevel, file, linenum)) {
@@ -751,7 +751,7 @@ static int _parseconfig(const char *file, struct section_t *section,
}
pm_printf(ALPM_LOG_DEBUG, "config: new section '%s'
", name);
section->name = name;
- section->is_options = (strcmp(name, "options") == 0);
+ section->is_options = (strcasecmp(name, "options") == 0);
continue;
}

@@ -777,7 +777,7 @@ static int _parseconfig(const char *file, struct section_t *section,
goto cleanup;
}
/* Include is allowed in both options and repo sections */
- if(strcmp(key, "Include") == 0) {
+ if(strcasecmp(key, "Include") == 0) {
glob_t globbuf;
int globret;
size_t gindex;
@@ -824,7 +824,7 @@ static int _parseconfig(const char *file, struct section_t *section,
}
} else if(!parse_options && !section->is_options) {
/* ... or in a repo section */
- if(strcmp(key, "Server") == 0) {
+ if(strcasecmp(key, "Server") == 0) {
if(value == NULL) {
pm_printf(ALPM_LOG_ERROR, _("config file %s, line %d: directive '%s' needs a value
"),
file, linenum, key);
@@ -832,7 +832,7 @@ static int _parseconfig(const char *file, struct section_t *section,
goto cleanup;
}
section->servers = alpm_list_add(section->servers, strdup(value));
- } else if(strcmp(key, "SigLevel") == 0) {
+ } else if(strcasecmp(key, "SigLevel") == 0) {
alpm_list_t *values = NULL;
setrepeatingoption(value, "SigLevel", &values);
if(values) {
--
1.7.8.3


All times are GMT. The time now is 06:59 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.