#include <string.h>
#include <stdlib.h>
-#include <unistd.h>
#include <curl/curl.h>
#include "kds_s2000w_client.h"
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code);
- if (response->code == 408) {
- sleep(1);
- CURLcode result = curl_easy_perform(curl);
- curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->code);
- }
-
curl_url_cleanup(url_handler);
url_handler = NULL;
curl_free(url);
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
+#include <unistd.h>
#include <curl/curl.h>
#include <json-c/json.h>
#include "kds_s2000w_handler.h"
resp = kds_s2000w_client_response_init();
int result = kds_s2000w_client_open_session("hhaalo", resp);
- if (result != 0 || resp->code == 404)
+ if (resp->code == 408) {
+ kds_s2000w_client_response_free(resp);
+ resp = NULL;
+ sleep(1);
+ resp = kds_s2000w_client_response_init();
+ result = kds_s2000w_client_open_session("hhaalo", resp);
+ }
+
+ if (result != 0 || resp->code == 404) {
+ kds_s2000w_client_response_free(resp);
+ resp = NULL;
return state;
+ }
- if (resp->code == 423)
+ if (resp->code == 423) {
+ kds_s2000w_client_response_free(resp);
+ resp = NULL;
state->state = BUSY;
+ }
- json_object* resObj = NULL;
if (resp->code == 200) {
resObj = json_tokener_parse(resp->data);
- json_object* valueObj = NULL;
- json_object_object_get_ex(resObj, "SessionId", &valueObj);
- state->sessionid = json_object_get_int64(valueObj);
- valueObj = NULL;
+ json_object* value_object = NULL;
+ json_object_object_get_ex(resObj, "SessionId", &value_object);
+ state->sessionid = json_object_get_int64(value_object);
state->state = OPENED;
+ value_object = NULL;
}
json_object_put(resObj);