]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
add debug info handler
authorBastian Dehn <hhaalo@arcor.de>
Fri, 16 Feb 2024 17:27:42 +0000 (18:27 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 16 Feb 2024 17:27:42 +0000 (18:27 +0100)
src/kds_s2000w_handler.c

index 464610e22a1179c9def73649fbd0a001ac4a485e..177806a92bc0cf50a920b0899c6b76b26850c8c4 100644 (file)
@@ -7,6 +7,7 @@
 #include "kds_s2000w_handler_opts.h"
 #include "kds_s2000w_client.h"
 #include "kds_s2000w_image_converter.h"
+#include "kds_s2000w_debug.h"
 
 response* resp = NULL;
 current_state* state = NULL;
@@ -27,6 +28,7 @@ scan_status current_scan_status;
 
 void _get_current_metadata()
 {
+       debug_printf(ALL, "get_current_metadata");
        resp = kds_s2000w_client_response_init();
        kds_s2000w_client_get_metadata(state->sessionid, current_scan_status.current_image_number, resp);
        if (resp->code != 200) {
@@ -92,7 +94,7 @@ void _get_current_metadata()
 
        current_scan_status.mdata.size = pnm_image.size;
        current_scan_status.mdata.image = pnm_image.data;
-       printf("size of pnm image: %i\n", pnm_image.size);
+       debug_printf_int(DEBUG, "size of pnm image", pnm_image.size);
 
        if (current_scan_status.mdata.depth == 1)
                current_scan_status.mdata.bytes_per_line = channels * floor((current_scan_status.mdata.pixels_per_line + 7) / 8);
@@ -110,6 +112,7 @@ void _get_current_metadata()
 
 void _delete_current_image()
 {
+       debug_printf(ALL, "delete_current_image");
        resp = kds_s2000w_client_response_init();
        kds_s2000w_client_delete_image(state->sessionid, current_scan_status.current_image_number, resp);
        kds_s2000w_client_response_free(resp);
@@ -119,6 +122,7 @@ void _delete_current_image()
 
 void _download_current_image()
 {
+       debug_printf(ALL, "download_current_image");
        if (image.size > 0) {
                free(image.data);
                image.data = NULL;
@@ -137,13 +141,13 @@ void _download_current_image()
 
 void _get_current_scan_status()
 {
+       debug_printf(ALL, "get_current_scan_status");
        json_object* status_resp_obj = NULL;
        json_object* status_obj = NULL;
        json_object* status_value_obj = NULL;
 
        resp = kds_s2000w_client_response_init();
        kds_s2000w_client_status_session(state->sessionid, resp);
-       printf("status response: %s\n", resp->data);
        status_resp_obj = json_tokener_parse(resp->data);
        status_obj = json_object_object_get(status_resp_obj, "Status");
        status_value_obj = json_object_object_get(status_obj, "NumImagesScanned");
@@ -163,6 +167,7 @@ void _get_current_scan_status()
 
 current_state* kds_s2000w_handler_open()
 {
+       debug_printf(ALL, "kds_s2000w_handler_open");
        init_gamma_table();
        image.size = 0;
        image.data = NULL;
@@ -220,6 +225,7 @@ current_state* kds_s2000w_handler_open()
 
 void kds_s2000w_handler_close()
 {
+       debug_printf(ALL, "kds_s2000w_handler_close");
        if (state == NULL || state->sessionid == 0)
                return;
 
@@ -243,6 +249,7 @@ current_state* kds_s2000w_handler_current_state()
 
 void kds_s2000w_handler_start_scan()
 {
+       debug_printf(ALL, "kds_s2000w_handler_start_scan");
        resp = kds_s2000w_client_response_init();
        kds_s2000w_client_start_scan(state->sessionid, resp);
        kds_s2000w_client_response_free(resp);
@@ -251,6 +258,7 @@ void kds_s2000w_handler_start_scan()
 
 void kds_s2000w_handler_stop_scan()
 {
+       debug_printf(ALL, "kds_s2000w_handler_stop_scan");
        resp = kds_s2000w_client_response_init();
        kds_s2000w_client_stop_scan(state->sessionid, resp);
        kds_s2000w_client_response_free(resp);
@@ -259,6 +267,7 @@ void kds_s2000w_handler_stop_scan()
 
 metadata kds_s2000w_handler_get_parameters()
 {
+       debug_printf(ALL, "kds_s2000w_handler_get_parameters");
        if (!current_scan_status.complete_scanned
                && current_scan_status.downloaded_images == current_scan_status.available_images) {
                _get_current_scan_status();
@@ -280,10 +289,6 @@ metadata kds_s2000w_handler_get_parameters()
        _download_current_image();
        _get_current_metadata();
        _delete_current_image();
-       printf("current image number: %i\n", current_scan_status.complete_scanned);
-       printf("current available images: %i\n", current_scan_status.available_images);
-       printf("current downloaded images: %i\n", current_scan_status.downloaded_images);
-       printf("complete scanned: %i\n", current_scan_status.complete_scanned);
        current_scan_status.current_image_number++;
 
        return current_scan_status.mdata;