mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-15 08:45:02 -05:00
bad first pass at setting config stuff... doesn't work for multivalued config values
This commit is contained in:
parent
3b5e89708f
commit
66fa97e8d1
@ -38,8 +38,25 @@ struct tag_xmlstruct {
|
|||||||
|
|
||||||
/* Forwards */
|
/* Forwards */
|
||||||
void xml_get_stats(WS_CONNINFO *pwsc);
|
void xml_get_stats(WS_CONNINFO *pwsc);
|
||||||
|
void xml_set_config(WS_CONNINFO *pwsc);
|
||||||
|
void xml_return_error(WS_CONNINFO *pwsc, int errno, char *errstr);
|
||||||
char *xml_entity_encode(char *original);
|
char *xml_entity_encode(char *original);
|
||||||
|
|
||||||
|
void xml_return_error(WS_CONNINFO *pwsc, int errno, char *errstr) {
|
||||||
|
XMLSTRUCT *pxml;
|
||||||
|
|
||||||
|
pxml=xml_init(pwsc,TRUE);
|
||||||
|
xml_push(pxml,"results");
|
||||||
|
|
||||||
|
xml_output(pxml,"status","%d",errno);
|
||||||
|
xml_output(pxml,"statusstring","%s",errstr);
|
||||||
|
|
||||||
|
xml_pop(pxml); /* results */
|
||||||
|
xml_deinit(pxml);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create an xml response structure, a helper struct for
|
* create an xml response structure, a helper struct for
|
||||||
* building xml responses.
|
* building xml responses.
|
||||||
@ -75,6 +92,37 @@ XMLSTRUCT *xml_init(WS_CONNINFO *pwsc, int emit_header) {
|
|||||||
return pxml;
|
return pxml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* post settings back to the config file
|
||||||
|
*
|
||||||
|
* @param pwsc connection do dump results back to
|
||||||
|
*/
|
||||||
|
void xml_set_config(WS_CONNINFO *pwsc) {
|
||||||
|
char *section;
|
||||||
|
char *key;
|
||||||
|
char *value;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
section = ws_getvar(pwsc,"section");
|
||||||
|
key = ws_getvar(pwsc,"key");
|
||||||
|
value = ws_getvar(pwsc,"value");
|
||||||
|
|
||||||
|
if((!section) || (!key) || (!value)) {
|
||||||
|
xml_return_error(pwsc,500,"Missing section, key, or value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((err=conf_set_string(section,key,value) != CONF_E_SUCCESS)) {
|
||||||
|
/* should return text error from conf_ */
|
||||||
|
xml_return_error(pwsc,500,"conf_set_string: error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
xml_return_error(pwsc,200,"Success");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* push a new term on the stack
|
* push a new term on the stack
|
||||||
*
|
*
|
||||||
@ -184,6 +232,11 @@ void xml_handle(WS_CONNINFO *pwsc) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strcasecmp(method,"setconfig") == 0) {
|
||||||
|
xml_set_config(pwsc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ws_returnerror(pwsc,500,"Invalid method");
|
ws_returnerror(pwsc,500,"Invalid method");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -296,6 +349,12 @@ void xml_get_stats(WS_CONNINFO *pwsc) {
|
|||||||
xml_pop(pxml); /* stat */
|
xml_pop(pxml); /* stat */
|
||||||
|
|
||||||
xml_pop(pxml); /* statistics */
|
xml_pop(pxml); /* statistics */
|
||||||
|
|
||||||
|
|
||||||
|
xml_push(pxml,"misc");
|
||||||
|
xml_output(pxml,"writable_config","%d",conf_iswritable());
|
||||||
|
xml_pop(pxml); /* misc */
|
||||||
|
|
||||||
xml_pop(pxml); /* status */
|
xml_pop(pxml); /* status */
|
||||||
|
|
||||||
xml_deinit(pxml);
|
xml_deinit(pxml);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user