wok diff sane-backends/stuff/xerox_mfp_fix_usb_devices.patch @ rev 21524
updated ncdu (1.13 -> 1.14)
author | Hans-G?nter Theisgen |
---|---|
date | Fri May 03 17:30:38 2019 +0100 (2019-05-03) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/sane-backends/stuff/xerox_mfp_fix_usb_devices.patch Fri May 03 17:30:38 2019 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +commit 5ea227caeacd504b64eef301e83fa63e0a25b3f7 1.5 +Author: Alex Belkin <abc@telekom.ru> 1.6 +Date: Tue Mar 8 17:57:19 2011 +0300 1.7 + 1.8 + keep usb device by default (correct for bug introduced by tcp sub-backend 1.9 + 1.10 +diff --git a/backend/xerox_mfp.c b/backend/xerox_mfp.c 1.11 +index e08b50f..d4672a7 100644 1.12 +--- a/backend/xerox_mfp.c 1.13 ++++ b/backend/xerox_mfp.c 1.14 +@@ -37,10 +37,10 @@ 1.15 + static const SANE_Device **devlist = NULL; /* sane_get_devices array */ 1.16 + static struct device *devices_head = NULL; /* sane_get_devices list */ 1.17 + 1.18 +-transport available_transports[] = { 1.19 ++enum { TRANSPORT_USB, TRANSPORT_TCP, TRANSPORTS_MAX }; 1.20 ++transport available_transports[TRANSPORTS_MAX] = { 1.21 + { "usb", usb_dev_request, usb_dev_open, usb_dev_close, usb_configure_device }, 1.22 + { "tcp", tcp_dev_request, tcp_dev_open, tcp_dev_close, tcp_configure_device }, 1.23 +- { 0 } 1.24 + }; 1.25 + 1.26 + static int resolv_state(int state) 1.27 +@@ -824,7 +824,13 @@ free_devices (void) 1.28 + devices_head = NULL; 1.29 + } 1.30 + 1.31 +-/* SANE API ignores return code of this callback */ 1.32 ++static transport *tr_from_devname(SANE_String_Const devname) 1.33 ++{ 1.34 ++ if (strncmp("tcp", devname, 3) == 0) 1.35 ++ return &available_transports[TRANSPORT_TCP]; 1.36 ++ return &available_transports[TRANSPORT_USB]; 1.37 ++} 1.38 ++ 1.39 + static SANE_Status 1.40 + list_one_device (SANE_String_Const devname) 1.41 + { 1.42 +@@ -839,12 +845,7 @@ list_one_device (SANE_String_Const devname) 1.43 + return SANE_STATUS_GOOD; 1.44 + } 1.45 + 1.46 +- for (tr = available_transports; tr->ttype; tr++) { 1.47 +- if (!strncmp (devname, tr->ttype, strlen(tr->ttype))) 1.48 +- break; 1.49 +- } 1.50 +- if (!tr->ttype) 1.51 +- return SANE_STATUS_INVAL; 1.52 ++ tr = tr_from_devname(devname); 1.53 + 1.54 + dev = calloc (1, sizeof (struct device)); 1.55 + if (dev == NULL) 1.56 +@@ -878,13 +879,7 @@ list_one_device (SANE_String_Const devname) 1.57 + static SANE_Status 1.58 + list_conf_devices (UNUSED (SANEI_Config * config), const char *devname) 1.59 + { 1.60 +- transport *tr; 1.61 +- 1.62 +- for (tr = available_transports; tr->ttype; tr++) { 1.63 +- if (!strncmp (devname, tr->ttype, strlen(tr->ttype))) 1.64 +- return tr->configure_device(devname, list_one_device); 1.65 +- } 1.66 +- return SANE_STATUS_INVAL; 1.67 ++ return tr_from_devname(devname)->configure_device(devname, list_one_device); 1.68 + } 1.69 + 1.70 + SANE_Status