예제 #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;
}
예제 #2
0
파일: jsonconf.c 프로젝트: stm2/server
void json_config(cJSON *json) {
    cJSON *child;
    assert(json);
    if (json->type != cJSON_Object) {
        log_error("config is not a json object: %d", json->type);
        return;
    }
    reset_locales();
    for (child = json->child; child; child = child->next) {
        if (strcmp(child->string, "races") == 0) {
            json_races(child);
        }
        else if (strcmp(child->string, "items") == 0) {
            json_items(child);
        }
        else if (strcmp(child->string, "include") == 0) {
            json_include(child);
        }
        else if (strcmp(child->string, "ships") == 0) {
            json_ships(child);
        }
        else if (strcmp(child->string, "strings") == 0) {
            json_strings(child);
        }
        else if (strcmp(child->string, "directions") == 0) {
            json_directions(child);
        }
        else if (strcmp(child->string, "keywords") == 0) {
            json_keywords(child);
        }
        else if (strcmp(child->string, "settings") == 0) {
            json_settings(child);
        }
        else if (strcmp(child->string, "skills") == 0) {
            json_skills(child);
        }
        else if (strcmp(child->string, "buildings") == 0) {
            json_buildings(child);
        }
        else if (strcmp(child->string, "spells") == 0) {
            json_spells(child);
        }
        else if (strcmp(child->string, "prefixes") == 0) {
            json_prefixes(child);
        }
        else if (strcmp(child->string, "disabled") == 0) {
            json_disable_features(child);
        }
        else if (strcmp(child->string, "terrains") == 0) {
            json_terrains(child);
            init_terrains();
        }
        else {
            log_error("config contains unknown attribute %s", child->string);
        }
    }
}