From 58912f68c2489bcee787599837447e0d64dfd61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 24 May 2017 21:03:56 +0200 Subject: New upstream version 1.0.27 --- backend/kodakaio.c | 56 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 25 deletions(-) (limited to 'backend/kodakaio.c') diff --git a/backend/kodakaio.c b/backend/kodakaio.c index 42b59a5..a9bec7b 100644 --- a/backend/kodakaio.c +++ b/backend/kodakaio.c @@ -1,7 +1,7 @@ /* * kodakaio.c - SANE library for Kodak ESP Aio scanners. * - * Copyright (C) 2011-2015 Paul Newall + * Copyright (C) 2011-2017 Paul Newall * * Based on the Magicolor sane backend: * Based on the epson2 sane backend: @@ -19,6 +19,7 @@ * 01/01/13 Now with adf, the scan can be padded to make up the full page length, * or the page can terminate at the end of the paper. This is a selectable option. * 25/11/12 Using avahi now for net autodiscovery. Use configure option --enable-avahi + * 1/5/17 patched to use local pointer for avahi callback */ /* @@ -31,13 +32,13 @@ convenient lines to paste export SANE_DEBUG_KODAKAIO=20 for ubuntu prior to 12.10 -./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-avahi --disable-latex BACKENDS="kodakaio test" +./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-avahi --without-api-spec BACKENDS="kodakaio test" for ubuntu 12.10 -./configure --prefix=/usr --libdir=/usr/lib/i386-linux-gnu --sysconfdir=/etc --localstatedir=/var --enable-avahi --disable-latex BACKENDS="kodakaio test" +./configure --prefix=/usr --libdir=/usr/lib/i386-linux-gnu --sysconfdir=/etc --localstatedir=/var --enable-avahi --without-api-spec BACKENDS="kodakaio test" -for ubuntu 14.10 -./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --sysconfdir=/etc --localstatedir=/var --enable-avahi --disable-latex BACKENDS="kodakaio test" +for ubuntu 14.10 up to at least 17.04 +./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --sysconfdir=/etc --localstatedir=/var --enable-avahi --without-api-spec BACKENDS="kodakaio test" If you want to use the test backend, for example with sane-troubleshoot, you should enable it in /etc/sane.d/dll.conf @@ -153,7 +154,7 @@ If you want to use the test backend, for example with sane-troubleshoot, you sho #define KODAKAIO_VERSION 02 #define KODAKAIO_REVISION 7 -#define KODAKAIO_BUILD 2 +#define KODAKAIO_BUILD 3 /* for usb (but also used for net though it's not required). */ #define MAX_BLOCK_SIZE 32768 @@ -207,6 +208,7 @@ normal levels. This system is a plan rather than a reality #include #include #include +#include #if WITH_AVAHI /* used for auto detecting network printers */ @@ -216,9 +218,6 @@ normal levels. This system is a plan rather than a reality #include #include #include - -static AvahiSimplePoll *simple_poll = NULL; /* global because called by several functions */ - #endif #include "../include/sane/saneopts.h" @@ -639,8 +638,10 @@ static SANE_Status attach_one_usb(SANE_String_Const devname); static SANE_Status attach_one_net(SANE_String_Const devname, unsigned int device); void kodakaio_com_str(unsigned char *buf, char *fmt_buf); int cmparray (unsigned char *array1, unsigned char *array2, size_t len); +#if WITH_AVAHI static struct KodakaioCap *get_device_from_identification (const char *ident, const char *vid, const char *pid); void ProcessAvahiDevice(const char *device_id, const char *vid, const char *pid, const char *ip_addr); +#endif /* Some utility functions */ @@ -731,7 +732,7 @@ That is probably if the scanner disconnected the network connection if (read == 0) *status = SANE_STATUS_IO_ERROR; - DBG(32, "net read %d bytes:%x,%x,%x,%x,%x,%x,%x,%x\n",read,buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]); + DBG(32, "net read %lu bytes:%x,%x,%x,%x,%x,%x,%x,%x\n",(unsigned long)read,buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]); return read; } @@ -881,7 +882,7 @@ In NET mode the timeout is in kodakaio_net_read time(&time_start); DBG(min(16,DBG_READ), "[%ld] %s: net req size = %ld ", (long) time_start, __func__, (long) buf_size); n = kodakaio_net_read(s, buf, buf_size, status); - DBG(min(16,DBG_READ), "returned %d\n", n); + DBG(min(16,DBG_READ), "returned %lu\n", (unsigned long)n); if (*status != SANE_STATUS_GOOD) { DBG(1, "%s: err returned from kodakaio_net_read, %s\n", __func__, sane_strstatus(*status)); } @@ -1109,7 +1110,7 @@ cmd_start_scan (SANE_Handle handle, size_t expect_total) return SANE_STATUS_IO_ERROR; } - DBG(20, "starting the scan, expected total bytes %d\n",expect_total); + DBG(20, "starting the scan, expected total bytes %lu\n",(unsigned long)expect_total); k_send(s, KodakEsp_Go, 8, &status); if (status != SANE_STATUS_GOOD) @@ -1365,25 +1366,25 @@ But it seems that the scanner takes care of that, and gives you the ack as a sep /* only compare 4 bytes because we sometimes get escSS02.. or escSS00.. is 4 the right number ? */ if (cmparray(Last8,KodakEsp_Ack,4) == 0) { - DBG(min(10,DBG_READ), "%s: found KodakEsp_Ack at %d bytes of %d\n", __func__, bytecount, *len); + DBG(min(10,DBG_READ), "%s: found KodakEsp_Ack at %lu bytes of %lu\n", __func__, (unsigned long) bytecount, (unsigned long) *len); s->ack = SANE_TRUE; *len = bytecount - 8; /* discard the Ack response */ s->bytes_unread -= *len; /* return a short block */ } else { /* a not full buffer is returned usb does this */ - DBG(min(10,DBG_READ), "%s: buffer not full, got %d bytes of %d\n", __func__, bytecount, *len); + DBG(min(10,DBG_READ), "%s: buffer not full, got %lu bytes of %lu\n", __func__, (unsigned long) bytecount, (unsigned long) *len); *len = bytecount; s->bytes_unread -= bytecount; } } else { - DBG(min(1,DBG_READ), "%s: tiny read, got %d bytes of %d\n", __func__, (int) bytecount, *len); + DBG(min(1,DBG_READ), "%s: tiny read, got %lu bytes of %lu\n", __func__, (unsigned long) bytecount, (unsigned long) *len); return SANE_STATUS_IO_ERROR; } - if (*len > s->params.bytes_per_line) { + lines = *len / s->params.bytes_per_line; + if (lines > 1) { /* store average colour as background. That's not the ideal method but it's easy to implement. What's it used for? */ - lines = *len / s->params.bytes_per_line; s->background[0] = 0; s->background[1] = 0; s->background[2] = 0; @@ -1934,17 +1935,18 @@ you don't know how many blocks there will be in advance because their size may b * SANE API implementation (high-level functions) */ +#if WITH_AVAHI static struct KodakaioCap * get_device_from_identification (const char *ident, const char *vid, const char *pid) { int n; SANE_Word pidnum, vidnum; - if(sscanf(vid, "%x", &vidnum) == EOF) { + if(sscanf(vid, "%x", (unsigned int *)&vidnum) == EOF) { DBG(5, "could not convert hex vid <%s>\n", vid); return NULL; } - if(sscanf(pid, "%x", &pidnum) == EOF) { + if(sscanf(pid, "%x", (unsigned int *)&pidnum) == EOF) { DBG(5, "could not convert hex pid <%s>\n", pid); return NULL; } @@ -1965,6 +1967,7 @@ get_device_from_identification (const char *ident, const char *vid, const char * } return NULL; } +#endif /* WITH_AVAHI */ /* * close_scanner() @@ -2359,9 +2362,9 @@ static void browse_callback( const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata) { + AvahiSimplePoll *simple_poll = userdata; - AvahiClient *c = userdata; - assert(b); + AvahiClient *c = avahi_service_browser_get_client (b); /* Called whenever a new services becomes available on the LAN or is removed from the LAN */ switch (event) { @@ -2395,7 +2398,8 @@ static void browse_callback( } } -static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { +static void client_callback(AvahiClient *c, AvahiClientState state, void * userdata) { + AvahiSimplePoll *simple_poll = userdata; assert(c); /* Called whenever the client or server state changes */ @@ -2412,6 +2416,7 @@ kodak_network_discovery(const char*host) /* If host = NULL do autodiscovery. If host != NULL try to verify the model First version only does autodiscovery */ { + AvahiSimplePoll *simple_poll; AvahiClient *client = NULL; AvahiServiceBrowser *sb = NULL; int error; @@ -2427,7 +2432,7 @@ First version only does autodiscovery */ } /* Allocate a new client */ - client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, NULL, &error); + client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, simple_poll, &error); /* Check wether creating the client object succeeded */ if (!client) { @@ -2436,14 +2441,15 @@ First version only does autodiscovery */ } /* Create the service browser */ - if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_scanner._tcp", NULL, 0, browse_callback, client))) { + if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_scanner._tcp", NULL, 0, browse_callback, simple_poll))) { DBG(min(1,DBG_AUTO), "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client))); goto fail; } /* Run the main loop */ for(i=1;i Date: Wed, 31 Jul 2019 16:59:49 +0200 Subject: New upstream version 1.0.28 --- backend/kodakaio.c | 150 ++++++++++++++++++++++++++--------------------------- 1 file changed, 75 insertions(+), 75 deletions(-) (limited to 'backend/kodakaio.c') diff --git a/backend/kodakaio.c b/backend/kodakaio.c index a9bec7b..c8cc9a7 100644 --- a/backend/kodakaio.c +++ b/backend/kodakaio.c @@ -3,7 +3,7 @@ * * Copyright (C) 2011-2017 Paul Newall * - * Based on the Magicolor sane backend: + * Based on the Magicolor sane backend: * Based on the epson2 sane backend: * Based on Kazuhiro Sasayama previous * work on epson.[ch] file from the SANE package. @@ -16,13 +16,13 @@ * Modified 30/12/14 to fix bug where network connection was broken after 30s of idle time. * The connection is now made in sane_start and ended in sane_cancel. - * 01/01/13 Now with adf, the scan can be padded to make up the full page length, + * 01/01/13 Now with adf, the scan can be padded to make up the full page length, * or the page can terminate at the end of the paper. This is a selectable option. * 25/11/12 Using avahi now for net autodiscovery. Use configure option --enable-avahi * 1/5/17 patched to use local pointer for avahi callback */ -/* +/* Packages to add to a clean ubuntu install libavahi-common-dev libusb-dev @@ -45,7 +45,7 @@ If you want to use the test backend, for example with sane-troubleshoot, you sho */ /* SANE-FLOW-DIAGRAM Kodakaio commands in [] brackets - + - sane_init() : initialize backend, attach scanners(devicename,0) . - sane_get_devices() : query list of scanner-devices . - sane_open() : open a particular scanner-device and attach_scanner(devicename,&dev) @@ -58,7 +58,7 @@ If you want to use the test backend, for example with sane-troubleshoot, you sho . . - sane_get_parameters() : returns actual scan-parameters . . - sane_read() : read image-data (from pipe) . . - sane_cancel() : cancel operation, kill reader_process [(F), U] - + . - sane_close() : close opened scanner-device, do_cancel, free buffer and handle - sane_exit() : terminate use of backend, free devicename and device-struture */ @@ -169,7 +169,7 @@ In terminal use: export SANE_DEBUG_KODAKAIO=40 to set the level to 40 or whateve level you want. Then you can scan with scanimage or simple-scan from terminal and see debug info -use these defines to promote certain functions that you are interested in +use these defines to promote certain functions that you are interested in define low values to make detail of a section appear when DBG level is low define a high value eg 99 to get normal behaviour. */ #define DBG_READ 99 @@ -248,7 +248,7 @@ FILE *RawScan = NULL; char RawScanPath[] = ""; /* empty path means no raw scan file is made */ /* - * Devices supported by this backend + * Devices supported by this backend */ /* kodak command strings */ @@ -286,7 +286,7 @@ The following are not used but may be in future commandtype, max depth, pointer to depth list */ -/* list of cap data the first scanner is the default +/* list of cap data the first scanner is the default */ /* KODAK AIO DEFAULT, */ { @@ -295,7 +295,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(100), 0}, {0, SANE_FIX(100), 0} /* ADF x/y ranges (TODO!) */ }, /* KODAK ESP 5100, */ @@ -305,7 +305,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP 5300, */ @@ -315,7 +315,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP 5500, */ @@ -325,7 +325,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP 5000, */ @@ -335,7 +335,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP 3300, */ @@ -345,7 +345,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP5, */ @@ -355,7 +355,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP7, */ @@ -365,7 +365,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP9, */ @@ -375,7 +375,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP5210 or 5250, */ @@ -385,7 +385,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP3200 , */ @@ -395,7 +395,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP4100 , */ @@ -405,7 +405,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP6100 , */ @@ -415,7 +415,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_TRUE, SANE_FALSE, /* ADF, duplex */ + SANE_TRUE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP7200 , */ @@ -425,7 +425,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP C110 , */ @@ -435,7 +435,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP C115 , */ @@ -445,7 +445,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP 2150 , */ @@ -455,7 +455,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_TRUE, SANE_FALSE, /* ADF, duplex */ + SANE_TRUE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP C310 , */ @@ -465,7 +465,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP C315 , */ @@ -475,7 +475,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_FALSE, SANE_FALSE, /* ADF, duplex */ + SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* ADVENT AW10, */ @@ -525,7 +525,7 @@ commandtype, max depth, pointer to depth list 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_TRUE, SANE_FALSE, /* ADF, duplex */ + SANE_TRUE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP2170 , */ @@ -535,7 +535,7 @@ commandtype, max depth, pointer to depth list 1200, {75, 1200, 0}, kodakaio_resolution_list, 5, /* 1200 dpi optical, {from, to, 0} 5 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ - SANE_TRUE, SANE_FALSE, /* ADF, duplex */ + SANE_TRUE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK HERO 9.1, */ @@ -748,7 +748,7 @@ sanei_kodakaio_net_write_raw(struct KodakAio_Scanner *s, SANE_Status *status) { DBG(32, "net write:%x,%x,%x,%x,%x,%x,%x,%x\n",buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]); - + sanei_tcp_write(s->fd, buf, buf_size); /* TODO: Check whether sending failed... */ @@ -863,8 +863,8 @@ static ssize_t k_recv(KodakAio_Scanner * s, void *buf, ssize_t buf_size, SANE_Status * status) { -/* requests and receives data this function makes the split between USB and NET -this function called by a number of others +/* requests and receives data this function makes the split between USB and NET +this function called by a number of others In USB mode, this function will wait until data is available for a maximum of SCANNER_READ_TIMEOUT seconds. In NET mode the timeout is in kodakaio_net_read @@ -878,7 +878,7 @@ In NET mode the timeout is in kodakaio_net_read usb_delay.tv_nsec = 300000000; /* 0.3 sec */ if (s->hw->connection == SANE_KODAKAIO_NET) { - + time(&time_start); DBG(min(16,DBG_READ), "[%ld] %s: net req size = %ld ", (long) time_start, __func__, (long) buf_size); n = kodakaio_net_read(s, buf, buf_size, status); @@ -1015,7 +1015,7 @@ and returns appropriate status s->adf_loaded = SANE_TRUE; DBG(5, "%s: News - docs in ADF\n", __func__); } - else if (rxbuf[4] != + else if (rxbuf[4] != 0x01 && s->adf_loaded == SANE_TRUE) { s->adf_loaded = SANE_FALSE; DBG(5, "%s: News - ADF is empty\n", __func__); @@ -1031,7 +1031,7 @@ and returns appropriate status } /* unused function -static ssize_t +static ssize_t kodakaio_rxflush(KodakAio_Scanner *s) Tries to get 64 byte reply @@ -1052,7 +1052,7 @@ and returns number of bytes read */ /* - * high-level communication commands + * high-level communication commands */ static SANE_Status @@ -1064,7 +1064,7 @@ k_hello (KodakAio_Scanner * s) DBG(5, "%s\n", __func__); -/* check that there is nothing already in the input buffer before starting +/* check that there is nothing already in the input buffer before starting kodakaio_rxflush(s); */ /* preset the reply, so I can see if it gets changed */ @@ -1129,12 +1129,12 @@ cmd_cancel_scan (SANE_Handle handle) unsigned char reply[8]; /* adf added 20/2/12 should it be adf? or adf with paper in? */ if (strcmp(source_list[s->val[OPT_SOURCE].w], ADF_STR) == 0) { /* adf */ - if (kodakaio_txrxack(s, KodakEsp_F, reply)!= SANE_STATUS_GOOD) + if (kodakaio_txrxack(s, KodakEsp_F, reply)!= SANE_STATUS_GOOD) { DBG(1, "%s: KodakEsp_F command failed\n", __func__); return SANE_STATUS_IO_ERROR; } - if (kodakaio_txrxack(s, KodakEsp_UnLock, reply)!= SANE_STATUS_GOOD) + if (kodakaio_txrxack(s, KodakEsp_UnLock, reply)!= SANE_STATUS_GOOD) { DBG(1, "%s: KodakEsp_UnLock command failed\n", __func__); return SANE_STATUS_IO_ERROR; @@ -1193,7 +1193,7 @@ cmd_set_color_curve(SANE_Handle handle, unsigned char col) int i; /* 7/9/14 was unsigned char and that stopped the loop that made the linear curve from going to 255 */ DBG(32, "%s: start\n", __func__); tx_col[0]=0x1b; tx_col[1]='S'; tx_col[2]='K'; tx_col[3]=col; tx_col[4]=0; tx_col[5]=0; tx_col[6]=0; tx_col[7]=0; -/* linear curve now but could send tailor made curves in future */ +/* linear curve now but could send tailor made curves in future */ for(i=0;i<=255;++i) tx_curve[i]=i; /* 7/9/14 was i<255 the missing elements caused speckles */ k_send(s, tx_col, 8, &status); @@ -1255,7 +1255,7 @@ cmd_set_scanning_parameters(SANE_Handle handle, tx_dpi[7]=0; kodakaio_txrxack(s, tx_dpi, bufread); -/* colour curves don't seem to be sent for usb preview +/* colour curves don't seem to be sent for usb preview but it seems to do no harm to send them */ cmd_set_color_curve(s, 'R'); cmd_set_color_curve(s, 'G'); @@ -1298,7 +1298,7 @@ this command needs actual DPI units*/ int cmparray (unsigned char *array1, unsigned char *array2, size_t len) { -/* compares len bytes of the arrays returns 0 if they match +/* compares len bytes of the arrays returns 0 if they match returns the first missmatch position if they don't match */ unsigned int i; for(i=0; iack and do padding if the padding option is selected @@ -1363,7 +1363,7 @@ But it seems that the scanner takes care of that, and gives you the ack as a sep /* it may be the last block from the scanner so look for Ack response in last 8 bytes */ Last8 = buf + bytecount - 8; - /* only compare 4 bytes because we sometimes get escSS02.. or escSS00.. + /* only compare 4 bytes because we sometimes get escSS02.. or escSS00.. is 4 the right number ? */ if (cmparray(Last8,KodakEsp_Ack,4) == 0) { DBG(min(10,DBG_READ), "%s: found KodakEsp_Ack at %lu bytes of %lu\n", __func__, (unsigned long) bytecount, (unsigned long) *len); @@ -1404,12 +1404,12 @@ But it seems that the scanner takes care of that, and gives you the ack as a sep if (status == SANE_STATUS_GOOD) if (s->bytes_unread <= 0) - DBG(min(2,DBG_READ), "%s: Page fully read %d blocks, %ld bytes unread\n", __func__, s->counter, (long) s->bytes_unread); + DBG(min(2,DBG_READ), "%s: Page fully read %d blocks, %ld bytes unread\n", __func__, s->counter, (long) s->bytes_unread); else DBG(min(20,DBG_READ), "%s: Image data successfully read %ld bytes, %ld bytes unread\n", __func__, (long) bytecount, (long) s->bytes_unread); else if (s->ack) /* was (status == SANE_STATUS_EOF) */ DBG(min(2,DBG_READ), "%s: scanner data read ended %d blocks %ld bytes, %ld bytes unread\n", __func__, s->counter, (long) bytecount, (long) s->bytes_unread); - else + else DBG(min(1,DBG_READ), "%s: Image data read stopped with %s after %d blocks %ld bytes, %ld bytes unread\n", __func__, sane_strstatus(status), s->counter, (long) bytecount, (long) s->bytes_unread); return status; @@ -1549,7 +1549,7 @@ k_setup_block_mode (KodakAio_Scanner *s) return SANE_STATUS_GOOD; } -/* Call the commands to set scanning parameters +/* Call the commands to set scanning parameters In the Kodak Aio the parameters are: (x1b,"S","F",0,0,0,0,0) (x1b,"S","S",1,0,0,0,0) @@ -1615,7 +1615,7 @@ k_set_scanning_parameters(KodakAio_Scanner * s) /* TODO: Any way to set PREVIEW??? */ /* Remaining bytes unused */ - status = cmd_set_scanning_parameters(s, dpi, + status = cmd_set_scanning_parameters(s, dpi, s->left * dpi / optres, s->top * dpi / optres, /* top/left start (dpi units)*/ s->params.pixels_per_line, s->params.lines, /* extent was s->width, s->height*/ source); /* source */ @@ -1696,7 +1696,7 @@ k_scan_finish(KodakAio_Scanner * s) static void k_copy_image_data(KodakAio_Scanner * s, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) -/* copies the read data from s->line_buffer to the position in data pointer to by s->ptr +/* copies the read data from s->line_buffer to the position in data pointer to by s->ptr uncompressed data is RRRR...GGGG...BBBB per line */ { SANE_Int bytes_available; @@ -1724,7 +1724,7 @@ uncompressed data is RRRR...GGGG...BBBB per line */ /* We have filled as much as possible of the current line * with data from the scanner. If we have a complete line, - * copy it over. + * copy it over. line points to the current byte in the input s->line_buffer data points to the output buffer*/ if ((s->bytes_read_in_line >= s->scan_bytes_per_line) && @@ -1753,8 +1753,8 @@ uncompressed data is RRRR...GGGG...BBBB per line */ *data &= ~mask; /* white clear the bit in mask */ else *data |= mask; /* black set the bit in mask */ - - if (offset == 7 || i == s->params.pixels_per_line-1) + + if (offset == 7 || i == s->params.pixels_per_line-1) data++; /* move on a byte if the byte is full or the line is complete */ } @@ -1768,7 +1768,7 @@ uncompressed data is RRRR...GGGG...BBBB per line */ } /*debug file The same for color or grey because the scan is colour */ if (RawScan != NULL) { - for (i=0; i< s->scan_bytes_per_line; ++i) fputc(s->line_buffer[i],RawScan); + for (i=0; i< s->scan_bytes_per_line; ++i) fputc(s->line_buffer[i],RawScan); } max_length -= s->params.bytes_per_line; s->bytes_read_in_line -= s->scan_bytes_per_line; @@ -1840,7 +1840,7 @@ k_init_parametersta(KodakAio_Scanner * s) s->params.last_frame = SANE_TRUE; s->params.bytes_per_line = 3 * ceil (s->params.depth * s->params.pixels_per_line / 8.0); -/* kodak only scans in color and conversion to grey or lineart is done in the driver +/* kodak only scans in color and conversion to grey or lineart is done in the driver s->params.format = SANE_FRAME_RGB; */ DBG(20, "%s: s->val[OPT_MODE].w = %d (color is %d)\n", __func__,s->val[OPT_MODE].w, MODE_COLOR); if (s->val[OPT_MODE].w == MODE_COLOR) s->params.format = SANE_FRAME_RGB; @@ -1870,7 +1870,7 @@ k_read(struct KodakAio_Scanner *s) { unsigned char rx[8]; -/* monitors progress of blocks and calls cmd_read_data to get each block +/* monitors progress of blocks and calls cmd_read_data to get each block you don't know how many blocks there will be in advance because their size may be determined by the scanner*/ SANE_Status status = SANE_STATUS_GOOD; size_t buf_len = 0; @@ -1907,7 +1907,7 @@ you don't know how many blocks there will be in advance because their size may b if (status == SANE_STATUS_EOF) { /* page ended prematurely. */ } - } + } else { /* s->bytes_unread <=0 This is the end of a page */ s->eof = SANE_TRUE; DBG(min(10,DBG_READ), "%s: set EOF after %d blocks\n=============\n", __func__, s->counter); @@ -1932,7 +1932,7 @@ you don't know how many blocks there will be in advance because their size may b } /* - * SANE API implementation (high-level functions) + * SANE API implementation (high-level functions) */ #if WITH_AVAHI @@ -1951,12 +1951,12 @@ get_device_from_identification (const char *ident, const char *vid, const char * return NULL; } for (n = 0; n < NELEMS (kodakaio_cap); n++) { - + if (strcmp (kodakaio_cap[n].model, ident)==0) { DBG(20, "matched <%s> & <%s>\n", kodakaio_cap[n].model, ident); return &kodakaio_cap[n]; } - else + else if (kodakaio_cap[n].id == pidnum && 0x040A == vidnum) { DBG(20, "matched <%s> & <%s:%s>\n", kodakaio_cap[n].model, vid, pid); return &kodakaio_cap[n]; @@ -2124,7 +2124,7 @@ detect_usb(struct KodakAio_Scanner *s) * about the device */ while (i != numIds && !is_valid) { /* if (product == kodakaio_usb_product_ids[i]) */ - if (product == kodakaio_cap[i].id) + if (product == kodakaio_cap[i].id) is_valid = SANE_TRUE; i++; } @@ -2259,20 +2259,20 @@ device_detect(const char *name, int type, SANE_Status *status) #if WITH_AVAHI /* ProcessAvahiDevice is called to process each discovered device in turn */ -void +void ProcessAvahiDevice(const char *device_id, const char *vid, const char *pid, const char *ip_addr) { struct KodakaioCap *cap; DBG(min(10,DBG_AUTO),"device_id = <%s> vid:pid = <%s:%s>\n", device_id,vid,pid); -/* check if it is a model likely to be supported: "KODAK ESP" or "KODAK HERO" +/* check if it is a model likely to be supported: "KODAK ESP" or "KODAK HERO" DBG(min(10,DBG_AUTO),"look up model <%s>\n", device_model); */ cap = get_device_from_identification("", vid, pid); if (cap == NULL) { return; - } + } DBG(min(10,DBG_AUTO), "%s: Found autodiscovered device: %s (type 0x%x)\n", __func__, cap->model, cap->id); attach_one_net (ip_addr, cap->id); @@ -2337,12 +2337,12 @@ static void resolve_callback( else DBG(min(10,DBG_AUTO), "didn't call ProcessAvahiDevice\n"); if(vid_pair_list != NULL) { - avahi_free(vidkey); + avahi_free(vidkey); avahi_free(vidvalue); DBG(min(15,DBG_AUTO), "vidkey and vidvalue freed\n"); } if(pid_pair_list != NULL) { - avahi_free(pidkey); + avahi_free(pidkey); avahi_free(pidvalue); DBG(min(15,DBG_AUTO), "pidkey and pidvalue freed\n"); } @@ -2413,7 +2413,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void * userd static int kodak_network_discovery(const char*host) -/* If host = NULL do autodiscovery. If host != NULL try to verify the model +/* If host = NULL do autodiscovery. If host != NULL try to verify the model First version only does autodiscovery */ { AvahiSimplePoll *simple_poll; @@ -2586,7 +2586,7 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line) /* Timeout for all other read requests */ DBG(50, "%s: Request timeout set to %d\n", __func__, timeout); K_Request_Timeout = timeout; - + } else { /* TODO: Warning about unparsable line! */ } @@ -2790,7 +2790,7 @@ init_options(KodakAio_Scanner *s) s->opt[OPT_BIT_DEPTH].constraint.word_list = s->hw->cap->depth_list; s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; s->val[OPT_BIT_DEPTH].w = s->hw->cap->depth_list[1]; /* the first "real" element is the default */ - + DBG(20, "%s: depth list has depth_list[0] = %d entries\n", __func__, s->hw->cap->depth_list[0]); if (s->hw->cap->depth_list[0] == 1) { /* only one element in the list -> hide the option */ s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; @@ -2814,7 +2814,7 @@ init_options(KodakAio_Scanner *s) s->val[OPT_RESOLUTION].w = s->hw->cap->dpi_range.min; - /* trial option for debugging + /* trial option for debugging s->opt[OPT_TRIALOPT].name = "trialoption"; s->opt[OPT_TRIALOPT].title = "trialoption"; s->opt[OPT_TRIALOPT].desc = "trialoption"; @@ -2834,7 +2834,7 @@ init_options(KodakAio_Scanner *s) for(i=0;source_list[i]!=NULL;++i) DBG(18, "source_list: %s\n",source_list[i]); - + /* source */ s->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; @@ -2850,7 +2850,7 @@ init_options(KodakAio_Scanner *s) s->opt[OPT_SOURCE].cap |= SANE_CAP_INACTIVE; } -/* Are there any ESP scanners that are duplex? */ +/* Are there any ESP scanners that are duplex? */ s->opt[OPT_ADF_MODE].name = "adf-mode"; s->opt[OPT_ADF_MODE].title = SANE_I18N("ADF Mode"); s->opt[OPT_ADF_MODE].desc = @@ -2991,7 +2991,7 @@ sane_open(SANE_String_Const name, SANE_Handle *handle) /* s is always valid here */ DBG(10, "handle obtained\n"); - status = k_discover_capabilities(s); /* added 27/12/11 to fix source list problem + status = k_discover_capabilities(s); /* added 27/12/11 to fix source list problem maybe we should only be rebuilding the source list here? */ if (status != SANE_STATUS_GOOD) return status; @@ -3000,7 +3000,7 @@ maybe we should only be rebuilding the source list here? */ *handle = (SANE_Handle) s; -/* moving the open scanner section below to sane_start 27/12/14 +/* moving the open scanner section below to sane_start 27/12/14 status = open_scanner(s); if (status != SANE_STATUS_GOOD) { free(s); @@ -3400,8 +3400,8 @@ sane_start(SANE_Handle handle) /* set scanning parameters; also query the current image * parameters from the sanner and save - * them to s->params -Only set scanning params the first time, or after a cancel + * them to s->params +Only set scanning params the first time, or after a cancel try change 22/2/12 take lock scanner out of k_set_scanning_parameters */ /* moved open_scanner here 27/12/14 from sane_open */ -- cgit v1.2.3 From ffa8801644a7d53cc1c785e3450f794c07a14eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 2 Feb 2020 17:13:01 +0100 Subject: New upstream version 1.0.29 --- backend/kodakaio.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'backend/kodakaio.c') diff --git a/backend/kodakaio.c b/backend/kodakaio.c index c8cc9a7..d5c2857 100644 --- a/backend/kodakaio.c +++ b/backend/kodakaio.c @@ -3276,12 +3276,11 @@ setvalue(SANE_Handle handle, SANE_Int option, void *value, SANE_Int *info) case OPT_BR_X: case OPT_BR_Y: - sval->w = *((SANE_Word *) value); - if (SANE_UNFIX(sval->w) == 0) { + if (SANE_UNFIX(*((SANE_Word *) value)) == 0) { DBG(17, "invalid br-x or br-y\n"); return SANE_STATUS_INVAL; } - /* passthru */ + // fall through case OPT_TL_X: case OPT_TL_Y: sval->w = *((SANE_Word *) value); -- cgit v1.2.3