#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include <curl/curl.h>
#include "config.h"
#include "kds_s2000w_config.h"
CURL* curl = NULL;
program_config* config = NULL;
-void _kds_s2000w_client_read_error_status(CURL* curl, response* resp)
+void _kds_s2000w_client_print_error_status(CURL* curl)
{
struct curl_header* header = NULL;
curl_easy_header(curl, X_STATUS_HEADER, 0, CURLH_HEADER, -1, &header);
if (header == NULL)
return;
- size_t size = strlen(header->value) + 1;
- resp->error_status = realloc(resp->error_status, size);
- memcpy(resp->error_status, header->value, size);
- resp->error_size = size;
+ fprintf(stderr, "%s\n", header->value);
}
void _kds_s2000w_client_stream_to_response(char* mem, response* resp, size_t* size)
response* resp = malloc(sizeof(response));
resp->data = malloc(sizeof(char));
- resp->error_status = malloc(sizeof(char));
resp->data[0] = '\0';
resp->size = 0;
resp->code = 0L;
- resp->error_size = 0;
return resp;
}
if (resp == NULL)
return;
- free(resp->error_status);
- resp->error_status = NULL;
free(resp->data);
resp->data = NULL;
free(resp);
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
- _kds_s2000w_client_read_error_status(curl, resp);
+ _kds_s2000w_client_print_error_status(curl);
_kds_s2000w_client_print_error_result(result);
fclose(stream);
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
- _kds_s2000w_client_read_error_status(curl, resp);
+ _kds_s2000w_client_print_error_status(curl);
_kds_s2000w_client_print_error_result(result);
fclose(stream);
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
- _kds_s2000w_client_read_error_status(curl, resp);
+ _kds_s2000w_client_print_error_status(curl);
_kds_s2000w_client_print_error_result(result);
fclose(stream);
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
- _kds_s2000w_client_read_error_status(curl, resp);
+ _kds_s2000w_client_print_error_status(curl);
_kds_s2000w_client_print_error_result(result);
fclose(stream);
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
- _kds_s2000w_client_read_error_status(curl, resp);
+ _kds_s2000w_client_print_error_status(curl);
_kds_s2000w_client_print_error_result(result);
fclose(stream);
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
- _kds_s2000w_client_read_error_status(curl, resp);
+ _kds_s2000w_client_print_error_status(curl);
_kds_s2000w_client_print_error_result(result);
fclose(stream);
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
- _kds_s2000w_client_read_error_status(curl, resp);
+ _kds_s2000w_client_print_error_status(curl);
_kds_s2000w_client_print_error_result(result);
fclose(stream);
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
- _kds_s2000w_client_read_error_status(curl, resp);
+ _kds_s2000w_client_print_error_status(curl);
_kds_s2000w_client_print_error_result(result);
fclose(stream);
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
- _kds_s2000w_client_read_error_status(curl, resp);
+ _kds_s2000w_client_print_error_status(curl);
_kds_s2000w_client_print_error_result(result);
curl_url_cleanup(url_handler);
response* resp = kds_s2000w_client_response_init();
kds_s2000w_client_delete_image(h->sessionid, h->current_scan_status->current_image_number, resp);
-
- if (resp->error_size > 0)
- fprintf(stderr, "%s\n", resp->error_status);
-
h->current_scan_status->available_images--;
kds_s2000w_client_response_free(resp);
response* resp = kds_s2000w_client_response_init();
kds_s2000w_client_get_image(h->sessionid, h->current_scan_status->current_image_number, resp);
-
- if (resp->error_size > 0)
- fprintf(stderr, "%s\n", resp->error_status);
-
h->image->size = resp->size;
h->image->data = malloc(sizeof(char) * resp->size);
memcpy(h->image->data, resp->data, resp->size);
response* resp = kds_s2000w_client_response_init();
kds_s2000w_client_status_session(h->sessionid, resp);
- if (resp->error_size > 0)
- fprintf(stderr, "%s\n", resp->error_status);
-
debug_printf(DEBUG, resp->data);
json_object* status_resp_obj = json_tokener_parse(resp->data);
response* resp = kds_s2000w_client_response_init();
kds_s2000w_client_open_session(resp);
- if (resp->error_size > 0)
- fprintf(stderr, "%s\n", resp->error_status);
if (resp->code != 200) {
kds_s2000w_client_response_free(resp);
resp->data = realloc(resp->data, resp->size);
resp->data = memcpy(resp->data, json_string, resp->size);
kds_s2000w_client_set_option(h->sessionid, resp);
- if (resp->error_size > 0)
- fprintf(stderr, "%s\n", resp->error_status);
kds_s2000w_client_response_free(resp);
resp = NULL;
response* resp = kds_s2000w_client_response_init();
int result = kds_s2000w_client_open_session(resp);
- if (resp->error_size > 0)
- fprintf(stderr, "%s\n", resp->error_status);
-
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(resp);
- if (resp->error_size > 0)
- fprintf(stderr, "%s\n", resp->error_status);
}
if (result != 0 || resp->code == 404) {
response* resp = kds_s2000w_client_response_init();
kds_s2000w_client_start_scan(h->sessionid, resp);
- if (resp->error_size > 0)
- fprintf(stderr, "%s\n", resp->error_status);
-
kds_s2000w_client_response_free(resp);
resp = NULL;
}
response* resp = kds_s2000w_client_response_init();
kds_s2000w_client_stop_scan(h->sessionid, resp);
- if (resp->error_size > 0)
- fprintf(stderr, "%s\n", resp->error_status);
kds_s2000w_client_response_free(resp);
resp = NULL;