initial commit
This commit is contained in:
commit
9246e48f03
39 files changed
+34142
No files matched your search
@@ -0,0 +1,21 @@
|
||||
#include "settings_file.h"
|
||||
#include <file.h>
|
||||
#include "config.h"
|
||||
|
||||
void set_settings_file(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
char *filename = cm_get_parameter_as_string(config, "dnsmasq_config");
|
||||
if (!filename) {
|
||||
mg_http_reply(c, 500, HTTP_HEADERS, "{%m:%m}", MG_ESC("error"),
|
||||
MG_ESC("can't read config file"));
|
||||
return;
|
||||
}
|
||||
char *res = write_file(cm_get_parameter_as_string(config, "dnsmasq_config"), hm->body.buf);
|
||||
if (!res) {
|
||||
mg_http_reply(c, 500, HTTP_HEADERS, "{%m:%m}", MG_ESC("error"),
|
||||
MG_ESC("can't write file"));
|
||||
return;
|
||||
}
|
||||
mg_http_reply(c, 200, "Content-Type: text/plain\r\nAccess-Control-Allow-Origin: *\r\n", res);
|
||||
free(filename);
|
||||
free(res);
|
||||
}
|
||||
Reference in new issue
Block a user