h->profile = 0;
h->sessionid = 0;
- h->state = NOTCONNECTED;
h->scan_status->state = STOPPED;
h->scan_status->image_number = 1;
h->scan_status->available_images = 0;
h->scan_status->read_bytes = 0;
}
-void kds_s2000w_handler_open(const char* devicename, void** handle)
+uint8_t kds_s2000w_handler_open(const char* devicename, void** handle)
{
kds_s2000w_debug_printf(ALL, "kds_s2000w_handler_open");
if (strcmp(devicename, DEVICE_NAME) != 0)
- return;
+ return NOTCONNECTED;
handler_t* h = kds_s2000w_handler_init();
if (h == NULL)
- return;
+ return NOTCONNECTED;
*handle = h;
_kds_s2000w_handler_load_config(h);
/* status code 408 request timeout waking up repeat open session */
response_t* resp = NULL;
uint8_t result = 0;
+ uint8_t connection_state = NOTCONNECTED;
for (uint32_t i = 0; i < ATTEMPT; i++) {
kds_s2000w_client_response_free(resp);
resp = NULL;
result = kds_s2000w_client_open_session(resp);
if (result != 0) {
- h->state = NOTCONNECTED;
+ connection_state = NOTCONNECTED;
break;
}
if (resp->code == 200) {
- h->state = OPENED;
+ connection_state = OPENED;
break;
}
if (resp->code == 423) {
- h->state = BUSY;
+ connection_state = BUSY;
break;
}
kds_s2000w_client_response_free(resp);
resp = NULL;
kds_s2000w_client_free();
- return;
+ return connection_state;
}
h->scanner_config = json_tokener_parse(resp->data);
h->scanner_config = NULL;
kds_s2000w_client_response_free(resp);
resp = NULL;
+
+ return connection_state;
}
void kds_s2000w_handler_close(handler_t* h)
typedef struct {
uint8_t profile;
uint64_t sessionid;
- uint8_t state;
json_object* scanner_config;
scan_status_t* scan_status;
imagedata_t* image;
void kds_s2000w_handler_free(handler_t* h);
void kds_s2000w_handler_reset(handler_t* h);
-void kds_s2000w_handler_open(const char* devicename, void** handle);
+uint8_t kds_s2000w_handler_open(const char* devicename, void** handle);
void kds_s2000w_handler_close(handler_t* h);
void kds_s2000w_handler_recreate_session(handler_t* h);
if (strcmp(devicename, NAME) != 0)
return SANE_STATUS_INVAL;
- kds_s2000w_handler_open(devicename, handle);
+ uint8_t connection_state = kds_s2000w_handler_open(devicename, handle);
if (handle == NULL)
return SANE_STATUS_NO_MEM;
handler_t* h = (handler_t*) *handle;
- if (h->state == NOTCONNECTED) {
+ if (connection_state == NOTCONNECTED) {
kds_s2000w_handler_free(h);
h = NULL;
*handle = NULL;
return SANE_STATUS_IO_ERROR;
}
- if (h->state == BUSY) {
+ if (connection_state == BUSY) {
kds_s2000w_handler_free(h);
h = NULL;
*handle = NULL;
kds_s2000w_debug_printf(ALL, "sane_kds_s2000w_net_close");
const handler_t* h = (const handler_t*) handle;
- if (h == NULL || h->state != OPENED)
+ if (h == NULL)
return;
kds_s2000w_option_descriptors_free();