diff options
author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-09-04 18:04:11 +0800 |
---|---|---|
committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-09-04 18:04:11 +0800 |
commit | e93d85b3c1515950fbb1c8d39f12566df87f1387 (patch) | |
tree | 121157c7f5658e487a8fc12795c65eb38e7f2cb0 /rtclient.c | |
parent | 578cf4ca96749ba0875d1f15333dea5b43e36011 (diff) |
The search function
For now it only takes the query parameter, and the library user is responsible for building the query.
Diffstat (limited to 'rtclient.c')
-rw-r--r-- | rtclient.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -21,6 +21,7 @@ bool rtclient_init(const char *url) if (curl) { curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); + curl_easy_setopt(curl, CURLOPT_REFERER, url); #ifdef DEBUG curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); #endif // DEBUG @@ -62,16 +63,29 @@ void rtclient_login(const char *name, const char *password) #endif // DEBUG } -void rtclient_user(const char *name) +static inline void request(const char *url) { - static const char *user_path = "/REST/1.0/user/"; - char user_url[strlen(server_url) + strlen(user_path) + strlen(name) + 1]; - sprintf(user_url, "%s%s%s", server_url, user_path, name); - curl_easy_setopt(curl, CURLOPT_URL, user_url); + curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); curl_easy_perform(curl); } +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); +} + +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); +} + void rtclient_cleanup() { if (curl) { |