(no commit message)
[prss.git] / src / ttrss_model.c
index 2c80c9e..3cba736 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
 
 #include "ttrss_model.h"
@@ -103,7 +104,7 @@ struct headline *headline_new(int id, const char *url, const char *title)
        h->unread = -1;
        h->excerpt = NULL;
        h->content = NULL;
-       
+
        return h;
 }
 
@@ -161,3 +162,34 @@ void feeds_free(struct feed **feeds)
                free(feeds);
        }
 }
+
+struct feed *feeds_get_feed(struct feed **feeds, int id)
+{
+       struct feed **cur;
+
+       if (feeds)
+               for (cur = feeds; *cur; cur++)
+                       if ((*cur)->id == id)
+                               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;
+}