From fffe34e5eb3f160eda31d2640c894fc341e9ebd5 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Tue, 23 Oct 2007 04:23:50 +0000 Subject: [PATCH] Fix bogus error messages on web config --- src/conf.c | 12 +++++++----- src/main.c | 4 ++-- src/xml-rpc.c | 6 ++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/conf.c b/src/conf.c index abe53154..1d508ace 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1109,6 +1109,7 @@ int conf_set_string(char *section, char *key, char *value, int verify) { err=_conf_verify_element(section,key,value); if(err != CONF_E_SUCCESS) { util_mutex_unlock(l_conf); + DPRINTF(E_DBG,L_CONF,"Couldn't validate %s = %s\n",key,value); return err; } @@ -1276,18 +1277,19 @@ int conf_write(void) { * @param fp file we are writing the config file to * @param pll list we are dumping k/v pairs for * @param sublevel whether this is the root, or a subkey - * @returns TRUE on success, FALSE otherwise + * @returns CONF_E_SUCCESS on success, failure code otherwise */ int _conf_write(IOHANDLE hfile, LL *pll, int sublevel, char *parent) { LL_ITEM *pli; LL_ITEM *ppre, *pin; LL_ITEM *plitemp; int first; + int err; char keybuffer[256]; if(!pll) - return TRUE; + return CONF_E_SUCCESS; /* ?? */ /* write all the solo keys, first! */ pli = pll->itemlist.next; @@ -1330,9 +1332,9 @@ int _conf_write(IOHANDLE hfile, LL *pll, int sublevel, char *parent) { } io_printf(hfile,"\n"); - if(!_conf_write(hfile, pli->value.as_ll, 1, pli->key)) { + if((err =_conf_write(hfile, pli->value.as_ll, 1, pli->key)) != CONF_E_SUCCESS) { DPRINTF(E_DBG,L_CONF,"Error writing key %s:%s\n",pli->key); - return FALSE; + return err; } } break; @@ -1364,7 +1366,7 @@ int _conf_write(IOHANDLE hfile, LL *pll, int sublevel, char *parent) { } } - return TRUE; + return CONF_E_SUCCESS; } diff --git a/src/main.c b/src/main.c index b1ddeefa..05d3514b 100644 --- a/src/main.c +++ b/src/main.c @@ -427,7 +427,7 @@ int main(int argc, char *argv[]) { configfile="mt-daapd.conf"; } - if(conf_read(configfile) != CONF_E_SUCCESS) { + if(CONF_E_SUCCESS != conf_read(configfile)) { fprintf(stderr,"Error reading config file (%s)\n",configfile); exit(EXIT_FAILURE); } @@ -437,7 +437,7 @@ int main(int argc, char *argv[]) { if(convert_conf) { fprintf(stderr,"Converting config file...\n"); - if(!conf_write()) { + if(CONF_E_SUCCESS != conf_write()) { fprintf(stderr,"Error writing config file.\n"); exit(EXIT_FAILURE); } diff --git a/src/xml-rpc.c b/src/xml-rpc.c index 2b04785a..41061ac4 100644 --- a/src/xml-rpc.c +++ b/src/xml-rpc.c @@ -139,8 +139,10 @@ void xml_update_config(WS_CONNINFO *pwsc) { *ptmp++ = '\0'; /* this is stupidly inefficient */ + DPRINTF(E_DBG,L_XML,"Setting %s/%s to %s\n",duparg,ptmp,value); err = conf_set_string(duparg,ptmp,value,TRUE); if(err != CONF_E_SUCCESS) { + DPRINTF(E_DBG,L_XML,"Error setting %s/%s\n",duparg,ptmp); has_error = TRUE; if(!badparms) { badparms_len = (int)strlen(arg) + 1; @@ -170,6 +172,8 @@ void xml_update_config(WS_CONNINFO *pwsc) { return; } + handle = NULL; + /* now set! */ while((handle=ws_enum_var(pwsc,&arg,&value,handle)) != NULL) { /* arg will be section:value */ @@ -179,9 +183,11 @@ void xml_update_config(WS_CONNINFO *pwsc) { *ptmp++ = '\0'; /* this is stupidly inefficient */ + DPRINTF(E_DBG,L_XML,"Setting %s/%s to %s\n",duparg,ptmp,value); err = conf_set_string(duparg,ptmp,value,FALSE); if(err != CONF_E_SUCCESS) { /* shouldn't happen */ + DPRINTF(E_DBG,L_XML,"Error setting %s/%s\n",duparg,ptmp); xml_return_error(pwsc,500,arg); return; }