summaryrefslogtreecommitdiff
path: root/sanei
diff options
context:
space:
mode:
Diffstat (limited to 'sanei')
-rw-r--r--sanei/Makefile.am4
-rw-r--r--sanei/Makefile.in62
-rw-r--r--[-rwxr-xr-x]sanei/sanei_DomainOS.c0
-rw-r--r--[-rwxr-xr-x]sanei/sanei_DomainOS.h0
-rw-r--r--sanei/sanei_ab306.c12
-rw-r--r--sanei/sanei_init_debug.c2
-rw-r--r--sanei/sanei_ir.c3
-rw-r--r--sanei/sanei_magic.c2
-rw-r--r--sanei/sanei_pa4s2.c4
-rw-r--r--sanei/sanei_pp.c6
-rw-r--r--sanei/sanei_scsi.c8
-rw-r--r--sanei/sanei_tcp.c2
-rw-r--r--sanei/sanei_thread.c15
-rw-r--r--sanei/sanei_usb.c262
14 files changed, 216 insertions, 166 deletions
diff --git a/sanei/Makefile.am b/sanei/Makefile.am
index c1106ae..a197343 100644
--- a/sanei/Makefile.am
+++ b/sanei/Makefile.am
@@ -4,8 +4,8 @@
## This file is part of the "Sane" build infra-structure. See
## included LICENSE file for license information.
-AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_builddir)/include \
- -I$(top_srcdir)/include
+AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include \
+ -I$(top_srcdir)/include $(USB_CFLAGS)
noinst_LTLIBRARIES = libsanei.la
diff --git a/sanei/Makefile.in b/sanei/Makefile.in
index 1fba44d..c6fa654 100644
--- a/sanei/Makefile.in
+++ b/sanei/Makefile.in
@@ -83,11 +83,16 @@ subdir = sanei
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/mkinstalldirs $(top_srcdir)/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ltoptions.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
+ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
+ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/byteorder.m4 \
- $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/configure.in
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/acinclude.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/byteorder.m4 $(top_srcdir)/m4/stdint.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -180,7 +185,11 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
+AM_CFLAGS = @AM_CFLAGS@
+AM_CPPFLAGS = @AM_CPPFLAGS@ -I. -I$(srcdir) -I$(top_builddir)/include \
+ -I$(top_srcdir)/include $(USB_CFLAGS)
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AM_LDFLAGS = @AM_LDFLAGS@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
@@ -201,7 +210,7 @@ CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
-DISTCLEAN_FILES = @DISTCLEAN_FILES@
+DLH = @DLH@
DLLTOOL = @DLLTOOL@
DL_LIBS = @DL_LIBS@
DSYMUTIL = @DSYMUTIL@
@@ -214,34 +223,42 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+FIG2DEV = @FIG2DEV@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
GPHOTO2_CPPFLAGS = @GPHOTO2_CPPFLAGS@
GPHOTO2_LDFLAGS = @GPHOTO2_LDFLAGS@
GPHOTO2_LIBS = @GPHOTO2_LIBS@
GREP = @GREP@
+GS = @GS@
HAVE_GPHOTO2 = @HAVE_GPHOTO2@
IEEE1284_LIBS = @IEEE1284_LIBS@
-INCLUDES = @INCLUDES@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_LOCKPATH = @INSTALL_LOCKPATH@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
JPEG_LIBS = @JPEG_LIBS@
LATEX = @LATEX@
LD = @LD@
LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
-LIBUSB_1_0_CFLAGS = @LIBUSB_1_0_CFLAGS@
-LIBUSB_1_0_LIBS = @LIBUSB_1_0_LIBS@
LIBV4L_CFLAGS = @LIBV4L_CFLAGS@
LIBV4L_LIBS = @LIBV4L_LIBS@
-LINKER_RPATH = @LINKER_RPATH@
LIPO = @LIPO@
LN_S = @LN_S@
LOCKPATH_GROUP = @LOCKPATH_GROUP@
+LTALLOCA = @LTALLOCA@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINDEX = @MAKEINDEX@
@@ -250,10 +267,10 @@ MANIFEST_TOOL = @MANIFEST_TOOL@
MATH_LIB = @MATH_LIB@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NM = @NM@
NMEDIT = @NMEDIT@
-NUMBER_VERSION = @NUMBER_VERSION@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
@@ -266,10 +283,13 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFLATEX = @PDFLATEX@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PNG_LIBS = @PNG_LIBS@
+POSUB = @POSUB@
+PPMTOGIF = @PPMTOGIF@
PRELOADABLE_BACKENDS = @PRELOADABLE_BACKENDS@
PRELOADABLE_BACKENDS_ENABLED = @PRELOADABLE_BACKENDS_ENABLED@
PTHREAD_LIBS = @PTHREAD_LIBS@
@@ -291,12 +311,16 @@ SYSLOG_LIBS = @SYSLOG_LIBS@
SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@
SYSTEMD_LIBS = @SYSTEMD_LIBS@
TIFF_LIBS = @TIFF_LIBS@
+USB_CFLAGS = @USB_CFLAGS@
USB_LIBS = @USB_LIBS@
+USE_NLS = @USE_NLS@
VERSION = @VERSION@
V_MAJOR = @V_MAJOR@
V_MINOR = @V_MINOR@
V_REV = @V_REV@
XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@@ -352,9 +376,6 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_builddir)/include \
- -I$(top_srcdir)/include
-
noinst_LTLIBRARIES = libsanei.la
libsanei_la_SOURCES = sanei_ab306.c sanei_constrain_value.c \
sanei_init_debug.c sanei_net.c sanei_wire.c \
@@ -445,22 +466,25 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanei_wire.Plo@am__quote@
.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
diff --git a/sanei/sanei_DomainOS.c b/sanei/sanei_DomainOS.c
index 5473151..5473151 100755..100644
--- a/sanei/sanei_DomainOS.c
+++ b/sanei/sanei_DomainOS.c
diff --git a/sanei/sanei_DomainOS.h b/sanei/sanei_DomainOS.h
index ff93503..ff93503 100755..100644
--- a/sanei/sanei_DomainOS.h
+++ b/sanei/sanei_DomainOS.h
diff --git a/sanei/sanei_ab306.c b/sanei/sanei_ab306.c
index c663d38..898acf6 100644
--- a/sanei/sanei_ab306.c
+++ b/sanei/sanei_ab306.c
@@ -81,7 +81,7 @@ inb (u_long port)
#include "../include/sane/sanei.h"
#include "../include/sane/sanei_ab306.h"
-#if (defined(HAVE_IOPERM) || defined(__FreeBSD__)) && !defined(IO_SUPPORT_MISSING)
+#if (defined(HAVE_IOPERM) || defined(__FreeBSD__) || defined(__DragonFly__)) && !defined(IO_SUPPORT_MISSING)
#include <errno.h>
#include <fcntl.h>
@@ -102,7 +102,7 @@ inb (u_long port)
#define PORT_DEV "/dev/port"
#define AB306_CIO 0x379 /* control i/o port */
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
static int dev_io_fd = 0;
#endif
@@ -290,7 +290,7 @@ sanei_ab306_open (const char *dev, int *fdp)
status = sanei_ab306_get_io_privilege (i);
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
status = sanei_ab306_get_io_privilege (i);
if (status != SANE_STATUS_GOOD)
return status;
@@ -369,7 +369,7 @@ sanei_ab306_get_io_privilege (int fd)
{
if (port[fd].port_fd < 0)
{
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
if (dev_io_fd == 0)
dev_io_fd = open ("/dev/io", O_RDONLY);
if (dev_io_fd < 0)
@@ -461,7 +461,6 @@ sanei_ab306_rdata (int fd, int planes, SANE_Byte * buf, int lines, int bpl)
{
Port *p = port + fd;
int lcnt, pcnt, bcnt, xmax;
- SANE_Byte *lsave_bp;
int nstat;
DBG(2, "sanei_ab306_rdata: start\n");
@@ -471,7 +470,6 @@ sanei_ab306_rdata (int fd, int planes, SANE_Byte * buf, int lines, int bpl)
/* the lines-loop: */
for (lcnt = 0; lcnt < lines; ++lcnt)
{
- lsave_bp = buf;
/* the planes-loop: */
for (pcnt = 0; pcnt < planes; ++pcnt)
{
@@ -520,7 +518,7 @@ sanei_ab306_exit (void)
/* power off the scanner: */
ab306_outb (port + i, port[i].base + 1, 0x00);
}
-#if defined(__FreeBSD)
+#if defined(__FreeBSD) || defined(__DragonFly__)
if (dev_io_fd >0)
close (dev_io_fd);
#endif /* defined(__FreeBSD__) */
diff --git a/sanei/sanei_init_debug.c b/sanei/sanei_init_debug.c
index bb5b755..0abb891 100644
--- a/sanei/sanei_init_debug.c
+++ b/sanei/sanei_init_debug.c
@@ -72,7 +72,7 @@
* instead, so the debugging env var name matches the docs.
* This is a particular problem in Turkish, where 'i' does
* not capitalize to 'I' */
-char
+static char
toupper_ascii (int c)
{
if(c > 0x60 && c < 0x7b)
diff --git a/sanei/sanei_ir.c b/sanei/sanei_ir.c
index 42e82ba..47e1e6e 100644
--- a/sanei/sanei_ir.c
+++ b/sanei/sanei_ir.c
@@ -29,7 +29,8 @@
#include <stdlib.h>
#include <string.h>
-#include <values.h>
+#include <float.h>
+#include <limits.h>
#include <math.h>
#define BACKEND_NAME sanei_ir /* name of this module for debugging */
diff --git a/sanei/sanei_magic.c b/sanei/sanei_magic.c
index 167d7dd..bfd56cc 100644
--- a/sanei/sanei_magic.c
+++ b/sanei/sanei_magic.c
@@ -710,7 +710,7 @@ sanei_magic_rotate (SANE_Parameters * params, SANE_Byte * buffer,
DBG(10,"sanei_magic_rotate: finish\n");
- return 0;
+ return ret;
}
SANE_Status
diff --git a/sanei/sanei_pa4s2.c b/sanei/sanei_pa4s2.c
index c15dd5a..d1be0c0 100644
--- a/sanei/sanei_pa4s2.c
+++ b/sanei/sanei_pa4s2.c
@@ -142,7 +142,7 @@ static int sanei_pa4s2_dbg_init_called = SANE_FALSE;
{ \
DBG_INIT(); \
DBG(6, "%s: interface called for" \
- " the first time\n", __PRETTY_FUNCTION__); \
+ " the first time\n", __func__); \
sanei_pa4s2_dbg_init_called = SANE_TRUE; \
}
@@ -309,7 +309,7 @@ pa4s2_init (SANE_Status *status)
if (first_time == SANE_FALSE)
{
- DBG (5, "pa4s2_init: sanei already initalized\n");
+ DBG (5, "pa4s2_init: sanei already initialized\n");
status = SANE_STATUS_GOOD;
return 0;
}
diff --git a/sanei/sanei_pp.c b/sanei/sanei_pp.c
index 6146d1e..dec84ee 100644
--- a/sanei/sanei_pp.c
+++ b/sanei/sanei_pp.c
@@ -126,9 +126,7 @@ inb( u_long port )
#elif defined(HAVE_LIBIEEE1284)
# include <ieee1284.h>
#else
-# if defined(__GNUC__)
-# warning "No I/O support for this architecture!"
-# endif
+# pragma message "No I/O support for this architecture!"
# define IO_SUPPORT_MISSING
#endif
@@ -697,7 +695,7 @@ pp_init( void )
#endif
if( first_time == SANE_FALSE ) {
- DBG( 5, "pp_init: already initalized\n" );
+ DBG( 5, "pp_init: already initialized\n" );
return SANE_STATUS_GOOD;
}
diff --git a/sanei/sanei_scsi.c b/sanei/sanei_scsi.c
index 6d171d3..2413d8f 100644
--- a/sanei/sanei_scsi.c
+++ b/sanei/sanei_scsi.c
@@ -96,7 +96,7 @@
#elif defined (HAVE__USR_SRC_LINUX_INCLUDE_SCSI_SG_H)
# define USE LINUX_INTERFACE
# include "/usr/src/linux/include/scsi/sg.h"
-#elif defined (HAVE_SYS_SCSICMD)
+#elif defined (HAVE_SYS_SCSICMD_H)
# define USE SCSO_OS5_INTERFACE
# include <sys/scsi.h>
# include <sys/scsicmd.h>
@@ -2719,7 +2719,7 @@ sanei_proc_scsi_find_devices (const char *findvendor, const char *findmodel,
int number, i, j, definedd;
char line[256], dev_name[128], *c1, *c2, ctmp;
- const char *string;
+ char *string;
FILE *proc_fp;
char *end;
struct
@@ -2818,7 +2818,7 @@ sanei_proc_scsi_find_devices (const char *findvendor, const char *findmodel,
while (!feof (proc_fp))
{
fgets (line, sizeof (line), proc_fp);
- string = sanei_config_skip_whitespace (line);
+ string = (char *) sanei_config_skip_whitespace (line);
while (*string)
{
@@ -2839,7 +2839,7 @@ sanei_proc_scsi_find_devices (const char *findvendor, const char *findmodel,
}
ctmp = *c2;
*c2 = 0;
- string = sanei_config_skip_whitespace (string);
+ string = (char *) sanei_config_skip_whitespace (string);
if (param[i].is_int)
{
diff --git a/sanei/sanei_tcp.c b/sanei/sanei_tcp.c
index a57d7c7..87a73d1 100644
--- a/sanei/sanei_tcp.c
+++ b/sanei/sanei_tcp.c
@@ -70,7 +70,7 @@ sanei_tcp_open(const char *host, int port, int *fdp)
#endif
DBG_INIT();
- DBG(1, "%s: host = %s, port = %d\n", __FUNCTION__, host, port);
+ DBG(1, "%s: host = %s, port = %d\n", __func__, host, port);
#ifdef HAVE_WINSOCK2_H
err = WSAStartup(MAKEWORD(2, 2), &wsaData);
diff --git a/sanei/sanei_thread.c b/sanei/sanei_thread.c
index 8db4a21..fcf52c1 100644
--- a/sanei/sanei_thread.c
+++ b/sanei/sanei_thread.c
@@ -71,9 +71,6 @@
#if !defined USE_PTHREAD && !defined HAVE_OS2_H && !defined __BEOS__
# include <sys/wait.h>
#endif
-#if defined USE_PTHREAD
-# include <pthread.h>
-#endif
#define BACKEND_NAME sanei_thread /**< name of this module for debugging */
@@ -135,9 +132,9 @@ sanei_thread_set_invalid( SANE_Pid *pid )
/* Return if PID is a valid PID or not. */
SANE_Bool
-sanei_thread_is_invalid( SANE_Pid pid )
+sanei_thread_is_valid( SANE_Pid pid )
{
- SANE_Bool rc = SANE_FALSE;
+ SANE_Bool rc = SANE_TRUE;
#ifdef WIN32
#ifdef WINPTHREAD_API
@@ -145,10 +142,10 @@ sanei_thread_is_invalid( SANE_Pid pid )
#else
if (pid.p == 0)
#endif
- rc = SANE_TRUE;
+ rc = SANE_FALSE;
#else
- if (pid == -1)
- rc = SANE_TRUE;
+ if (pid == (SANE_Pid) -1)
+ rc = SANE_FALSE;
#endif
return rc;
@@ -491,7 +488,7 @@ sanei_thread_waitpid( SANE_Pid pid, int *status )
#else
int ls;
#endif
- SANE_Pid result;
+ SANE_Pid result = pid;
int stat;
stat = 0;
diff --git a/sanei/sanei_usb.c b/sanei/sanei_usb.c
index f210d4f..e4b23dc 100644
--- a/sanei/sanei_usb.c
+++ b/sanei/sanei_usb.c
@@ -62,31 +62,22 @@
#include <dirent.h>
#include <time.h>
-/* for debug messages */
-#if __STDC_VERSION__ < 199901L
-# if __GNUC__ >= 2
-# define __func__ __FUNCTION__
-# else
-# define __func__ "<unknown>"
-# endif
-#endif
-
#ifdef HAVE_RESMGR
#include <resmgr.h>
#endif
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
#ifdef HAVE_LUSB0_USB_H
#include <lusb0_usb.h>
#else
#include <usb.h>
#endif
-#endif /* HAVE_LIBUSB */
+#endif /* HAVE_LIBUSB_LEGACY */
-#ifdef HAVE_LIBUSB_1_0
+#ifdef HAVE_LIBUSB
#include <libusb.h>
-#endif /* HAVE_LIBUSB_1_0 */
+#endif /* HAVE_LIBUSB */
#ifdef HAVE_USBCALLS
#include <usb.h>
@@ -156,14 +147,14 @@ typedef struct
SANE_Int interface_nr;
SANE_Int alt_setting;
SANE_Int missing;
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
usb_dev_handle *libusb_handle;
struct usb_device *libusb_device;
-#endif /* HAVE_LIBUSB */
-#ifdef HAVE_LIBUSB_1_0
+#endif /* HAVE_LIBUSB_LEGACY */
+#ifdef HAVE_LIBUSB
libusb_device *lu_device;
libusb_device_handle *lu_handle;
-#endif /* HAVE_LIBUSB_1_0 */
+#endif /* HAVE_LIBUSB */
}
device_list_type;
@@ -183,13 +174,13 @@ static int device_number=0;
* count number of time sanei_usb has been initialized */
static int initialized=0;
-#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0)
+#if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB)
static int libusb_timeout = 30 * 1000; /* 30 seconds */
-#endif /* HAVE_LIBUSB */
+#endif /* HAVE_LIBUSB_LEGACY */
-#ifdef HAVE_LIBUSB_1_0
+#ifdef HAVE_LIBUSB
static libusb_context *sanei_usb_ctx;
-#endif /* HAVE_LIBUSB_1_0 */
+#endif /* HAVE_LIBUSB */
#if defined (__linux__)
/* From /usr/src/linux/driver/usb/scanner.h */
@@ -266,7 +257,7 @@ print_buffer (const SANE_Byte * buffer, SANE_Int size)
}
}
-#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0)
+#if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB)
static void
kernel_get_vendor_product (int fd, const char *name, int *vendorID, int *productID)
{
@@ -340,7 +331,7 @@ kernel_get_vendor_product (int fd, const char *name, int *vendorID, int *product
#endif /* defined (__linux__), defined(__BEOS__), ... */
/* put more os-dependant stuff ... */
}
-#endif /* !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) */
+#endif /* !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) */
/**
* store the given device in device list if it isn't already
@@ -366,10 +357,10 @@ store_device (device_list_type device)
* Need to update the LibUSB device pointer, since it might
* have changed after the latest USB scan.
*/
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
devices[i].libusb_device = device.libusb_device;
#endif
-#ifdef HAVE_LIBUSB_1_0
+#ifdef HAVE_LIBUSB
devices[i].lu_device = device.lu_device;
#endif
@@ -408,7 +399,7 @@ store_device (device_list_type device)
devices[pos].open = SANE_FALSE;
}
-#ifdef HAVE_LIBUSB_1_0
+#ifdef HAVE_LIBUSB
static char *
sanei_libusb_strerror (int errcode)
{
@@ -462,14 +453,14 @@ sanei_libusb_strerror (int errcode)
return "Unknown libusb-1.0 error code";
}
}
-#endif /* HAVE_LIBUSB_1_0 */
+#endif /* HAVE_LIBUSB */
void
sanei_usb_init (void)
{
-#ifdef HAVE_LIBUSB_1_0
+#ifdef HAVE_LIBUSB
int ret;
-#endif /* HAVE_LIBUSB_1_0 */
+#endif /* HAVE_LIBUSB */
DBG_INIT ();
#ifdef DBG_LEVEL
@@ -483,18 +474,18 @@ sanei_usb_init (void)
memset (devices, 0, sizeof (devices));
/* initialize USB with old libusb library */
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
DBG (4, "%s: Looking for libusb devices\n", __func__);
usb_init ();
#ifdef DBG_LEVEL
if (DBG_LEVEL > 4)
usb_set_debug (255);
#endif /* DBG_LEVEL */
-#endif /* HAVE_LIBUSB */
+#endif /* HAVE_LIBUSB_LEGACY */
/* initialize USB using libusb-1.0 */
-#ifdef HAVE_LIBUSB_1_0
+#ifdef HAVE_LIBUSB
if (!sanei_usb_ctx)
{
DBG (4, "%s: initializing libusb-1.0\n", __func__);
@@ -511,9 +502,9 @@ sanei_usb_init (void)
libusb_set_debug (sanei_usb_ctx, 3);
#endif /* DBG_LEVEL */
}
-#endif /* HAVE_LIBUSB_1_0 */
+#endif /* HAVE_LIBUSB */
-#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0)
+#if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB)
DBG (4, "%s: SANE is built without support for libusb\n", __func__);
#endif
@@ -553,7 +544,7 @@ int i;
devices[i].devname=NULL;
}
}
-#ifdef HAVE_LIBUSB_1_0
+#ifdef HAVE_LIBUSB
if (sanei_usb_ctx)
{
libusb_exit (sanei_usb_ctx);
@@ -643,7 +634,7 @@ static void usbcall_scan_devices(void)
}
#endif /* HAVE_USBCALLS */
-#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0)
+#if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB)
/** scan for devices using kernel device.
* Check for devices using kernel device
*/
@@ -742,9 +733,9 @@ static void kernel_scan_devices(void)
closedir (dir);
}
}
-#endif /* !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0) */
+#endif /* !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) */
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
/** scan for devices using old libusb
* Check for devices using 0.1.x libusb
*/
@@ -855,9 +846,9 @@ static void libusb_scan_devices(void)
}
}
}
-#endif /* HAVE_LIBUSB */
+#endif /* HAVE_LIBUSB_LEGACY */
-#ifdef HAVE_LIBUSB_1_0
+#ifdef HAVE_LIBUSB
/** scan for devices using libusb
* Check for devices using libusb-1.0
*/
@@ -1031,7 +1022,7 @@ static void libusb_scan_devices(void)
libusb_free_device_list (devlist, 1);
}
-#endif /* HAVE_LIBUSB_1_0 */
+#endif /* HAVE_LIBUSB */
void
@@ -1057,11 +1048,11 @@ sanei_usb_scan_devices (void)
}
/* Check for devices using the kernel scanner driver */
-#if !defined(HAVE_LIBUSB) && !defined(HAVE_LIBUSB_1_0)
+#if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB)
kernel_scan_devices();
#endif
-#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0)
+#if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB)
/* Check for devices using libusb (old or new)*/
libusb_scan_devices();
#endif
@@ -1308,7 +1299,6 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
{
int devcount;
SANE_Bool found = SANE_FALSE;
- int c, i, a;
DBG (5, "sanei_usb_open: trying to open device `%s'\n", devname);
if (!dn)
@@ -1341,10 +1331,11 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
if (devices[devcount].method == sanei_usb_method_libusb)
{
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
struct usb_device *dev;
struct usb_interface_descriptor *interface;
int result, num;
+ int c, i, a;
devices[devcount].libusb_handle =
usb_open (devices[devcount].libusb_device);
@@ -1600,13 +1591,14 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
}
}
-#elif defined(HAVE_LIBUSB_1_0) /* libusb-1.0 */
+#elif defined(HAVE_LIBUSB) /* libusb-1.0 */
int config;
libusb_device *dev;
struct libusb_device_descriptor desc;
struct libusb_config_descriptor *config0;
int result, num;
+ int c, i, a;
dev = devices[devcount].lu_device;
@@ -1902,11 +1894,11 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
libusb_free_config_descriptor (config);
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
DBG (1, "sanei_usb_open: can't open device `%s': "
"libusb support missing\n", devname);
return SANE_STATUS_UNSUPPORTED;
-#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
}
else if (devices[devcount].method == sanei_usb_method_scanner_driver)
{
@@ -2108,6 +2100,17 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
void
sanei_usb_close (SANE_Int dn)
{
+ char *env;
+ int workaround = 0;
+
+ DBG (5, "sanei_usb_close: evaluating environment variable SANE_USB_WORKAROUND\n");
+ env = getenv ("SANE_USB_WORKAROUND");
+ if (env)
+ {
+ workaround = atoi(env);
+ DBG (5, "sanei_usb_close: workaround: %d\n", workaround);
+ }
+
DBG (5, "sanei_usb_close: closing device %d\n", dn);
if (dn >= device_number || dn < 0)
{
@@ -2133,31 +2136,37 @@ sanei_usb_close (SANE_Int dn)
#endif
}
else
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
{
/* This call seems to be required by Linux xhci driver
* even though it should be a no-op. Without it, the
* host or driver does not reset it's data toggle bit.
* We intentionally ignore the return val */
- sanei_usb_set_altinterface (dn, devices[dn].alt_setting);
+ if (workaround)
+ {
+ sanei_usb_set_altinterface (dn, devices[dn].alt_setting);
+ }
usb_release_interface (devices[dn].libusb_handle,
devices[dn].interface_nr);
usb_close (devices[dn].libusb_handle);
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
{
/* This call seems to be required by Linux xhci driver
* even though it should be a no-op. Without it, the
* host or driver does not reset it's data toggle bit.
* We intentionally ignore the return val */
- sanei_usb_set_altinterface (dn, devices[dn].alt_setting);
+ if (workaround)
+ {
+ sanei_usb_set_altinterface (dn, devices[dn].alt_setting);
+ }
libusb_release_interface (devices[dn].lu_handle,
devices[dn].interface_nr);
libusb_close (devices[dn].lu_handle);
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
DBG (1, "sanei_usb_close: libusb support missing\n");
#endif
devices[dn].open = SANE_FALSE;
@@ -2165,19 +2174,28 @@ sanei_usb_close (SANE_Int dn)
}
void
-sanei_usb_set_timeout (SANE_Int timeout)
+sanei_usb_set_timeout (SANE_Int __sane_unused__ timeout)
{
-#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0)
+#if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB)
libusb_timeout = timeout;
#else
DBG (1, "sanei_usb_set_timeout: libusb support missing\n");
-#endif /* HAVE_LIBUSB || HAVE_LIBUSB_1_0 */
+#endif /* HAVE_LIBUSB_LEGACY || HAVE_LIBUSB */
}
SANE_Status
sanei_usb_clear_halt (SANE_Int dn)
{
- int ret;
+ char *env;
+ int workaround = 0;
+
+ DBG (5, "sanei_usb_clear_halt: evaluating environment variable SANE_USB_WORKAROUND\n");
+ env = getenv ("SANE_USB_WORKAROUND");
+ if (env)
+ {
+ workaround = atoi(env);
+ DBG (5, "sanei_usb_clear_halt: workaround: %d\n", workaround);
+ }
if (dn >= device_number || dn < 0)
{
@@ -2185,13 +2203,17 @@ sanei_usb_clear_halt (SANE_Int dn)
return SANE_STATUS_INVAL;
}
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
+ int ret;
/* This call seems to be required by Linux xhci driver
* even though it should be a no-op. Without it, the
* host or driver does not send the clear to the device.
* We intentionally ignore the return val */
- sanei_usb_set_altinterface (dn, devices[dn].alt_setting);
+ if (workaround)
+ {
+ sanei_usb_set_altinterface (dn, devices[dn].alt_setting);
+ }
ret = usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_in_ep);
if (ret){
@@ -2205,13 +2227,17 @@ sanei_usb_clear_halt (SANE_Int dn)
return SANE_STATUS_INVAL;
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
+ int ret;
/* This call seems to be required by Linux xhci driver
* even though it should be a no-op. Without it, the
* host or driver does not send the clear to the device.
* We intentionally ignore the return val */
- sanei_usb_set_altinterface (dn, devices[dn].alt_setting);
+ if (workaround)
+ {
+ sanei_usb_set_altinterface (dn, devices[dn].alt_setting);
+ }
ret = libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_in_ep);
if (ret){
@@ -2224,17 +2250,17 @@ sanei_usb_clear_halt (SANE_Int dn)
DBG (1, "sanei_usb_clear_halt: BULK_OUT ret=%d\n", ret);
return SANE_STATUS_INVAL;
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
DBG (1, "sanei_usb_clear_halt: libusb support missing\n");
-#endif /* HAVE_LIBUSB || HAVE_LIBUSB_1_0 */
+#endif /* HAVE_LIBUSB_LEGACY || HAVE_LIBUSB */
return SANE_STATUS_GOOD;
}
SANE_Status
-sanei_usb_reset (SANE_Int dn)
+sanei_usb_reset (SANE_Int __sane_unused__ dn)
{
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
int ret;
ret = usb_reset (devices[dn].libusb_handle);
@@ -2243,7 +2269,7 @@ sanei_usb_reset (SANE_Int dn)
return SANE_STATUS_INVAL;
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
int ret;
ret = libusb_reset_device (devices[dn].lu_handle);
@@ -2252,9 +2278,9 @@ sanei_usb_reset (SANE_Int dn)
return SANE_STATUS_INVAL;
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
DBG (1, "sanei_usb_reset: libusb support missing\n");
-#endif /* HAVE_LIBUSB || HAVE_LIBUSB_1_0 */
+#endif /* HAVE_LIBUSB_LEGACY || HAVE_LIBUSB */
return SANE_STATUS_GOOD;
}
@@ -2287,7 +2313,7 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size)
strerror (errno));
}
else if (devices[dn].method == sanei_usb_method_libusb)
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
{
if (devices[dn].bulk_in_ep)
{
@@ -2306,14 +2332,14 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL;
}
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
{
if (devices[dn].bulk_in_ep)
{
- int ret;
+ int ret, rsize;
ret = libusb_bulk_transfer (devices[dn].lu_handle,
devices[dn].bulk_in_ep, buffer,
- (int) *size, (int *) &read_size,
+ (int) *size, &rsize,
libusb_timeout);
if (ret < 0)
@@ -2323,6 +2349,10 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size)
read_size = -1;
}
+ else
+ {
+ read_size = rsize;
+ }
}
else
{
@@ -2331,12 +2361,12 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL;
}
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
{
DBG (1, "sanei_usb_read_bulk: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED;
}
-#endif /* not HAVE_LIBUSB */
+#endif /* not HAVE_LIBUSB_LEGACY */
else if (devices[dn].method == sanei_usb_method_usbcalls)
{
#ifdef HAVE_USBCALLS
@@ -2382,10 +2412,10 @@ sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size)
if (read_size < 0)
{
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
if (devices[dn].method == sanei_usb_method_libusb)
usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_in_ep);
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
if (devices[dn].method == sanei_usb_method_libusb)
libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_in_ep);
#endif
@@ -2437,7 +2467,7 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size)
strerror (errno));
}
else if (devices[dn].method == sanei_usb_method_libusb)
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
{
if (devices[dn].bulk_out_ep)
{
@@ -2456,7 +2486,7 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL;
}
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
{
if (devices[dn].bulk_out_ep)
{
@@ -2464,7 +2494,7 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size)
int trans_bytes;
ret = libusb_bulk_transfer (devices[dn].lu_handle,
devices[dn].bulk_out_ep,
- buffer,
+ (unsigned char *) buffer,
(int) *size, &trans_bytes,
libusb_timeout);
if (ret < 0)
@@ -2484,12 +2514,12 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL;
}
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
{
DBG (1, "sanei_usb_write_bulk: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED;
}
-#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else if (devices[dn].method == sanei_usb_method_usbcalls)
{
#ifdef HAVE_USBCALLS
@@ -2537,10 +2567,10 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size)
if (write_size < 0)
{
*size = 0;
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
if (devices[dn].method == sanei_usb_method_libusb)
usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_out_ep);
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
if (devices[dn].method == sanei_usb_method_libusb)
libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_out_ep);
#endif
@@ -2616,7 +2646,7 @@ sanei_usb_control_msg (SANE_Int dn, SANE_Int rtype, SANE_Int req,
#endif /* not __linux__ */
}
else if (devices[dn].method == sanei_usb_method_libusb)
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
{
int result;
@@ -2633,7 +2663,7 @@ sanei_usb_control_msg (SANE_Int dn, SANE_Int rtype, SANE_Int req,
print_buffer (data, len);
return SANE_STATUS_GOOD;
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
{
int result;
@@ -2650,12 +2680,12 @@ sanei_usb_control_msg (SANE_Int dn, SANE_Int rtype, SANE_Int req,
print_buffer (data, len);
return SANE_STATUS_GOOD;
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0*/
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB*/
{
DBG (1, "sanei_usb_control_msg: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED;
}
-#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else if (devices[dn].method == sanei_usb_method_usbcalls)
{
#ifdef HAVE_USBCALLS
@@ -2692,7 +2722,7 @@ SANE_Status
sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size)
{
ssize_t read_size = 0;
-#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1_0)
+#if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB)
SANE_Bool stalled = SANE_FALSE;
#endif
@@ -2717,7 +2747,7 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL;
}
else if (devices[dn].method == sanei_usb_method_libusb)
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
{
if (devices[dn].int_in_ep)
{
@@ -2739,7 +2769,7 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL;
}
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
{
if (devices[dn].int_in_ep)
{
@@ -2764,12 +2794,12 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size)
return SANE_STATUS_INVAL;
}
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
{
DBG (1, "sanei_usb_read_int: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED;
}
-#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else if (devices[dn].method == sanei_usb_method_usbcalls)
{
#ifdef HAVE_USBCALLS
@@ -2808,11 +2838,11 @@ sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size)
if (read_size < 0)
{
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
if (devices[dn].method == sanei_usb_method_libusb)
if (stalled)
usb_clear_halt (devices[dn].libusb_handle, devices[dn].int_in_ep);
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
if (devices[dn].method == sanei_usb_method_libusb)
if (stalled)
libusb_clear_halt (devices[dn].lu_handle, devices[dn].int_in_ep);
@@ -2858,7 +2888,7 @@ sanei_usb_set_configuration (SANE_Int dn, SANE_Int configuration)
#endif /* not __linux__ */
}
else if (devices[dn].method == sanei_usb_method_libusb)
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
{
int result;
@@ -2872,7 +2902,7 @@ sanei_usb_set_configuration (SANE_Int dn, SANE_Int configuration)
}
return SANE_STATUS_GOOD;
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
{
int result;
@@ -2885,12 +2915,12 @@ sanei_usb_set_configuration (SANE_Int dn, SANE_Int configuration)
}
return SANE_STATUS_GOOD;
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
{
DBG (1, "sanei_usb_set_configuration: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED;
}
-#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else
{
DBG (1,
@@ -2928,7 +2958,7 @@ sanei_usb_claim_interface (SANE_Int dn, SANE_Int interface_number)
#endif /* not __linux__ */
}
else if (devices[dn].method == sanei_usb_method_libusb)
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
{
int result;
@@ -2941,7 +2971,7 @@ sanei_usb_claim_interface (SANE_Int dn, SANE_Int interface_number)
}
return SANE_STATUS_GOOD;
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
{
int result;
@@ -2954,12 +2984,12 @@ sanei_usb_claim_interface (SANE_Int dn, SANE_Int interface_number)
}
return SANE_STATUS_GOOD;
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
{
DBG (1, "sanei_usb_claim_interface: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED;
}
-#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else
{
DBG (1, "sanei_usb_claim_interface: access method %d not implemented\n",
@@ -2995,7 +3025,7 @@ sanei_usb_release_interface (SANE_Int dn, SANE_Int interface_number)
#endif /* not __linux__ */
}
else if (devices[dn].method == sanei_usb_method_libusb)
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
{
int result;
@@ -3008,7 +3038,7 @@ sanei_usb_release_interface (SANE_Int dn, SANE_Int interface_number)
}
return SANE_STATUS_GOOD;
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
{
int result;
@@ -3021,12 +3051,12 @@ sanei_usb_release_interface (SANE_Int dn, SANE_Int interface_number)
}
return SANE_STATUS_GOOD;
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
{
DBG (1, "sanei_usb_release_interface: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED;
}
-#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else
{
DBG (1,
@@ -3061,7 +3091,7 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate)
#endif /* not __linux__ */
}
else if (devices[dn].method == sanei_usb_method_libusb)
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
{
int result;
@@ -3074,7 +3104,7 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate)
}
return SANE_STATUS_GOOD;
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
{
int result;
@@ -3088,12 +3118,12 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate)
}
return SANE_STATUS_GOOD;
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
{
DBG (1, "sanei_set_altinterface: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED;
}
-#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
else
{
DBG (1,
@@ -3104,7 +3134,9 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate)
}
extern SANE_Status
-sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc )
+sanei_usb_get_descriptor( SANE_Int dn,
+ struct sanei_usb_dev_descriptor __sane_unused__
+ *desc )
{
if (dn >= device_number || dn < 0)
{
@@ -3115,7 +3147,7 @@ sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc )
}
DBG (5, "sanei_usb_get_descriptor\n");
-#ifdef HAVE_LIBUSB
+#ifdef HAVE_LIBUSB_LEGACY
{
struct usb_device_descriptor *usb_descr;
@@ -3130,7 +3162,7 @@ sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc )
desc->max_packet_size = usb_descr->bMaxPacketSize0;
return SANE_STATUS_GOOD;
}
-#elif defined(HAVE_LIBUSB_1_0)
+#elif defined(HAVE_LIBUSB)
{
struct libusb_device_descriptor lu_desc;
int ret;
@@ -3155,10 +3187,10 @@ sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc )
desc->max_packet_size = lu_desc.bMaxPacketSize0;
return SANE_STATUS_GOOD;
}
-#else /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#else /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
{
DBG (1, "sanei_usb_get_descriptor: libusb support missing\n");
return SANE_STATUS_UNSUPPORTED;
}
-#endif /* not HAVE_LIBUSB && not HAVE_LIBUSB_1_0 */
+#endif /* not HAVE_LIBUSB_LEGACY && not HAVE_LIBUSB */
}