use config_get_string() instead of config_get_param()

config_get_string() is easier to use than config_get_param() because
it unpacks the config_param struct.
This commit is contained in:
Max Kellermann 2009-01-25 16:00:51 +01:00
parent bdfb6c239a
commit 80799fa84e
5 changed files with 24 additions and 31 deletions

View File

@ -630,10 +630,10 @@ input_curl_easy_init(struct input_stream *is)
struct input_curl *c = is->data;
CURLcode code;
CURLMcode mcode;
struct config_param *proxy_host;
struct config_param *proxy_port;
struct config_param *proxy_user;
struct config_param *proxy_pass;
const char *proxy_host;
const char *proxy_port;
const char *proxy_user;
const char *proxy_pass;
c->eof = false;
@ -661,27 +661,28 @@ input_curl_easy_init(struct input_stream *is)
curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, true);
curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error);
proxy_host = config_get_param(CONF_HTTP_PROXY_HOST);
proxy_port = config_get_param(CONF_HTTP_PROXY_PORT);
proxy_user = config_get_param(CONF_HTTP_PROXY_USER);
proxy_pass = config_get_param(CONF_HTTP_PROXY_PASSWORD);
proxy_host = config_get_string(CONF_HTTP_PROXY_HOST, NULL);
proxy_port = config_get_string(CONF_HTTP_PROXY_PORT, NULL);
if (proxy_host != NULL) {
char *proxy_host_str;
if (proxy_port == NULL) {
proxy_host_str = g_strdup(proxy_host->value);
proxy_host_str = g_strdup(proxy_host);
} else {
proxy_host_str =
g_strconcat(proxy_host->value, ":", proxy_port->value, NULL);
g_strconcat(proxy_host, ":", proxy_port, NULL);
}
curl_easy_setopt(c->easy, CURLOPT_PROXY, proxy_host_str);
g_free(proxy_host_str);
}
proxy_user = config_get_string(CONF_HTTP_PROXY_USER, NULL);
proxy_pass = config_get_string(CONF_HTTP_PROXY_PASSWORD, NULL);
if ((proxy_user != NULL) && (proxy_pass != NULL)) {
char *proxy_auth_str =
g_strconcat(proxy_user->value, ":", proxy_pass->value, NULL);
g_strconcat(proxy_user, ":", proxy_pass, NULL);
curl_easy_setopt(c->easy, CURLOPT_PROXYUSERPWD, proxy_auth_str);
g_free(proxy_auth_str);
}

View File

@ -66,13 +66,10 @@ const char *path_get_fs_charset(void)
void path_global_init(void)
{
struct config_param *fs_charset_param =
config_get_param(CONF_FS_CHARSET);
const char *charset = NULL;
if (fs_charset_param) {
charset = fs_charset_param->value;
} else {
charset = config_get_string(CONF_FS_CHARSET, NULL);
if (charset == NULL) {
const gchar **encodings;
g_get_filename_charsets(&encodings);

View File

@ -71,6 +71,7 @@ static size_t items_size(const struct tag *tag)
void tag_lib_init(void)
{
const char *value;
int quit = 0;
char *temp;
char *s;
@ -83,17 +84,16 @@ void tag_lib_init(void)
memset(ignoreTagItems, 0, TAG_NUM_OF_ITEM_TYPES);
ignoreTagItems[TAG_ITEM_COMMENT] = 1; /* ignore comments by default */
param = config_get_param(CONF_METADATA_TO_USE);
if (!param)
value = config_get_string(CONF_METADATA_TO_USE, NULL);
if (value == NULL)
return;
memset(ignoreTagItems, 1, TAG_NUM_OF_ITEM_TYPES);
if (0 == strcasecmp(param->value, "none"))
if (0 == strcasecmp(value, "none"))
return;
temp = c = s = g_strdup(param->value);
temp = c = s = g_strdup(value);
while (!quit) {
if (*s == ',' || *s == '\0') {
if (*s == '\0')

View File

@ -65,12 +65,11 @@ char *parsePath(char *path)
const char *home;
if (path[1] == '/' || path[1] == '\0') {
struct config_param *param = config_get_param(CONF_USER);
if (param && param->value) {
struct passwd *passwd = getpwnam(param->value);
const char *user = config_get_string(CONF_USER, NULL);
if (user != NULL) {
struct passwd *passwd = getpwnam(user);
if (!passwd) {
g_warning("no such user %s",
param->value);
g_warning("no such user %s", user);
return NULL;
}

View File

@ -35,17 +35,13 @@ static int zeroconfEnabled;
void initZeroconf(void)
{
const char *serviceName = SERVICE_NAME;
struct config_param *param;
zeroconfEnabled = config_get_bool(CONF_ZEROCONF_ENABLED,
DEFAULT_ZEROCONF_ENABLED);
if (!zeroconfEnabled)
return;
param = config_get_param(CONF_ZEROCONF_NAME);
if (param && *param->value != 0)
serviceName = param->value;
serviceName = config_get_string(CONF_ZEROCONF_NAME, NULL);
#ifdef HAVE_AVAHI
init_avahi(serviceName);