*/
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include "ttrss_model.h"
h->id = id;
h->url = strdup(url);
h->title = strdup(title);
+ h->unread = -1;
h->excerpt = NULL;
h->content = NULL;
}
}
+struct feed *feed_new(int id, const char *url, const char *title)
+{
+ struct feed *f;
+
+ f = malloc(sizeof(struct feed));
+
+ f->id = id;
+ f->url = strdup(url);
+ f->title = strdup(title);
+ f->unread = -1;
+ f->headlines = NULL;
+
+ return f;
+}
+
void feed_free(struct feed *feed)
{
if (feed) {
free(feeds);
}
}
+
+struct feed *feeds_get_feed(struct feed **feeds, int id)
+{
+ struct feed **cur;
+
+ printf("%p\n", feeds);
+
+ if (feeds)
+ for (cur = feeds; *cur; cur++)
+ if ((*cur)->id == id) {
+ printf("match!\n");
+ return *cur;
+ }
+
+ return NULL;
+}
+
+struct headline *feeds_get_headline(struct feed **feeds, int id)
+{
+ struct headline *h;
+
+ if (!feeds)
+ return NULL;
+
+ while (*feeds) {
+ h = feed_get_headline(*feeds, id);
+
+ if (h)
+ return h;
+
+ feeds++;
+ }
+
+ return NULL;
+}