mirror of https://github.com/vmware/tdnf.git
Merge pull request #495 from vmware/topic/okurth/set-string-macro
use SET_STRING() macro for config and repo settings
This commit is contained in:
commit
066bd38db2
|
@ -119,15 +119,15 @@ TDNFConfigFromCnfTree(PTDNF_CONF pConf, struct cnfnode *cn_top)
|
|||
else if (strcmp(cn->name, TDNF_CONF_KEY_REPOSDIR) == 0 ||
|
||||
strcmp(cn->name, TDNF_CONF_KEY_REPODIR) == 0)
|
||||
{
|
||||
pConf->pszRepoDir = strdup(cn->value);
|
||||
SET_STRING(pConf->pszRepoDir, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_CONF_KEY_CACHEDIR) == 0)
|
||||
{
|
||||
pConf->pszCacheDir = strdup(cn->value);
|
||||
SET_STRING(pConf->pszCacheDir, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_CONF_KEY_PERSISTDIR) == 0)
|
||||
{
|
||||
pConf->pszPersistDir = strdup(cn->value);
|
||||
SET_STRING(pConf->pszPersistDir, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_CONF_KEY_DISTROVERPKGS) == 0)
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ TDNFConfigFromCnfTree(PTDNF_CONF pConf, struct cnfnode *cn_top)
|
|||
}
|
||||
else if (strcmp(cn->name, TDNF_CONF_KEY_PROXY) == 0)
|
||||
{
|
||||
pConf->pszProxy = strdup(cn->value);
|
||||
SET_STRING(pConf->pszProxy, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_CONF_KEY_PROXY_USER) == 0)
|
||||
{
|
||||
|
@ -189,11 +189,11 @@ TDNFConfigFromCnfTree(PTDNF_CONF pConf, struct cnfnode *cn_top)
|
|||
}
|
||||
else if (strcmp(cn->name, TDNF_CONF_KEY_PLUGIN_CONF_PATH) == 0)
|
||||
{
|
||||
pConf->pszPluginConfPath = strdup(cn->value);
|
||||
SET_STRING(pConf->pszPluginConfPath, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_CONF_KEY_PLUGIN_PATH) == 0)
|
||||
{
|
||||
pConf->pszPluginPath = strdup(cn->value);
|
||||
SET_STRING(pConf->pszPluginPath, cn->value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -539,7 +539,7 @@ TDNFLoadReposFromFile(
|
|||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_NAME) == 0)
|
||||
{
|
||||
pRepo->pszName = strdup(cn->value);
|
||||
SET_STRING(pRepo->pszName, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_BASEURL) == 0)
|
||||
{
|
||||
|
@ -549,7 +549,7 @@ TDNFLoadReposFromFile(
|
|||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_METALINK) == 0)
|
||||
{
|
||||
pRepo->pszMetaLink = strdup(cn->value);
|
||||
SET_STRING(pRepo->pszMetaLink, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_MIRRORLIST) == 0)
|
||||
{
|
||||
|
@ -571,11 +571,11 @@ TDNFLoadReposFromFile(
|
|||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_USERNAME) == 0)
|
||||
{
|
||||
pRepo->pszUser = strdup(cn->value);
|
||||
SET_STRING(pRepo->pszUser, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_PASSWORD) == 0)
|
||||
{
|
||||
pRepo->pszPass = strdup(cn->value);
|
||||
SET_STRING(pRepo->pszPass, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_PRIORITY) == 0)
|
||||
{
|
||||
|
@ -603,15 +603,15 @@ TDNFLoadReposFromFile(
|
|||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_SSL_CA_CERT) == 0)
|
||||
{
|
||||
pRepo->pszSSLCaCert = strdup(cn->value);
|
||||
SET_STRING(pRepo->pszSSLCaCert, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_SSL_CLI_CERT) == 0)
|
||||
{
|
||||
pRepo->pszSSLClientCert = strdup(cn->value);
|
||||
SET_STRING(pRepo->pszSSLClientCert, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_SSL_CLI_KEY) == 0)
|
||||
{
|
||||
pRepo->pszSSLClientKey = strdup(cn->value);
|
||||
SET_STRING(pRepo->pszSSLClientKey, cn->value);
|
||||
}
|
||||
else if (strcmp(cn->name, TDNF_REPO_KEY_METADATA_EXPIRE) == 0)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#define STR_IS_TRUE(s) ((s) && (!strcmp((s), "1") || !strcasecmp((s), "true")))
|
||||
|
||||
#define SET_STRING(s, v) {if (s) free(s); if(v) s = strdup(v); else s = NULL;}
|
||||
|
||||
//Misc
|
||||
#define TDNF_RPM_EXT ".rpm"
|
||||
#define TDNF_NAME "tdnf"
|
||||
|
|
Loading…
Reference in New Issue