#include "kds_s2000w_handler.h"
#include "kds_s2000w_debug.h"
-typedef struct {
- int scan_started;
- int cancel;
- int read_size;
- int readed_bytes_per_line;
- int readed_lines;
- metadata current_metadata;
-} readinfo;
-
readinfo read_info;
readinfo* get_read_info()
SANE_Parameters* params)
{
debug_printf(ALL, "sane_kds_s2000w_net_get_parameters");
- if (!read_info.scan_started)
+ handler* h = (handler*) handle;
+ if (!h->read_info.scan_started)
return SANE_STATUS_INVAL;
for (int i = 0; i < 10; i++) {
SANE_Status _sane_kds_s2000w_net_start(SANE_Handle handle)
{
debug_printf(ALL, "sane_kds_s2000w_net_start");
+ handler* h = (handler*) handle;
read_info.cancel = 0;
- read_info.scan_started = 1;
+ h->read_info.scan_started = 1;
kds_s2000w_handler_start_scan(handle);
return SANE_STATUS_GOOD;
}
SANE_Int max_length, SANE_Int* length)
{
debug_printf(ALL, "sane_kds_s2000w_net_read");
+ handler* h = (handler*) handle;
if (read_info.cancel) {
- read_info.scan_started = 0;
+ h->read_info.scan_started = 0;
*length = 0;
kds_s2000w_handler_stop_scan(handle);
sleep(1);
START_TEST(kds_s2000w_net_get_parameters_invalid_metdata)
{
- readinfo* read_info = get_read_info();
- read_info->scan_started = 1;
+ handler h;
+ h.read_info.scan_started = 1;
mdata.valid = 0;
SANE_Parameters* params = malloc(sizeof(SANE_Parameters));
- SANE_Status status = _sane_kds_s2000w_net_get_parameters(NULL, params);
+ SANE_Status status = _sane_kds_s2000w_net_get_parameters(&h, params);
ck_assert_int_eq(status, SANE_STATUS_UNSUPPORTED);
START_TEST(sane_kds_s2000w_net_read_cancel_test)
{
readinfo* read_info = get_read_info();
+ handler h;
+ h.read_info.scan_started = 1;
read_info->cancel = 1;
int* length = malloc(sizeof(int));
*length = 0;
- SANE_Status status = _sane_kds_s2000w_net_read(NULL, NULL, 0, length);
+ SANE_Status status = _sane_kds_s2000w_net_read(&h, NULL, 0, length);
ck_assert_int_eq(status, SANE_STATUS_CANCELLED);