]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
init handler with default values
authorBastian Dehn <hhaalo@arcor.de>
Tue, 20 Feb 2024 18:54:07 +0000 (19:54 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 20 Feb 2024 18:54:07 +0000 (19:54 +0100)
src/kds_s2000w_handler.c

index 39f35a108c1b659d2d5d4e741c71fcea7a708eae..8f326beb12da5af8f047bb9791e51d305d22110f 100644 (file)
@@ -160,42 +160,40 @@ void kds_s2000w_handler_open(const char* devicename, void** handle)
        if (strcmp(devicename, "kds_s2000w_net") != 0)
                return;
 
-       handler* h = NULL;
-       h = malloc(sizeof(handler));
-       *handle = h;
+       handler* h = malloc(sizeof(handler));
+       h->current_scan_status = malloc(sizeof(scan_status));
+       h->current_metadata = malloc(sizeof(metadata));
+       h->read_info = malloc(sizeof(readinfo));
 
        h->sessionid = 0;
        h->state = NOTCONNECTED;
-       h->current_scan_status = malloc(sizeof(scan_status));
-       h->current_scan_status->current_image_number = 0;
+       h->current_scan_status->current_image_number = 1;
        h->current_scan_status->available_images = 0;
        h->current_scan_status->downloaded_images = 0;
        h->current_scan_status->complete_scanned = 0;
-       h->current_metadata = malloc(sizeof(metadata));
-       h->current_metadata->format = 0;
-       h->current_metadata->is_last = 0;
+       h->current_metadata->format = 1;
+       h->current_metadata->is_last = 1;
        h->current_metadata->size = 0;
        h->current_metadata->bytes_per_line = 0;
        h->current_metadata->pixels_per_line = 0;
        h->current_metadata->lines = 0;
-       h->current_metadata->depth = 0;
+       h->current_metadata->depth = 8;
        h->current_metadata->valid = 0;
        h->current_metadata->scanned_all_complete = 0;
        h->current_metadata->image = NULL;
-       h->read_info = malloc(sizeof(readinfo));
        h->read_info->scan_started = 0;
        h->read_info->cancel = 0;
        h->read_info->read_size = 0;
        h->read_info->readed_bytes_per_line = 0;
        h->read_info->readed_lines = 0;
 
+       *handle = h;
+
        init_gamma_table();
        image.size = 0;
        image.data = NULL;
        pnm_image.size = 0;
        pnm_image.data = NULL;
-       h->sessionid = 0;
-       h->state = NOTCONNECTED;
 
        resp = kds_s2000w_client_response_init();
        int result = kds_s2000w_client_open_session("hhaalo", resp);
@@ -234,11 +232,6 @@ void kds_s2000w_handler_open(const char* devicename, void** handle)
        kds_s2000w_client_response_free(resp);
        resp = NULL;
 
-       h->current_scan_status->current_image_number = 1;
-       h->current_scan_status->available_images = 0;
-       h->current_scan_status->downloaded_images = 0;
-       h->current_scan_status->complete_scanned = 0;
-       h->current_metadata->scanned_all_complete = 0;
        return;
 }