1234567891011121314151617181920212223242526272829303132333435363738 |
- #include <stdio.h>
- #include <string.h>
- #include <json-c/json.h>
- #include <json-c/json_util.h>
- #include <json-c/json_object.h>
- #include <mosquitto.h>
- #include "common.h"
- #include "command.h"
- int main(int argc, char *argv[])
- {
- struct json_object *proot=NULL, *resp_obj = NULL;
- const char *resp_string=NULL;
-
- #if ENABLE_HTTP_COOKIE
- if (auth_user() ==false)
- return 0;
- #endif
- proot = json_object_from_file("./cookie/cookied.json");
- if(proot == NULL)
- {
- printf("Location:/index.html\n\n");
- }
- json_object_object_add(proot,"cookied", json_object_new_string(""));
- json_object_to_file_ext("./cookie/cookied.json", proot,JSON_C_TO_STRING_PRETTY);
- json_object_put(proot);
- printf("%s\n\n","Content-Type:application/json;charset=UTF-8");
- resp_obj = json_object_new_object();
- json_object_object_add(resp_obj, "state", json_object_new_string("success"));
- resp_string = json_object_to_json_string(resp_obj);
- printf("%s",resp_string);
- json_object_put(resp_obj);
-
- return 0;
- }
|