make bulk update of config file work

This commit is contained in:
Ron Pedde 2006-05-17 05:42:32 +00:00
parent f9a3b37583
commit b48e99dd70
3 changed files with 55 additions and 2 deletions

View File

@ -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;
}

View File

@ -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_ */

View File

@ -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;