{"action":"created","comment":{"url":"https://api.github.com/repos/solettaproject/soletta/pulls/comments/33966780","id":33966780,"diff_hunk":"@@ -58,93 +61,198 @@ sol_conffile_entry_sort_cb(const void *data1, const void *data2)\n     return strcasecmp(e1->id, e2->id);\n }\n \n+static char**\n+str_split(const char* a_str, const char a_delim)\n+{\n+    char** result = 0;\n+    size_t count = 0;\n+    char* tmp_counter = 0;\n+    char* tmp = 0;\n+    char* last_comma = 0;\n+    char delim[2];\n+    delim[0] = a_delim;\n+    delim[1] = 0;\n+\n+    tmp = strdup(a_str);\n+    tmp_counter = tmp;\n+    while (*tmp_counter) {\n+        if (a_delim == *tmp_counter) {\n+            count++;\n+            last_comma = tmp_counter;\n+        }\n+        tmp_counter++;\n+    }\n+\n+    count += last_comma < (tmp + strlen(tmp) - 1); // space for last comma\n+    count += 1; // space for null\n+\n+    result = malloc(sizeof(char*) * count);\n+    if (result) {\n+        size_t idx  = 0;\n+        char* token = strtok(tmp, delim);\n+        while (token) {\n+            SOL_INT_CHECK(idx, >= count, NULL);\n+            *(result + idx++) = strdup(token);\n+            token = strtok(0, delim);\n+        }\n+        SOL_INT_CHECK(idx, == count, NULL);\n+        *(result + idx) = 0;\n+    }\n+\n+    free (tmp);\n+    return result;\n+}\n+\n+static char * dup_string_from_json_token(struct sol_json_token token)\n+{\n+    int len;\n+    char *dupped;\n+\n+    len = sol_json_token_get_size(&token) -2;\n+    dupped = malloc(len); // remove quotes.\n+    strncpy(dupped, token.start+1, len);\n+    dupped[len] = '\\0';\n+    return dupped;\n+}\n+\n+static void sol_conffile_set_entry_options(struct sol_conffile_entry *entry, struct sol_json_token options_object)\n+{\n+    char **options = NULL;\n+    int len, i;\n+    int numOptions = 0, curr_option = 0;\n+    struct sol_json_scanner scanner;\n+    struct sol_json_token token, key, value;\n+    enum sol_json_loop_reason reason;\n+\n+    sol_json_scanner_init_from_token(&scanner, &options_object);\n+    SOL_JSON_SCANNER_OBJECT_LOOP(&scanner, &token, &key, &value, reason) {\n+        numOptions += 1;\n+    }\n+\n+    options = malloc(sizeof(char*) * numOptions);\n+    sol_json_scanner_init_from_token(&scanner, &options_object);\n+    SOL_JSON_SCANNER_OBJECT_LOOP(&scanner, &token, &key, &value, reason) {\n+        int key_len, value_len;\n+        key_len = sol_json_token_get_size(&key) - 2; // remove quotes from the key.\n+        value_len = sol_json_token_get_size(&value); // do not remove quotes from the value. ( not everythign is a string here )\n+\n+        len = key_len + value_len + 1;\n+        options[curr_option] = malloc( len );\n+        sprintf(options[curr_option], \"%.*s=%.*s\\0\",\n+                 key_len, key.start + 1, value_len, value.start);\n+        curr_option += 1;\n+    }\n+    entry->options = (const char**) options;\n+}\n+\n static struct sol_ptr_vector\n-sol_conffile_keyfile_to_vector(GKeyFile *keyfile)\n+sol_conffile_keyfile_to_vector(struct sol_json_scanner scanner)\n {\n     struct sol_ptr_vector pv;\n-    gchar **groups, **groups_ptr;\n     struct sol_conffile_entry *entry = NULL;\n+    const char *node_group = \"nodetypes\";\n+    const char *node_name = \"name\";\n+    const char *node_type = \"type\";\n+    const char *node_options = \"options\";\n+\n+    struct sol_json_token token, key, value;\n+    struct sol_json_scanner obj_scanner, obj_scanner2;\n+    enum sol_json_loop_reason reason;\n+    bool found_nodes = false;\n \n     sol_ptr_vector_init(&pv);\n \n-    groups = g_key_file_get_groups(keyfile, NULL);\n-    for (groups_ptr = groups; *groups_ptr; groups_ptr++) {\n+    SOL_JSON_SCANNER_OBJECT_LOOP (&scanner, &token, &key, &value, reason) {\n+        if (sol_json_token_str_eq(&key, node_group, strlen(node_group))) {\n+            found_nodes = true;\n+            break;\n+        }\n+    }\n+\n+    if(!found_nodes)","path":"src/shared/sol-conffile.c","position":136,"original_position":136,"commit_id":"baa4946eb01931ddb646a9e04ab0382a7c9b6df4","original_commit_id":"baa4946eb01931ddb646a9e04ab0382a7c9b6df4","user":{"login":"lpereira","id":15001,"avatar_url":"https://avatars.githubusercontent.com/u/15001?v=3","gravatar_id":"","url":"https://api.github.com/users/lpereira","html_url":"https://github.com/lpereira","followers_url":"https://api.github.com/users/lpereira/followers","following_url":"https://api.github.com/users/lpereira/following{/other_user}","gists_url":"https://api.github.com/users/lpereira/gists{/gist_id}","starred_url":"https://api.github.com/users/lpereira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpereira/subscriptions","organizations_url":"https://api.github.com/users/lpereira/orgs","repos_url":"https://api.github.com/users/lpereira/repos","events_url":"https://api.github.com/users/lpereira/events{/privacy}","received_events_url":"https://api.github.com/users/lpereira/received_events","type":"User","site_admin":false},"body":"check-style.","created_at":"2015-07-06T18:33:05Z","updated_at":"2015-07-06T18:33:05Z","html_url":"https://github.com/solettaproject/soletta/pull/246#discussion_r33966780","pull_request_url":"https://api.github.com/repos/solettaproject/soletta/pulls/246","_links":{"self":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/comments/33966780"},"html":{"href":"https://github.com/solettaproject/soletta/pull/246#discussion_r33966780"},"pull_request":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/246"}}},"pull_request":{"url":"https://api.github.com/repos/solettaproject/soletta/pulls/246","id":39295563,"html_url":"https://github.com/solettaproject/soletta/pull/246","diff_url":"https://github.com/solettaproject/soletta/pull/246.diff","patch_url":"https://github.com/solettaproject/soletta/pull/246.patch","issue_url":"https://api.github.com/repos/solettaproject/soletta/issues/246","number":246,"state":"open","locked":false,"title":"Json config again","user":{"login":"tcanabrava","id":4027216,"avatar_url":"https://avatars.githubusercontent.com/u/4027216?v=3","gravatar_id":"","url":"https://api.github.com/users/tcanabrava","html_url":"https://github.com/tcanabrava","followers_url":"https://api.github.com/users/tcanabrava/followers","following_url":"https://api.github.com/users/tcanabrava/following{/other_user}","gists_url":"https://api.github.com/users/tcanabrava/gists{/gist_id}","starred_url":"https://api.github.com/users/tcanabrava/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcanabrava/subscriptions","organizations_url":"https://api.github.com/users/tcanabrava/orgs","repos_url":"https://api.github.com/users/tcanabrava/repos","events_url":"https://api.github.com/users/tcanabrava/events{/privacy}","received_events_url":"https://api.github.com/users/tcanabrava/received_events","type":"User","site_admin":false},"body":"Change the config files to json, removing the hard dependency on the glib.\r\ntested creating a json config file and using it in a small test fbp file.\r\n","created_at":"2015-07-06T18:20:24Z","updated_at":"2015-07-06T18:33:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"61da46b914bf9955ffdc230d5e06451cf4a088b5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/solettaproject/soletta/pulls/246/commits","review_comments_url":"https://api.github.com/repos/solettaproject/soletta/pulls/246/comments","review_comment_url":"https://api.github.com/repos/solettaproject/soletta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/solettaproject/soletta/issues/246/comments","statuses_url":"https://api.github.com/repos/solettaproject/soletta/statuses/baa4946eb01931ddb646a9e04ab0382a7c9b6df4","head":{"label":"tcanabrava:json_config_again","ref":"json_config_again","sha":"baa4946eb01931ddb646a9e04ab0382a7c9b6df4","user":{"login":"tcanabrava","id":4027216,"avatar_url":"https://avatars.githubusercontent.com/u/4027216?v=3","gravatar_id":"","url":"https://api.github.com/users/tcanabrava","html_url":"https://github.com/tcanabrava","followers_url":"https://api.github.com/users/tcanabrava/followers","following_url":"https://api.github.com/users/tcanabrava/following{/other_user}","gists_url":"https://api.github.com/users/tcanabrava/gists{/gist_id}","starred_url":"https://api.github.com/users/tcanabrava/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcanabrava/subscriptions","organizations_url":"https://api.github.com/users/tcanabrava/orgs","repos_url":"https://api.github.com/users/tcanabrava/repos","events_url":"https://api.github.com/users/tcanabrava/events{/privacy}","received_events_url":"https://api.github.com/users/tcanabrava/received_events","type":"User","site_admin":false},"repo":{"id":37602505,"name":"soletta","full_name":"tcanabrava/soletta","owner":{"login":"tcanabrava","id":4027216,"avatar_url":"https://avatars.githubusercontent.com/u/4027216?v=3","gravatar_id":"","url":"https://api.github.com/users/tcanabrava","html_url":"https://github.com/tcanabrava","followers_url":"https://api.github.com/users/tcanabrava/followers","following_url":"https://api.github.com/users/tcanabrava/following{/other_user}","gists_url":"https://api.github.com/users/tcanabrava/gists{/gist_id}","starred_url":"https://api.github.com/users/tcanabrava/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcanabrava/subscriptions","organizations_url":"https://api.github.com/users/tcanabrava/orgs","repos_url":"https://api.github.com/users/tcanabrava/repos","events_url":"https://api.github.com/users/tcanabrava/events{/privacy}","received_events_url":"https://api.github.com/users/tcanabrava/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tcanabrava/soletta","description":"Soletta Project is a framework for making IoT devices.  With Soletta Project's libraries developers can easily write software for devices that control actuators/sensors and communicate using standard technologies. It enables adding smartness even on the smallest edge devices.  Portable and scalable, it abstracts details of hardware and OS, enabling developers to reuse their code and knowledge on different targets.","fork":true,"url":"https://api.github.com/repos/tcanabrava/soletta","forks_url":"https://api.github.com/repos/tcanabrava/soletta/forks","keys_url":"https://api.github.com/repos/tcanabrava/soletta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tcanabrava/soletta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tcanabrava/soletta/teams","hooks_url":"https://api.github.com/repos/tcanabrava/soletta/hooks","issue_events_url":"https://api.github.com/repos/tcanabrava/soletta/issues/events{/number}","events_url":"https://api.github.com/repos/tcanabrava/soletta/events","assignees_url":"https://api.github.com/repos/tcanabrava/soletta/assignees{/user}","branches_url":"https://api.github.com/repos/tcanabrava/soletta/branches{/branch}","tags_url":"https://api.github.com/repos/tcanabrava/soletta/tags","blobs_url":"https://api.github.com/repos/tcanabrava/soletta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tcanabrava/soletta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tcanabrava/soletta/git/refs{/sha}","trees_url":"https://api.github.com/repos/tcanabrava/soletta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tcanabrava/soletta/statuses/{sha}","languages_url":"https://api.github.com/repos/tcanabrava/soletta/languages","stargazers_url":"https://api.github.com/repos/tcanabrava/soletta/stargazers","contributors_url":"https://api.github.com/repos/tcanabrava/soletta/contributors","subscribers_url":"https://api.github.com/repos/tcanabrava/soletta/subscribers","subscription_url":"https://api.github.com/repos/tcanabrava/soletta/subscription","commits_url":"https://api.github.com/repos/tcanabrava/soletta/commits{/sha}","git_commits_url":"https://api.github.com/repos/tcanabrava/soletta/git/commits{/sha}","comments_url":"https://api.github.com/repos/tcanabrava/soletta/comments{/number}","issue_comment_url":"https://api.github.com/repos/tcanabrava/soletta/issues/comments{/number}","contents_url":"https://api.github.com/repos/tcanabrava/soletta/contents/{+path}","compare_url":"https://api.github.com/repos/tcanabrava/soletta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tcanabrava/soletta/merges","archive_url":"https://api.github.com/repos/tcanabrava/soletta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tcanabrava/soletta/downloads","issues_url":"https://api.github.com/repos/tcanabrava/soletta/issues{/number}","pulls_url":"https://api.github.com/repos/tcanabrava/soletta/pulls{/number}","milestones_url":"https://api.github.com/repos/tcanabrava/soletta/milestones{/number}","notifications_url":"https://api.github.com/repos/tcanabrava/soletta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tcanabrava/soletta/labels{/name}","releases_url":"https://api.github.com/repos/tcanabrava/soletta/releases{/id}","created_at":"2015-06-17T15:11:28Z","updated_at":"2015-06-17T15:11:30Z","pushed_at":"2015-07-06T18:19:04Z","git_url":"git://github.com/tcanabrava/soletta.git","ssh_url":"git@github.com:tcanabrava/soletta.git","clone_url":"https://github.com/tcanabrava/soletta.git","svn_url":"https://github.com/tcanabrava/soletta","homepage":"","size":2177,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"solettaproject:master","ref":"master","sha":"bd5ac00acab24ff9476c90186205c0a12c6a9385","user":{"login":"solettaproject","id":12736897,"avatar_url":"https://avatars.githubusercontent.com/u/12736897?v=3","gravatar_id":"","url":"https://api.github.com/users/solettaproject","html_url":"https://github.com/solettaproject","followers_url":"https://api.github.com/users/solettaproject/followers","following_url":"https://api.github.com/users/solettaproject/following{/other_user}","gists_url":"https://api.github.com/users/solettaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/solettaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solettaproject/subscriptions","organizations_url":"https://api.github.com/users/solettaproject/orgs","repos_url":"https://api.github.com/users/solettaproject/repos","events_url":"https://api.github.com/users/solettaproject/events{/privacy}","received_events_url":"https://api.github.com/users/solettaproject/received_events","type":"Organization","site_admin":false},"repo":{"id":37087063,"name":"soletta","full_name":"solettaproject/soletta","owner":{"login":"solettaproject","id":12736897,"avatar_url":"https://avatars.githubusercontent.com/u/12736897?v=3","gravatar_id":"","url":"https://api.github.com/users/solettaproject","html_url":"https://github.com/solettaproject","followers_url":"https://api.github.com/users/solettaproject/followers","following_url":"https://api.github.com/users/solettaproject/following{/other_user}","gists_url":"https://api.github.com/users/solettaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/solettaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solettaproject/subscriptions","organizations_url":"https://api.github.com/users/solettaproject/orgs","repos_url":"https://api.github.com/users/solettaproject/repos","events_url":"https://api.github.com/users/solettaproject/events{/privacy}","received_events_url":"https://api.github.com/users/solettaproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/solettaproject/soletta","description":"Soletta Project is a framework for making IoT devices.  With Soletta Project's libraries developers can easily write software for devices that control actuators/sensors and communicate using standard technologies. It enables adding smartness even on the smallest edge devices.  ","fork":false,"url":"https://api.github.com/repos/solettaproject/soletta","forks_url":"https://api.github.com/repos/solettaproject/soletta/forks","keys_url":"https://api.github.com/repos/solettaproject/soletta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/solettaproject/soletta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/solettaproject/soletta/teams","hooks_url":"https://api.github.com/repos/solettaproject/soletta/hooks","issue_events_url":"https://api.github.com/repos/solettaproject/soletta/issues/events{/number}","events_url":"https://api.github.com/repos/solettaproject/soletta/events","assignees_url":"https://api.github.com/repos/solettaproject/soletta/assignees{/user}","branches_url":"https://api.github.com/repos/solettaproject/soletta/branches{/branch}","tags_url":"https://api.github.com/repos/solettaproject/soletta/tags","blobs_url":"https://api.github.com/repos/solettaproject/soletta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/solettaproject/soletta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/solettaproject/soletta/git/refs{/sha}","trees_url":"https://api.github.com/repos/solettaproject/soletta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/solettaproject/soletta/statuses/{sha}","languages_url":"https://api.github.com/repos/solettaproject/soletta/languages","stargazers_url":"https://api.github.com/repos/solettaproject/soletta/stargazers","contributors_url":"https://api.github.com/repos/solettaproject/soletta/contributors","subscribers_url":"https://api.github.com/repos/solettaproject/soletta/subscribers","subscription_url":"https://api.github.com/repos/solettaproject/soletta/subscription","commits_url":"https://api.github.com/repos/solettaproject/soletta/commits{/sha}","git_commits_url":"https://api.github.com/repos/solettaproject/soletta/git/commits{/sha}","comments_url":"https://api.github.com/repos/solettaproject/soletta/comments{/number}","issue_comment_url":"https://api.github.com/repos/solettaproject/soletta/issues/comments{/number}","contents_url":"https://api.github.com/repos/solettaproject/soletta/contents/{+path}","compare_url":"https://api.github.com/repos/solettaproject/soletta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/solettaproject/soletta/merges","archive_url":"https://api.github.com/repos/solettaproject/soletta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/solettaproject/soletta/downloads","issues_url":"https://api.github.com/repos/solettaproject/soletta/issues{/number}","pulls_url":"https://api.github.com/repos/solettaproject/soletta/pulls{/number}","milestones_url":"https://api.github.com/repos/solettaproject/soletta/milestones{/number}","notifications_url":"https://api.github.com/repos/solettaproject/soletta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/solettaproject/soletta/labels{/name}","releases_url":"https://api.github.com/repos/solettaproject/soletta/releases{/id}","created_at":"2015-06-08T19:13:18Z","updated_at":"2015-07-02T15:05:08Z","pushed_at":"2015-07-06T18:20:25Z","git_url":"git://github.com/solettaproject/soletta.git","ssh_url":"git@github.com:solettaproject/soletta.git","clone_url":"https://github.com/solettaproject/soletta.git","svn_url":"https://github.com/solettaproject/soletta","homepage":"","size":3664,"stargazers_count":35,"watchers_count":35,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":29,"mirror_url":null,"open_issues_count":24,"forks":29,"open_issues":24,"watchers":35,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/246"},"html":{"href":"https://github.com/solettaproject/soletta/pull/246"},"issue":{"href":"https://api.github.com/repos/solettaproject/soletta/issues/246"},"comments":{"href":"https://api.github.com/repos/solettaproject/soletta/issues/246/comments"},"review_comments":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/246/comments"},"review_comment":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/246/commits"},"statuses":{"href":"https://api.github.com/repos/solettaproject/soletta/statuses/baa4946eb01931ddb646a9e04ab0382a7c9b6df4"}}}}