]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
change variables top of handler
authorBastian Dehn <hhaalo@arcor.de>
Sun, 21 Jan 2024 14:58:58 +0000 (15:58 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 21 Jan 2024 14:58:58 +0000 (15:58 +0100)
src/kds_s2000w_handler.c
src/kds_s2000w_handler.h
src/kds_s2000w_net.c

index bc6bafc0194abe7ef29722c0f0d7fdcea933ddb7..145762d69caab8e7751cd233b8e40cb8535a5d95 100644 (file)
@@ -29,6 +29,21 @@ size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata)
        return fullsize;
 }
 
+void* kds_s2000w_handler_get_option(int option)
+{
+       return NULL;
+}
+
+void kds_s2000w_handler_set_option(int option, void* value)
+{
+       return;
+}
+
+void kds_s2000w_handler_set_option_auto(int option)
+{
+       return;
+}
+
 device_state kds_s2000w_handler_open()
 {
        device_state returnState = NOTCONNECTED;
index 4f632399157b9730b9245ef66683b5da764bb72e..97532199010fa8050b940682dbe81fbb84af226f 100644 (file)
@@ -7,4 +7,7 @@ typedef enum {
 
 device_state kds_s2000w_handler_open();
 void kds_s2000w_handler_close();
+void* kds_s2000w_handler_get_option(int option);
+void kds_s2000w_handler_set_option(int option, void* value);
+void kds_s2000w_handler_set_option_auto(int option);
 #endif
\ No newline at end of file
index 2b9f84e4fc3fa3a15d1d97c4f6b2fa5a1bd03fb9..5ca2b59e9a950e2ef5fca6712b68f5dcef0b77e5 100644 (file)
@@ -4,11 +4,16 @@
 #include <sane/sane.h>
 #include "kds_s2000w_handler.h"
 
+SANE_Option_Descriptor* optionDescripor = NULL;
 SANE_Device* device_info = NULL;
+SANE_Parameters* parameter = NULL;
 
 SANE_Status _sane_kds_s2000w_net_init(SANE_Int* version_code, SANE_Auth_Callback authorize)
 {
        *version_code = SANE_VERSION_CODE(1, 0, 0);
+       optionDescripor = malloc(sizeof(SANE_Option_Descriptor));
+       device_info = malloc(sizeof(SANE_Device));
+       parameter = malloc(sizeof(SANE_Parameters));
        return SANE_STATUS_GOOD;
 }
 
@@ -16,8 +21,13 @@ void _sane_kds_s2000w_net_exit(void)
 {
        printf("kds_s2000w_net exit\n");
        kds_s2000w_handler_close();
+
        free(device_info);
        device_info = NULL;
+       free(optionDescripor);
+       optionDescripor = NULL;
+       free(parameter);
+       parameter = NULL;
 }
 
 SANE_Status _sane_kds_s2000w_net_get_devices(SANE_Device*** device_list,
@@ -26,7 +36,6 @@ SANE_Status _sane_kds_s2000w_net_get_devices(SANE_Device*** device_list,
        if (local_only)
                return SANE_STATUS_NO_MEM;
 
-       device_info = malloc(sizeof(SANE_Device));
        device_info->name = "kds_s2000w_net";
        device_info->vendor = "Kodak";
        device_info->model = "Kodak Alaris s2000w series";
@@ -62,7 +71,6 @@ void _sane_kds_s2000w_net_close(SANE_Handle handle)
 const SANE_Option_Descriptor* _sane_kds_s2000w_net_get_option_descriptor(
        SANE_Handle handle, SANE_Int option)
 {
-       SANE_Option_Descriptor* optionDescripor = malloc(sizeof(SANE_Option_Descriptor));
        optionDescripor->name = "test";
        optionDescripor->title = "test get option descriptor";
        optionDescripor->desc = "function get option descriptor test";
@@ -81,8 +89,15 @@ SANE_Status _sane_kds_s2000w_net_control_option(SANE_Handle handle,
 {
        printf("kds_s2000w_net control option\n");
 
-       int int_value = 0;
-       value = (void*) &int_value;
+       if (action == SANE_ACTION_GET_VALUE)
+               value = kds_s2000w_handler_get_option(option);
+
+       if (action == SANE_ACTION_SET_VALUE)
+               kds_s2000w_handler_set_option(option, value);
+
+       if (action == SANE_ACTION_SET_AUTO)
+               kds_s2000w_handler_set_option_auto(option);
+
        return SANE_STATUS_GOOD;
 }
 
@@ -90,7 +105,13 @@ SANE_Status _sane_kds_s2000w_net_get_parameters(SANE_Handle handle,
        SANE_Parameters* params)
 {
        printf("kds_s2000w_net get parameters\n");
+       parameter->format = SANE_FRAME_GRAY;
+       parameter->last_frame = SANE_TRUE;
+       parameter->bytes_per_line = 0;
+       parameter->lines = 0;
+       parameter->depth = 0;
 
+       params = parameter;
        return SANE_STATUS_GOOD;
 }