- release:
- json_object_put(rp);
- }
- return h->content;
-}
-
-static struct headline **get_headlines(int feed_id)
-{
- struct json_object *rp, *rq, *content, *jheadline, *j;
- int i, n;
- struct headline **headlines, *h;
-
- printf("get_headlines %d\n", feed_id);
-
- rq = create_op("getHeadlines");
- json_object_object_add(rq, "feed_id", json_object_new_int(feed_id));
-
- 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);
- headlines = malloc((n+1)*sizeof(struct headline *));
- for (i = 0; i < n; i++) {
- jheadline = json_object_array_get_idx(content, i);
-
- h = malloc(sizeof(struct headline));
-
- j = json_object_object_get(jheadline, "id");
- h->id = json_object_get_int(j);
-
- j = json_object_object_get(jheadline, "title");
- h->title = strdup(json_object_get_string(j));
-
- j = json_object_object_get(jheadline, "link");
- h->url = strdup(json_object_get_string(j));
-
- h->excerpt = NULL;
- h->content = NULL;
-
- j = json_object_object_get(jheadline, "unread");
- h->unread = json_object_get_boolean(j);
-
- headlines[i] = h;