summaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'client.c')
-rw-r--r--client.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/client.c b/client.c
index 2213ebf..4e8c5df 100644
--- a/client.c
+++ b/client.c
@@ -1,7 +1,6 @@
#include <stdbool.h>
-#include <string.h>
#include <stdlib.h>
-#include <curl/curl.h>
+#include "login.h"
#include "icclient/client.h"
CURL *curl = NULL;
@@ -17,13 +16,29 @@ bool icclient_init(const char *url)
#ifdef DEBUG
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
#endif
- server_url = malloc(strlen(url) + 1);
+ size_t length = strlen(url);
+ bool prepend = !(bool)(url[length - 1] == '/');
+ server_url = malloc(length + (size_t)prepend + 1);
strcpy(server_url, url);
+ if (prepend)
+ strcat(server_url, "/");
}
return (bool)curl;
}
+void icclient_login(const char *username, const char *password
+ , const char *successpage, const char *nextpage
+ , const char *failpage)
+{
+ login(username, password, NULL, "Login", successpage, nextpage, failpage);
+}
+
+void icclient_logout()
+{
+ request(NULL, NULL, NULL, "%s", "logout");
+}
+
void icclient_cleanup()
{
if (curl) {