#include "kds_s2000w_debug.h"
#endif
-void _get_current_metadata(handler* h)
+handler* init_handler()
+{
+#ifndef NODEBUG
+ debug_printf(ALL, "init handler");
+#endif
+
+ handler* h = malloc(sizeof(handler));
+ h->current_scanner_config = NULL;
+ h->current_scan_status = malloc(sizeof(scanstatus));
+ h->current_metadata = malloc(sizeof(metadata));
+ h->read_info = malloc(sizeof(readinfo));
+ h->image = malloc(sizeof(imagedata));
+
+ h->sessionid = 0;
+ h->state = NOTCONNECTED;
+ h->current_scan_status->load_options = 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_scan_status->feeder = 1;
+ h->current_metadata->format = 1;
+ h->current_metadata->bytes_per_line = 0;
+ h->current_metadata->pixels_per_line = 0;
+ h->current_metadata->lines = 0;
+ h->current_metadata->depth = 8;
+ h->current_metadata->valid = 0;
+ 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;
+ h->image->size = 0;
+ h->image->data = NULL;
+
+ return h;
+}
+
+void free_handler(handler* h)
+{
+#ifndef NODEBUG
+ debug_printf(ALL, "free handler");
+#endif
+
+ json_object_put(h->current_scanner_config);
+ h->current_scanner_config = NULL;
+ free(h->current_scan_status);
+ h->current_scan_status = NULL;
+ free(h->current_metadata);
+ h->current_metadata = NULL;
+ free(h->read_info);
+ h->read_info = NULL;
+ free(h->image->data);
+ h->image->data = NULL;
+ free(h->image);
+ h->image = NULL;
+ free(h);
+ h = NULL;
+}
+
+void reset_handler(handler* h)
+{
+#ifndef NODEBUG
+ debug_printf(ALL, "reset handler");
+#endif
+
+ free(h->image->data);
+ h->image->data = NULL;
+
+ h->state = NOTCONNECTED;
+ h->current_scan_status->load_options = 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->format = 1;
+ h->current_metadata->bytes_per_line = 0;
+ h->current_metadata->pixels_per_line = 0;
+ h->current_metadata->lines = 0;
+ h->current_metadata->depth = 8;
+ h->current_metadata->valid = 0;
+ 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;
+}
+
+void kds_s2000w_handler_get_current_metadata(handler* h)
{
#ifndef NODEBUG
debug_printf(ALL, "get_current_metadata");
scanner_image = NULL;
}
-void _delete_current_image(handler* h)
+void kds_s2000w_handler_delete_current_image(handler* h)
{
#ifndef NODEBUG
debug_printf(ALL, "delete_current_image");
resp = NULL;
}
-void _download_current_image(handler* h)
+void kds_s2000w_handler_download_current_image(handler* h)
{
#ifndef NODEBUG
debug_printf(ALL, "download_current_image");
h->current_scan_status->downloaded_images++;
}
-void _get_current_scan_status(handler* h)
+void kds_s2000w_net_handler_get_current_scan_status(handler* h)
{
#ifndef NODEBUG
debug_printf(ALL, "get_current_scan_status");
resp = NULL;
}
-handler* init_handler()
-{
-#ifndef NODEBUG
- debug_printf(ALL, "init handler");
-#endif
-
- handler* h = malloc(sizeof(handler));
- h->current_scanner_config = NULL;
- h->current_scan_status = malloc(sizeof(scanstatus));
- h->current_metadata = malloc(sizeof(metadata));
- h->read_info = malloc(sizeof(readinfo));
- h->image = malloc(sizeof(imagedata));
-
- h->sessionid = 0;
- h->state = NOTCONNECTED;
- h->current_scan_status->load_options = 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_scan_status->feeder = 1;
- h->current_metadata->format = 1;
- h->current_metadata->bytes_per_line = 0;
- h->current_metadata->pixels_per_line = 0;
- h->current_metadata->lines = 0;
- h->current_metadata->depth = 8;
- h->current_metadata->valid = 0;
- 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;
- h->image->size = 0;
- h->image->data = NULL;
-
- return h;
-}
-
-void free_handler(handler* h)
-{
-#ifndef NODEBUG
- debug_printf(ALL, "free handler");
-#endif
-
- json_object_put(h->current_scanner_config);
- h->current_scanner_config = NULL;
- free(h->current_scan_status);
- h->current_scan_status = NULL;
- free(h->current_metadata);
- h->current_metadata = NULL;
- free(h->read_info);
- h->read_info = NULL;
- free(h->image->data);
- h->image->data = NULL;
- free(h->image);
- h->image = NULL;
- free(h);
- h = NULL;
-}
-
-void reset_handler(handler* h)
-{
-#ifndef NODEBUG
- debug_printf(ALL, "reset handler");
-#endif
-
- free(h->image->data);
- h->image->data = NULL;
-
- h->state = NOTCONNECTED;
- h->current_scan_status->load_options = 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->format = 1;
- h->current_metadata->bytes_per_line = 0;
- h->current_metadata->pixels_per_line = 0;
- h->current_metadata->lines = 0;
- h->current_metadata->depth = 8;
- h->current_metadata->valid = 0;
- 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;
-}
-
void kds_s2000w_handler_recreate_session(handler* h)
{
kds_s2000w_client_close_session(h->sessionid);
kds_s2000w_client_response_free(resp);
resp = NULL;
-}
-
-void kds_s2000w_handler_get_parameters(handler* h)
-{
-#ifndef NODEBUG
- debug_printf(ALL, "kds_s2000w_handler_get_parameters");
-#endif
-
- if (h->current_scan_status->complete_scanned
- && h->current_scan_status->available_images <= 0) {
- h->current_metadata->valid = 1;
- return;
- }
-
-#ifndef NODEBUG
- debug_printf(DEBUG, "get scanner status");
-#endif
- _get_current_scan_status(h);
-
-#ifndef NODEBUG
- debug_printf_int(DEBUG, "available images", h->current_scan_status->available_images);
-#endif
- if (h->current_scan_status->available_images > 0) {
-#ifndef NODEBUG
- debug_printf_int(DEBUG, "download image", h->current_scan_status->current_image_number);
-#endif
- _download_current_image(h);
-#ifndef NODEBUG
- debug_printf_int(DEBUG, "get metadata for image", h->current_scan_status->current_image_number);
-#endif
- _get_current_metadata(h);
-#ifndef NODEBUG
- debug_printf_int(DEBUG, "delete image", h->current_scan_status->current_image_number);
-#endif
- _delete_current_image(h);
- h->current_scan_status->current_image_number++;
- }
}
\ No newline at end of file