Ejemplo n.º 1
0
/** Considers user-defined configuration. Loads and parses user-defined configuration
* '.config.json' present in user's home directory for 'plugin interface' and
* 'plugins' configuration properties and concats with iotkit-comm configuration properties.
*/
void concatUserDefinedConfigurations() {
    char *home, config_file[1024];

    home = getenv("HOME");
    if (home == NULL || strlen(home) == 0) {
        struct passwd *pw = getpwuid(getuid());
        home = pw->pw_dir;
    }

    strcpy(config_file, home);
    if (*(home + (strlen(home) - 1)) != '/') {
        strcat(config_file, "/");
    }

    strcat(config_file, USER_CONFIG_FILENAME);

    char *out;
    cJSON *json = NULL, *jitem;
    FILE *fp = fopen(config_file, "rb");

    if (fp == NULL) {
        fprintf(stderr,"Warning: Optional user config file not found. Continuing...\n");
    } else {
        fseek(fp, 0, SEEK_END);
        long size = ftell(fp);
        rewind(fp);

        // read the file
        char *buffer = (char *)malloc(size+1);
        if (buffer != NULL) {
            fread(buffer, 1, size, fp);
            // parse the file
            json = cJSON_Parse(buffer);
        }
        if (json == NULL || !json) {
            fprintf(stderr,"Error before: [%s]\n",cJSON_GetErrorPtr());
        } else {
            #if DEBUG
                out = cJSON_Print(json, 2);
                fprintf(stderr,"%s\n", out);
                free(out);
            #endif

            if (!isJsonObject(json)) {
                handleParseConfigError();
            }

            jitem = cJSON_GetObjectItem(json, "pluginInterfaceDirPaths");
            if (!isJsonString(jitem)) {
                handleParseConfigError();
            }

            int pathSize = strlen(g_configData.pluginInterfaceDir) + strlen(jitem->valuestring) + 2;
            char *pluginInterfaceDirPaths = (char *)malloc(sizeof(char) * pathSize);
            if (pluginInterfaceDirPaths != NULL) {
                strcpy(pluginInterfaceDirPaths, g_configData.pluginInterfaceDir);
                strcat(pluginInterfaceDirPaths, ":");
                strcat(pluginInterfaceDirPaths, jitem->valuestring);
                g_configData.pluginInterfaceDir = pluginInterfaceDirPaths;
            }
            #if DEBUG
                printf("pluginInterfaceDir = %s\n", g_configData.pluginInterfaceDir);
            #endif

            jitem = cJSON_GetObjectItem(json, "pluginDirPaths");
            if (!isJsonString(jitem)) {
                handleParseConfigError();
            }

            pathSize = strlen(g_configData.pluginDir) + strlen(jitem->valuestring) + 2;
            char *pluginDirPaths = (char *)malloc(sizeof(char) * pathSize);
            if (pluginDirPaths != NULL) {
                strcpy(pluginDirPaths, g_configData.pluginDir);
                strcat(pluginDirPaths, ":");
                strcat(pluginDirPaths, jitem->valuestring);
                g_configData.pluginDir = pluginDirPaths;
            }
            #if DEBUG
                printf("pluginDir = %s\n", g_configData.pluginDir);
            #endif

endParseConfig:
            cJSON_Delete(json);
        }

        free(buffer);
        fclose(fp); // close the file pointer
    }
}
Ejemplo n.º 2
0
/** Parses iotkit-comm configuration file
 * @param[in] config_file path to the configuration file
 */
