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 --- frontend/saned.c | 3 ++ frontend/scanimage.c | 84 +++++++++++++++++++++------------------------------ frontend/tstbackend.c | 4 +-- 3 files changed, 40 insertions(+), 51 deletions(-) (limited to 'frontend') diff --git a/frontend/saned.c b/frontend/saned.c index ac5e700..6c3c40d 100644 --- a/frontend/saned.c +++ b/frontend/saned.c @@ -2674,6 +2674,9 @@ saned_avahi_callback (AvahiClient *c, AvahiClientState state, void *userdata) case AVAHI_CLIENT_S_COLLISION: DBG (DBG_INFO, "saned_avahi_callback: AVAHI_CLIENT_S_COLLISION\n"); + if (avahi_group) + avahi_entry_group_reset (avahi_group); + break; case AVAHI_CLIENT_S_REGISTERING: DBG (DBG_INFO, "saned_avahi_callback: AVAHI_CLIENT_S_REGISTERING\n"); diff --git a/frontend/scanimage.c b/frontend/scanimage.c index 6906f90..ae65ebf 100644 --- a/frontend/scanimage.c +++ b/frontend/scanimage.c @@ -32,6 +32,7 @@ #include #include "lgetopt.h" +#include #include #include #include @@ -204,51 +205,30 @@ auth_callback (SANE_String_Const resource, if ((strlen (tmp) > 0) && (tmp[strlen (tmp) - 1] == '\r')) tmp[strlen (tmp) - 1] = 0; - if (strchr (tmp, ':') != NULL) + char *colon1 = strchr (tmp, ':'); + if (colon1 != NULL) { + char *tmp_username = tmp; + *colon1 = '\0'; - if (strchr (strchr (tmp, ':') + 1, ':') != NULL) + char *colon2 = strchr (colon1 + 1, ':'); + if (colon2 != NULL) { + char *tmp_password = colon1 + 1; + *colon2 = '\0'; - if ((strncmp - (strchr (strchr (tmp, ':') + 1, ':') + 1, - resource, len) == 0) - && - ((int) strlen - (strchr (strchr (tmp, ':') + 1, ':') + 1) == - len)) + if ((strncmp (colon2 + 1, resource, len) == 0) + && ((int) strlen (colon2 + 1) == len)) { - - if ((strchr (tmp, ':') - tmp) < - SANE_MAX_USERNAME_LEN) - { - - if ((strchr (strchr (tmp, ':') + 1, ':') - - (strchr (tmp, ':') + 1)) < - SANE_MAX_PASSWORD_LEN) - { - - strncpy (username, tmp, - strchr (tmp, ':') - tmp); - - username[strchr (tmp, ':') - tmp] = 0; - - strncpy (password, - strchr (tmp, ':') + 1, - strchr (strchr (tmp, ':') + 1, - ':') - - (strchr (tmp, ':') + 1)); - password[strchr - (strchr (tmp, ':') + 1, - ':') - (strchr (tmp, - ':') + 1)] = - 0; - - query_user = 0; - break; - } - } - + if ((strlen (tmp_username) < SANE_MAX_USERNAME_LEN) && + (strlen (tmp_password) < SANE_MAX_PASSWORD_LEN)) + { + strncpy (username, tmp_username, SANE_MAX_USERNAME_LEN); + strncpy (password, tmp_password, SANE_MAX_PASSWORD_LEN); + + query_user = 0; + break; + } } } } @@ -1317,7 +1297,8 @@ advance (Image * image) static SANE_Status scan_it (FILE *ofp) { - int i, len, first_frame = 1, offset = 0, must_buffer = 0, hundred_percent; + int i, len, first_frame = 1, offset = 0, must_buffer = 0; + uint64_t hundred_percent = 0; SANE_Byte min = 0xff, max = 0; SANE_Parameters parm; SANE_Status status; @@ -1325,7 +1306,7 @@ scan_it (FILE *ofp) static const char *format_name[] = { "gray", "RGB", "red", "green", "blue" }; - SANE_Word total_bytes = 0, expected_bytes; + uint64_t total_bytes = 0, expected_bytes; SANE_Int hang_over = -1; #ifdef HAVE_LIBPNG int pngrow = 0; @@ -1486,7 +1467,7 @@ scan_it (FILE *ofp) offset = parm.format - SANE_FRAME_RED; image.x = image.y = 0; } - hundred_percent = parm.bytes_per_line * parm.lines + hundred_percent = ((uint64_t)parm.bytes_per_line) * parm.lines * ((parm.format == SANE_FRAME_RGB || parm.format == SANE_FRAME_GRAY) ? 1:3); while (1) @@ -1498,7 +1479,12 @@ scan_it (FILE *ofp) if (progr > 100.) progr = 100.; if (progress) - fprintf (stderr, "Progress: %3.1f%%\r", progr); + { + if (parm.lines >= 0) + fprintf(stderr, "Progress: %3.1f%%\r", progr); + else + fprintf(stderr, "Progress: (unknown)\r"); + } if (status != SANE_STATUS_GOOD) { @@ -1760,7 +1746,7 @@ cleanup: free (image.data); - expected_bytes = parm.bytes_per_line * parm.lines * + expected_bytes = ((uint64_t)parm.bytes_per_line) * parm.lines * ((parm.format == SANE_FRAME_RGB || parm.format == SANE_FRAME_GRAY) ? 1 : 3); if (parm.lines < 0) @@ -1769,10 +1755,10 @@ cleanup: { fprintf (stderr, "%s: WARNING: read more data than announced by backend " - "(%u/%u)\n", prog_name, total_bytes, expected_bytes); + "(%" PRIu64 "/%" PRIu64 ")\n", prog_name, total_bytes, expected_bytes); } else if (verbose) - fprintf (stderr, "%s: read %u bytes in total\n", prog_name, total_bytes); + fprintf (stderr, "%s: read %" PRIu64 " bytes in total\n", prog_name, total_bytes); return status; } @@ -2260,15 +2246,15 @@ main (int argc, char **argv) if (defdevname) printf ("default device is `%s'\n", defdevname); scanimage_exit (0); + break; } - case 'V': printf ("scanimage (%s) %s; backend version %d.%d.%d\n", PACKAGE, VERSION, SANE_VERSION_MAJOR (version_code), SANE_VERSION_MINOR (version_code), SANE_VERSION_BUILD (version_code)); scanimage_exit (0); - + break; default: break; /* ignore device specific options for now */ } diff --git a/frontend/tstbackend.c b/frontend/tstbackend.c index 37ba660..985684d 100644 --- a/frontend/tstbackend.c +++ b/frontend/tstbackend.c @@ -46,10 +46,10 @@ static struct option basic_options[] = { {"device-name", required_argument, NULL, 'd'}, {"level", required_argument, NULL, 'l'}, - {"scan", NULL, NULL, 's'}, + {"scan", no_argument, NULL, 's'}, {"recursion", required_argument, NULL, 'r'}, {"get-devices", required_argument, NULL, 'g'}, - {"help", 0, NULL, 'h'} + {"help", no_argument, NULL, 'h'} }; static void -- cgit v1.2.3