summaryrefslogtreecommitdiff
path: root/registration.c
diff options
context:
space:
mode:
Diffstat (limited to 'registration.c')
-rw-r--r--registration.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/registration.c b/registration.c
index 5e0fe00..5f21f74 100644
--- a/registration.c
+++ b/registration.c
@@ -1,28 +1,21 @@
+#include <stdlib.h>
+#include <string.h>
+#include <icclient.h>
+
#ifdef DEBUG
#ifdef __ANDROID__
#include <android/log.h>
#else
#include <stdio.h>
#endif
-#ifdef __EMSCRIPTEN__
-#include <emscripten/fetch.h>
-#else
-#include <threads.h>
-#include <curl/curl.h>
#endif
-#include <stdlib.h>
-#include <string.h>
-#include <icclient/typedefs.h>
#ifdef __EMSCRIPTEN__
-
-static void clean_up(struct emscripten_fetch_t *fetch)
-{
- free(fetch->userData);
- emscripten_fetch_close(fetch);
-}
+#include <emscripten/fetch.h>
#else
+#include <threads.h>
+#include <curl/curl.h>
struct container {
CURL *curl;
@@ -65,24 +58,22 @@ static int async(void *arg)
}
#endif
-#endif
-
void sign_up(const char *brand, const char *certificate, void (*handler)(icclient_response *))
{
char *data = malloc(strlen(brand) + 1);
strcpy(data, brand);
#ifdef __EMSCRIPTEN__
+ (void)certificate;
emscripten_fetch_attr_t attr;
emscripten_fetch_attr_init(&attr);
attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY;
strcpy(attr.requestMethod, "POST");
+ attr.userData = data;
attr.requestData = data;
attr.requestDataSize = strlen(data);
- attr.userData = data;
attr.onsuccess = handler;
- attr.onerror = clean_up;
+ attr.onerror = icclient_free_response;
emscripten_fetch(&attr, "registration");
- (void)certificate;
#else
curl_global_init(CURL_GLOBAL_SSL);
CURL *curl = curl_easy_init();