]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
get options
authorBastian Dehn <hhaalo@arcor.de>
Sun, 21 Jan 2024 16:06:05 +0000 (17:06 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 21 Jan 2024 16:06:05 +0000 (17:06 +0100)
src/kds_s2000w_handler.c

index 55b89f13c0f93eee7dd5e1fa3f1da0e28195ad3d..3ffa7254bef9b9574df621ac6ef74a20a21c9937 100644 (file)
@@ -31,6 +31,34 @@ size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata)
 
 void* kds_s2000w_handler_get_option(int option)
 {
+       CURL *curl = curl_easy_init();
+       if(!curl)
+               return NULL;
+
+       response resp = {0};
+       CURLU* url_handler = curl_url();
+       curl_url_set(url_handler, CURLUPART_URL, "http://scanner.lan.hhaalo.de/api/session", 0);
+       char query[75];
+       sprintf(query, "SessionId=%li", sessionid);
+       curl_url_set(url_handler, CURLUPART_QUERY, query, CURLU_APPENDQUERY | CURLU_URLENCODE);
+       char* url = NULL;
+       curl_url_get(url_handler, CURLUPART_URL, &url, 0);
+       printf(url);
+
+       curl_easy_setopt(curl, CURLOPT_URL, url);
+       curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
+       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
+       curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*) &resp);
+       CURLcode result = curl_easy_perform(curl);
+       curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp.code);
+
+       printf("%s", resp.data);
+
+       curl_url_cleanup(url_handler);
+       url_handler = NULL;
+       curl_free(url);
+       url = NULL;
+       free(resp.data);
        return NULL;
 }
 
@@ -56,6 +84,7 @@ device_state kds_s2000w_handler_open()
        curl_url_set(url_handler, CURLUPART_URL, "http://scanner.lan.hhaalo.de/api/session", 0);
        char* url = NULL;
        curl_url_get(url_handler, CURLUPART_URL, &url, 0);
+
        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_POST, 1L);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"OCPUserName\":\"hhaalo\"}");