diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-07-15 06:09:50 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-15 07:46:57 +0200 |
commit | 35aca1f0582c43b5f6818c8fc00b924247e45881 (patch) | |
tree | 66d5e8f7954481863ba6d79db22a6df32f78af69 /src/rss_html_common.c | |
parent | 5b20475c7faf89bbabc9eab43c7e5622317a18fc (diff) |
Implement rss sync
Diffstat (limited to 'src/rss_html_common.c')
-rw-r--r-- | src/rss_html_common.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/rss_html_common.c b/src/rss_html_common.c index 56e1ccb..f1aa7ad 100644 --- a/src/rss_html_common.c +++ b/src/rss_html_common.c @@ -4,16 +4,6 @@ #include <string.h> #include <stdio.h> -static void create_json_string(struct json_string_s *json_result, const char *str, int len) { - json_result->string = str; - json_result->string_size = len; -} - -static void init_json_value_str(struct json_value_s *json_value, struct json_string_s *json_str) { - json_value->payload = json_str; - json_value->type = json_type_string; -} - int write_plugin_json_to_file(const char *dir, const char *filename, const char *url, const char *updated, const char *start_after, const char *start_after_url, const char *plugin_name) { struct json_string_s title_json_key; create_json_string(&title_json_key, "title", 5); @@ -144,7 +134,7 @@ int write_plugin_json_to_file(const char *dir, const char *filename, const char json_root_value.type = json_type_object; size_t json_body_size = 0; char *json_body_str = json_write_pretty(&json_root_value, " ", "\n", &json_body_size); - if(!json_body_str || json_body_size == 0) { + if(!json_body_str) { fprintf(stderr, "Failed to write json data to file %s/%s\n", dir, filename); return -1; } @@ -155,4 +145,24 @@ int write_plugin_json_to_file(const char *dir, const char *filename, const char int result = file_overwrite_in_dir(dir, filename, json_body_str, json_body_size); free(json_body_str); return result; -}
\ No newline at end of file +} + +struct json_value_s* json_object_get_field_by_name(struct json_object_s *json_obj, const char *name) { + struct json_object_element_s *obj_element = json_obj->start; + while(obj_element) { + if(strcmp(obj_element->name->string, name) == 0) + return obj_element->value; + obj_element = obj_element->next; + } + return NULL; +} + +void create_json_string(struct json_string_s *json_result, const char *str, int len) { + json_result->string = str; + json_result->string_size = len; +} + +void init_json_value_str(struct json_value_s *json_value, struct json_string_s *json_str) { + json_value->payload = json_str; + json_value->type = json_type_string; +} |