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; struct input_curl *c = is->data;
CURLcode code; CURLcode code;
CURLMcode mcode; CURLMcode mcode;
struct config_param *proxy_host; const char *proxy_host;
struct config_param *proxy_port; const char *proxy_port;
struct config_param *proxy_user; const char *proxy_user;
struct config_param *proxy_pass; const char *proxy_pass;
c->eof = false; 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_FAILONERROR, true);
curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error); curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error);
proxy_host = config_get_param(CONF_HTTP_PROXY_HOST); proxy_host = config_get_string(CONF_HTTP_PROXY_HOST, NULL);
proxy_port = config_get_param(CONF_HTTP_PROXY_PORT); proxy_port = config_get_string(CONF_HTTP_PROXY_PORT, NULL);
proxy_user = config_get_param(CONF_HTTP_PROXY_USER);
proxy_pass = config_get_param(CONF_HTTP_PROXY_PASSWORD);
if (proxy_host != NULL) { if (proxy_host != NULL) {
char *proxy_host_str; char *proxy_host_str;
if (proxy_port == NULL) { if (proxy_port == NULL) {
proxy_host_str = g_strdup(proxy_host->value); proxy_host_str = g_strdup(proxy_host);
} else { } else {
proxy_host_str = 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); curl_easy_setopt(c->easy, CURLOPT_PROXY, proxy_host_str);
g_free(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)) { if ((proxy_user != NULL) && (proxy_pass != NULL)) {
char *proxy_auth_str = 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); curl_easy_setopt(c->easy, CURLOPT_PROXYUSERPWD, proxy_auth_str);
g_free(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) void path_global_init(void)
{ {
struct config_param *fs_charset_param =
config_get_param(CONF_FS_CHARSET);
const char *charset = NULL; const char *charset = NULL;
if (fs_charset_param) { charset = config_get_string(CONF_FS_CHARSET, NULL);
charset = fs_charset_param->value; if (charset == NULL) {
} else {
const gchar **encodings; const gchar **encodings;
g_get_filename_charsets(&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) void tag_lib_init(void)
{ {
const char *value;
int quit = 0; int quit = 0;
char *temp; char *temp;
char *s; char *s;
@ -83,17 +84,16 @@ void tag_lib_init(void)
memset(ignoreTagItems, 0, TAG_NUM_OF_ITEM_TYPES); memset(ignoreTagItems, 0, TAG_NUM_OF_ITEM_TYPES);
ignoreTagItems[TAG_ITEM_COMMENT] = 1; /* ignore comments by default */ ignoreTagItems[TAG_ITEM_COMMENT] = 1; /* ignore comments by default */
param = config_get_param(CONF_METADATA_TO_USE); value = config_get_string(CONF_METADATA_TO_USE, NULL);
if (value == NULL)
if (!param)
return; return;
memset(ignoreTagItems, 1, TAG_NUM_OF_ITEM_TYPES); memset(ignoreTagItems, 1, TAG_NUM_OF_ITEM_TYPES);
if (0 == strcasecmp(param->value, "none")) if (0 == strcasecmp(value, "none"))
return; return;
temp = c = s = g_strdup(param->value); temp = c = s = g_strdup(value);
while (!quit) { while (!quit) {
if (*s == ',' || *s == '\0') { if (*s == ',' || *s == '\0') {
if (*s == '\0') if (*s == '\0')

View File

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

View File

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