add: more debugging
add: more options for testing
This commit is contained in:
parent
0efbd2a22f
commit
e84d54f562
23 changed files with 130 additions and 63 deletions
src/models
|
@ -187,13 +187,17 @@ controller_free_list(controller_t **controllers)
|
|||
free(controllers);
|
||||
}
|
||||
|
||||
char*
|
||||
cJSON*
|
||||
controller_to_json(controller_t *controller)
|
||||
{
|
||||
cJSON *json;
|
||||
|
||||
char *cached = cache_get_json_controller(controller->id);
|
||||
if(cached)
|
||||
{
|
||||
return cached;
|
||||
json = cJSON_CreateRaw(cached);
|
||||
free(cached);
|
||||
return json;
|
||||
}
|
||||
|
||||
char uuid_str[UUID_STR_LEN];
|
||||
|
@ -201,7 +205,7 @@ controller_to_json(controller_t *controller)
|
|||
|
||||
LOGGER_DEBUG("JSONifying controller %s\n", uuid_str);
|
||||
|
||||
cJSON *json = cJSON_CreateObject();
|
||||
json = cJSON_CreateObject();
|
||||
|
||||
cJSON *json_name = cJSON_CreateString(controller->name);
|
||||
if(json_name == NULL)
|
||||
|
@ -255,17 +259,19 @@ controller_to_json(controller_t *controller)
|
|||
cJSON *json_relays = cJSON_CreateArray();
|
||||
for(int i = 0; relays[i] != NULL; ++i)
|
||||
{
|
||||
cJSON *json_relay = cJSON_CreateRaw(relay_to_json(relays[i]));
|
||||
cJSON *json_relay = relay_to_json(relays[i]);
|
||||
cJSON_AddItemToArray(json_relays, json_relay);
|
||||
}
|
||||
cJSON_AddItemToObject(json, "relays", json_relays);
|
||||
relay_free_list(relays);
|
||||
|
||||
char *result = cJSON_Print(json);
|
||||
char *json_str = cJSON_Print(json);
|
||||
cache_put_json_controller(controller->id, json_str);
|
||||
cJSON_Delete(json);
|
||||
|
||||
cache_put_json_controller(controller->id, result);
|
||||
return result;
|
||||
json = cJSON_CreateRaw(json_str);
|
||||
free(json_str);
|
||||
return json;
|
||||
}
|
||||
|
||||
controller_t*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue