From 4b27c1a348d8de036dabd5525452f5b9ad08a32b Mon Sep 17 00:00:00 2001 From: nirav Date: Thu, 21 Mar 2019 16:34:24 +0530 Subject: Use g_threads, add builder ui for timeline --- src/timeline.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/timeline.c') diff --git a/src/timeline.c b/src/timeline.c index 753f9f1..be1a4c4 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -5,11 +5,28 @@ #include #include "timeline.h" #include "auth.h" +#include "config.h" #include "http.h" #include "string-util.h" #include "log.h" -static char *timeline_url = "/api/v1/timelines/home"; +#define TIMELINE_URL "https://%s/api/v1/timelines/home" + +static char *get_timeline_url(const char *domain) +{ + char *url; + size_t size; + + size = strlen(TIMELINE_URL) + strlen(domain) - 1; + url = malloc(size); + if (!url) { + err(1, NULL); + return NULL; + } + + sprintf(url, TIMELINE_URL, domain); + return url; +} struct timeline *timeline_from_json(const char *json_data) { @@ -77,19 +94,15 @@ struct timeline *get_timeline(const char *max_id, const char *since_id, const ch int limit) { char *url, *resp; - size_t size; struct timeline *t; - size = strlen(get_instance_url()) + strlen(timeline_url) + 1; - url = malloc(size); + url = get_timeline_url(config->instance_url); if (!url) { err(1, "get_timeline"); return NULL; } - strlcpy(url, get_instance_url(), size); - strlcat(url, timeline_url, size); - + printf("url: %s\n", url); resp = get_request(url); free(url); if (!resp) { -- cgit v1.2.3