From 3143fc2733736a52ed94e07827993fe32be90ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Sat, 7 Sep 2019 17:51:50 +0800 Subject: Unified the get requests for now --- rtclient.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rtclient.c b/rtclient.c index 7d75946..f109e8e 100644 --- a/rtclient.c +++ b/rtclient.c @@ -63,8 +63,10 @@ void rtclient_login(const char *name, const char *password) #endif // DEBUG } -static inline void request(const char *url) +static inline void request(const char *path, const char *suffix) { + char url[strlen(server_url) + strlen(path) + strlen(suffix) + 1]; + sprintf(url, "%s%s%s", server_url, path, suffix); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); curl_easy_perform(curl); @@ -72,18 +74,12 @@ static inline void request(const char *url) void rtclient_user(const char *name) { - static const char *path = "/REST/1.0/user/"; - char url[strlen(server_url) + strlen(path) + strlen(name) + 1]; - sprintf(url, "%s%s%s", server_url, path, name); - request(url); + request("/REST/1.0/user/", name); } void rtclient_search(const char *query) { - static const char *path = "/REST/1.0/search/ticket?query="; - char url[strlen(server_url) + strlen(path) + strlen(query) + 1]; - sprintf(url, "%s%s%s", server_url, path, query); - request(url); + request("/REST/1.0/search/ticket?query=", query); } void rtclient_cleanup() -- cgit v1.2.3