mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-13 16:03:23 -05:00
make bulk update of config file work
This commit is contained in:
parent
f9a3b37583
commit
b48e99dd70
@ -1619,3 +1619,19 @@ WS_CONNINFO *ws_thread_enum_next(WSHANDLE wsh, WSTHREADENUM *vpp) {
|
||||
return pwsc;
|
||||
}
|
||||
|
||||
void *ws_enum_var(WS_CONNINFO *pwsc, char **key, char **value, void *last) {
|
||||
ARGLIST *plist = (ARGLIST *)last;
|
||||
|
||||
if(!plist) {
|
||||
plist = pwsc->request_vars.next;
|
||||
} else {
|
||||
plist = plist->next;
|
||||
}
|
||||
|
||||
if(plist) {
|
||||
if(key) *key = plist->key;
|
||||
if(value) *value = plist->value;
|
||||
}
|
||||
|
||||
return plist;
|
||||
}
|
||||
|
@ -32,8 +32,6 @@
|
||||
/*
|
||||
* Typedefs
|
||||
*/
|
||||
|
||||
|
||||
typedef void* WSHANDLE;
|
||||
typedef void* WSTHREADENUM;
|
||||
|
||||
@ -98,4 +96,7 @@ extern char *ws_getrequestheader(WS_CONNINFO *pwsc, char *header);
|
||||
extern int ws_testrequestheader(WS_CONNINFO *pwsc, char *header, char *value);
|
||||
extern void ws_emitheaders(WS_CONNINFO *pwsc);
|
||||
|
||||
extern void *ws_enum_var(WS_CONNINFO *pwsc, char **key, char **value, void *last);
|
||||
|
||||
|
||||
#endif /* _WEBSERVER_H_ */
|
||||
|
@ -104,6 +104,37 @@ XMLSTRUCT *xml_init(WS_CONNINFO *pwsc, int emit_header) {
|
||||
return pxml;
|
||||
}
|
||||
|
||||
/**
|
||||
* bulk set config
|
||||
*/
|
||||
void xml_update_config(WS_CONNINFO *pwsc) {
|
||||
char *arg, *value, *duparg;
|
||||
char *ptmp;
|
||||
void *handle;
|
||||
|
||||
int err;
|
||||
|
||||
handle = NULL;
|
||||
|
||||
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");
|
||||
return;
|
||||
}
|
||||
}
|
||||
free(duparg);
|
||||
}
|
||||
|
||||
xml_return_error(pwsc,200,"Success");
|
||||
}
|
||||
|
||||
/**
|
||||
* post settings back to the config file
|
||||
@ -273,6 +304,11 @@ void xml_handle(WS_CONNINFO *pwsc) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(strcasecmp(method,"updateconfig") == 0) {
|
||||
xml_update_config(pwsc);
|
||||
return;
|
||||
}
|
||||
|
||||
if(strcasecmp(method,"browse_path") == 0) {
|
||||
xml_browse_path(pwsc);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user