bool parseConfigFile(char *config_file) {
    char *out;
    cJSON *json = NULL, *jitem, *child, *subjson;
    bool status = true;
    FILE *fp = fopen(config_file, "rb");

    if (fp == NULL) {
        fprintf(stderr,"Error can't open file %s\n", config_file);
        status = false;
    } else {
        fseek(fp, 0, SEEK_END);
        long size = ftell(fp);
        rewind(fp);

        // read the file
        char *buffer = (char *)malloc(size+1);
        if (buffer != NULL) {
            fread(buffer, 1, size, fp);
            // parse the file
            json = cJSON_Parse(buffer);
        }
        if (json == NULL || !json) {
            fprintf(stderr,"Error before: [%s]\n",cJSON_GetErrorPtr());
            status = false;
        } else {
            #if DEBUG
                out = cJSON_Print(json, 2);
                fprintf(stderr,"%s\n", out);
                free(out);
            #endif

            if (!isJsonObject(json)) {
                handleParseConfigError();
            }

            jitem = cJSON_GetObjectItem(json, "pluginInterfaceDir");
            if (!isJsonString(jitem)) {
                handleParseConfigError();
            }

            g_configData.pluginInterfaceDir = strdup(jitem->valuestring);
            #if DEBUG
                printf("pluginInterfaceDir = %s\n", g_configData.pluginInterfaceDir);
            #endif

            jitem = cJSON_GetObjectItem(json, "pluginDir");
            if (!isJsonString(jitem)) {
                handleParseConfigError();
            }

            g_configData.pluginDir = strdup(jitem->valuestring);
            #if DEBUG
                printf("pluginDir = %s\n", g_configData.pluginDir);
            #endif


            jitem = cJSON_GetObjectItem(json, "communication");
            if (!isJsonObject(json)) {
                handleParseConfigError();
            }

            subjson = cJSON_GetObjectItem(jitem, "pluginFileSuffixes");
            if (!isJsonObject(json)) {
                handleParseConfigError();
            }

            jitem = cJSON_GetObjectItem(subjson, "clientFileSuffix");
            if (!isJsonString(jitem)) {
                handleParseConfigError();
            }

            g_configData.clientFileSuffix = strdup(jitem->valuestring);
            #if DEBUG
                printf("clientFileSuffix = %s\n", g_configData.clientFileSuffix);
            #endif


            jitem = cJSON_GetObjectItem(subjson, "serverFileSuffix");
            if (!isJsonString(jitem)) {
                handleParseConfigError();
            }

            g_configData.serverFileSuffix = strdup(jitem->valuestring);
            #if DEBUG
                printf("serverFileSuffix = %s\n", g_configData.serverFileSuffix);
            #endif

endParseConfig:
            cJSON_Delete(json);
        }

        free(buffer);
        fclose(fp); // close the file pointer
    }

    concatUserDefinedConfigurations();

    return status;
}
Ejemplo n.º 3
0
/** Parses plugin interfaces. Loads the function names present in the corresponding plugin defined in the service specification JSON
* @param[in] inf_file file path for the plugin interface
* @return returns true upon successful parsing and false otherwise
*/
bool parsePluginInterfaces(char *inf_file) {
    char *out;
    int numentries = 0, i = 0;
    cJSON *json = NULL, *jitem, *child;
    bool status = true;
    FILE *fp = fopen(inf_file, "rb");

    if (fp == NULL) {
        fprintf(stderr,"Error can't open file %s\n", inf_file);
        status = false;
    } else {
        fseek(fp, 0, SEEK_END);
        long size = ftell(fp);
        rewind(fp);

        // read the file
        char *buffer = (char *)malloc(size+1);
        if (buffer != NULL) {
            fread(buffer, 1, size, fp);
            // parse the file
            json = cJSON_Parse(buffer);
        }
        if (json == NULL || !json) {
            fprintf(stderr,"Error before: [%s]\n",cJSON_GetErrorPtr());
            status = false;
        } else {
            #if DEBUG
                out = cJSON_Print(json, 2);
                printf("%s\n", out);
                free(out);
            #endif

            if (!isJsonObject(json)) {
                handleParseInterfacesError();
            }

            jitem = cJSON_GetObjectItem(json, "functions");
            if (!isJsonArray(jitem)) {
                handleParseInterfacesError();
            }

            child = jitem->child;
            /* How many entries in the array? */
            while (child && numentries++ < MAX_PROPERTIES) {
                child = child->next;
            }
            if (!numentries) {
                handleParseInterfacesError();
            }

            g_funcEntries = numentries;
            g_funcSignatures = (char **)malloc(numentries*sizeof(char*));
            if (!g_funcSignatures) {
                handleParseInterfacesError();
            }

            memset(g_funcSignatures,0,numentries*sizeof(char*));
            child = jitem->child;
            while (child) {
                if (!isJsonString(child)) {
                    handleParseInterfacesError();
                }

                g_funcSignatures[i] = strdup(child->valuestring);
                child = child->next;
                #if DEBUG
                    printf("g_funcSignature = %s\n", g_funcSignatures[i]);
                #endif
                i++;
            }

endParseInterfaces:
            cJSON_Delete(json);
        }

        free(buffer);
        fclose(fp); // close the file pointer
    }

    return status;
}
Ejemplo n.º 4
0
/** Parses configuration JSON
* @param[in] config file path to the JSON
* @return returns client query description object upon successful parsing and NULL otherwise
*/
void parseConfiguration(char *config_file_path) {
    char *out;
    int i = 0;
    cJSON *json, *jitem, *child1, *child2;
    bool status = true;

    FILE *fp = fopen(config_file_path, "rb");
    if (fp == NULL) {
        fprintf(stderr,"Error can't open file %s\n", config_file_path);
    }
    else {
        fseek(fp, 0, SEEK_END);
        long size = ftell(fp);
        rewind(fp);

        // read the file
        char *buffer = (char *)malloc(size+1);
        fread(buffer, 1, size, fp);

        // parse the file
        json = cJSON_Parse(buffer);
        if (!json) {
            fprintf(stderr,"Error before: [%s]\n",cJSON_GetErrorPtr());
        }
        else {
            #if DEBUG
                out = cJSON_Print(json, 2);
                printf("%s\n", out);
                free(out);
            #endif

            if (!isJsonObject(json)) {
                fprintf(stderr,"Invalid JSON format for %s file\n", config_file_path);
                return;
            }

            jitem = cJSON_GetObjectItem(json, "isSecure");
            if (!isJsonBooleanTrue(jitem)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", jitem->string);
                return;
            }
            configurations.isSecure = true;

            jitem = cJSON_GetObjectItem(json, "host");
            if (!isJsonString(jitem)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", jitem->string);
                return;
            }
            configurations.base_url = strdup(jitem->valuestring);

            jitem = cJSON_GetObjectItem(json, "store_path");
            if (isJsonString(jitem)) {
                configurations.store_path = strdup(jitem->valuestring);
            } else {
                configurations.store_path = "./"; // means, use current folder for the runtime store
            }

            jitem = cJSON_GetObjectItem(json, "apipath");
            if (!isJsonObject(jitem)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", jitem->string);
                return;
            }

            child1 = cJSON_GetObjectItem(jitem, "alert_management");
            if (!isJsonObject(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }

            child2 = cJSON_GetObjectItem(child1, "create_new_alert");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.create_new_alert = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_list_of_alerts");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_list_of_alerts = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_alert_information");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_alert_information = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "reset_alert");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.reset_alert = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "update_alert_status");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.update_alert_status = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "add_comment_to_alert");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.add_comment_to_alert = strdup(child2->valuestring);


            child1 = cJSON_GetObjectItem(jitem, "account_management");
            if (!isJsonObject(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }

            child2 = cJSON_GetObjectItem(child1, "create_an_account");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.create_an_account = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_account_information");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_account_information = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_account_activation_code");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_account_activation_code = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "renew_account_activation");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.renew_account_activation = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "update_an_account_name");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.update_an_account_name = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "delete_an_account_name");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.delete_an_account_name = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "add_an_user_to_account");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.add_an_user_to_account = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_user_associated_with_account");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_user_associated_with_account = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "update_user_associated_with_account");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.update_user_associated_with_account = strdup(child2->valuestring);

            child1 = cJSON_GetObjectItem(jitem, "advanced_data_inquiry");
            if (!isJsonString(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }
            configurations.advanced_data_inquiry = strdup(child1->valuestring);

            child1 = cJSON_GetObjectItem(jitem, "aggregated_report_interface");
            if (!isJsonString(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }
            configurations.aggregated_report_interface = strdup(child1->valuestring);

            child1 = cJSON_GetObjectItem(jitem, "authorization");
            if (!isJsonObject(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }

            child2 = cJSON_GetObjectItem(child1, "new_auth_token");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.new_auth_token = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "auth_token_info");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.auth_token_info = strdup(child2->valuestring);
            #if DEBUG
                printf("Read auth_token_info is %s\n", configurations.auth_token_info);
            #endif

            child2 = cJSON_GetObjectItem(child1, "me_info");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.me_info = strdup(child2->valuestring);
            #if DEBUG
                printf("Read me_info is %s\n", configurations.me_info);
            #endif


            child1 = cJSON_GetObjectItem(jitem, "cmpcatalog");
            if (!isJsonObject(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }

            child2 = cJSON_GetObjectItem(child1, "list_components");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.list_components = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_component_details");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_component_details = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "create_an_cmp_catalog");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.create_an_cmp_catalog = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "update_an_cmp_catalog");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.update_an_cmp_catalog = strdup(child2->valuestring);


            child1 = cJSON_GetObjectItem(jitem, "device_management");
            if (!isJsonObject(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }

            child2 = cJSON_GetObjectItem(child1, "list_all_devices");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.list_all_devices = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_device_info");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_device_info = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_my_device_info");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_my_device_info = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "create_a_device");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.create_a_device = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "update_a_device");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.update_a_device = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "activate_a_device");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.activate_a_device = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "activate_a_device2");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.activate_a_device2 = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "delete_a_device");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.delete_a_device = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "add_a_component");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.add_a_component = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "delete_a_component");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.delete_a_component = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "list_all_tags_for_devices");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.list_all_tags_for_devices = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "list_all_attributes_for_devices");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.list_all_attributes_for_devices = strdup(child2->valuestring);


            child1 = cJSON_GetObjectItem(jitem, "invitation_management");
            if (!isJsonObject(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }

            child2 = cJSON_GetObjectItem(child1, "get_list_of_invitation");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_list_of_invitation = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_invitation_list_send_to_specific_user");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_invitation_list_send_to_specific_user = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "create_invitation");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.create_invitation = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "delete_invitations");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.delete_invitations = strdup(child2->valuestring);


            child1 = cJSON_GetObjectItem(jitem, "data");
            if (!isJsonObject(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }

            child2 = cJSON_GetObjectItem(child1, "submit_data");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.submit_data = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "retrieve_data");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.retrieve_data = strdup(child2->valuestring);


            child1 = cJSON_GetObjectItem(jitem, "rule_management");
            if (!isJsonObject(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }

            child2 = cJSON_GetObjectItem(child1, "create_a_rule");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.create_a_rule = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "update_a_rule");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.update_a_rule = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_list_of_rules");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_list_of_rules = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_one_rule_info");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_one_rule_info = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "create_a_rule_as_draft");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.create_a_rule_as_draft = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "update_status_of_a_rule");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.update_status_of_a_rule = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "delete_a_draft_rule");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.delete_a_draft_rule = strdup(child2->valuestring);


            child1 = cJSON_GetObjectItem(jitem, "user_management");
            if (!isJsonObject(child1)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child1->string);
                return;
            }

            child2 = cJSON_GetObjectItem(child1, "create_a_user");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.create_a_user = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "get_user_information");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.get_user_information = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "update_user_attributes");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.update_user_attributes = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "accept_terms_and_conditions");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.accept_terms_and_conditions = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "delete_a_user");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.delete_a_user = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "request_change_password");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.request_change_password = strdup(child2->valuestring);

            child2 = cJSON_GetObjectItem(child1, "change_password");
            if (!isJsonString(child2)) {
                fprintf(stderr,"Invalid JSON format for json property %s\n", child2->string);
                return;
            }
            configurations.change_password = strdup(child2->valuestring);


            cJSON_Delete(json);
        }

        // free buffers
        fclose(fp);
        free(buffer);
    }

    return ;
}