aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-25 16:00:51 +0100
committerMax Kellermann <max@duempel.org>2009-01-25 16:00:51 +0100
commit80799fa84eb4330083e4de20b87f97beea7d6ba7 (patch)
treec2a329d7fc7b08213ea83bdbaa169e95a78b6cd3
parentbdfb6c239af53d72f0808fc34e15d671036e8832 (diff)
downloadmpd-80799fa84eb4330083e4de20b87f97beea7d6ba7.tar.gz
mpd-80799fa84eb4330083e4de20b87f97beea7d6ba7.tar.xz
mpd-80799fa84eb4330083e4de20b87f97beea7d6ba7.zip
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.
-rw-r--r--src/input_curl.c23
-rw-r--r--src/path.c7
-rw-r--r--src/tag.c10
-rw-r--r--src/utils.c9
-rw-r--r--src/zeroconf.c6
5 files changed, 24 insertions, 31 deletions
diff --git a/src/input_curl.c b/src/input_curl.c
index 0ce648401..fd28c480e 100644
--- a/src/input_curl.c
+++ b/src/input_curl.c
@@ -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);
}
diff --git a/src/path.c b/src/path.c
index 3b9b1eff6..01480bee4 100644
--- a/src/path.c
+++ b/src/path.c
@@ -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);
diff --git a/src/tag.c b/src/tag.c
index 242ea7383..fa8a4e517 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -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')
diff --git a/src/utils.c b/src/utils.c
index a2f112e72..ce9a09f72 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -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;
}
diff --git a/src/zeroconf.c b/src/zeroconf.c
index dad9a8b7a..54bab6551 100644
--- a/src/zeroconf.c
+++ b/src/zeroconf.c
@@ -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);