diff options
author | nirav <nirav@teisuu.com> | 2019-03-21 16:34:24 +0530 |
---|---|---|
committer | Dandelion <nirav@teisuu.com> | 2019-03-21 16:50:20 +0530 |
commit | 4b27c1a348d8de036dabd5525452f5b9ad08a32b (patch) | |
tree | f70c35351dc357d4297f985607fce9221ced96f0 /src/timeline.c | |
parent | c608bcc3dfab2abe7b66c10f8556086b2d45b3a3 (diff) | |
download | ap_client-4b27c1a348d8de036dabd5525452f5b9ad08a32b.tar.gz ap_client-4b27c1a348d8de036dabd5525452f5b9ad08a32b.zip |
Use g_threads, add builder ui for timeline
Diffstat (limited to 'src/timeline.c')
-rw-r--r-- | src/timeline.c | 27 |
1 files changed, 20 insertions, 7 deletions
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 <jansson.h> #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) { |