X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fttrss_model.c;h=93c94093630e0f9f240b1d4cfc80defe8e7da07d;hb=ae4284cdb2445a16b5fd872af089b7d41d585c69;hp=c65a71072818418e0faf5bcbe69dae6009c46cc1;hpb=9e8f000157c9c09742b5cc55f768782e16db240c;p=prss.git diff --git a/src/ttrss_model.c b/src/ttrss_model.c index c65a710..93c9409 100644 --- a/src/ttrss_model.c +++ b/src/ttrss_model.c @@ -18,6 +18,7 @@ */ #include +#include #include #include "ttrss_model.h" @@ -100,6 +101,7 @@ struct headline *headline_new(int id, const char *url, const char *title) h->id = id; h->url = strdup(url); h->title = strdup(title); + h->unread = -1; h->excerpt = NULL; h->content = NULL; @@ -120,6 +122,21 @@ void headlines_free(struct headline **headlines) } } +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) { @@ -145,3 +162,38 @@ void feeds_free(struct feed **feeds) 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; +}