diff --git a/src/conf.c b/src/conf.c index fdbc3554..e9c11718 100644 --- a/src/conf.c +++ b/src/conf.c @@ -128,6 +128,11 @@ static CONF_ELEMENTS conf_elements[] = { { 0, 0, CONF_T_MULTICOMMA,"plugins","plugins" }, { 0, 0, CONF_T_INT,"daap","empty_strings" }, { 0, 0, CONF_T_INT,"daap","supports_browse" }, + { 0, 0, CONF_T_INT,"daap","supports_update" }, + { 0, 0, CONF_T_INT,"scanning","process_xml" }, + { 0, 0, CONF_T_INT,"scanning","ignore_appledouble" }, + { 0, 0, CONF_T_INT,"scanning","ignore_dotfiles" }, + { 0, 0, CONF_T_INT,"scanning","concat_compilations" }, { 0, 0, CONF_T_INT, NULL, NULL } }; @@ -541,6 +546,7 @@ int conf_read(char *file) { if(conf_main_file) { conf_close(); + free(conf_main_file); } conf_main_file = strdup(file); @@ -1129,10 +1135,7 @@ int conf_iswritable(void) { if(!conf_main_file) return FALSE; - if((fp = fopen(conf_main_file,"r+")) != NULL) { - fclose(fp); - retval = TRUE; - } + retval = !access(conf_main_file,W_OK); _conf_unlock(); return retval; diff --git a/src/xml-rpc.c b/src/xml-rpc.c index 7cf2c616..b653ef8d 100644 --- a/src/xml-rpc.c +++ b/src/xml-rpc.c @@ -110,12 +110,15 @@ XMLSTRUCT *xml_init(WS_CONNINFO *pwsc, int emit_header) { void xml_update_config(WS_CONNINFO *pwsc) { char *arg, *value, *duparg; char *ptmp; + char *badparms=NULL; void *handle; - + int has_error=0; + int badparms_len=0; int err; handle = NULL; + while((handle=ws_enum_var(pwsc,&arg,&value,handle)) != NULL) { /* arg will be section:value */ duparg = strdup(arg); @@ -123,10 +126,51 @@ void xml_update_config(WS_CONNINFO *pwsc) { if(ptmp) { *ptmp++ = '\0'; /* this is stupidly inefficient */ + + err = conf_set_string(duparg,ptmp,value,TRUE); + if(err != CONF_E_SUCCESS) { + has_error = TRUE; + if(!badparms) { + badparms_len = (int)strlen(arg) + 1; + badparms = (char*)malloc(badparms_len); + if(!badparms) { + DPRINTF(E_FATAL,L_MISC,"xml_update_config: malloc\n"); + } + strcpy(badparms,arg); + } else { + badparms_len += strlen(arg) + 1; + badparms = (char*)realloc(badparms,badparms_len); + if(!badparms) { + DPRINTF(E_FATAL,L_MISC,"xml_update_config: malloc\n"); + } + strcat(badparms,","); + strcat(badparms,arg); + } + } + } + free(duparg); + } + + if(has_error) { + DPRINTF(E_INF,L_MISC,"Bad parms; %s\n",badparms); + xml_return_error(pwsc,500,badparms); + free(badparms); + return; + } + + /* now set! */ + while((handle=ws_enum_var(pwsc,&arg,&value,handle)) != NULL) { + /* arg will be section:value */ + duparg = strdup(arg); + ptmp = strchr(duparg,':'); + if(ptmp) { + *ptmp++ = '\0'; + /* this is stupidly inefficient */ + err = conf_set_string(duparg,ptmp,value,FALSE); if(err != CONF_E_SUCCESS) { - free(duparg); - xml_return_error(pwsc,500,"Bad values"); + /* shouldn't happen */ + xml_return_error(pwsc,500,arg); return; } }