(no commit message)
[prss.git] / src / ttrss.c
index 9228519..99b8bc4 100644 (file)
@@ -31,60 +31,7 @@ static char *session_url;
 static char *session_user;
 static char *session_pwd;
 
-static int list_length(void **list)
-{
-       int n;
-
-       if (!list)
-               return 0;
-
-       n = 0;
-       while (*list) {
-               n++;
-               list++;
-       }
-
-       return n;
-}
-
-static void **list_add(void **list, void *item)
-{
-       int n;
-       void **result;
-
-       n = list_length(list);
-
-       result = malloc((n + 1 + 1) * sizeof(void *));
-
-       if (list)
-               memcpy(result, list, n * sizeof(void *));
-
-       result[n] = item;
-       result[n + 1] = NULL;
-
-       return result;
-}
-
-struct headline **
-headlines_add(struct headline **list, struct headline *h)
-{
-       return (struct headline **)list_add((void **)list, (void *)h);
-}
-
-struct headline *feed_get_headline(struct feed *feed, int id)
-{
-       struct headline **headlines;
-
-       headlines = feed->headlines;
-       if (headlines)
-               while (*headlines) {
-                       if ((*headlines)->id == id)
-                               return *headlines;
-                       headlines++;
-               }
-
-       return NULL;
-}
+static struct feed **data;
 
 void ws_request_add_att_str(json_object *rq, const char *k, const char *str)
 {
@@ -366,7 +313,7 @@ struct feed **ttrss_get_feeds()
 
                        feed->headlines = NULL;
 
-                       tmp = (struct feed **)list_add((void **)feeds, feed);
+                       tmp = feeds_add(feeds, feed);
                        free(feeds);
                        feeds = tmp;
                }
@@ -405,3 +352,10 @@ void ttrss_set_article_unread(int id, int unread)
        json_object_put(rq);
        json_object_put(rp);
 }
+
+void ttrss_set_config(const char *url, const char *user, const char *pwd)
+{
+       feeds_free(data);
+       data = NULL;
+       ws_init(url, user, pwd);
+}