- struct json_object *rp, *rq, *content, *jfeed, *j;
- int i, n;
- struct feed **feeds, *feed, **tmp;
-
- printf("ttrss_get_feeds\n");
-
- rq = create_op("getFeeds");
-
- rp = http_json_get(session_url, rq);
- json_object_put(rq);
-
- content = json_object_object_get(rp, "content");
-
- if (content) {
- n = json_object_array_length(content);
-
- feeds = NULL;
- for (i = 0; i < n; i++) {
- jfeed = json_object_array_get_idx(content, i);
-
- feed = malloc(sizeof(struct feed));
-
- j = json_object_object_get(jfeed, "title");
- feed->title = strdup(json_object_get_string(j));
-
- j = json_object_object_get(jfeed, "feed_url");
- feed->url = strdup(json_object_get_string(j));
-
- j = json_object_object_get(jfeed, "id");
- feed->id = json_object_get_int(j);
-
- j = json_object_object_get(jfeed, "unread");
- feed->unread = json_object_get_int(j);
-
- feed->headlines = NULL;
-
- tmp = feeds_add(feeds, feed);
- free(feeds);
- feeds = tmp;
- }
- } else {
- feeds = NULL;
- }
-
- json_object_put(rp);
-
- printf("ttrss_get_feeds ended\n");
-
- return feeds;