- 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;
-}
-
-void ws_request_add_att_str(json_object *rq, const char *k, const char *str)
-{
- json_object_object_add(rq, k, json_object_new_string(str));
-}
-
-void ws_request_add_att_int(json_object *rq, const char *k, int v)
-{
- json_object_object_add(rq, k, json_object_new_int(v));
-}
-
-struct json_object *ws_request_new(const char *op)
-{
- struct json_object *rq;
-
- rq = json_object_new_object();
-
- ws_request_add_att_str(rq, "op", op);
-
- if (session_id)
- ws_request_add_att_str(rq, "sid", session_id);
-
- return rq;
-}
-
-void ws_init(const char *url, const char *user, const char *pwd)
-{
- char *tmp;