Esempio n. 1
0
bool print_config_schema_json(POOL_MEM &buffer)
{
   RES_TABLE *resources = my_config->m_resources;

   initialize_json();

   json_t *json = json_object();
   json_object_set_new(json, "format-version", json_integer(2));
   json_object_set_new(json, "component", json_string("bconsole"));
   json_object_set_new(json, "version", json_string(VERSION));

   /*
    * Resources
    */
   json_t *resource = json_object();
   json_object_set(json, "resource", resource);
   json_t *bconsole = json_object();
   json_object_set(resource, "bconsole", bconsole);

   for (int r = 0; resources[r].name; r++) {
      RES_TABLE resource = my_config->m_resources[r];
      json_object_set(bconsole, resource.name, json_items(resource.items));
   }

   pm_strcat(buffer, json_dumps(json, JSON_INDENT(2)));
   json_decref(json);

   return true;
}
OUTPUT_FORMATTER::OUTPUT_FORMATTER(SEND_HANDLER *send_func_arg, void *send_ctx_arg,
                                   int api_mode)
{
   initialize_json();

   send_func = send_func_arg;
   send_ctx = send_ctx_arg;
   api = api_mode;

   result_message_plain = new POOL_MEM(PM_MESSAGE);
#if HAVE_JANSSON
   result_array_json = json_array();
   result_stack_json = New(alist(10, false));
#endif
}