summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rtclient.c24
-rw-r--r--rtclient.h1
2 files changed, 20 insertions, 5 deletions
diff --git a/rtclient.c b/rtclient.c
index 30f2942..7d75946 100644
--- a/rtclient.c
+++ b/rtclient.c
@@ -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) {
diff --git a/rtclient.h b/rtclient.h
index 50a44c7..dd3cb61 100644
--- a/rtclient.h
+++ b/rtclient.h
@@ -8,6 +8,7 @@ extern "C" {
bool rtclient_init(const char *server_url);
void rtclient_login(const char *name, const char *password);
void rtclient_user(const char *name);
+ void rtclient_search(const char *query);
void rtclient_cleanup();
#ifdef __cplusplus