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 --- tools/sane-find-scanner.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'tools/sane-find-scanner.c') diff --git a/tools/sane-find-scanner.c b/tools/sane-find-scanner.c index ae0e116..04f19d9 100644 --- a/tools/sane-find-scanner.c +++ b/tools/sane-find-scanner.c @@ -46,7 +46,7 @@ #include "../include/sane/sanei_pa4s2.h" #include "../include/sane/sanei_config.h" -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY #ifdef HAVE_LUSB0_USB_H #include #else @@ -55,7 +55,7 @@ extern char * check_usb_chip (struct usb_device *dev, int verbosity, SANE_Bool from_file); #endif -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB #include extern char * check_usb_chip (int verbosity, struct libusb_device_descriptor desc, @@ -76,7 +76,7 @@ static SANE_Bool device_found = SANE_FALSE; static SANE_Bool libusb_device_found = SANE_FALSE; static SANE_Bool unknown_found = SANE_FALSE; -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB libusb_context *sfs_usb_ctx; #endif @@ -115,7 +115,7 @@ usage (char *msg) fprintf (stderr, "\t-f: force opening devname as SCSI even if it looks " "like USB\n"); fprintf (stderr, "\t-p: enable scanning for parallel port devices\n"); -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY fprintf (stderr, "\t-F file: try to detect chipset from given " "/proc/bus/usb/devices file\n"); #endif @@ -403,7 +403,7 @@ check_usb_file (char *file_name) } } -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY static char * get_libusb_string_descriptor (struct usb_device *dev, int index) @@ -701,10 +701,10 @@ check_libusb_device (struct usb_device *dev, SANE_Bool from_file) if (product) free (product); } -#endif /* HAVE_LIBUSB */ +#endif /* HAVE_LIBUSB_LEGACY */ -#ifdef HAVE_LIBUSB_1_0 +#ifdef HAVE_LIBUSB static char * sfs_libusb_strerror (int errcode) { @@ -1095,7 +1095,7 @@ check_libusb_device (libusb_device *dev, SANE_Bool from_file) if (product) free (product); } -#endif /* HAVE_LIBUSB_1_0 */ +#endif /* HAVE_LIBUSB */ static DIR * @@ -1355,7 +1355,7 @@ check_mustek_pp_device (void) return (found > 0 || scsi > 0); } -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY static SANE_Bool parse_num (char* search, const char* line, int base, long int * number) { @@ -1596,9 +1596,9 @@ main (int argc, char **argv) break; case 'F': -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY parse_file ((char *) (*(++ap))); -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) printf ("option -F not implemented with libusb-1.0\n"); #else printf ("libusb not available: option -F can't be used\n"); @@ -1797,7 +1797,7 @@ main (int argc, char **argv) "/dev/scanner", "/dev/scanner0", "/dev/scanner1", "/dev/pass0", "/dev/pass1", "/dev/pass2", "/dev/pass3", "/dev/pass4", "/dev/pass5", "/dev/pass6", "/dev/pass7", -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) "/dev/uk0", "/dev/uk1", "/dev/uk2", "/dev/uk3", "/dev/uk4", "/dev/uk5", "/dev/uk6", #elif defined(__NetBSD__) @@ -1948,7 +1948,7 @@ main (int argc, char **argv) check_usb_file (dev_name); } } -#ifdef HAVE_LIBUSB +#ifdef HAVE_LIBUSB_LEGACY /* Now the libusb devices */ { struct usb_bus *bus; @@ -1973,7 +1973,7 @@ main (int argc, char **argv) } /* for (bus) */ } } -#elif defined(HAVE_LIBUSB_1_0) +#elif defined(HAVE_LIBUSB) /* Now the libusb-1.0 devices */ { if (ap < argv + argc) @@ -2026,10 +2026,10 @@ main (int argc, char **argv) ; /* init failed, jumping here */ } } -#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ if (verbose > 1) printf ("libusb not available\n"); -#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */ +#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */ if (device_found) { @@ -2062,7 +2062,7 @@ main (int argc, char **argv) "make sure that\n # you have loaded a kernel driver for your USB host " "controller and have setup\n # the USB system correctly. " "See man sane-usb for details.\n"); -#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) +#if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) if (verbose > 0) printf (" # SANE has been built without libusb support. This may be a " "reason\n # for not detecting USB scanners. Read README for " @@ -2074,7 +2074,7 @@ main (int argc, char **argv) if (!check_mustek_pp_device() && verbose > 0) printf ("\n # No Mustek parallel port scanners found. If you expected" " something\n # different, make sure the scanner is correctly" - " connected to your computer\n # and you have apropriate" + " connected to your computer\n # and you have appropriate" " access rights.\n"); } else if (verbose > 0) -- cgit v1.2.3 From 1687222e1b9e74c89cafbb5910e72d8ec7bfd40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 31 Jul 2019 16:59:49 +0200 Subject: New upstream version 1.0.28 --- tools/sane-find-scanner.c | 59 ++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'tools/sane-find-scanner.c') diff --git a/tools/sane-find-scanner.c b/tools/sane-find-scanner.c index 04f19d9..a62ceac 100644 --- a/tools/sane-find-scanner.c +++ b/tools/sane-find-scanner.c @@ -225,7 +225,7 @@ scanner_do_scsi_inquiry (unsigned char *buffer, int sfd) memset (buffer, '\0', 256); /* clear buffer */ - size = 5; /* first get only 5 bytes to get size of + size = 5; /* first get only 5 bytes to get size of inquiry_return_block */ set_inquiry_return_size (inquiry.cmd, size); status = sanei_scsi_cmd (sfd, inquiry.cmd, inquiry.size, buffer, &size); @@ -433,13 +433,13 @@ get_libusb_string_descriptor (struct usb_device *dev, int index) return 0; } - if (sd->bLength < 2 + if (sd->bLength < 2 || sd->bDescriptorType != USB_DT_STRING) { usb_close (handle); return 0; } - + size = sd->bLength; buffer = calloc (1, size + 1); @@ -659,7 +659,7 @@ check_libusb_device (struct usb_device *dev, SANE_Bool from_file) ++is_scanner; break; case USB_CLASS_PER_INTERFACE: - if (dev->config[0].interface[interface_nr].num_altsetting == 0 || + if (dev->config[0].interface[interface_nr].num_altsetting == 0 || !dev->config[0].interface[interface_nr].altsetting) break; switch (dev->config[0].interface[interface_nr].altsetting[0].bInterfaceClass) @@ -782,7 +782,7 @@ get_libusb_string_descriptor (libusb_device_handle *hdl, int index) if ((short_buffer[0] < 2) /* descriptor length */ || (short_buffer[1] != LIBUSB_DT_STRING)) /* descriptor type */ return NULL; - + size = short_buffer[0]; buffer = calloc (1, size + 1); @@ -934,7 +934,7 @@ check_libusb_device (libusb_device *dev, SANE_Bool from_file) printf (" iConfiguration %d (%s)\n", c->iConfiguration, (buf) ? buf : ""); free (buf); - + printf (" bmAttributes %d (%s%s)\n", c->bmAttributes, c->bmAttributes & 64 ? "Self-powered" : "", c->bmAttributes & 32 ? "Remote Wakeup" : ""); @@ -1064,7 +1064,7 @@ check_libusb_device (libusb_device *dev, SANE_Bool from_file) if (is_scanner > 0) { char *chipset = NULL; - + if(!from_file) chipset = check_usb_chip (verbose, desc, hdl, config0); @@ -1084,7 +1084,7 @@ check_libusb_device (libusb_device *dev, SANE_Bool from_file) libusb_device_found = SANE_TRUE; device_found = SANE_TRUE; } - + libusb_free_config_descriptor (config0); out_free: @@ -1212,14 +1212,14 @@ static char **build_scsi_dev_list(void) adapter = (PSCSI_ADAPTER_BUS_INFO)buffer; - for(i = 0; i < adapter->NumberOfBuses; i++) { + for(i = 0; i < adapter->NumberOfBuses; i++) { if (adapter->BusData[i].InquiryDataOffset == 0) { /* No device here */ continue; } - inquiry = (PSCSI_INQUIRY_DATA) (buffer + + inquiry = (PSCSI_INQUIRY_DATA) (buffer + adapter->BusData[i].InquiryDataOffset); while(1) { /* Check if it is a scanner or a processor @@ -1233,7 +1233,7 @@ static char **build_scsi_dev_list(void) dev_list[dev_list_index] = strdup(device_name); dev_list_index++; } - + if (inquiry->NextInquiryDataOffset == 0) { /* No device here */ break; @@ -1300,7 +1300,7 @@ check_mustek_pp_device (void) printf ("checking %s...", devices[ctr]); result = sanei_pa4s2_open (devices[ctr], &fd); - + if (verbose > 1) { if (result != 0) @@ -1315,13 +1315,13 @@ check_mustek_pp_device (void) found++; sanei_pa4s2_close(fd); } - + /* trying scsi over pp devices */ if (verbose > 1) printf ("checking %s (SCSI emulation)...", devices[ctr]); result = sanei_pa4s2_scsi_pp_open (devices[ctr], &fd); - + if (verbose > 1) { if (result != 0) @@ -1365,7 +1365,7 @@ parse_num (char* search, const char* line, int base, long int * number) if (start_number == NULL) return SANE_FALSE; start_number += strlen (search); - + *number = strtol (start_number, NULL, base); if (verbose > 2) printf ("Found %s%ld\n", search, *number); @@ -1384,11 +1384,11 @@ parse_bcd (char* search, const char* line, long int * number) if (start_number == NULL) return SANE_FALSE; start_number += strlen (search); - + first_part = strtol (start_number, &end_number, 10); start_number = end_number + 1; /* skip colon */ second_part = strtol (start_number, NULL, 10); - *number = ((first_part / 10) << 12) + ((first_part % 10) << 8) + *number = ((first_part / 10) << 12) + ((first_part % 10) << 8) + ((second_part / 10) << 4) + (second_part % 10); if (verbose > 2) printf ("Found %s%ld\n", search, *number); @@ -1478,7 +1478,7 @@ parse_file (char *filename) } if (parse_num ("Ifs=", line, 10, &number)) dev->config[current_config].bNumInterfaces = number; - dev->config[current_config].interface + dev->config[current_config].interface = calloc (number, sizeof (struct usb_interface)); if (parse_num ("Atr=", line, 16, &number)) dev->config[current_config].bmAttributes = number; @@ -1504,24 +1504,24 @@ parse_file (char *filename) if (parse_num ("Alt=", line, 10, &number)) { current_as = number; - dev->config[current_config].interface[current_if].altsetting[current_as].bInterfaceNumber + dev->config[current_config].interface[current_if].altsetting[current_as].bInterfaceNumber = current_if; - dev->config[current_config].interface[current_if].altsetting[current_as].bAlternateSetting + dev->config[current_config].interface[current_if].altsetting[current_as].bAlternateSetting = current_as; } if (parse_num ("#EPs=", line, 10, &number)) - dev->config[current_config].interface[current_if].altsetting[current_as].bNumEndpoints + dev->config[current_config].interface[current_if].altsetting[current_as].bNumEndpoints = number; - dev->config[current_config].interface[current_if].altsetting[current_as].endpoint + dev->config[current_config].interface[current_if].altsetting[current_as].endpoint = calloc (number, sizeof (struct usb_endpoint_descriptor)); if (parse_num ("Cls=", line, 16, &number)) - dev->config[current_config].interface[current_if].altsetting[current_as].bInterfaceClass + dev->config[current_config].interface[current_if].altsetting[current_as].bInterfaceClass = number; if (parse_num ("Sub=", line, 16, &number)) - dev->config[current_config].interface[current_if].altsetting[current_as].bInterfaceSubClass + dev->config[current_config].interface[current_if].altsetting[current_as].bInterfaceSubClass = number; if (parse_num ("Prot=", line, 16, &number)) - dev->config[current_config].interface[current_if].altsetting[current_as].bInterfaceProtocol + dev->config[current_config].interface[current_if].altsetting[current_as].bInterfaceProtocol = number; break; case 'E': @@ -1605,6 +1605,13 @@ main (int argc, char **argv) #endif exit (0); + case '-': + if (!strcmp((*ap), "--help")) + { + usage (0); + exit (0); + } + default: printf ("unknown option: -%c, try -h for help\n", (*ap)[1]); exit (0); @@ -2069,7 +2076,7 @@ main (int argc, char **argv) "more details.\n"); #endif } - if (enable_pp_checks == SANE_TRUE) + if (enable_pp_checks == SANE_TRUE) { if (!check_mustek_pp_device() && verbose > 0) printf ("\n # No Mustek parallel port scanners found. If you expected" -- 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 --- tools/sane-find-scanner.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tools/sane-find-scanner.c') diff --git a/tools/sane-find-scanner.c b/tools/sane-find-scanner.c index a62ceac..ac25c55 100644 --- a/tools/sane-find-scanner.c +++ b/tools/sane-find-scanner.c @@ -1611,7 +1611,7 @@ main (int argc, char **argv) usage (0); exit (0); } - + // fall through default: printf ("unknown option: -%c, try -h for help\n", (*ap)[1]); exit (0); @@ -2009,7 +2009,12 @@ main (int argc, char **argv) } if (verbose > 3) +#if LIBUSB_API_VERSION >= 0x01000106 + libusb_set_option (sfs_usb_ctx, LIBUSB_OPTION_LOG_LEVEL, + LIBUSB_LOG_LEVEL_INFO); +#else libusb_set_debug (sfs_usb_ctx, 3); +#endif devcnt = libusb_get_device_list (sfs_usb_ctx, &devlist); if (devcnt < 0) -- cgit v1.2.3