Mail archive
alpine-aports

[alpine-aports] [PATCH] testing/sane: new port

From: Fabio Riga <rifabio_at_dpersonam.me>
Date: Fri, 27 Feb 2015 17:27:16 +0000

http://www.sane-project.org
Scanner Access Now Easy
---
 testing/sane/10-network.patch                    |    42 +
 testing/sane/20-segfault-avahi-fix-kodakio.patch |    98 +
 testing/sane/30-musl.patch                       | 11719 +++++++++++++++++++++
 testing/sane/APKBUILD                            |    75 +
 4 files changed, 11934 insertions(+)
 create mode 100644 testing/sane/10-network.patch
 create mode 100644 testing/sane/20-segfault-avahi-fix-kodakio.patch
 create mode 100644 testing/sane/30-musl.patch
 create mode 100644 testing/sane/APKBUILD
diff --git a/testing/sane/10-network.patch b/testing/sane/10-network.patch
new file mode 100644
index 0000000..2605ea8
--- /dev/null
+++ b/testing/sane/10-network.patch
_at_@ -0,0 +1,42 @@
+diff --git a/sanei/sanei_tcp.c b/sanei/sanei_tcp.c
+index a57d7c7..d0a1e92 100644
+--- a/sanei/sanei_tcp.c
++++ b/sanei/sanei_tcp.c
+_at_@ -45,6 +45,7 @@
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <time.h>
+ 
+ #ifdef HAVE_WINSOCK2_H
+ #include <winsock2.h>
+_at_@ -123,14 +124,27 @@ sanei_tcp_write(int fd, const u_char * buf, int count)
+ ssize_t
+ sanei_tcp_read(int fd, u_char * buf, int count)
+ {
+-        ssize_t bytes_recv = 0, rc = 1;
++    ssize_t bytes_recv = 0, rc = 1;
++	int retry = 5;
+ 
+ 	while (bytes_recv < count && rc > 0)
+ 	{
+ 		rc = recv(fd, buf+bytes_recv, count-bytes_recv, 0);
++		DBG(1, "%s: bytes received %d\n", __FUNCTION__, rc);
+ 		if (rc > 0)
+ 		  bytes_recv += rc;
+-
++		else {
++			if ( errno == EAGAIN && retry-- ) {
++				DBG(1, "%s: waiting  %d\n", __FUNCTION__, retry);
++				/* wait for max 1s */
++				struct timespec req;
++				struct timespec rem;
++				req.tv_sec = 0;
++				req.tv_nsec= 100000000;
++				nanosleep(&req, &rem);	
++				rc = 1;
++			}
++		}
+ 	}
+ 	return bytes_recv;
+ }
diff --git a/testing/sane/20-segfault-avahi-fix-kodakio.patch b/testing/sane/20-segfault-avahi-fix-kodakio.patch
new file mode 100644
index 0000000..23f9d1c
--- /dev/null
+++ b/testing/sane/20-segfault-avahi-fix-kodakio.patch
_at_@ -0,0 +1,98 @@
+From 37523b867d411c2f82d08128246be7e38bc9812c Mon Sep 17 00:00:00 2001
+From: Paul Newall <quandry_at_ntlworld.com>
+Date: Mon, 14 Oct 2013 22:22:53 +0100
+Subject: [PATCH] Bugfix in kodakaio.c to fix segfault when non kodak scanners
+ return unexpected data via avahi auto discovery
+
+---
+ backend/kodakaio.c             |   43 ++++++++++++++++++++++++++++++----------
+ doc/descriptions/kodakaio.desc |    2 +-
+ 3 files changed, 37 insertions(+), 12 deletions(-)
+
+diff --git a/backend/kodakaio.c b/backend/kodakaio.c
+index 8c4583a..b442e50 100644
+--- a/backend/kodakaio.c
++++ b/backend/kodakaio.c
+_at_@ -127,7 +127,7 @@ for ubuntu 12.10
+ 
+ #define KODAKAIO_VERSION	02
+ #define KODAKAIO_REVISION	4
+-#define KODAKAIO_BUILD		6
++#define KODAKAIO_BUILD		7
+ 
+ /* for usb (but also used for net though it's not required). */
+ #define MAX_BLOCK_SIZE		32768
+_at_@ -2184,6 +2184,7 @@ static void resolve_callback(
+     AvahiLookupResultFlags flags,
+     AVAHI_GCC_UNUSED void* userdata) {
+ 
++	AvahiStringList *vid_pair_list = NULL, *pid_pair_list = NULL;
+ 	char *pidkey, *pidvalue;
+ 	char *vidkey, *vidvalue;
+ 	size_t valuesize;
+_at_@ -2204,20 +2205,40 @@ static void resolve_callback(
+             avahi_address_snprint(a, sizeof(a), address);
+ 
+ /* Output short for Kodak ESP */
+-	DBG(min(10,DBG_AUTO), "%s:%u  %s  ", a,port,host_name);
+-	avahi_string_list_get_pair(avahi_string_list_find(txt, "vid"), 
+-		&vidkey, &vidvalue, &valuesize);
+-	DBG(min(10,DBG_AUTO), "%s=%s  ", vidkey, vidvalue);
+-	avahi_string_list_get_pair(avahi_string_list_find(txt, "pid"), 
+-		&pidkey, &pidvalue, &valuesize);
+-	DBG(min(10,DBG_AUTO), "%s=%s\n", pidkey, pidvalue);
++	DBG(min(10,DBG_AUTO), "%s:%u  %s\n", a,port,host_name);
+ 
++	vid_pair_list = avahi_string_list_find(txt, "vid");
++	if(vid_pair_list != NULL) {
++		avahi_string_list_get_pair(vid_pair_list, &vidkey, &vidvalue, &valuesize);
++		DBG(min(10,DBG_AUTO), "%s=%s  ", vidkey, vidvalue);
++	}
++	else	DBG(min(10,DBG_AUTO), "failed to find key vid\n");
++
++	pid_pair_list = avahi_string_list_find(txt, "pid");
++	if(pid_pair_list != NULL) {
++		avahi_string_list_get_pair(pid_pair_list, &pidkey, &pidvalue, &valuesize);
++		DBG(min(10,DBG_AUTO), "%s=%s\n", pidkey, pidvalue);
++	}
++	else	DBG(min(10,DBG_AUTO), "failed to find key pid\n");
++
++	if(pid_pair_list != NULL && vid_pair_list != NULL) {
+ 		ProcessAvahiDevice(name, vidvalue, pidvalue, a);
+-	avahi_free(vidkey); avahi_free(vidvalue);
+-	avahi_free(pidkey); avahi_free(pidvalue);
++	}
++	else DBG(min(10,DBG_AUTO), "didn't call ProcessAvahiDevice\n");
++
++	if(vid_pair_list != NULL) {
++		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(pidvalue);
++		DBG(min(15,DBG_AUTO), "pidkey and pidvalue freed\n");
++	}
+         }
+     }
+-
++    DBG(min(10,DBG_AUTO), "ending resolve_callback\n");
+     avahi_service_resolver_free(r);
+ }
+ 
+diff --git a/doc/descriptions/kodakaio.desc b/doc/descriptions/kodakaio.desc
+index 7882513..5fb18ed 100644
+--- a/doc/descriptions/kodakaio.desc
++++ b/doc/descriptions/kodakaio.desc
+_at_@ -1,6 +1,6 @@
+ :backend "kodakaio"
+ :url "http://sourceforge.net/projects/cupsdriverkodak/" 
+-:version "2.4.6"
++:version "2.4.7"
+ :manpage "sane-kodakaio"
+ :comment "Backend for Kodak AiO ESP and Hero printers. Also possibly Advent AWL10"
+ :devicetype :scanner
+-- 
+1.7.10.4
+
diff --git a/testing/sane/30-musl.patch b/testing/sane/30-musl.patch
new file mode 100644
index 0000000..509a0cd
--- /dev/null
+++ b/testing/sane/30-musl.patch
_at_@ -0,0 +1,11719 @@
+--- sane-backends-1.0.24.orig/backend/abaton.c
++++ sane-backends-1.0.24/backend/abaton.c
+_at_@ -235,7 +235,7 @@
+ }
+ 
+ static SANE_Status
+-sense_handler (int scsi_fd, u_char * result, void *arg)
++sense_handler (int scsi_fd, unsigned char * result, void *arg)
+ {
+   scsi_fd = scsi_fd;			/* silence gcc */
+   arg = arg;					/* silence gcc */
+--- sane-backends-1.0.24.orig/backend/agfafocus.c
++++ sane-backends-1.0.24/backend/agfafocus.c
+_at_@ -233,7 +233,7 @@
+ }
+ 
+ static SANE_Status
+-sense_handler (int scsi_fd, u_char *result, void *arg)
++sense_handler (int scsi_fd, unsigned char *result, void *arg)
+ {
+   scsi_fd = scsi_fd;			/* silence gcc */
+   arg = arg;					/* silence gcc */
+_at_@ -771,11 +771,11 @@
+   if (size != ((unsigned int) lines * bpl))
+     {
+       DBG (1, "sanei_scsi_cmd(): got %lu bytes, expected %d\n",
+-	   (u_long) size, lines * bpl);
++	   (unsigned long) size, lines * bpl);
+       return SANE_STATUS_INVAL;
+     }
+   
+-  DBG (1, "Got %lu bytes\n", (u_long) size);
++  DBG (1, "Got %lu bytes\n", (unsigned long) size);
+ 
+   /* Reverse: */
+   if (s->bpp != 1)
+_at_@ -1839,7 +1839,7 @@
+   data = malloc (lines_per_buffer * bytes_per_line);
+   if (!data)
+     {
+-      DBG (1, "open  malloc(%lu) failed.\n", (u_long) lines_per_buffer * bytes_per_line);
++      DBG (1, "open  malloc(%lu) failed.\n", (unsigned long) lines_per_buffer * bytes_per_line);
+       do_cancel (s);
+       close (fd);
+       return 1;
+--- sane-backends-1.0.24.orig/backend/apple.c
++++ sane-backends-1.0.24/backend/apple.c
+_at_@ -312,7 +312,7 @@
+ 	  if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME)
+ 	    {
+ 	      DBG (ERROR_MESSAGE, "wait_ready: timed out after %lu seconds\n",
+-		   (u_long) now.tv_sec - start.tv_sec);
++		   (unsigned long) now.tv_sec - start.tv_sec);
+ 	      return SANE_STATUS_INVAL;
+ 	    }
+ 	  usleep (100000);	/* retry after 100ms */
+_at_@ -327,7 +327,7 @@
+ }
+ 
+ static SANE_Status
+-sense_handler (int scsi_fd, u_char * result, void *arg)
++sense_handler (int scsi_fd, unsigned char * result, void *arg)
+ {
+   scsi_fd = scsi_fd;			/* silence gcc */
+   arg = arg;					/* silence gcc */
+--- sane-backends-1.0.24.orig/backend/artec.c
++++ sane-backends-1.0.24/backend/artec.c
+_at_@ -385,7 +385,7 @@
+ /* DB added a sense handler */
+ /* last argument is expected to be a pointer to a Artec_Scanner structure */
+ static SANE_Status
+-sense_handler (int fd, u_char * sense, void *arg)
++sense_handler (int fd, unsigned char * sense, void *arg)
+ {
+   ARTEC_Scanner *s = (ARTEC_Scanner *)arg;
+   int err;
+_at_@ -735,9 +735,9 @@
+ 
+ 
+ static SANE_Status
+-read_data (int fd, int data_type_code, u_char * dest, size_t * len)
++read_data (int fd, int data_type_code, unsigned char * dest, size_t * len)
+ {
+-  static u_char read_6[10];
++  static unsigned char read_6[10];
+ 
+   DBG (7, "read_data()\n");
+ 
+_at_@ -754,8 +754,8 @@
+ static int
+ artec_get_status (int fd)
+ {
+-  u_char write_10[10];
+-  u_char read_12[12];
++  unsigned char write_10[10];
++  unsigned char read_12[12];
+   size_t nread;
+ 
+   DBG (7, "artec_get_status()\n");
+_at_@ -769,7 +769,7 @@
+   sanei_scsi_cmd (fd, write_10, 10, read_12, &nread);
+ 
+   nread = (read_12[9] << 16) + (read_12[10] << 8) + read_12[11];
+-  DBG (9, "artec_status: %lu\n", (u_long) nread);
++  DBG (9, "artec_status: %lu\n", (unsigned long) nread);
+ 
+   return (nread);
+ }
+_at_@ -902,7 +902,7 @@
+       cur_line = 0;
+ 
+       DBG (9, "buffer_line_offset: offset = %d, len = %lu\n",
+-	   line_offset, (u_long) * len);
++	   line_offset, (unsigned long) * len);
+ 
+       tmp_line_buf = malloc (*len);
+       if (tmp_line_buf == NULL)
+_at_@ -1283,7 +1283,7 @@
+ 	      s->y_resolution));
+ 
+   DBG (5, "  Image Comp. : %s\n", s->mode);
+-  DBG (5, "  Line Offset : %lu\n", (u_long) s->line_offset);
++  DBG (5, "  Line Offset : %lu\n", (unsigned long) s->line_offset);
+ 
+   memset (write_6, 0, 4096);
+   write_6[0] = 0x24;
+_at_@ -1581,7 +1581,7 @@
+ {
+   ARTEC_Scanner *s = handle;
+   SANE_Status status;		/* DB added */
+-  u_char buf[76800];		/* should be big enough */
++  unsigned char buf[76800];		/* should be big enough */
+   size_t len;
+   SANE_Word save_x_resolution;
+   SANE_Word save_pixels_per_line;
+_at_@ -1712,7 +1712,7 @@
+ {
+   int cap_model, loop;
+   SANE_Status status;
+-  u_char cap_buf[256];		/* buffer for cap data */
++  unsigned char cap_buf[256];		/* buffer for cap data */
+ 
+   DBG (7, "artec_get_cap_data()\n");
+ 
+_at_@ -2622,7 +2622,7 @@
+ 	continue;
+ 
+       DBG (50, "%s line: '%s', len = %lu\n", ARTEC_CONFIG_FILE, cp,
+-	   (u_long) len);
++	   (unsigned long) len);
+ 
+       /* check to see if they forced a vendor string in artec.conf */
+       if ((strncmp (cp, "vendor", 6) == 0) && isspace (cp[6]))
+_at_@ -3365,7 +3365,7 @@
+   DBG (9, "%d pixels per line, %d bytes, %d lines high, xdpi = %d, "
+        "ydpi = %d, btr = %lu\n",
+        s->params.pixels_per_line, s->params.bytes_per_line, s->params.lines,
+-       s->x_resolution, s->y_resolution, (u_long) s->bytes_to_read);
++       s->x_resolution, s->y_resolution, (unsigned long) s->bytes_to_read);
+ 
+   /* DAL: For single pass scans and the first pass of a 3 pass scan */
+   if ((strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) != 0) || !s->threepasscolor ||
+_at_@ -3511,7 +3511,7 @@
+   while ((rows_read < max_ret_rows) && (rows_read < remaining_rows))
+     {
+       DBG (50, "top of while loop, rr = %lu, mrr = %lu, rem = %lu\n",
+-	   (u_long) rows_read, (u_long) max_ret_rows, (u_long) remaining_rows);
++	   (unsigned long) rows_read, (unsigned long) max_ret_rows, (unsigned long) remaining_rows);
+ 
+       if (s->bytes_to_read - bytes_read <= s->params.bytes_per_line * max_read_rows)
+ 	{
+_at_@ -3555,11 +3555,11 @@
+ 	}
+ 
+       DBG (50, "rows_available = %lu, params.lines = %d, bytes_per_line = %d\n",
+-	   (u_long) rows_available, s->params.lines, s->params.bytes_per_line);
++	   (unsigned long) rows_available, s->params.lines, s->params.bytes_per_line);
+       DBG (50, "bytes_to_read = %lu, max_len = %d, max_rows = %lu\n",
+-	   (u_long) s->bytes_to_read, max_len, (u_long) max_ret_rows);
++	   (unsigned long) s->bytes_to_read, max_len, (unsigned long) max_ret_rows);
+       DBG (50, "nread = %lu, lread = %lu, bytes_read = %lu, rows_read = %lu\n",
+-	   (u_long) nread, (u_long) lread, (u_long) bytes_read, (u_long) rows_read);
++	   (unsigned long) nread, (unsigned long) lread, (unsigned long) bytes_read, (unsigned long) rows_read);
+ 
+       status = read_data (s->fd, ARTEC_DATA_IMAGE, temp_buf, &nread);
+ 
+_at_@ -3654,7 +3654,7 @@
+   s->bytes_to_read -= bytes_read;
+ 
+   DBG (9, "artec_sane_read() returning, we read %lu bytes, %lu left\n",
+-       (u_long) * len, (u_long) s->bytes_to_read);
++       (unsigned long) * len, (unsigned long) s->bytes_to_read);
+ 
+   if ((s->bytes_to_read == 0) &&
+       (s->hw->flags & ARTEC_FLAG_RGB_LINE_OFFSET) &&
+--- sane-backends-1.0.24.orig/backend/artec_eplus48u.c
++++ sane-backends-1.0.24/backend/artec_eplus48u.c
+_at_@ -1471,7 +1471,7 @@
+   if (!dev)
+     {
+       XDBG ((3, "%s: couldn't malloc %lu bytes for device\n",
+-	     function_name, (u_long) sizeof (Artec48U_Device)));
++	     function_name, (unsigned long) sizeof (Artec48U_Device)));
+       *dev_return = 0;
+       return SANE_STATUS_NO_MEM;
+     }
+_at_@ -3718,7 +3718,7 @@
+ 
+   /*read values */
+   cnt = fwrite (s->shading_buffer_b, sizeof (unsigned char), 30720*s->dev->epro_mult, f); /*epro*/
+-  XDBG ((1, "Wrote %li bytes to black shading buffer \n", (u_long) cnt));
++  XDBG ((1, "Wrote %li bytes to black shading buffer \n", (unsigned long) cnt));
+   if (cnt != (30720*s->dev->epro_mult))/*epro*/
+     {
+       fclose (f);
+--- sane-backends-1.0.24.orig/backend/as6e.c
++++ sane-backends-1.0.24/backend/as6e.c
+_at_@ -274,7 +274,7 @@
+     }				/*while there's space in the buffer */
+   s->image_counter += *len;
+   DBG (3, "image ctr = %d bytes_to_read = %lu returning %d\n",
+-       s->image_counter, (u_long) s->bytes_to_read, *len);
++       s->image_counter, (unsigned long) s->bytes_to_read, *len);
+ 
+   return SANE_STATUS_GOOD;
+ }
+--- sane-backends-1.0.24.orig/backend/avision.c
++++ sane-backends-1.0.24/backend/avision.c
+_at_@ -1383,7 +1383,7 @@
+   DBG (dbg_level, "%s", info);
+   for (i = 0; i < count; ++ i) {
+     DBG (dbg_level, "  [%lu] %1d%1d%1d%1d%1d%1d%1d%1db %3oo %3dd %2xx\n",
+-	 (u_long) i,
++	 (unsigned long) i,
+ 	 BIT(data[i],7), BIT(data[i],6), BIT(data[i],5), BIT(data[i],4),
+ 	 BIT(data[i],3), BIT(data[i],2), BIT(data[i],1), BIT(data[i],0),
+ 	 data[i], data[i], data[i]);
+_at_@ -1926,7 +1926,7 @@
+       status = sanei_usb_read_bulk (av_con->usb_dn, usb_status,
+ 				    &count);
+       DBG (5, "<== (bulk read) got: %ld, status: %d\n",
+-	   (u_long)count, valid_status(status, usb_status[0]));
++	   (unsigned long)count, valid_status(status, usb_status[0]));
+ 
+       if (count > 0) {
+ 	av_con->usb_status = AVISION_USB_BULK_STATUS;
+_at_@ -1950,7 +1950,7 @@
+     status = sanei_usb_read_int (av_con->usb_dn, usb_status,
+ 				 &count);
+     DBG (5, "<== (interrupt read) got: %ld, status: %d\n",
+-	 (u_long)count, valid_status(status, usb_status[0]));
++	 (unsigned long)count, valid_status(status, usb_status[0]));
+     
+     if (count > 0)
+       av_con->usb_status = AVISION_USB_INT_STATUS;
+_at_@ -2066,7 +2066,7 @@
+     /* 1st send command data - at least 10 Bytes for USB scanners */
+     uint8_t enlarged_cmd [min_usb_size];
+     if (cmd_size < min_usb_size) {
+-      DBG (1, "filling command to have a length of 10, was: %lu\n", (u_long) cmd_size);
++      DBG (1, "filling command to have a length of 10, was: %lu\n", (unsigned long) cmd_size);
+       memcpy (enlarged_cmd, m_cmd, cmd_size);
+       memset (enlarged_cmd + cmd_size, 0, min_usb_size - cmd_size);
+       m_cmd = enlarged_cmd;
+_at_@ -2097,10 +2097,10 @@
+     count = cmd_size;
+ 
+     sanei_usb_set_timeout (write_timeout);
+-    DBG (8, "try to write cmd, count: %lu.\n", (u_long) count);
++    DBG (8, "try to write cmd, count: %lu.\n", (unsigned long) count);
+     status = sanei_usb_write_bulk (av_con->usb_dn, m_cmd, &count);
+       
+-    DBG (8, "wrote %lu bytes\n", (u_long) count);
++    DBG (8, "wrote %lu bytes\n", (unsigned long) count);
+     if (status != SANE_STATUS_GOOD || count != cmd_size) {
+       DBG (3, "=== Got error %d trying to write, wrote: %ld. ===\n",
+            status, (long)count);
+_at_@ -2129,11 +2129,11 @@
+       /* if (count > max_usb_size)
+   	   count = max_usb_size; */
+       
+-      DBG (8, "try to write src, count: %lu.\n", (u_long) count);
++      DBG (8, "try to write src, count: %lu.\n", (unsigned long) count);
+       sanei_usb_set_timeout (write_timeout);
+       status = sanei_usb_write_bulk (av_con->usb_dn, &(m_src[i]), &count);
+       
+-      DBG (8, "wrote %lu bytes\n", (u_long) count);
++      DBG (8, "wrote %lu bytes\n", (unsigned long) count);
+       if (status == SANE_STATUS_GOOD) {
+ 	i += count;
+       }
+_at_@ -2149,10 +2149,10 @@
+       while (out_count < *dst_size) {
+ 	count = (*dst_size - out_count);
+ 	
+-	DBG (8, "try to read %lu bytes\n", (u_long) count);
++	DBG (8, "try to read %lu bytes\n", (unsigned long) count);
+         status = sanei_usb_read_bulk(av_con->usb_dn, &(m_dst[out_count]),
+ 				     &count);
+-	DBG (8, "read %lu bytes\n", (u_long) count);
++	DBG (8, "read %lu bytes\n", (unsigned long) count);
+ 
+ 	if (count == 1 && (*dst_size - out_count > 1)) {
+ 	  DBG (1, "Got 1 byte - status? (%d) Resending.\n", m_dst[out_count]);
+_at_@ -2198,11 +2198,11 @@
+       
+       count = sizeof(sense_cmd);
+       
+-      DBG (8, "try to write %lu bytes\n", (u_long) count);
++      DBG (8, "try to write %lu bytes\n", (unsigned long) count);
+       sanei_usb_set_timeout (write_timeout);
+       status = sanei_usb_write_bulk (av_con->usb_dn,
+ 				     (uint8_t*) &sense_cmd, &count);
+-      DBG (8, "wrote %lu bytes\n", (u_long) count);
++      DBG (8, "wrote %lu bytes\n", (unsigned long) count);
+       
+       if (status != SANE_STATUS_GOOD) {
+ 	DBG (3, "=== Got error %d trying to request sense! ===\n", status);
+_at_@ -2210,10 +2210,10 @@
+       else {
+ 	count = sizeof (sense_buffer);
+ 	
+-	DBG (8, "try to read %lu bytes sense data\n", (u_long) count);
++	DBG (8, "try to read %lu bytes sense data\n", (unsigned long) count);
+ 	sanei_usb_set_timeout (read_timeout);
+ 	status = sanei_usb_read_bulk(av_con->usb_dn, sense_buffer, &count);
+-	DBG (8, "read %lu bytes sense data\n", (u_long) count);
++	DBG (8, "read %lu bytes sense data\n", (unsigned long) count);
+ 	
+ 	/* we need to read out the status from the scanner i/o buffer */
+ 	status = avision_usb_status (av_con, 1, status_timeout);
+_at_@ -2750,7 +2750,7 @@
+   
+   for (try = 0; try < 90; ++ try) {
+     
+-    DBG (5, "wait_4_light: read bytes %lu\n", (u_long) size);
++    DBG (5, "wait_4_light: read bytes %lu\n", (unsigned long) size);
+     status = avision_cmd (&s->av_con, &rcmd, sizeof (rcmd), 0, 0, &result, &size);
+     
+     if (status != SANE_STATUS_GOOD || size != sizeof (result)) {
+_at_@ -4522,7 +4522,7 @@
+   set_double (rcmd.datatypequal, s->hw->data_dq);
+   set_triple (rcmd.transferlen, size);
+   
+-  DBG (3, "get_calib_format: read_data: %lu bytes\n", (u_long) size);
++  DBG (3, "get_calib_format: read_data: %lu bytes\n", (unsigned long) size);
+   status = avision_cmd (&s->av_con, &rcmd, sizeof (rcmd), 0, 0, result, &size);
+   if (status != SANE_STATUS_GOOD || size != sizeof (result) ) {
+     DBG (1, "get_calib_format: read calib. info failed (%s)\n",
+_at_@ -4579,7 +4579,7 @@
+   chunk_size = calib_size;
+   
+   DBG (3, "get_calib_data: type %x, size %lu, chunk_size: %lu\n",
+-       data_type, (u_long) calib_size, (u_long) chunk_size);
++       data_type, (unsigned long) calib_size, (unsigned long) chunk_size);
+   
+   memset (&rcmd, 0, sizeof (rcmd));
+   
+_at_@ -4685,7 +4685,7 @@
+     {
+       size_t send_size = elements_per_line * 2;
+       DBG (3, "set_calib_data: all channels in one command\n");
+-      DBG (3, "set_calib_data: send_size: %lu\n", (u_long) send_size);
++      DBG (3, "set_calib_data: send_size: %lu\n", (unsigned long) send_size);
+       
+       memset (&scmd, 0, sizeof (scmd) );
+       scmd.opc = AVISION_SCSI_SEND;
+_at_@ -5170,9 +5170,9 @@
+   gamma_values = gamma_table_size / 256;
+   
+   DBG (3, "send_gamma: table_raw_size: %lu, table_size: %lu\n",
+-       (u_long) gamma_table_raw_size, (u_long) gamma_table_size);
++       (unsigned long) gamma_table_raw_size, (unsigned long) gamma_table_size);
+   DBG (3, "send_gamma: values: %lu, invert_table: %d\n",
+-       (u_long) gamma_values, invert_table);
++       (unsigned long) gamma_values, invert_table);
+   
+   /* prepare for emulating contrast, brightness ... via the gamma-table */
+   brightness = SANE_UNFIX (s->val[OPT_BRIGHTNESS].w);
+_at_@ -5267,7 +5267,7 @@
+       }
+       
+       DBG (4, "send_gamma: sending %lu bytes gamma table.\n",
+-	   (u_long) gamma_table_raw_size);
++	   (unsigned long) gamma_table_raw_size);
+       status = avision_cmd (&s->av_con, &scmd, sizeof (scmd),
+ 			    gamma_data, gamma_table_raw_size, 0, 0);
+       
+_at_@ -5363,7 +5363,7 @@
+   set_double (rcmd.datatypequal, s->hw->data_dq);
+   set_triple (rcmd.transferlen, size);
+   
+-  DBG (3, "get_acceleration_info: read_data: %lu bytes\n", (u_long) size);
++  DBG (3, "get_acceleration_info: read_data: %lu bytes\n", (unsigned long) size);
+   status = avision_cmd (&s->av_con, &rcmd, sizeof (rcmd), 0, 0, result, &size);
+   if (status != SANE_STATUS_GOOD || size != sizeof (result) ) {
+     DBG (1, "get_acceleration_info: read accel. info failed (%s)\n",
+_at_@ -5866,7 +5866,7 @@
+       this_read = bytes_per_line * this_lines;
+       
+       DBG (3, "get_background_raster: line: %d, lines: %d, %lu bytes\n",
+-	   i, this_lines, (u_long) this_read);
++	   i, this_lines, (unsigned long) this_read);
+ 
+       set_triple (rcmd.transferlen, this_read);
+       
+_at_@ -6166,7 +6166,7 @@
+     SET_BIT(cmd.bitset1,7);
+   }
+   
+-  DBG (3, "start_scan: sending command. Bytes: %lu\n", (u_long) size);
++  DBG (3, "start_scan: sending command. Bytes: %lu\n", (unsigned long) size);
+   return avision_cmd (&s->av_con, &cmd, size, 0, 0, 0, 0);
+ }
+ 
+_at_@ -6230,7 +6230,7 @@
+   struct command_read rcmd;
+   SANE_Status status;
+ 
+-  DBG (9, "read_data: %lu\n", (u_long) *count);
++  DBG (9, "read_data: %lu\n", (unsigned long) *count);
+   
+   memset (&rcmd, 0, sizeof (rcmd));
+   
+_at_@ -6891,7 +6891,7 @@
+ 					       s->avdimen.rear_offset);
+   if (deinterlace != NONE && !s->duplex_rear_valid)
+     total_size *= 2;
+-  DBG (3, "reader_process: total_size: %lu\n", (u_long) total_size);
++  DBG (3, "reader_process: total_size: %lu\n", (unsigned long) total_size);
+   
+   /* write a RAW PNM file for debugging -ReneR */
+   if (0 /* DEBUG */ &&
+_at_@ -6944,8 +6944,8 @@
+           read_constrains(s, this_read);
+ 
+ 	  DBG (5, "reader_process: processed_bytes: %lu, total_size: %lu\n",
+-	       (u_long) processed_bytes, (u_long) total_size);
+-	  DBG (5, "reader_process: this_read: %lu\n", (u_long) this_read);
++	       (unsigned long) processed_bytes, (unsigned long) total_size);
++	  DBG (5, "reader_process: this_read: %lu\n", (unsigned long) this_read);
+ 
+ 	  sigprocmask (SIG_BLOCK, &sigterm_set, 0);
+ 	  status = read_data (s, stripe_data + stripe_fill, &this_read);
+_at_@ -6995,8 +6995,8 @@
+ 	    this_read = total_size - processed_bytes;
+ 	  
+ 	  DBG (5, "reader_process: virtual processed_bytes: %lu, total_size: %lu\n",
+-	       (u_long) processed_bytes, (u_long) total_size);
+-	  DBG (5, "reader_process: virtual this_read: %lu\n", (u_long) this_read);
++	       (unsigned long) processed_bytes, (unsigned long) total_size);
++	  DBG (5, "reader_process: virtual this_read: %lu\n", (unsigned long) this_read);
+ 	  
+ 	  got = fread (stripe_data + stripe_fill, 1, this_read, rear_fp);
+ 	  stripe_fill += got;
+--- sane-backends-1.0.24.orig/backend/bh.c
++++ sane-backends-1.0.24/backend/bh.c
+_at_@ -606,7 +606,7 @@
+ {
+   SANE_Status status = SANE_STATUS_GOOD;
+   size_t nread;
+-  DBG (3, "read_barfile called (%lu bytes)\n", (u_long) *buf_size);
++  DBG (3, "read_barfile called (%lu bytes)\n", (unsigned long) *buf_size);
+ 
+   if (s->barf != NULL)
+     {
+_at_@ -650,7 +650,7 @@
+ {
+   static SANE_Byte cmd[10];
+   SANE_Status status;
+-  DBG (3, "read_data called (%lu bytes)\n", (u_long) *buf_size);
++  DBG (3, "read_data called (%lu bytes)\n", (unsigned long) *buf_size);
+ 
+   if (s->readlist[s->readptr] == BH_SCSI_READ_TYPE_SENDBARFILE)
+     {
+_at_@ -1373,7 +1373,7 @@
+   char buf[255+1], *x, *y, *w, *l, *f, *ep;
+   const char *seps = "x+:";
+   double mm, fpixels;
+-  u_long pixels;
++  unsigned long pixels;
+ 
+   DBG(3, "section_parse called\n");
+ 
+_at_@ -1971,11 +1971,11 @@
+ /* a sensible sense handler, courtesy of Franck;
+    arg is a pointer to the associated BH_Scanner structure */
+ static SANE_Status
+-sense_handler (int scsi_fd, u_char *result, void *arg)
++sense_handler (int scsi_fd, unsigned char *result, void *arg)
+ {
+   BH_Scanner *s = (BH_Scanner *) arg;
+-  u_char sense, asc, ascq, EOM, ILI, ErrorCode, ValidData;
+-  u_long InvalidBytes;
++  unsigned char sense, asc, ascq, EOM, ILI, ErrorCode, ValidData;
++  unsigned long InvalidBytes;
+   char *sense_str = "", *as_str = "";
+   SANE_Int i;
+   SANE_Status status = SANE_STATUS_INVAL;
+_at_@ -3767,7 +3767,7 @@
+ 
+   nread = maxlen;
+ 
+-  DBG (3, "sane_read: request %lu bytes\n", (u_long) nread);
++  DBG (3, "sane_read: request %lu bytes\n", (unsigned long) nread);
+   /* set InvalidBytes to 0 before read; sense_handler will set it
+    * to non-zero if we do the last partial read.
+    */
+_at_@ -3781,7 +3781,7 @@
+       return status;
+     }
+   nread = maxlen - s->InvalidBytes;
+-  DBG (3, "sane_read: got %lu bytes\n", (u_long) nread);
++  DBG (3, "sane_read: got %lu bytes\n", (unsigned long) nread);
+   *len = nread;
+ 
+   return (maxlen != 0 && nread == 0) ? SANE_STATUS_EOF : SANE_STATUS_GOOD;
+--- sane-backends-1.0.24.orig/backend/bh.h
++++ sane-backends-1.0.24/backend/bh.h
+_at_@ -224,7 +224,7 @@
+ typedef struct _BH_Section
+ {
+   /* section dimensions - in millimeters */
+-  u_long top, left, width, length;
++  unsigned long top, left, width, length;
+ 
+   /* compression type/arg/frameformat */
+   SANE_Byte compressiontype;
+_at_@ -352,14 +352,14 @@
+   SANE_Byte readlist[NUM_READS];
+   SANE_Int readcnt, readptr;
+ 
+-  u_long InvalidBytes;
++  unsigned long InvalidBytes;
+   SANE_Bool scanning;
+   SANE_Bool cancelled;
+   SANE_Bool backpage;
+   SANE_Bool barcodes;
+   SANE_Bool patchcodes;
+   SANE_Bool icons;
+-  u_long iconwidth, iconlength;
++  unsigned long iconwidth, iconlength;
+   SANE_Bool barcode_not_found;
+ };
+ 
+_at_@ -557,14 +557,14 @@
+ }
+ 
+ static /* inline */ void
+-_lto2b(u_long val, SANE_Byte *bytes)
++_lto2b(unsigned long val, SANE_Byte *bytes)
+ {
+   bytes[0] = (val >> 8) & 0xff;
+   bytes[1] = val & 0xff;
+ }
+ 
+ static /* inline */ void
+-_lto3b(u_long val, SANE_Byte *bytes)
++_lto3b(unsigned long val, SANE_Byte *bytes)
+ {
+   bytes[0] = (val >> 16) & 0xff;
+   bytes[1] = (val >> 8) & 0xff;
+_at_@ -572,7 +572,7 @@
+ }
+ 
+ static /* inline */ void
+-_lto4b(u_long val, SANE_Byte *bytes)
++_lto4b(unsigned long val, SANE_Byte *bytes)
+ {
+   bytes[0] = (val >> 24) & 0xff;
+   bytes[1] = (val >> 16) & 0xff;
+_at_@ -583,7 +583,7 @@
+ static /* inline */ u_long
+ _2btol(SANE_Byte *bytes)
+ {
+-  u_long rv;
++  unsigned long rv;
+ 
+   rv = (bytes[0] << 8) | bytes[1];
+ 
+_at_@ -593,7 +593,7 @@
+ static /* inline */ u_long
+ _4btol(SANE_Byte *bytes)
+ {
+-  u_long rv;
++  unsigned long rv;
+ 
+   rv = (bytes[0] << 24) |
+     (bytes[1] << 16) |
+--- sane-backends-1.0.24.orig/backend/canon-sane.c
++++ sane-backends-1.0.24/backend/canon-sane.c
+_at_@ -1108,8 +1108,8 @@
+   char *mode_str;
+   CANON_Scanner *s = handle;
+   SANE_Status status;
+-  u_char wbuf[72], dbuf[28], ebuf[72];
+-  u_char cbuf[2];			/* modification for FB620S */
++  unsigned char wbuf[72], dbuf[28], ebuf[72];
++  unsigned char cbuf[2];			/* modification for FB620S */
+   size_t buf_size, i;
+ 
+   char tmpfilename[] = "/tmp/canon.XXXXXX"; /* for FB1200S */
+_at_@ -1656,7 +1656,7 @@
+ 
+   DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, "
+        "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line,
+-       s->params.lines, (u_long) s->bytes_to_read,
++       s->params.lines, (unsigned long) s->bytes_to_read,
+        s->val[OPT_X_RESOLUTION].w);
+ 
+ /**************************************************/
+_at_@ -1722,9 +1722,9 @@
+   SANE_Status status;
+   int c;
+   size_t i, nread, nread2;
+-  u_char *p;
++  unsigned char *p;
+ #if defined(WORDS_BIGENDIAN)
+-  u_char b;
++  unsigned char b;
+ #endif
+ 
+   DBG (21, ">> sane_read\n");
+_at_@ -1757,7 +1757,7 @@
+ 	{				/* extend buffer? */
+ 	  if (s->auxbuf_len > 0) free (s->auxbuf);
+ 	  s->auxbuf_len = max_len;
+-	  if ((s->auxbuf = (u_char *) malloc (2 * max_len)) == NULL)
++	  if ((s->auxbuf = (unsigned char *) malloc (2 * max_len)) == NULL)
+ 	    {
+ 	      DBG (1, "sane_read buffer size insufficient\n");
+ 	      do_cancel (s);
+_at_@ -1926,7 +1926,7 @@
+ 	    primaryHigh[256], primaryLow[256], secondaryHigh[256],
+ 	    secondaryLow[256] */;
+   SANE_Int ncopy;
+-  u_char dbuf[28];
++  unsigned char dbuf[28];
+   size_t buf_size, nread, remain, nwritten, nremain, pos, pix, pixel_per_line,
+ 	 byte, byte_per_line/*, bit*/;
+   ssize_t wres, readres;
+--- sane-backends-1.0.24.orig/backend/canon-scsi.c
++++ sane-backends-1.0.24/backend/canon-scsi.c
+_at_@ -47,7 +47,7 @@
+ static SANE_Status
+ test_unit_ready (int fd)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   DBG (31, ">> test_unit_ready\n");
+ 
+_at_@ -62,7 +62,7 @@
+ static SANE_Status
+ request_sense (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   DBG (31, ">> request_sense\n");
+ 
+_at_@ -79,7 +79,7 @@
+ static SANE_Status
+ inquiry (int fd, int evpd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   DBG (31, ">> inquiry\n");
+ 
+_at_@ -98,7 +98,7 @@
+ static SANE_Status
+ mode_select (int fd)
+ {
+-  static u_char cmd[6 + 12];
++  static unsigned char cmd[6 + 12];
+   int status;
+   DBG (31, ">> mode_select\n");
+ 
+_at_@ -120,7 +120,7 @@
+ static SANE_Status
+ reserve_unit (int fd)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   DBG (31, ">> reserve_unit\n");
+ 
+_at_@ -136,7 +136,7 @@
+ static SANE_Status
+ release_unit (int fd)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   DBG (31, ">> release_unit\n");
+ 
+_at_@ -152,7 +152,7 @@
+ static SANE_Status
+ mode_sense (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   DBG (31, ">> mode_sense\n");
+ 
+_at_@ -169,7 +169,7 @@
+ static SANE_Status
+ scan (int fd)
+ {
+-  static u_char cmd[6 + 1];
++  static unsigned char cmd[6 + 1];
+   int status;
+   DBG (31, ">> scan\n");
+ 
+_at_@ -185,7 +185,7 @@
+ static SANE_Status
+ send_diagnostic (int fd)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   DBG (31, ">> send_diagnostic\n");
+ 
+_at_@ -201,7 +201,7 @@
+ static SANE_Status
+ set_window (int fd, void *data)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> set_window\n");
+ 
+_at_@ -217,7 +217,7 @@
+ static SANE_Status
+ get_window (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> get_window\n");
+ 
+_at_@ -234,7 +234,7 @@
+ static SANE_Status
+ read_data (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> read_data\n");
+ 
+_at_@ -252,7 +252,7 @@
+ static SANE_Status
+ medium_position (int fd)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> medium_position\n");
+ 
+_at_@ -268,7 +268,7 @@
+ static SANE_Status
+ execute_shading (int fd)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> execute shading\n");
+ 
+_at_@ -284,7 +284,7 @@
+ static SANE_Status
+ execute_auto_focus (int fd, int AF, int speed, int AE, int count)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (7, ">> execute_auto_focus\n");
+   DBG (7, ">> focus: mode='%d', speed='%d', AE='%d', count='%d'\n",
+_at_@ -306,9 +306,9 @@
+ }
+ 
+ static SANE_Status
+-set_adf_mode (int fd, u_char priority)
++set_adf_mode (int fd, unsigned char priority)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+ 
+   memset (cmd, 0, sizeof (cmd));
+_at_@ -321,9 +321,9 @@
+ }
+ 
+ static SANE_Status
+-get_scan_mode (int fd, u_char page, void *buf, size_t *buf_size)
++get_scan_mode (int fd, unsigned char page, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   int PageLen = 0x00;
+ 
+_at_@ -360,10 +360,10 @@
+ }
+ 
+ static SANE_Status
+-define_scan_mode (int fd, u_char page, void *data)
++define_scan_mode (int fd, unsigned char page, void *data)
+ {
+-  static u_char cmd[6];
+-  u_char pdata[36];
++  static unsigned char cmd[6];
++  unsigned char pdata[36];
+   size_t i;
+   int status, pdatalen;
+   DBG (31, ">> define scan mode\n");
+_at_@ -405,7 +405,7 @@
+ get_density_curve (int fd, int component, void *buf, size_t *buf_size,
+ 		   int transfer_data_type)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> get_density_curve\n");
+ 
+_at_@ -427,7 +427,7 @@
+ static SANE_Status
+ get_density_curve_data_format (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> get_density_curve_data_format\n");
+ 
+_at_@ -450,7 +450,7 @@
+ set_density_curve (int fd, int component, void *buf, size_t *buf_size,
+ 		   int transfer_data_type)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> set_density_curve\n");
+ 
+_at_@ -474,7 +474,7 @@
+ /* static SANE_Status */
+ /* set_density_curve_data_format (int fd, void *buf, size_t *buf_size) */
+ /* { */
+-/*   static u_char cmd[10]; */
++/*   static unsigned char cmd[10]; */
+ /*   int status, i; */
+ /*   DBG (31, ">> set_density_curve_data_format\n"); */
+ 
+_at_@ -496,7 +496,7 @@
+ static SANE_Status
+ get_power_on_timer (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> get power on timer\n");
+ 
+_at_@ -515,7 +515,7 @@
+ static SANE_Status
+ get_film_status (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> get film status\n");
+ 
+_at_@ -533,7 +533,7 @@
+ static SANE_Status
+ get_data_status (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> get_data_status\n");
+ 
+_at_@ -550,7 +550,7 @@
+ static SANE_Status
+ reset_scanner (int fd)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   DBG (31, ">> reset_scanner\n");
+ 
+_at_@ -565,8 +565,8 @@
+ static SANE_Status
+ execute_calibration (int fd)
+ {
+-  static u_char cmd[6];
+-  u_char data[2];
++  static unsigned char cmd[6];
++  unsigned char data[2];
+   int status;
+   DBG (31, ">> execute_calibration\n");
+ 
+_at_@ -584,7 +584,7 @@
+ static SANE_Status
+ get_calibration_status (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   DBG (31, ">> get_calibration_status\n");
+ 
+_at_@ -601,7 +601,7 @@
+ static SANE_Status
+ get_switch_status (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   int status;
+   DBG (31, ">> get_switch_status\n");
+ 
+_at_@ -635,7 +635,7 @@
+ static SANE_Status
+ cancel (int fd)
+ {
+-  static u_char cmd[10];
++  static unsigned char cmd[10];
+   int status;
+   DBG (31, ">> cancel_FB1200S\n");
+ 
+_at_@ -653,7 +653,7 @@
+    stored in the CANON_Scanner structure. */
+ 
+ static SANE_Status
+-get_density_curve_fs2710 (SANE_Handle handle, int component, u_char *buf,
++get_density_curve_fs2710 (SANE_Handle handle, int component, unsigned char *buf,
+ 			  size_t *buf_size)
+ {
+   CANON_Scanner *s = handle;
+_at_@ -666,11 +666,11 @@
+ }
+ 
+ static SANE_Status
+-set_density_curve_fs2710 (SANE_Handle handle, int component, u_char *buf)
++set_density_curve_fs2710 (SANE_Handle handle, int component, unsigned char *buf)
+ {
+   CANON_Scanner *s = handle;
+   int i, j, hi, lo;
+-  u_char *p;
++  unsigned char *p;
+ 
+   for (i = 1, hi = *buf++, p = &s->gamma_map[component][0]; i <= 256; i++)
+     {
+--- sane-backends-1.0.24.orig/backend/canon.c
++++ sane-backends-1.0.24/backend/canon.c
+_at_@ -322,10 +322,10 @@
+ /**************************************************************************/
+ 
+ static SANE_Status
+-sense_handler (int scsi_fd, u_char * result, void *arg)
++sense_handler (int scsi_fd, unsigned char * result, void *arg)
+ {
+   static char me[] = "canon_sense_handler";
+-  u_char sense;
++  unsigned char sense;
+   int asc;
+   char *sense_str = NULL;
+   SANE_Status status;
+_at_@ -547,7 +547,7 @@
+ do_gamma (CANON_Scanner * s)
+ {
+   SANE_Status status;
+-  u_char gbuf[256];
++  unsigned char gbuf[256];
+   size_t buf_size;
+   int i, j, neg, transfer_data_type, from;
+ 
+_at_@ -636,7 +636,7 @@
+   CANON_Device *dev;
+ 
+   int fd;
+-  u_char ibuf[36], ebuf[74], mbuf[12];
++  unsigned char ibuf[36], ebuf[74], mbuf[12];
+   size_t buf_size, i;
+   char *str;
+ 
+_at_@ -1814,7 +1814,7 @@
+ do_focus (CANON_Scanner * s)
+ {
+   SANE_Status status;
+-  u_char ebuf[74];
++  unsigned char ebuf[74];
+   size_t buf_size;
+ 
+   DBG (3, "do_focus: sending GET FILM STATUS\n");
+--- sane-backends-1.0.24.orig/backend/canon.h
++++ sane-backends-1.0.24/backend/canon.h
+_at_@ -318,10 +318,10 @@
+   size_t bytes_to_read;
+   int scanning;
+ 
+-  u_char gamma_map[4][4096];	/* for FS2710S: */
++  unsigned char gamma_map[4][4096];	/* for FS2710S: */
+   int colour;			/* index to gamma_map */
+   int auxbuf_len;		/* size of auxiliary buffer */
+-  u_char *auxbuf;
++  unsigned char *auxbuf;
+ }
+ CANON_Scanner;
+ 
+--- sane-backends-1.0.24.orig/backend/canon630u-common.c
++++ sane-backends-1.0.24/backend/canon630u-common.c
+_at_@ -237,7 +237,7 @@
+ {
+   SANE_Status status;
+ 
+-  DBG (13, "write_bulk(fd, 0x%02x, buf, 0x%04lx);\n", addr, (u_long) count);
++  DBG (13, "write_bulk(fd, 0x%02x, buf, 0x%04lx);\n", addr, (unsigned long) count);
+ 
+   if (!src)
+     {
+_at_@ -259,7 +259,7 @@
+ {
+   SANE_Status status;
+ 
+-  DBG (13, "read_bulk(fd, 0x%02x, buf, 0x%04lx);\n", addr, (u_long) count);
++  DBG (13, "read_bulk(fd, 0x%02x, buf, 0x%04lx);\n", addr, (unsigned long) count);
+ 
+   if (!dst)
+     {
+_at_@ -300,10 +300,10 @@
+   SANE_Status status;
+   size_t i;
+ 
+-  DBG (14, "multi write %lu\n", (u_long) count);
++  DBG (14, "multi write %lu\n", (unsigned long) count);
+   for (i = 0; i < count; i++)
+     {
+-      DBG (15, " %04lx:%02x", (u_long) (addr + i), ((byte *) src)[i]);
++      DBG (15, " %04lx:%02x", (unsigned long) (addr + i), ((byte *) src)[i]);
+       status = write_byte (fd, addr + i, ((byte *) src)[i]);
+       if (status != SANE_STATUS_GOOD)
+ 	{
+_at_@ -324,12 +324,12 @@
+   size_t i;
+   byte val;
+ 
+-  DBG (14, "multi read %lu\n", (u_long) count);
++  DBG (14, "multi read %lu\n", (unsigned long) count);
+   for (i = 0; i < count; i++)
+     {
+       status = read_byte (fd, addr + i, &val);
+       ((byte *) dst)[i] = val;
+-      DBG (15, " %04lx:%02x", (u_long) (addr + i), ((byte *) dst)[i]);
++      DBG (15, " %04lx:%02x", (unsigned long) (addr + i), ((byte *) dst)[i]);
+       /* on err, return number of success */
+       if (status != SANE_STATUS_GOOD)
+ 	{
+--- sane-backends-1.0.24.orig/backend/canon_dr.c
++++ sane-backends-1.0.24/backend/canon_dr.c
+_at_@ -6282,7 +6282,7 @@
+ 
+   if (inBuff && inLen){
+     if(ret == SANE_STATUS_EOF){
+-      DBG(25, "in: short read, remainder %lu bytes\n", (u_long)s->rs_info);
++      DBG(25, "in: short read, remainder %lu bytes\n", (unsigned long)s->rs_info);
+       *inLen -= s->rs_info;
+     }
+     hexdump(30, "in: <<", inBuff, *inLen);
+--- sane-backends-1.0.24.orig/backend/canon_dr.h
++++ sane-backends-1.0.24/backend/canon_dr.h
+_at_@ -480,7 +480,7 @@
+ static SANE_Status connect_fd (struct scanner *s);
+ static SANE_Status disconnect_fd (struct scanner *s);
+ 
+-static SANE_Status sense_handler (int scsi_fd, u_char * result, void *arg);
++static SANE_Status sense_handler (int scsi_fd, unsigned char * result, void *arg);
+ 
+ static SANE_Status init_inquire (struct scanner *s);
+ static SANE_Status init_vpd (struct scanner *s);
+--- sane-backends-1.0.24.orig/backend/coolscan.c
++++ sane-backends-1.0.24/backend/coolscan.c
+_at_@ -136,13 +136,13 @@
+   if ((out_len != 0) && (out_len != ol))
+     {
+       DBG (1, "sanei_scsi_cmd: asked %lu bytes, got %lu\n",
+-	   (u_long) out_len, (u_long) ol);
++	   (unsigned long) out_len, (unsigned long) ol);
+     }
+   if (ret)
+     {
+       DBG (1, "sanei_scsi_cmd: returning 0x%08x\n", ret);
+     }
+-  DBG (10, "sanei_scsi_cmd: returning %lu bytes:\n", (u_long) ol);
++  DBG (10, "sanei_scsi_cmd: returning %lu bytes:\n", (unsigned long) ol);
+   if (out != NULL && out_len != 0)
+     hexdump (15, "", out, (out_len > 0x60) ? 0x60 : out_len);
+ 
+--- sane-backends-1.0.24.orig/backend/coolscan2.c
++++ sane-backends-1.0.24/backend/coolscan2.c
+_at_@ -298,7 +298,7 @@
+ 			     cs2_t ** sp);
+ static void cs2_close (cs2_t * s);
+ static SANE_Status cs2_attach (const char *dev);
+-static SANE_Status cs2_scsi_sense_handler (int fd, u_char * sense_buffer,
++static SANE_Status cs2_scsi_sense_handler (int fd, unsigned char * sense_buffer,
+ 					   void *arg);
+ static SANE_Status cs2_parse_sense_data (cs2_t * s);
+ static void cs2_init_buffer (cs2_t * s);
+_at_@ -2000,7 +2000,7 @@
+ }
+ 
+ static SANE_Status
+-cs2_scsi_sense_handler (int fd, u_char * sense_buffer, void *arg)
++cs2_scsi_sense_handler (int fd, unsigned char * sense_buffer, void *arg)
+ {
+   cs2_t *s = (cs2_t *) arg;
+ 
+--- sane-backends-1.0.24.orig/backend/coolscan3.c
++++ sane-backends-1.0.24/backend/coolscan3.c
+_at_@ -259,7 +259,7 @@
+ 			    cs3_t ** sp);
+ static void cs3_close(cs3_t * s);
+ static SANE_Status cs3_attach(const char *dev);
+-static SANE_Status cs3_scsi_sense_handler(int fd, u_char * sense_buffer,
++static SANE_Status cs3_scsi_sense_handler(int fd, unsigned char * sense_buffer,
+ 					  void *arg);
+ static SANE_Status cs3_parse_sense_data(cs3_t * s);
+ static void cs3_init_buffer(cs3_t * s);
+_at_@ -2022,7 +2022,7 @@
+ }
+ 
+ static SANE_Status
+-cs3_scsi_sense_handler(int fd, u_char * sense_buffer, void *arg)
++cs3_scsi_sense_handler(int fd, unsigned char * sense_buffer, void *arg)
+ {
+ 	cs3_t *s = (cs3_t *) arg;
+ 
+_at_@ -2295,7 +2295,7 @@
+ 			if (n_data) {
+ 				DBG(4,
+ 				    "%s: Unexpected non-data phase, but n_data != 0 (%lu).\n",
+-				    __func__, (u_long) n_data);
++				    __func__, (unsigned long) n_data);
+ 				status_only = 1;
+ 			}
+ 			break;
+--- sane-backends-1.0.24.orig/backend/dc25.c
++++ sane-backends-1.0.24/backend/dc25.c
+_at_@ -1907,7 +1907,7 @@
+ 		  tty_baud = DEFAULT_TTY_BAUD;
+ 		  break;
+ 		}
+-	      DBG (20, "Config file baud=%lu\n", (u_long) tty_baud);
++	      DBG (20, "Config file baud=%lu\n", (unsigned long) tty_baud);
+ 	    }
+ 	  else if (strcmp (dev_name, "dumpinquiry") == 0)
+ 	    {
+_at_@ -2337,7 +2337,7 @@
+   int n, i;
+   FILE *f;
+ 
+-  DBG (127, "sane_start called, handle=%lx\n", (u_long) handle);
++  DBG (127, "sane_start called, handle=%lx\n", (unsigned long) handle);
+ 
+   if (handle != MAGIC || !is_open ||
+       (dc25_opt_image_number == 0 && dc25_opt_snap == SANE_FALSE))
+--- sane-backends-1.0.24.orig/backend/dell1600n_net.c
++++ sane-backends-1.0.24/backend/dell1600n_net.c
+_at_@ -1923,7 +1923,7 @@
+         /* allocate space for RGBA representation of image */
+         numPixels = height * width;
+         DBG (20, "ProcessPageData: num TIFF RGBA pixels: %d\n", numPixels);
+-        if (!(pTiffRgba = calloc (numPixels, sizeof (u_long))))
++        if (!(pTiffRgba = calloc (numPixels, sizeof (unsigned long))))
+           {
+             ret = SANE_STATUS_NO_MEM;
+             goto TIFF_CLEANUP;
+_at_@ -1941,7 +1941,7 @@
+ 
+         /* read RGBA image */
+         DBG (20, "ProcessPageData: setting up read buffer\n");
+-        TIFFReadBufferSetup (pTiff, NULL, width * height * sizeof (u_long));
++        TIFFReadBufferSetup (pTiff, NULL, width * height * sizeof (unsigned long));
+         DBG (20, "ProcessPageData: reading RGBA data\n");
+         TIFFReadRGBAImageOriented (pTiff, width, height, pTiffRgba,
+                                    ORIENTATION_TOPLEFT, 0);
+--- sane-backends-1.0.24.orig/backend/dll.c
++++ sane-backends-1.0.24/backend/dll.c
+_at_@ -158,9 +158,9 @@
+ {
+   struct backend *next;
+   char *name;
+-  u_int permanent:1;		/* is the backend preloaded? */
+-  u_int loaded:1;		/* are the functions available? */
+-  u_int inited:1;		/* has the backend been initialized? */
++  unsigned int permanent:1;		/* is the backend preloaded? */
++  unsigned int loaded:1;		/* are the functions available? */
++  unsigned int inited:1;		/* has the backend been initialized? */
+   void *handle;			/* handle returned by dlopen() */
+   void *(*op[NUM_OPS]) (void);
+ };
+--- sane-backends-1.0.24.orig/backend/dmc.c
++++ sane-backends-1.0.24/backend/dmc.c
+_at_@ -138,11 +138,11 @@
+     readCmd[8] = maxlen & 0xFF;
+     readCmd[9] = 0;
+     DBG(3, "DMCRead: typecode=%x, qualifier=%x, maxlen=%lu\n",
+-	typecode, qualifier, (u_long) maxlen);
++	typecode, qualifier, (unsigned long) maxlen);
+ 
+     *len = maxlen;
+     status = sanei_scsi_cmd(fd, readCmd, sizeof(readCmd), buf, len);
+-    DBG(3, "DMCRead: Read %lu bytes\n", (u_long) *len);
++    DBG(3, "DMCRead: Read %lu bytes\n", (unsigned long) *len);
+     return status;
+ }
+ 
+_at_@ -182,7 +182,7 @@
+     memcpy(writeCmd+10, buf, maxlen);
+ 
+     DBG(3, "DMCWrite: typecode=%x, qualifier=%x, maxlen=%lu\n",
+-	typecode, qualifier, (u_long) maxlen);
++	typecode, qualifier, (unsigned long) maxlen);
+ 
+     status = sanei_scsi_cmd(fd, writeCmd, 10+maxlen, NULL, NULL);
+     free(writeCmd);
+--- sane-backends-1.0.24.orig/backend/epson.c
++++ sane-backends-1.0.24/backend/epson.c
+_at_@ -796,45 +796,45 @@
+ 
+ typedef struct
+ {
+-  u_char code;
+-  u_char status;
+-  u_char count1;
+-  u_char count2;
+-  u_char buf[1];
++  unsigned char code;
++  unsigned char status;
++  unsigned char count1;
++  unsigned char count2;
++  unsigned char buf[1];
+ 
+ } EpsonHdrRec, *EpsonHdr;
+ 
+ typedef struct
+ {
+-  u_char code;
+-  u_char status;
+-  u_char count1;
+-  u_char count2;
++  unsigned char code;
++  unsigned char status;
++  unsigned char count1;
++  unsigned char count2;
+ 
+-  u_char type;
+-  u_char level;
++  unsigned char type;
++  unsigned char level;
+ 
+-  u_char buf[1];
++  unsigned char buf[1];
+ 
+ } EpsonIdentRec, *EpsonIdent;
+ 
+ 
+ typedef struct
+ {
+-  u_char code;
+-  u_char status;
+-  u_short count;
++  unsigned char code;
++  unsigned char status;
++  unsigned short count;
+ 
+-  u_char buf[1];
++  unsigned char buf[1];
+ 
+ } EpsonParameterRec, *EpsonParameter;
+ 
+ typedef struct
+ {
+-  u_char code;
+-  u_char status;
++  unsigned char code;
++  unsigned char status;
+ 
+-  u_char buf[4];
++  unsigned char buf[4];
+ 
+ } EpsonDataRec, *EpsonData;
+ 
+_at_@ -843,7 +843,7 @@
+  *
+  */
+ 
+-static EpsonHdr command (Epson_Scanner * s, u_char * cmd, size_t cmd_size,
++static EpsonHdr command (Epson_Scanner * s, unsigned char * cmd, size_t cmd_size,
+                          SANE_Status * status);
+ static SANE_Status get_identity_information (SANE_Handle handle);
+ static SANE_Status get_identity2_information (SANE_Handle handle);
+_at_@ -853,7 +853,7 @@
+                         SANE_Status * status);
+ static SANE_Status color_shuffle (SANE_Handle handle, int *new_length);
+ static SANE_Status request_focus_position (SANE_Handle handle,
+-                                           u_char * position);
++                                           unsigned char * position);
+ static SANE_Bool request_push_button_status (SANE_Handle handle,
+                                              SANE_Bool * theButtonStatus);
+ static void activateOption (Epson_Scanner * s, SANE_Int option,
+_at_@ -878,12 +878,12 @@
+ static int
+ send (Epson_Scanner * s, void *buf, size_t buf_size, SANE_Status * status)
+ {
+-  DBG (3, "send buf, size = %lu\n", (u_long) buf_size);
++  DBG (3, "send buf, size = %lu\n", (unsigned long) buf_size);
+ 
+ #if 1
+   {
+     unsigned int k;
+-    const u_char *s = buf;
++    const unsigned char *s = buf;
+ 
+     for (k = 0; k < buf_size; k++)
+     {
+_at_@ -957,13 +957,13 @@
+       *status = SANE_STATUS_GOOD;
+   }
+ 
+-  DBG (7, "receive buf, expected = %lu, got = %ld\n", (u_long) buf_size, (long) n);
++  DBG (7, "receive buf, expected = %lu, got = %ld\n", (unsigned long) buf_size, (long) n);
+ 
+ #if 1
+   if (n > 0)
+   {
+     int k;
+-    const u_char *s = buf;
++    const unsigned char *s = buf;
+ 
+     for (k = 0; k < n; k++)
+     {
+_at_@ -975,7 +975,7 @@
+     int i;
+     ssize_t k;
+     ssize_t hex_start = 0;
+-    const u_char *s = buf;
++    const unsigned char *s = buf;
+     char hex_str[NUM_OF_HEX_ELEMENTS * 3 + 1];
+     char tmp_str[NUM_OF_HEX_ELEMENTS * 3 + 1];
+     char ascii_str[NUM_OF_HEX_ELEMENTS * 2 + 1];
+_at_@ -1034,7 +1034,7 @@
+ static SANE_Status
+ expect_ack (Epson_Scanner * s)
+ {
+-  u_char result[1];
++  unsigned char result[1];
+   size_t len;
+   SANE_Status status;
+ 
+_at_@ -1057,10 +1057,10 @@
+  */
+ 
+ static SANE_Status
+-set_cmd (Epson_Scanner * s, u_char cmd, int val)
++set_cmd (Epson_Scanner * s, unsigned char cmd, int val)
+ {
+   SANE_Status status;
+-  u_char params[2];
++  unsigned char params[2];
+ 
+   if (!cmd)
+     return SANE_STATUS_UNSUPPORTED;
+_at_@ -1083,7 +1083,7 @@
+       gotten from scanners with known buggy firmware.
+  */
+ static void
+-fix_up_extended_status_reply (const char *model, u_char * buf)
++fix_up_extended_status_reply (const char *model, unsigned char * buf)
+ {
+ 
+   if (0 == strncmp (model, "ES-9000H", strlen ("ES-9000H"))
+_at_@ -1138,8 +1138,8 @@
+ set_zoom (Epson_Scanner * s, int x_zoom, int y_zoom)
+ {
+   SANE_Status status;
+-  u_char cmd[2];
+-  u_char params[2];
++  unsigned char cmd[2];
++  unsigned char params[2];
+ 
+   if (!s->hw->cmd->set_zoom)
+     return SANE_STATUS_GOOD;
+_at_@ -1167,7 +1167,7 @@
+ set_resolution (Epson_Scanner * s, int xres, int yres)
+ {
+   SANE_Status status;
+-  u_char params[4];
++  unsigned char params[4];
+ 
+   if (!s->hw->cmd->set_resolution)
+     return SANE_STATUS_GOOD;
+_at_@ -1203,7 +1203,7 @@
+ set_scan_area (Epson_Scanner * s, int x, int y, int width, int height)
+ {
+   SANE_Status status;
+-  u_char params[8];
++  unsigned char params[8];
+ 
+   DBG (1, "set_scan_area: %p %d %d %d %d\n", (void *) s, x, y, width, height);
+ 
+_at_@ -1251,8 +1251,8 @@
+ set_color_correction_coefficients (Epson_Scanner * s)
+ {
+   SANE_Status status;
+-  u_char cmd = s->hw->cmd->set_color_correction_coefficients;
+-  u_char params[2];
++  unsigned char cmd = s->hw->cmd->set_color_correction_coefficients;
++  unsigned char params[2];
+   const int length = 9;
+   signed char cct[9];
+ 
+_at_@ -1298,10 +1298,10 @@
+ {
+ 
+   SANE_Status status;
+-  u_char cmd = s->hw->cmd->set_gamma_table;
+-  u_char params[2];
++  unsigned char cmd = s->hw->cmd->set_gamma_table;
++  unsigned char params[2];
+   const int length = 257;
+-  u_char gamma[257];
++  unsigned char gamma[257];
+   int n;
+   int table;
+ /*      static const char gamma_cmds[] = { 'M', 'R', 'G', 'B' }; */
+_at_@ -1475,9 +1475,9 @@
+ check_ext_status (Epson_Scanner * s, int *max_x, int *max_y)
+ {
+   SANE_Status status;
+-  u_char cmd = s->hw->cmd->request_extended_status;
+-  u_char params[2];
+-  u_char *buf;
++  unsigned char cmd = s->hw->cmd->request_extended_status;
++  unsigned char params[2];
++  unsigned char *buf;
+   EpsonHdr head;
+ 
+   *max_x = 0;
+_at_@ -1598,7 +1598,7 @@
+ reset (Epson_Scanner * s)
+ {
+   SANE_Status status;
+-  u_char param[2];
++  unsigned char param[2];
+   SANE_Bool needToClose = SANE_FALSE;
+ 
+   DBG (5, "reset()\n");
+_at_@ -1647,8 +1647,8 @@
+   if (r_cmd_count % 2) 
+   {
+     /* send a request_status. This toggles w_cmd_count and r_cmd_count */
+-    u_char param[3];
+-    u_char result[5];
++    unsigned char param[3];
++    unsigned char result[5];
+     SANE_Status status;
+ 
+     param[0] = ESC;
+_at_@ -1765,8 +1765,8 @@
+ feed (Epson_Scanner * s)
+ {
+   SANE_Status status;
+-  u_char params[2];
+-  u_char cmd = s->hw->cmd->feed;
++  unsigned char params[2];
++  unsigned char cmd = s->hw->cmd->feed;
+ 
+   DBG (5, "feed()\n");
+ 
+_at_@ -1802,8 +1802,8 @@
+ eject (Epson_Scanner * s)
+ {
+   SANE_Status status;
+-  u_char params[2];
+-  u_char cmd = s->hw->cmd->eject;
++  unsigned char params[2];
++  unsigned char cmd = s->hw->cmd->eject;
+   SANE_Bool needToClose = SANE_FALSE;
+ 
+   DBG (5, "eject()\n");
+_at_@ -1845,11 +1845,11 @@
+ 
+ 
+ static EpsonHdr
+-command (Epson_Scanner * s, u_char * cmd, size_t cmd_size,
++command (Epson_Scanner * s, unsigned char * cmd, size_t cmd_size,
+          SANE_Status * status)
+ {
+   EpsonHdr head;
+-  u_char *buf;
++  unsigned char *buf;
+   int count;
+ 
+   if (NULL == (head = walloc (EpsonHdrRec)))
+_at_@ -1872,7 +1872,7 @@
+       return (EpsonHdr) 0;
+   }
+ 
+-  buf = (u_char *) head;
++  buf = (unsigned char *) head;
+ 
+   if (s->hw->connection == SANE_EPSON_SCSI)
+   {
+_at_@ -2050,7 +2050,7 @@
+ 
+   if (s->hw->connection == SANE_EPSON_SCSI)
+   {
+-    u_char buf[INQUIRY_BUF_SIZE + 1];
++    unsigned char buf[INQUIRY_BUF_SIZE + 1];
+     size_t buf_size = INQUIRY_BUF_SIZE;
+ 
+     status =
+_at_@ -2343,8 +2343,8 @@
+    */
+   if (s->hw->cmd->request_extended_status != 0)
+   {
+-    u_char *buf;
+-    u_char params[2];
++    unsigned char *buf;
++    unsigned char params[2];
+     EpsonHdr head;
+ 
+     params[0] = ESC;
+_at_@ -4366,7 +4366,7 @@
+   SANE_Status status;
+   SANE_Bool button_status;
+   const struct mode_param *mparam;
+-  u_char params[4];
++  unsigned char params[4];
+   int ndpi;
+   int left, top;
+   int lcount;
+_at_@ -4941,8 +4941,8 @@
+   if (s->hw->cmd->request_extended_status != 0
+       && SANE_TRUE == s->hw->extension)
+   {
+-    u_char result[4];
+-    u_char *buf;
++    unsigned char result[4];
++    unsigned char *buf;
+     size_t len;
+ 
+     params[0] = ESC;
+_at_@ -4982,8 +4982,8 @@
+ #if 1
+   if (s->hw->cmd->request_condition != 0)
+   {
+-    u_char result[4];
+-    u_char *buf;
++    unsigned char result[4];
++    unsigned char *buf;
+     size_t len;
+ 
+     params[0] = ESC;
+_at_@ -5102,8 +5102,8 @@
+   {                             /* sequence! */
+     SANE_Status status;
+ 
+-    u_char params[1];
+-    u_char cmd = s->hw->cmd->eject;
++    unsigned char params[1];
++    unsigned char cmd = s->hw->cmd->eject;
+ 
+     if (!cmd)
+       return SANE_STATUS_UNSUPPORTED;
+_at_@ -5130,7 +5130,7 @@
+ read_data_block (Epson_Scanner * s, EpsonDataRec * result)
+ {
+   SANE_Status status;
+-  u_char param[3];
++  unsigned char param[3];
+ 
+   receive (s, result, s->block ? 6 : 4, &status);
+ 
+_at_@ -5293,12 +5293,12 @@
+ 
+     buf_len = result.buf[1] << 8 | result.buf[0];
+ 
+-    DBG (5, "sane_read: buf len = %lu\n", (u_long) buf_len);
++    DBG (5, "sane_read: buf len = %lu\n", (unsigned long) buf_len);
+ 
+     if (s->block)
+     {
+       buf_len *= (result.buf[3] << 8 | result.buf[2]);
+-      DBG (5, "sane_read: buf len (adjusted) = %lu\n", (u_long) buf_len);
++      DBG (5, "sane_read: buf len (adjusted) = %lu\n", (unsigned long) buf_len);
+     }
+ 
+     if (!s->block && SANE_FRAME_RGB == s->params.format)
+_at_@ -5354,7 +5354,7 @@
+       if (s->block)
+         buf_len *= (result.buf[3] << 8 | result.buf[2]);
+ 
+-      DBG (5, "sane_read: buf len2 = %lu\n", (u_long) buf_len);
++      DBG (5, "sane_read: buf len2 = %lu\n", (unsigned long) buf_len);
+ 
+       switch (GET_COLOR (result))
+       {
+_at_@ -5396,7 +5396,7 @@
+       if (s->block)
+         buf_len *= (result.buf[3] << 8 | result.buf[2]);
+ 
+-      DBG (5, "sane_read: buf len3 = %lu\n", (u_long) buf_len);
++      DBG (5, "sane_read: buf len3 = %lu\n", (unsigned long) buf_len);
+ 
+       switch (GET_COLOR (result))
+       {
+_at_@ -5859,9 +5859,9 @@
+   Epson_Scanner *s = (Epson_Scanner *) handle;
+   Epson_Device *dev = s->hw;
+   EpsonIdent ident;
+-  u_char param[3];
++  unsigned char param[3];
+   SANE_Status status;
+-  u_char *buf;
++  unsigned char *buf;
+ 
+   DBG (5, "get_identity_information()\n");
+ 
+_at_@ -6009,8 +6009,8 @@
+            */
+           if (s->hw->cmd->request_extended_status != 0)
+           {
+-            u_char *buf;
+-            u_char params[2];
++            unsigned char *buf;
++            unsigned char params[2];
+             EpsonHdr head;
+ 
+             params[0] = ESC;
+_at_@ -6112,9 +6112,9 @@
+   Epson_Scanner *s = (Epson_Scanner *) handle;
+   SANE_Status status;
+   int len;
+-  u_char param[3];
+-  u_char result[4];
+-  u_char *buf;
++  unsigned char param[3];
++  unsigned char result[4];
++  unsigned char *buf;
+ 
+   DBG (5, "get_identity2_information()\n");
+ 
+_at_@ -6177,7 +6177,7 @@
+ 
+   if (s->buf != NULL)
+   {
+-    u_char *dummy;
++    unsigned char *dummy;
+     int len;
+ 
+     /* malloc one line */
+_at_@ -6209,14 +6209,14 @@
+ 
+ 
+ static SANE_Status
+-request_focus_position (SANE_Handle handle, u_char * position)
++request_focus_position (SANE_Handle handle, unsigned char * position)
+ {
+   Epson_Scanner *s = (Epson_Scanner *) handle;
+   SANE_Status status;
+   int len;
+-  u_char param[3];
+-  u_char result[4];
+-  u_char *buf;
++  unsigned char param[3];
++  unsigned char result[4];
++  unsigned char *buf;
+ 
+   DBG (5, "request_focus_position()\n");
+ 
+_at_@ -6264,9 +6264,9 @@
+   Epson_Scanner *s = (Epson_Scanner *) handle;
+   SANE_Status status;
+   int len;
+-  u_char param[3];
+-  u_char result[4];
+-  u_char *buf;
++  unsigned char param[3];
++  unsigned char result[4];
++  unsigned char *buf;
+ 
+   DBG (5, "request_push_button_status()\n");
+ 
+--- sane-backends-1.0.24.orig/backend/epson.h
++++ sane-backends-1.0.24/backend/epson.h
+_at_@ -147,26 +147,26 @@
+ 
+ typedef struct
+ {
+-  u_short opt_resolution;
+-  u_char sensor;
+-  u_char scan_order;
+-  u_char line_dist1;
+-  u_char line_dist2;
++  unsigned short opt_resolution;
++  unsigned char sensor;
++  unsigned char scan_order;
++  unsigned char line_dist1;
++  unsigned char line_dist2;
+ 
+-  u_short main_res1;
+-  u_short main_res2;
+-  u_short main_res3;
+-  u_short main_res4;
+-  u_short main_res5;
+-  u_short main_res6;
+-  u_short main_res7;
++  unsigned short main_res1;
++  unsigned short main_res2;
++  unsigned short main_res3;
++  unsigned short main_res4;
++  unsigned short main_res5;
++  unsigned short main_res6;
++  unsigned short main_res7;
+ 
+-  u_short sub_res1;
+-  u_short sub_res2;
+-  u_short sub_res3;
+-  u_short sub_res4;
+-  u_short sub_res5;
+-  u_short sub_res6;
++  unsigned short sub_res1;
++  unsigned short sub_res2;
++  unsigned short sub_res3;
++  unsigned short sub_res4;
++  unsigned short sub_res5;
++  unsigned short sub_res6;
+ } Epson_Identity2;
+ 
+ 
+--- sane-backends-1.0.24.orig/backend/epson2-commands.c
++++ sane-backends-1.0.24/backend/epson2-commands.c
+_at_@ -707,17 +707,17 @@
+ 		return status;
+ 
+ 	DBG(10, "resolution of main scan     : %lu\n",
+-	    (u_long) le32atoh(&buf[0]));
++	    (unsigned long) le32atoh(&buf[0]));
+ 	DBG(10, "resolution of sub scan      : %lu\n",
+-	    (u_long) le32atoh(&buf[4]));
++	    (unsigned long) le32atoh(&buf[4]));
+ 	DBG(10, "offset length of main scan  : %lu\n",
+-	    (u_long) le32atoh(&buf[8]));
++	    (unsigned long) le32atoh(&buf[8]));
+ 	DBG(10, "offset length of sub scan   : %lu\n",
+-	    (u_long) le32atoh(&buf[12]));
++	    (unsigned long) le32atoh(&buf[12]));
+ 	DBG(10, "scanning length of main scan: %lu\n",
+-	    (u_long) le32atoh(&buf[16]));
++	    (unsigned long) le32atoh(&buf[16]));
+ 	DBG(10, "scanning length of sub scan : %lu\n",
+-	    (u_long) le32atoh(&buf[20]));
++	    (unsigned long) le32atoh(&buf[20]));
+ 	DBG(10, "scanning color              : %d\n", buf[24]);
+ 	DBG(10, "data format                 : %d\n", buf[25]);
+ 	DBG(10, "option control              : %d\n", buf[26]);
+--- sane-backends-1.0.24.orig/backend/epson2-io.c
++++ sane-backends-1.0.24/backend/epson2-io.c
+_at_@ -47,7 +47,7 @@
+ 	    SANE_Status * status)
+ {
+ 	DBG(15, "%s: size = %lu, reply = %lu\n",
+-	    __func__, (u_long) buf_size, (u_long) reply_len);
++	    __func__, (unsigned long) buf_size, (unsigned long) reply_len);
+ 
+ 	if (buf_size == 2) {
+ 		char *cmd = buf;
+_at_@ -143,7 +143,7 @@
+ 
+ 	if (n < buf_size) {
+ 		DBG(1, "%s: expected = %lu, got = %ld\n", __func__,
+-		    (u_long) buf_size, (long) n);
++		    (unsigned long) buf_size, (long) n);
+ 		*status = SANE_STATUS_IO_ERROR;
+ 	}
+ 
+_at_@ -193,7 +193,7 @@
+ 	unsigned char result;
+ 	SANE_Status status;
+ 
+-	DBG(12, "%s: size = %lu\n", __func__, (u_long) buf_size);
++	DBG(12, "%s: size = %lu\n", __func__, (unsigned long) buf_size);
+ 
+ 	status = e2_txrx(s, buf, buf_size, &result, 1);
+ 	if (status != SANE_STATUS_GOOD) {
+_at_@ -260,7 +260,7 @@
+ 			*payload_size *= le16atoh(&info[4]);
+ 
+ 		DBG(14, "%s: payload length: %lu\n", __func__,
+-			(u_long) *payload_size);
++			(unsigned long) *payload_size);
+ 	}
+ 
+ 	return SANE_STATUS_GOOD;
+_at_@ -283,7 +283,7 @@
+ 	size_t len;
+ 
+ 	DBG(13, "%s, params len = %d, reply len = %lu, buf = %p\n",
+-	    __func__, params_len, (u_long) reply_len, (void *) buf);
++	    __func__, params_len, (unsigned long) reply_len, (void *) buf);
+ 
+ 	if (buf == NULL)
+ 		return SANE_STATUS_INVAL;
+_at_@ -315,7 +315,7 @@
+ 	 */
+ 	if (reply_len && (len != reply_len)) {
+ 		DBG(1, "%s: mismatched len - expected %lu, got %lu\n",
+-		    __func__, (u_long) reply_len, (u_long) len);
++		    __func__, (unsigned long) reply_len, (unsigned long) len);
+ 	}
+ 
+ 	/* allocate and receive the payload */
+--- sane-backends-1.0.24.orig/backend/epson2_net.c
++++ sane-backends-1.0.24/backend/epson2_net.c
+_at_@ -62,7 +62,7 @@
+ 	/* read from buffer, if available */
+ 	if (s->netptr != s->netbuf) {
+ 		DBG(23, "reading %lu from buffer at %p, %lu available\n",
+-			(u_long) wanted, s->netptr, (u_long) s->netlen);
++			(unsigned long) wanted, s->netptr, (unsigned long) s->netlen);
+ 
+ 		memcpy(buf, s->netptr, wanted);
+ 		read = wanted;
+_at_@ -95,7 +95,7 @@
+ 	size = be32atoh(&header[6]);
+ 
+ 	DBG(23, "%s: wanted = %lu, available = %lu\n", __FUNCTION__,
+-		(u_long) wanted, (u_long) size);
++		(unsigned long) wanted, (unsigned long) size);
+ 
+ 	*status = SANE_STATUS_GOOD;
+ 
+_at_@ -131,7 +131,7 @@
+ 
+ 		DBG(23, "0,4 %02x %02x\n", s->netbuf[0], s->netbuf[4]);
+ 		DBG(23, "storing %lu to buffer at %p, next read at %p, %lu bytes left\n",
+-			(u_long) size, s->netbuf, s->netptr, (u_long) s->netlen);
++			(unsigned long) size, s->netbuf, s->netptr, (unsigned long) s->netlen);
+ 
+ 		memcpy(buf, s->netbuf, wanted);
+ 	}
+_at_@ -157,11 +157,11 @@
+ 		s->netbuf = s->netptr = malloc(reply_len);
+ 		s->netlen = reply_len;
+ 		DBG(24, "allocated %lu bytes at %p\n",
+-			(u_long) reply_len, s->netbuf);
++			(unsigned long) reply_len, s->netbuf);
+ 	}
+ 
+ 	DBG(24, "%s: cmd = %04x, buf = %p, buf_size = %lu, reply_len = %lu\n",
+-		__FUNCTION__, cmd, buf, (u_long) buf_size, (u_long) reply_len);
++		__FUNCTION__, cmd, buf, (unsigned long) buf_size, (unsigned long) reply_len);
+ 
+ 	memset(h1, 0x00, 12);
+ 	memset(h2, 0x00, 8);
+_at_@ -183,9 +183,9 @@
+ 		htobe32a(&h2[0], buf_size);
+ 		htobe32a(&h2[4], reply_len);
+ 
+-		DBG(24, "H1[6]: %02x %02x %02x %02x (%lu)\n", h1[6], h1[7], h1[8], h1[9], (u_long) (buf_size + 8));
+-		DBG(24, "H2[0]: %02x %02x %02x %02x (%lu)\n", h2[0], h2[1], h2[2], h2[3], (u_long) buf_size);
+-		DBG(24, "H2[4]: %02x %02x %02x %02x (%lu)\n", h2[4], h2[5], h2[6], h2[7], (u_long) reply_len);
++		DBG(24, "H1[6]: %02x %02x %02x %02x (%lu)\n", h1[6], h1[7], h1[8], h1[9], (unsigned long) (buf_size + 8));
++		DBG(24, "H2[0]: %02x %02x %02x %02x (%lu)\n", h2[0], h2[1], h2[2], h2[3], (unsigned long) buf_size);
++		DBG(24, "H2[4]: %02x %02x %02x %02x (%lu)\n", h2[4], h2[5], h2[6], h2[7], (unsigned long) reply_len);
+ 	}
+ 
+ 	if ((cmd >> 8) == 0x20 && (buf_size || reply_len)) {
+--- sane-backends-1.0.24.orig/backend/epson_scsi.c
++++ sane-backends-1.0.24/backend/epson_scsi.c
+_at_@ -29,7 +29,7 @@
+  * sense handler for the sanei_scsi_XXX comands
+  */
+ SANE_Status
+-sanei_epson_scsi_sense_handler (int scsi_fd, u_char * result, void *arg)
++sanei_epson_scsi_sense_handler (int scsi_fd, unsigned char * result, void *arg)
+ {
+   /* to get rid of warnings */
+   scsi_fd = scsi_fd;
+_at_@ -53,7 +53,7 @@
+ SANE_Status
+ sanei_epson_scsi_inquiry (int fd, int page_code, void *buf, size_t * buf_size)
+ {
+-  u_char cmd[6];
++  unsigned char cmd[6];
+   int status;
+ 
+   memset (cmd, 0, 6);
+_at_@ -73,7 +73,7 @@
+ sanei_epson_scsi_read (int fd, void *buf, size_t buf_size,
+                        SANE_Status * status)
+ {
+-  u_char cmd[6];
++  unsigned char cmd[6];
+ 
+   memset (cmd, 0, 6);
+   cmd[0] = READ_6_COMMAND;
+_at_@ -96,7 +96,7 @@
+ sanei_epson_scsi_write (int fd, const void *buf, size_t buf_size,
+                         SANE_Status * status)
+ {
+-  u_char *cmd;
++  unsigned char *cmd;
+ 
+   cmd = alloca (8 + buf_size);
+   memset (cmd, 0, 8);
+--- sane-backends-1.0.24.orig/backend/epson_scsi.h
++++ sane-backends-1.0.24/backend/epson_scsi.h
+_at_@ -12,7 +12,7 @@
+ 
+ #define INQUIRY_BUF_SIZE		(36)
+ 
+-SANE_Status sanei_epson_scsi_sense_handler (int scsi_fd, u_char * result,
++SANE_Status sanei_epson_scsi_sense_handler (int scsi_fd, unsigned char * result,
+ 					    void *arg);
+ SANE_Status sanei_epson_scsi_inquiry (int fd, int page_code, void *buf,
+ 				      size_t * buf_size);
+--- sane-backends-1.0.24.orig/backend/fujitsu.h
++++ sane-backends-1.0.24/backend/fujitsu.h
+_at_@ -737,7 +737,7 @@
+ static SANE_Status connect_fd (struct fujitsu *s);
+ static SANE_Status disconnect_fd (struct fujitsu *s);
+ 
+-static SANE_Status sense_handler (int scsi_fd, u_char * result, void *arg);
++static SANE_Status sense_handler (int scsi_fd, unsigned char * result, void *arg);
+ 
+ static SANE_Status init_inquire (struct fujitsu *s);
+ static SANE_Status init_vpd (struct fujitsu *s);
+--- sane-backends-1.0.24.orig/backend/genesys.c
++++ sane-backends-1.0.24/backend/genesys.c
+_at_@ -4278,7 +4278,7 @@
+     {
+       DBG (DBG_error,
+ 	   "accurate_line_read: failed to read %lu bytes (%s)\n",
+-	   (u_long) size, sane_strstatus (status));
++	   (unsigned long) size, sane_strstatus (status));
+       return SANE_STATUS_IO_ERROR;
+     }
+ 
+_at_@ -4308,7 +4308,7 @@
+ 	    {
+ 	      DBG (DBG_error,
+ 		   "%s: failed to read %lu bytes (%s)\n", __FUNCTION__,
+-		   (u_long) dev->oe_buffer.size, sane_strstatus (status));
++		   (unsigned long) dev->oe_buffer.size, sane_strstatus (status));
+ 	      return SANE_STATUS_IO_ERROR;
+ 	    }
+ 	}
+_at_@ -4345,7 +4345,7 @@
+                 {
+                   DBG (DBG_error,
+                        "%s: failed to read %lu bytes (%s)\n", __FUNCTION__, 
+-                       (u_long) dev->oe_buffer.size, sane_strstatus (status));
++                       (unsigned long) dev->oe_buffer.size, sane_strstatus (status));
+                   return SANE_STATUS_IO_ERROR;
+                 }
+ 	    }
+_at_@ -4379,7 +4379,7 @@
+ 	    {
+ 	      DBG (DBG_error,
+ 		   "%s: failed to read %lu bytes (%s)\n", __FUNCTION__,
+-		   (u_long) dev->oe_buffer.size, sane_strstatus (status));
++		   (unsigned long) dev->oe_buffer.size, sane_strstatus (status));
+ 	      return SANE_STATUS_IO_ERROR;
+ 	    }
+ 	}
+_at_@ -4470,7 +4470,7 @@
+                 {
+                   DBG (DBG_error,
+                        "%s: failed to read %lu bytes (%s)\n", __FUNCTION__, 
+-                       (u_long) dev->oe_buffer.size, sane_strstatus (status));
++                       (unsigned long) dev->oe_buffer.size, sane_strstatus (status));
+                   return SANE_STATUS_IO_ERROR;
+                 }
+ 	    }
+_at_@ -4527,7 +4527,7 @@
+     return SANE_STATUS_GOOD;
+ 
+   DBG (DBG_io, "genesys_fill_read_buffer: reading %lu bytes\n",
+-       (u_long) size);
++       (unsigned long) size);
+ 
+   /* size is already maxed to our needs. for most models bulk_read_data
+      will read as much data as requested. */
+_at_@ -4560,7 +4560,7 @@
+     {
+       DBG (DBG_error,
+            "genesys_fill_read_buffer: failed to read %lu bytes (%s)\n",
+-           (u_long) size, sane_strstatus (status));
++           (unsigned long) size, sane_strstatus (status));
+       return SANE_STATUS_IO_ERROR;
+     }
+ 
+_at_@ -4663,11 +4663,11 @@
+ 
+   DBG (DBG_info,
+        "genesys_read_ordered_data: frontend requested %lu bytes\n",
+-       (u_long) * len);
++       (unsigned long) * len);
+ 
+   DBG (DBG_info,
+        "genesys_read_ordered_data: bytes_to_read=%lu, total_bytes_read=%lu\n",
+-       (u_long) dev->total_bytes_to_read, (u_long) dev->total_bytes_read);
++       (unsigned long) dev->total_bytes_to_read, (unsigned long) dev->total_bytes_read);
+   /* is there data left to scan */
+   if (dev->total_bytes_read >= dev->total_bytes_to_read)
+     {
+_at_@ -5073,7 +5073,7 @@
+     }
+ 
+   DBG (DBG_proc, "genesys_read_ordered_data: completed, %lu bytes read\n",
+-       (u_long) bytes);
++       (unsigned long) bytes);
+   return SANE_STATUS_GOOD;
+ }
+ 
+_at_@ -7692,8 +7692,8 @@
+ 
+   DBG (DBG_proc, "sane_read: start, %d maximum bytes required\n", max_len);
+   DBG (DBG_io2, "sane_read: bytes_to_read=%lu, total_bytes_read=%lu\n",
+-       (u_long) dev->total_bytes_to_read, (u_long) dev->total_bytes_read);
+-  DBG (DBG_io2, "sane_read: physical bytes to read = %lu\n", (u_long) dev->read_bytes_left);
++       (unsigned long) dev->total_bytes_to_read, (unsigned long) dev->total_bytes_read);
++  DBG (DBG_io2, "sane_read: physical bytes to read = %lu\n", (unsigned long) dev->read_bytes_left);
+   
+   if(dev->total_bytes_read>=dev->total_bytes_to_read)
+     {
+--- sane-backends-1.0.24.orig/backend/genesys_gl124.c
++++ sane-backends-1.0.24/backend/genesys_gl124.c
+_at_@ -73,7 +73,7 @@
+   size_t size, target, read, done;
+   uint8_t outdata[8], *buffer;
+ 
+-  DBG (DBG_io, "gl124_bulk_read_data: requesting %lu bytes (unused addr=0x%02x)\n", (u_long) len,addr);
++  DBG (DBG_io, "gl124_bulk_read_data: requesting %lu bytes (unused addr=0x%02x)\n", (unsigned long) len,addr);
+ 
+   if (len == 0)
+     return SANE_STATUS_GOOD;
+_at_@ -125,7 +125,7 @@
+         {
+           DBG (DBG_io2,
+                "gl124_bulk_read_data: trying to read %lu bytes of data\n",
+-               (u_long) read);
++               (unsigned long) read);
+           status = sanei_usb_read_bulk (dev->dn, data, &read);
+           if (status != SANE_STATUS_GOOD)
+             {
+_at_@ -143,7 +143,7 @@
+ 	  read = size - read;
+ 	  DBG (DBG_io2,
+ 	       "gl124_bulk_read_data: trying to read remaining %lu bytes of data\n",
+-	       (u_long) read);
++	       (unsigned long) read);
+ 	  status = sanei_usb_read_bulk (dev->dn, data+done, &read);
+ 	  if (status != SANE_STATUS_GOOD)
+ 	    {
+_at_@ -155,7 +155,7 @@
+ 	}
+ 
+       DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __FUNCTION__,
+-	   (u_long) size, (u_long) (target - size));
++	   (unsigned long) size, (unsigned long) (target - size));
+ 
+       target -= size;
+       data += size;
+_at_@ -1733,7 +1733,7 @@
+ 
+   DBG (DBG_info,
+        "gl124_init_scan_regs: physical bytes to read = %lu\n",
+-       (u_long) dev->read_bytes_left);
++       (unsigned long) dev->read_bytes_left);
+   dev->read_active = SANE_TRUE;
+ 
+ 
+_at_@ -1760,7 +1760,7 @@
+       dev->settings.pixels * dev->settings.lines * channels * (depth / 8);
+ 
+   DBG (DBG_info, "gl124_init_scan_regs: total bytes to send = %lu\n",
+-       (u_long) dev->total_bytes_to_read);
++       (unsigned long) dev->total_bytes_to_read);
+ 
+   DBGCOMPLETED;
+   return SANE_STATUS_GOOD;
+--- sane-backends-1.0.24.orig/backend/genesys_gl646.c
++++ sane-backends-1.0.24/backend/genesys_gl646.c
+_at_@ -114,7 +114,7 @@
+   size = i * 2;
+ 
+   DBG (DBG_io, "gl646_bulk_write_register (elems= %lu, size = %lu)\n",
+-       (u_long) elems, (u_long) size);
++       (unsigned long) elems, (unsigned long) size);
+ 
+ 
+   outdata[0] = BULK_OUT;
+_at_@ -182,7 +182,7 @@
+     }
+ 
+   DBG (DBG_io, "gl646_bulk_write_register: wrote %lu bytes, %lu registers\n",
+-       (u_long) size, (u_long) elems);
++       (unsigned long) size, (unsigned long) elems);
+   return status;
+ }
+ 
+_at_@ -195,7 +195,7 @@
+   size_t size;
+   uint8_t outdata[8];
+ 
+-  DBG (DBG_io, "gl646_bulk_write_data writing %lu bytes\n", (u_long) len);
++  DBG (DBG_io, "gl646_bulk_write_data writing %lu bytes\n", (unsigned long) len);
+ 
+   status =
+     sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER,
+_at_@ -247,7 +247,7 @@
+ 
+       DBG (DBG_io2,
+ 	   "gl646_bulk_write_data wrote %lu bytes, %lu remaining\n",
+-	   (u_long) size, (u_long) (len - size));
++	   (unsigned long) size, (unsigned long) (len - size));
+ 
+       len -= size;
+       data += size;
+_at_@ -301,7 +301,7 @@
+   size_t size;
+   uint8_t outdata[8];
+ 
+-  DBG (DBG_io, "gl646_bulk_read_data: requesting %lu bytes\n", (u_long) len);
++  DBG (DBG_io, "gl646_bulk_read_data: requesting %lu bytes\n", (unsigned long) len);
+ 
+   /* write requested size */
+   status =
+_at_@ -344,7 +344,7 @@
+ 
+       DBG (DBG_io2,
+ 	   "gl646_bulk_read_data: trying to read %lu bytes of data\n",
+-	   (u_long) size);
++	   (unsigned long) size);
+       status = sanei_usb_read_bulk (dev->dn, data, &size);
+       if (status != SANE_STATUS_GOOD)
+ 	{
+_at_@ -356,7 +356,7 @@
+ 
+       DBG (DBG_io2,
+ 	   "gl646_bulk_read_data read %lu bytes, %lu remaining\n",
+-	   (u_long) size, (u_long) (len - size));
++	   (unsigned long) size, (unsigned long) (len - size));
+ 
+       len -= size;
+       data += size;
+_at_@ -1284,7 +1284,7 @@
+ 
+   DBG (DBG_info,
+        "gl646_setup_registers: physical bytes to read = %lu\n",
+-       (u_long) dev->read_bytes_left);
++       (unsigned long) dev->read_bytes_left);
+   dev->read_active = SANE_TRUE;
+ 
+   dev->current_setup.pixels =
+_at_@ -2564,11 +2564,11 @@
+        * read_bytes_left is the number of bytes to read from the scanner
+        */
+       DBG (DBG_io, "gl646_detect_document_end: total_bytes_to_read=%lu\n",
+-	   (u_long) dev->total_bytes_to_read);
++	   (unsigned long) dev->total_bytes_to_read);
+       DBG (DBG_io, "gl646_detect_document_end: total_bytes_read   =%lu\n",
+-	   (u_long) dev->total_bytes_read);
++	   (unsigned long) dev->total_bytes_read);
+       DBG (DBG_io, "gl646_detect_document_end: read_bytes_left    =%lu\n",
+-	   (u_long) dev->read_bytes_left);
++	   (unsigned long) dev->read_bytes_left);
+ 
+       /* amount of data available from scanner is what to scan */
+       status = sanei_genesys_read_valid_words (dev, &bytes_left);
+_at_@ -2594,11 +2594,11 @@
+ 	  dev->read_bytes_left = bytes_left;
+ 	}
+       DBG (DBG_io, "gl646_detect_document_end: total_bytes_to_read=%lu\n",
+-	   (u_long) dev->total_bytes_to_read);
++	   (unsigned long) dev->total_bytes_to_read);
+       DBG (DBG_io, "gl646_detect_document_end: total_bytes_read   =%lu\n",
+-	   (u_long) dev->total_bytes_read);
++	   (unsigned long) dev->total_bytes_read);
+       DBG (DBG_io, "gl646_detect_document_end: read_bytes_left    =%lu\n",
+-	   (u_long) dev->read_bytes_left);
++	   (unsigned long) dev->read_bytes_left);
+     }
+   DBG (DBG_proc, "gl646_detect_document_end: end\n");
+ 
+--- sane-backends-1.0.24.orig/backend/genesys_gl841.c
++++ sane-backends-1.0.24/backend/genesys_gl841.c
+_at_@ -82,7 +82,7 @@
+   elems = i;
+ 
+   DBG (DBG_io, "gl841_bulk_write_register (elems = %lu)\n",
+-       (u_long) elems);
++       (unsigned long) elems);
+ 
+   for (i = 0; i < elems; i++) {
+ 
+_at_@ -112,7 +112,7 @@
+   }
+ 
+   DBG (DBG_io, "gl841_bulk_write_register: wrote %lu registers\n",
+-       (u_long) elems);
++       (unsigned long) elems);
+   return status;
+ }
+ 
+_at_@ -126,7 +126,7 @@
+   uint8_t outdata[8];
+ 
+   DBG (DBG_io, "gl841_bulk_write_data writing %lu bytes\n",
+-       (u_long) len);
++       (unsigned long) len);
+ 
+   status =
+     sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER,
+_at_@ -178,7 +178,7 @@
+ 
+       DBG (DBG_io2,
+ 	   "gl841_bulk_write_data wrote %lu bytes, %lu remaining\n",
+-	   (u_long) size, (u_long) (len - size));
++	   (unsigned long) size, (unsigned long) (len - size));
+ 
+       len -= size;
+       data += size;
+_at_@ -218,7 +218,7 @@
+   uint8_t outdata[8];
+ 
+   DBG (DBG_io, "gl841_bulk_read_data: requesting %lu bytes\n",
+-       (u_long) len);
++       (unsigned long) len);
+ 
+   if (len == 0) 
+       return SANE_STATUS_GOOD;
+_at_@ -263,7 +263,7 @@
+ 
+       DBG (DBG_io2,
+ 	   "gl841_bulk_read_data: trying to read %lu bytes of data\n",
+-	   (u_long) size);
++	   (unsigned long) size);
+ 
+       status = sanei_usb_read_bulk (dev->dn, data, &size);
+ 
+_at_@ -277,7 +277,7 @@
+ 
+       DBG (DBG_io2,
+ 	   "gl841_bulk_read_data read %lu bytes, %lu remaining\n",
+-	   (u_long) size, (u_long) (len - size));
++	   (unsigned long) size, (unsigned long) (len - size));
+ 
+       len -= size;
+       data += size;
+_at_@ -333,7 +333,7 @@
+   uint8_t outdata[8];
+ 
+   DBG (DBG_io, "gl841_bulk_write_data_gamma writing %lu bytes\n",
+-       (u_long) len);
++       (unsigned long) len);
+ 
+   status =
+     sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER,
+_at_@ -385,7 +385,7 @@
+ 
+       DBG (DBG_io2,
+ 	   "genesys_bulk_write_data:gamma wrote %lu bytes, %lu remaining\n",
+-	   (u_long) size, (u_long) (len - size));
++	   (unsigned long) size, (unsigned long) (len - size));
+ 
+       len -= size;
+       data += size;
+_at_@ -2514,7 +2514,7 @@
+ 
+   DBG (DBG_info,
+        "gl841_init_scan_regs: physical bytes to read = %lu\n",
+-       (u_long) dev->read_bytes_left);
++       (unsigned long) dev->read_bytes_left);
+   dev->read_active = SANE_TRUE;
+ 
+ 
+_at_@ -2555,7 +2555,7 @@
+ 	  dev->settings.pixels * dev->settings.lines * channels * (depth / 8);
+ 
+   DBG (DBG_info, "gl841_init_scan_regs: total bytes to send = %lu\n",
+-       (u_long) dev->total_bytes_to_read);
++       (unsigned long) dev->total_bytes_to_read);
+ /* END TODO */
+ 
+   DBG (DBG_proc, "gl841_init_scan_regs: completed\n");
+--- sane-backends-1.0.24.orig/backend/genesys_gl843.c
++++ sane-backends-1.0.24/backend/genesys_gl843.c
+_at_@ -67,7 +67,7 @@
+   uint8_t outdata[8];
+ 
+   DBGSTART;
+-  DBG (DBG_io, "gl843_bulk_write_data writing %lu bytes\n", (u_long) len);
++  DBG (DBG_io, "gl843_bulk_write_data writing %lu bytes\n", (unsigned long) len);
+ 
+   status =
+     sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER,
+_at_@ -119,7 +119,7 @@
+ 
+       DBG (DBG_io2,
+ 	   "gl843_bulk_write_data: wrote %lu bytes, %lu remaining\n",
+-	   (u_long) size, (u_long) (len - size));
++	   (unsigned long) size, (unsigned long) (len - size));
+ 
+       len -= size;
+       data += size;
+_at_@ -220,7 +220,7 @@
+   DBGSTART;
+   DBG (DBG_io,
+        "gl843_bulk_read_data: requesting %lu bytes from 0x%02x addr\n",
+-       (u_long) len, addr);
++       (unsigned long) len, addr);
+ 
+   status =
+     sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER,
+_at_@ -270,7 +270,7 @@
+ 
+       DBG (DBG_io2,
+ 	   "gl843_bulk_read_data: trying to read %lu bytes of data\n",
+-	   (u_long) size);
++	   (unsigned long) size);
+ 
+       status = sanei_usb_read_bulk (dev->dn, data, &size);
+       if (status != SANE_STATUS_GOOD)
+_at_@ -283,7 +283,7 @@
+ 
+       DBG (DBG_io2,
+ 	   "gl843_bulk_read_data read %lu bytes, %lu remaining\n",
+-	   (u_long) size, (u_long) (len - size));
++	   (unsigned long) size, (unsigned long) (len - size));
+ 
+       len -= size;
+       data += size;
+_at_@ -1647,7 +1647,7 @@
+ 
+   DBG (DBG_info,
+        "gl843_init_scan_regs: physical bytes to read = %lu\n",
+-       (u_long) dev->read_bytes_left);
++       (unsigned long) dev->read_bytes_left);
+   dev->read_active = SANE_TRUE;
+ 
+ 
+_at_@ -1674,7 +1674,7 @@
+       dev->settings.pixels * dev->settings.lines * channels * (depth / 8);
+ 
+   DBG (DBG_info, "gl843_init_scan_regs: total bytes to send = %lu\n",
+-       (u_long) dev->total_bytes_to_read);
++       (unsigned long) dev->total_bytes_to_read);
+ 
+   DBG (DBG_proc, "gl843_init_scan_regs: completed\n");
+   return SANE_STATUS_GOOD;
+--- sane-backends-1.0.24.orig/backend/genesys_gl846.c
++++ sane-backends-1.0.24/backend/genesys_gl846.c
+_at_@ -78,7 +78,7 @@
+   uint8_t outdata[8];
+   uint8_t *buffer;
+ 
+-  DBG (DBG_io, "gl846_bulk_read_data: requesting %lu bytes at addr=0x%02x\n", (u_long) len, addr);
++  DBG (DBG_io, "gl846_bulk_read_data: requesting %lu bytes at addr=0x%02x\n", (unsigned long) len, addr);
+ 
+   if (len == 0)
+     return SANE_STATUS_GOOD;
+_at_@ -131,7 +131,7 @@
+      
+       DBG (DBG_io2,
+ 	   "gl846_bulk_read_data: trying to read %lu bytes of data\n",
+-	   (u_long) read);
++	   (unsigned long) read);
+       status = sanei_usb_read_bulk (dev->dn, buffer, &read);
+       if (status != SANE_STATUS_GOOD)
+ 	{
+_at_@ -141,7 +141,7 @@
+ 	  return status;
+ 	}
+       done=read;
+-      DBG (DBG_io2, "gl846_bulk_read_data: %lu bytes of data read\n", (u_long) done);
++      DBG (DBG_io2, "gl846_bulk_read_data: %lu bytes of data read\n", (unsigned long) done);
+ 
+       /* read less than 512 bytes remainder */
+       if (read < size)
+_at_@ -149,7 +149,7 @@
+ 	  read = size - read;
+ 	  DBG (DBG_io2,
+ 	       "gl846_bulk_read_data: trying to read %lu bytes of data\n",
+-	       (u_long) read);
++	       (unsigned long) read);
+ 	  status = sanei_usb_read_bulk (dev->dn, buffer+done, &read);
+ 	  if (status != SANE_STATUS_GOOD)
+ 	    {
+_at_@ -159,11 +159,11 @@
+ 	      return status;
+ 	    }
+           done=read;
+-          DBG (DBG_io2, "gl846_bulk_read_data: %lu bytes of data read\n", (u_long) done);
++          DBG (DBG_io2, "gl846_bulk_read_data: %lu bytes of data read\n", (unsigned long) done);
+ 	}
+ 
+       DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __FUNCTION__,
+-	   (u_long) size, (u_long) (target - size));
++	   (unsigned long) size, (unsigned long) (target - size));
+ 
+       target -= size;
+       buffer += size;
+_at_@ -1484,7 +1484,7 @@
+ 
+   DBG (DBG_info,
+        "gl846_init_scan_regs: physical bytes to read = %lu\n",
+-       (u_long) dev->read_bytes_left);
++       (unsigned long) dev->read_bytes_left);
+   dev->read_active = SANE_TRUE;
+ 
+ 
+_at_@ -1525,7 +1525,7 @@
+       dev->settings.pixels * dev->settings.lines * channels * (depth / 8);
+ 
+   DBG (DBG_info, "gl846_init_scan_regs: total bytes to send = %lu\n",
+-       (u_long) dev->total_bytes_to_read);
++       (unsigned long) dev->total_bytes_to_read);
+ /* END TODO */
+ 
+   DBGCOMPLETED;
+--- sane-backends-1.0.24.orig/backend/genesys_gl847.c
++++ sane-backends-1.0.24/backend/genesys_gl847.c
+_at_@ -74,7 +74,7 @@
+   uint8_t outdata[8];
+   uint8_t *buffer;
+ 
+-  DBG (DBG_io, "gl847_bulk_read_data: requesting %lu bytes at addr=0x%02x\n", (u_long) len, addr);
++  DBG (DBG_io, "gl847_bulk_read_data: requesting %lu bytes at addr=0x%02x\n", (unsigned long) len, addr);
+ 
+   if (len == 0)
+     return SANE_STATUS_GOOD;
+_at_@ -127,7 +127,7 @@
+      
+       DBG (DBG_io2,
+ 	   "gl847_bulk_read_data: trying to read %lu bytes of data\n",
+-	   (u_long) read);
++	   (unsigned long) read);
+       status = sanei_usb_read_bulk (dev->dn, buffer, &read);
+       if (status != SANE_STATUS_GOOD)
+ 	{
+_at_@ -137,7 +137,7 @@
+ 	  return status;
+ 	}
+       done=read;
+-      DBG (DBG_io2, "gl847_bulk_read_data: %lu bytes of data read\n", (u_long) done);
++      DBG (DBG_io2, "gl847_bulk_read_data: %lu bytes of data read\n", (unsigned long) done);
+ 
+       /* read less than 512 bytes remainder */
+       if (read < size)
+_at_@ -145,7 +145,7 @@
+ 	  read = size - read;
+ 	  DBG (DBG_io2,
+ 	       "gl847_bulk_read_data: trying to read %lu bytes of data\n",
+-	       (u_long) read);
++	       (unsigned long) read);
+ 	  status = sanei_usb_read_bulk (dev->dn, buffer+done, &read);
+ 	  if (status != SANE_STATUS_GOOD)
+ 	    {
+_at_@ -155,11 +155,11 @@
+ 	      return status;
+ 	    }
+           done=read;
+-          DBG (DBG_io2, "gl847_bulk_read_data: %lu bytes of data read\n", (u_long) done);
++          DBG (DBG_io2, "gl847_bulk_read_data: %lu bytes of data read\n", (unsigned long) done);
+ 	}
+ 
+       DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __FUNCTION__,
+-	   (u_long) size, (u_long) (target - size));
++	   (unsigned long) size, (unsigned long) (target - size));
+ 
+       target -= size;
+       buffer += size;
+_at_@ -1508,7 +1508,7 @@
+ 
+   DBG (DBG_info,
+        "gl847_init_scan_regs: physical bytes to read = %lu\n",
+-       (u_long) dev->read_bytes_left);
++       (unsigned long) dev->read_bytes_left);
+   dev->read_active = SANE_TRUE;
+ 
+ 
+_at_@ -1549,7 +1549,7 @@
+       dev->settings.pixels * dev->settings.lines * channels * (depth / 8);
+ 
+   DBG (DBG_info, "gl847_init_scan_regs: total bytes to send = %lu\n",
+-       (u_long) dev->total_bytes_to_read);
++       (unsigned long) dev->total_bytes_to_read);
+ /* END TODO */
+ 
+   DBGCOMPLETED;
+--- sane-backends-1.0.24.orig/backend/genesys_low.c
++++ sane-backends-1.0.24/backend/genesys_low.c
+_at_@ -983,7 +983,7 @@
+   unsigned int words = 0;
+ 
+   DBG (DBG_proc, "sanei_genesys_read_data_from_scanner (size = %lu bytes)\n",
+-       (u_long) size);
++       (unsigned long) size);
+ 
+   if (size & 1)
+     DBG (DBG_info,
+_at_@ -1089,7 +1089,7 @@
+ 	}
+     }
+ 
+-  DBG (DBG_io, "%s: wrote %lu registers\n", __FUNCTION__, (u_long) elems);
++  DBG (DBG_io, "%s: wrote %lu registers\n", __FUNCTION__, (unsigned long) elems);
+   return status;
+ }
+ 
+--- sane-backends-1.0.24.orig/backend/gt68xx_low.c
++++ sane-backends-1.0.24/backend/gt68xx_low.c
+_at_@ -157,7 +157,7 @@
+   if (!dev)
+     {
+       DBG (3, "gt68xx_device_new: couldn't malloc %lu bytes for device\n",
+-	   (u_long) sizeof (GT68xx_Device));
++	   (unsigned long) sizeof (GT68xx_Device));
+       *dev_return = 0;
+       return SANE_STATUS_NO_MEM;
+     }
+--- sane-backends-1.0.24.orig/backend/hp3900_usb.c
++++ sane-backends-1.0.24/backend/hp3900_usb.c
+_at_@ -332,7 +332,7 @@
+     {
+       dataline_count++;
+       DBG (DBG_CTL, "%06i BLK DI: Buffer length = %lu. bytes\n",
+-	   dataline_count, (u_long) size);
++	   dataline_count, (unsigned long) size);
+ 
+ #ifdef STANDALONE
+       if (usb_handle != NULL)
+--- sane-backends-1.0.24.orig/backend/hp5400_internal.c
++++ sane-backends-1.0.24/backend/hp5400_internal.c
+_at_@ -991,7 +991,7 @@
+ 
+   if (hp5400_command_write (iHandle, 0xF10B, sizeof (UISetup1), UISetup1) < 0)
+     {
+-      HP5400_DBG (DBG_MSG, "failed to send UISetup1 (%lu)\n", (u_long) sizeof (UISetup1));
++      HP5400_DBG (DBG_MSG, "failed to send UISetup1 (%lu)\n", (unsigned long) sizeof (UISetup1));
+       return -1;
+     }
+ 
+--- sane-backends-1.0.24.orig/backend/hp5400_sanei.c
++++ sane-backends-1.0.24/backend/hp5400_sanei.c
+_at_@ -283,7 +283,7 @@
+       res = block;
+       sanei_usb_read_bulk (fd, buffer, &res);
+       HP5400_DBG (DBG_MSG, "Read bulk returned %lu, %lu remain\n",
+-		  (u_long) res, (u_long) len);
++		  (unsigned long) res, (unsigned long) len);
+       if (res > 0)
+ 	{
+ 	  fwrite (buffer, (len < res) ? len : res, 1, file);
+_at_@ -314,7 +314,7 @@
+   res = len;
+   sanei_usb_read_bulk (fd, (SANE_Byte *) buffer, &res);
+   HP5400_DBG (DBG_MSG, "Read block returned %lu when reading %d\n", 
+-	      (u_long) res, len);
++	      (unsigned long) res, len);
+   return res;
+ }
+ 
+_at_@ -351,7 +351,7 @@
+       }
+       res = (datalen < block) ? datalen : block;
+       sanei_usb_write_bulk (fd, (SANE_Byte *) (data + offset), &res);
+-      HP5400_DBG (DBG_MSG, "Write returned %lu, %d remain\n", (u_long) res, datalen);
++      HP5400_DBG (DBG_MSG, "Write returned %lu, %d remain\n", (unsigned long) res, datalen);
+       datalen -= block;
+       offset += block;
+     }
+--- sane-backends-1.0.24.orig/backend/hp5590_low.c
++++ sane-backends-1.0.24/backend/hp5590_low.c
+_at_@ -767,7 +767,7 @@
+ 
+       /* Bulk read next page */
+       DBG (DBG_usb, "%s: USB-in-USB: bulk reading %lu bytes\n",
+-	   __FUNCTION__, (u_long) next_portion);
++	   __FUNCTION__, (unsigned long) next_portion);
+       ret = sanei_usb_read_bulk (dn,
+ 				 bulk_read_state->buffer_in_ptr,
+ 				 &next_portion);
+_at_@ -785,7 +785,7 @@
+ 	{
+ 	  DBG (DBG_err, "%s: USB-in-USB: incomplete bulk read "
+ 	       "(requested %u bytes, got %lu bytes)\n",
+-	       __FUNCTION__, BULK_READ_PAGE_SIZE, (u_long) next_portion);
++	       __FUNCTION__, BULK_READ_PAGE_SIZE, (unsigned long) next_portion);
+ 	  return SANE_STATUS_IO_ERROR;
+ 	}
+ 
+_at_@ -919,7 +919,7 @@
+ 	next_portion = len;
+ 
+       DBG (3, "%s: USB-in-USB: next portion %lu bytes\n",
+-	   __FUNCTION__, (u_long) next_portion);
++	   __FUNCTION__, (unsigned long) next_portion);
+ 
+       /* Prepare bulk write request */
+       memset (&ctrl, 0, sizeof (ctrl));
+_at_@ -941,7 +941,7 @@
+ 
+       /* Write bulk data */
+       DBG (3, "%s: USB-in-USB: bulk writing %lu bytes\n",
+-	   __FUNCTION__, (u_long) next_portion);
++	   __FUNCTION__, (unsigned long) next_portion);
+       ret = sanei_usb_write_bulk (dn, ptr, &next_portion);
+       if (ret != SANE_STATUS_GOOD)
+ 	{
+--- sane-backends-1.0.24.orig/backend/hs2p-scsi.c
++++ sane-backends-1.0.24/backend/hs2p-scsi.c
+_at_@ -426,10 +426,10 @@
+    Byte 13: Additional Sense Code Qualifier
+ */
+ static SANE_Status
+-sense_handler (int __sane_unused__ scsi_fd, u_char * sense_buffer, void *sd)
++sense_handler (int __sane_unused__ scsi_fd, unsigned char * sense_buffer, void *sd)
+ {
+-  u_char sense, asc, ascq, EOM, ILI, ErrorCode, ValidData;
+-  u_long MissingBytes;
++  unsigned char sense, asc, ascq, EOM, ILI, ErrorCode, ValidData;
++  unsigned long MissingBytes;
+   char *sense_str = "";
+ 
+   struct sense_key *skey;
+_at_@ -445,7 +445,7 @@
+ 
+   /* store sense_buffer */
+   DBG (DBG_info, ">> copying %lu bytes from sense_buffer[] to sense_data\n",
+-       (u_long) sizeof (SENSE_DATA));
++       (unsigned long) sizeof (SENSE_DATA));
+   memcpy (sdp, sense_buffer, sizeof (SENSE_DATA));
+   if (DBG_LEVEL >= DBG_info)
+     print_sense_data (DBG_LEVEL, sdp);
+_at_@ -942,9 +942,9 @@
+   nbytes = (page_code == 2) ? 20 : 12;
+   DBG (DBG_info,
+        ">>>>> sizeof(cmd)=%lu sizeof(msp)=%lu sizeof(hdr)=%lu sizeof(page)=%lu requesting %lu bytes\n",
+-       (u_long) sizeof (cmd), (u_long) sizeof (msp),
+-       (u_long) sizeof (msp.hdr), (u_long) sizeof (msp.page),
+-       (u_long) nbytes);
++       (unsigned long) sizeof (cmd), (unsigned long) sizeof (msp),
++       (unsigned long) sizeof (msp.hdr), (unsigned long) sizeof (msp.page),
++       (unsigned long) nbytes);
+ 
+   status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), &msp, &nbytes);
+ 
+_at_@ -954,7 +954,7 @@
+ 	   sane_strstatus (status));
+       DBG (DBG_error,
+ 	   ">>>>> mode sense: number of bytes received from scanner: %lu\n",
+-	   (u_long) nbytes);
++	   (unsigned long) nbytes);
+       DBG (DBG_error, "PRINTING CMD BLOCK:\n");
+       print_bytes (&cmd, sizeof (cmd));
+       DBG (DBG_error, "PRINTING MP HEADER:\n");
+_at_@ -965,12 +965,12 @@
+   else
+     {
+       /* nbytes = (page_code==2)? 14 : 6; */
+-      DBG (DBG_info, ">> >> got %lu bytes from scanner\n", (u_long) nbytes);
++      DBG (DBG_info, ">> >> got %lu bytes from scanner\n", (unsigned long) nbytes);
+       nbytes -= 4;		/* we won't copy 4 byte hdr */
+       DBG (DBG_info, ">>>>> copying from msp to calling function's buf\n"
+ 	   ">>>>> msp.page_size=%lu bytes=%lu buf_size=%lu\n",
+-	   (u_long) sizeof (msp.page), (u_long) nbytes,
+-	   (u_long) sizeof (*buf));
++	   (unsigned long) sizeof (msp.page), (unsigned long) nbytes,
++	   (unsigned long) sizeof (*buf));
+       memcpy (buf, &(msp.page), nbytes);
+     }
+ 
+_at_@ -1008,7 +1008,7 @@
+   /* Copy data from swd (including 8-byte header) to win.swd */
+   DBG (DBG_info,
+        "set_window: COPYING %lu bytes from settings to Set Window Command (%lu)\n",
+-       (u_long) sizeof (*swd), (u_long) sizeof (win.swd));
++       (unsigned long) sizeof (*swd), (unsigned long) sizeof (win.swd));
+   if (!memcpy (&(win.swd), swd, sizeof (*swd)))
+     {
+       DBG (DBG_error, "set_window: error with memcpy\n");
+_at_@ -1024,7 +1024,7 @@
+   /* Now execute command */
+   DBG (DBG_info,
+        "set_window: calling sanei_scsi_cmd(%d,&win,%lu, NULL, NULL)\n", fd,
+-       (u_long) sizeof (win));
++       (unsigned long) sizeof (win));
+   status = sanei_scsi_cmd (fd, &win, sizeof (win), NULL, NULL);
+   /*
+      status = sanei_scsi_cmd2 (fd, &win.cmd, sizeof(win.cmd),  &win.swd, sizeof(win.swd), NULL, NULL);
+_at_@ -1154,7 +1154,7 @@
+ }
+ 
+ static SANE_Status
+-read_data (int fd, void *buf, size_t * buf_size, SANE_Byte dtc, u_long dtq)
++read_data (int fd, void *buf, size_t * buf_size, SANE_Byte dtc, unsigned long dtq)
+ {
+   static struct scsi_rs_scanner_cmd cmd;
+   SANE_Status status;
+_at_@ -1794,7 +1794,7 @@
+ 	    {
+ 	      DBG (DBG_error,
+ 		   "hs2p_wait_ready: timed out after %lu seconds\n",
+-		   (u_long) (now - start));
++		   (unsigned long) (now - start));
+ 	      return SANE_STATUS_INVAL;
+ 	    }
+ 	  break;
+--- sane-backends-1.0.24.orig/backend/hs2p.c
++++ sane-backends-1.0.24/backend/hs2p.c
+_at_@ -1916,7 +1916,7 @@
+   SANE_Byte *buf;
+   size_t *len = &(s->data.bufsize);
+   int dtc, fd = s->fd;
+-  u_long dtq = 0;		/* two bytes */
++  unsigned long dtq = 0;		/* two bytes */
+   va_list ap;
+ 
+   DBG (DBG_proc, ">> get_hs2p_data\n");
+_at_@ -1969,7 +1969,7 @@
+ 	}
+       DBG (DBG_info,
+ 	   "get_hs2p_data calling read_data for dtc=%2.2x and bufsize=%lu\n",
+-	   (int) dtc, (u_long) * len);
++	   (int) dtc, (unsigned long) * len);
+       status = read_data (s->fd, buf, len, (SANE_Byte) dtc, dtq);
+       if (status != SANE_STATUS_GOOD)
+ 	{
+_at_@ -2127,7 +2127,7 @@
+ 	  strcpy (val, s->val[option].s);
+ 	  return (SANE_STATUS_GOOD);
+ 	  DBG (DBG_proc, "sizeof(val)=%lu sizeof(s)=%lu\n",
+-	       (u_long) sizeof (val), (u_long) sizeof (s->val[option].s));
++	       (unsigned long) sizeof (val), (unsigned long) sizeof (s->val[option].s));
+ 	  return (SANE_STATUS_GOOD);
+ 
+ 	  /* gamma */
+_at_@ -2626,7 +2626,7 @@
+   DBG (DBG_proc,
+        "%d pixels per line, %d bytes per line, %d lines high, total %lu bytes, "
+        "dpi=%ld\n", s->params.pixels_per_line, s->params.bytes_per_line,
+-       s->params.lines, (u_long) s->bytes_to_read,
++       s->params.lines, (unsigned long) s->bytes_to_read,
+        (long) SANE_UNFIX (s->val[OPT_Y_RESOLUTION].w));
+ 
+   DBG (DBG_proc, "<< sane_get_parameters\n");
+_at_@ -2642,7 +2642,7 @@
+   double offset;
+ 
+   DBG (DBG_proc, ">> set_window_data: sizeof(*wbuf)=%lu; window len=%lu\n",
+-       (u_long) sizeof (*wbuf), (u_long) sizeof (wbuf->data));
++       (unsigned long) sizeof (*wbuf), (unsigned long) sizeof (wbuf->data));
+ 
+   /* initialize our window buffer with zeros */
+   DBG (DBG_proc, ">> set_window_data: CLEARING wbuf\n");
+_at_@ -2651,7 +2651,7 @@
+   /* Header */
+   DBG (DBG_proc,
+        ">> set_window_data: writing Window Descriptor Length =%lu\n",
+-       (u_long) sizeof (wbuf->data));
++       (unsigned long) sizeof (wbuf->data));
+   _lto2b (sizeof (wbuf->data), &wbuf->hdr.len[0]);
+ 
+   /* X-Axis Resolution 100-800dpi in 1 dpi steps */
+_at_@ -3185,7 +3185,7 @@
+   *len = 0;
+ 
+   DBG (DBG_info, "sane_read: bytes left to read: %ld\n",
+-       (u_long) s->bytes_to_read);
++       (unsigned long) s->bytes_to_read);
+ 
+   if (s->bytes_to_read == 0)
+     {				/* We've reached the end of one side of sheet */
+_at_@ -3225,7 +3225,7 @@
+       if (s->val[OPT_PADDING].w)
+ 	{
+ 	  DBG (DBG_info, "sane_read s->EOM padding from %ld to %ld\n",
+-	       (u_long) start, (u_long) bytes_requested);
++	       (unsigned long) start, (unsigned long) bytes_requested);
+ 	  color = (s->val[OPT_NEGATIVE].w) ? 0 : 255;
+ 	  /* pad to requested length */
+ 	  for (i = start; i < bytes_requested; i++)
+_at_@ -3242,7 +3242,7 @@
+     }
+   else
+     {
+-      DBG (DBG_info, "sane_read: trying to read %ld bytes\n", (u_long) nread);
++      DBG (DBG_info, "sane_read: trying to read %ld bytes\n", (unsigned long) nread);
+       status = read_data (s->fd, buf, &nread, DATA_TYPE_IMAGE, DTQ);
+       switch (status)
+ 	{
+--- sane-backends-1.0.24.orig/backend/hs2p.h
++++ sane-backends-1.0.24/backend/hs2p.h
+_at_@ -277,7 +277,7 @@
+   SANE_Byte bpp;		/* 1,4,6,or 8 Bits Per Pixel    */
+ 
+ 
+-  u_long InvalidBytes;
++  unsigned long InvalidBytes;
+   size_t bytes_to_read;
+   SANE_Bool cancelled;
+   /*SANE_Bool backpage; */
+_at_@ -379,14 +379,14 @@
+ #endif
+ 
+ static /* inline */ void
+-_lto2b (u_long val, SANE_Byte * bytes)
++_lto2b (unsigned long val, SANE_Byte * bytes)
+ {
+   bytes[0] = (val >> 8) & 0xff;
+   bytes[1] = val & 0xff;
+ }
+ 
+ static /* inline */ void
+-_lto3b (u_long val, SANE_Byte * bytes)
++_lto3b (unsigned long val, SANE_Byte * bytes)
+ {
+   bytes[0] = (val >> 16) & 0xff;
+   bytes[1] = (val >> 8) & 0xff;
+_at_@ -394,7 +394,7 @@
+ }
+ 
+ static /* inline */ void
+-_lto4b (u_long val, SANE_Byte * bytes)
++_lto4b (unsigned long val, SANE_Byte * bytes)
+ {
+   bytes[0] = (val >> 24) & 0xff;
+   bytes[1] = (val >> 16) & 0xff;
+_at_@ -405,7 +405,7 @@
+ static /* inline */ u_long
+ _2btol (SANE_Byte * bytes)
+ {
+-  u_long rv;
++  unsigned long rv;
+ 
+   rv = (bytes[0] << 8) | bytes[1];
+ 
+_at_@ -415,7 +415,7 @@
+ static /* inline */ u_long
+ _4btol (SANE_Byte * bytes)
+ {
+-  u_long rv;
++  unsigned long rv;
+ 
+   rv = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3];
+ 
+--- sane-backends-1.0.24.orig/backend/ibm-scsi.c
++++ sane-backends-1.0.24/backend/ibm-scsi.c
+_at_@ -382,7 +382,7 @@
+           if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME)
+             {
+               DBG(1, "ibm_wait_ready: timed out after %lu seconds\n",
+-                  (u_long) (now.tv_sec - start.tv_sec));
++                  (unsigned long) (now.tv_sec - start.tv_sec));
+               return SANE_STATUS_INVAL;
+             }
+           usleep (100000);      /* retry after 100ms */
+_at_@ -423,7 +423,7 @@
+           if (now - start >= MAX_WAITING_TIME)
+             {
+               DBG(1, "ibm_wait_ready: timed out after %lu seconds\n",
+-                  (u_long) (now - start));
++                  (unsigned long) (now - start));
+               return SANE_STATUS_INVAL;
+             }
+           break;
+--- sane-backends-1.0.24.orig/backend/ibm.c
++++ sane-backends-1.0.24/backend/ibm.c
+_at_@ -924,7 +924,7 @@
+ 
+   DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, "
+        "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line,
+-       s->params.lines, (u_long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w);
++       s->params.lines, (unsigned long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w);
+ 
+   DBG (11, "<< sane_get_parameters\n");
+   return (SANE_STATUS_GOOD);
+_at_@ -1100,7 +1100,7 @@
+ 
+   DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, "
+        "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line,
+-       s->params.lines, (u_long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w);
++       s->params.lines, (unsigned long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w);
+  
+   s->scanning = SANE_TRUE;
+ 
+_at_@ -1119,7 +1119,7 @@
+ 
+   *len = 0;
+ 
+-  DBG (11, "sane_read: bytes left to read: %ld\n", (u_long) s->bytes_to_read);
++  DBG (11, "sane_read: bytes left to read: %ld\n", (unsigned long) s->bytes_to_read);
+   
+   if (s->bytes_to_read == 0)
+     {
+_at_@ -1136,7 +1136,7 @@
+   if (nread > s->bytes_to_read)
+     nread = s->bytes_to_read;
+ 
+-  DBG (11, "sane_read: read %ld bytes\n", (u_long) nread);
++  DBG (11, "sane_read: read %ld bytes\n", (unsigned long) nread);
+   status = read_data (s->fd, buf, &nread);
+   if (status != SANE_STATUS_GOOD)
+     {
+--- sane-backends-1.0.24.orig/backend/kodak.h
++++ sane-backends-1.0.24/backend/kodak.h
+_at_@ -237,7 +237,7 @@
+ static SANE_Status attach_one (const char *name);
+ static SANE_Status connect_fd (struct scanner *s);
+ static SANE_Status disconnect_fd (struct scanner *s);
+-static SANE_Status sense_handler (int scsi_fd, u_char * result, void *arg);
++static SANE_Status sense_handler (int scsi_fd, unsigned char * result, void *arg);
+ 
+ static SANE_Status init_inquire (struct scanner *s);
+ static SANE_Status init_model (struct scanner *s);
+--- sane-backends-1.0.24.orig/backend/kodakaio.c
++++ sane-backends-1.0.24/backend/kodakaio.c
+_at_@ -802,7 +802,7 @@
+ 	char fmt_buf[25];
+ 
+ 	kodakaio_com_str(buf, fmt_buf);
+-	DBG(15, "%s: size = %lu :%s\n", __func__, (u_long) buf_size, fmt_buf);
++	DBG(15, "%s: size = %lu :%s\n", __func__, (unsigned long) buf_size, fmt_buf);
+ 
+ 	if (DBG_LEVEL >= 125) {
+ 		const unsigned char *s = buf;
+--- sane-backends-1.0.24.orig/backend/kvs20xx_cmd.c
++++ sane-backends-1.0.24/backend/kvs20xx_cmd.c
+_at_@ -82,7 +82,7 @@
+ 
+ SANE_Status
+ kvs20xx_sense_handler (int __sane_unused__ fd,
+-		       u_char * sense_buffer, void __sane_unused__ * arg)
++		       unsigned char * sense_buffer, void __sane_unused__ * arg)
+ {
+   unsigned i;
+   SANE_Status st = SANE_STATUS_GOOD;
+--- sane-backends-1.0.24.orig/backend/kvs20xx_cmd.h
++++ sane-backends-1.0.24/backend/kvs20xx_cmd.h
+_at_@ -123,6 +123,6 @@
+ 				     unsigned max_size, unsigned *size);
+ SANE_Status kvs20xx_document_exist (struct scanner *s);
+ SANE_Status get_adjust_data (struct scanner *s, unsigned *dummy_length);
+-SANE_Status kvs20xx_sense_handler (int fd, u_char * sense_buffer, void *arg);
++SANE_Status kvs20xx_sense_handler (int fd, unsigned char * sense_buffer, void *arg);
+ 
+ #endif /*__KVS20XX_CMD_H*/
+--- sane-backends-1.0.24.orig/backend/kvs40xx.h
++++ sane-backends-1.0.24/backend/kvs40xx.h
+_at_@ -10,6 +10,7 @@
+ 
+ #include "../include/sane/config.h"
+ #include <semaphore.h>
++#include <pthread.h>
+ 
+ #undef  BACKEND_NAME
+ #define BACKEND_NAME kvs40xx
+_at_@ -208,7 +209,7 @@
+ SANE_Status kvs40xx_document_exist (struct scanner *s);
+ SANE_Status get_buffer_status (struct scanner *s, unsigned *data_avalible);
+ SANE_Status kvs40xx_scan (struct scanner *s);
+-SANE_Status kvs40xx_sense_handler (int fd, u_char * sense_buffer, void *arg);
++SANE_Status kvs40xx_sense_handler (int fd, unsigned char * sense_buffer, void *arg);
+ SANE_Status stop_adf (struct scanner *s);
+ SANE_Status hopper_down (struct scanner *s);
+ SANE_Status inquiry (struct scanner *s, char *id);
+--- sane-backends-1.0.24.orig/backend/kvs40xx_cmd.c
++++ sane-backends-1.0.24/backend/kvs40xx_cmd.c
+_at_@ -247,7 +247,7 @@
+ 
+ SANE_Status
+ kvs40xx_sense_handler (int __sane_unused__ fd,
+-		       u_char * sense_buffer, void __sane_unused__ * arg)
++		       unsigned char * sense_buffer, void __sane_unused__ * arg)
+ {
+   unsigned i;
+   SANE_Status st = SANE_STATUS_GOOD;
+--- sane-backends-1.0.24.orig/backend/lexmark_low.c
++++ sane-backends-1.0.24/backend/lexmark_low.c
+_at_@ -863,7 +863,7 @@
+     {
+       DBG (5,
+ 	   "low_usb_bulk_write: returned %s (size = %lu, expected %lu)\n",
+-	   sane_strstatus (status), (u_long) * size, (u_long) cmd_size);
++	   sane_strstatus (status), (unsigned long) * size, (unsigned long) cmd_size);
+       /* F.O. should reset the pipe here... */
+     }
+   return status;
+_at_@ -885,11 +885,11 @@
+     {
+       DBG (5,
+ 	   "low_usb_bulk_read: returned %s (size = %lu, expected %lu)\n",
+-	   sane_strstatus (status), (u_long) * size, (u_long) exp_size);
++	   sane_strstatus (status), (unsigned long) * size, (unsigned long) exp_size);
+       /* F.O. should reset the pipe here... */
+     }
+   DBG (7, "low_usb_bulk_read: returned size = %lu (required %lu)\n",
+-       (u_long) * size, (u_long) exp_size);
++       (unsigned long) * size, (unsigned long) exp_size);
+   return status;
+ }
+ 
+_at_@ -1097,7 +1097,7 @@
+   /* data reading loop */
+   needed = bpl * lines;
+   DBG (1, "low_simple_scan: bpl=%d, lines=%d, needed=%lu.\n", bpl, lines,
+-       (u_long) needed);
++       (unsigned long) needed);
+   read = 0;
+   do
+     {
+_at_@ -4991,8 +4991,8 @@
+ 	  dev->read_pointer = dev->transfer_buffer;
+ 	  DBG (2, "sanei_lexmark_low_read_scan_data:\n");
+ 	  DBG (2, "   Filled a buffer from the scanner\n");
+-	  DBG (2, "   bytes_remaining: %lu\n", (u_long) dev->bytes_remaining);
+-	  DBG (2, "   bytes_in_buffer: %lu\n", (u_long) dev->bytes_in_buffer);
++	  DBG (2, "   bytes_remaining: %lu\n", (unsigned long) dev->bytes_remaining);
++	  DBG (2, "   bytes_in_buffer: %lu\n", (unsigned long) dev->bytes_in_buffer);
+ 	  DBG (2, "   read_pointer: %p\n", dev->read_pointer);
+ 	}
+     }
+_at_@ -5001,8 +5001,8 @@
+   DBG (5, "   write ptr:     %p\n", dev->read_buffer->writeptr);
+   DBG (5, "   read ptr:      %p\n", dev->read_buffer->readptr);
+   DBG (5, "   max write ptr: %p\n", dev->read_buffer->max_writeptr);
+-  DBG (5, "   buffer size:   %lu\n", (u_long) dev->read_buffer->size);
+-  DBG (5, "   line size:     %lu\n", (u_long) dev->read_buffer->linesize);
++  DBG (5, "   buffer size:   %lu\n", (unsigned long) dev->read_buffer->size);
++  DBG (5, "   line size:     %lu\n", (unsigned long) dev->read_buffer->linesize);
+   DBG (5, "   empty:         %d\n", dev->read_buffer->empty);
+   DBG (5, "   line no:       %d\n", dev->read_buffer->image_line_no);
+ 
+_at_@ -5061,8 +5061,8 @@
+   DBG (5, "   write ptr:     %p\n", dev->read_buffer->writeptr);
+   DBG (5, "   read ptr:      %p\n", dev->read_buffer->readptr);
+   DBG (5, "   max write ptr: %p\n", dev->read_buffer->max_writeptr);
+-  DBG (5, "   buffer size:   %lu\n", (u_long) dev->read_buffer->size);
+-  DBG (5, "   line size:     %lu\n", (u_long) dev->read_buffer->linesize);
++  DBG (5, "   buffer size:   %lu\n", (unsigned long) dev->read_buffer->size);
++  DBG (5, "   line size:     %lu\n", (unsigned long) dev->read_buffer->linesize);
+   DBG (5, "   empty:         %d\n", dev->read_buffer->empty);
+   DBG (5, "   line no:       %d\n", dev->read_buffer->image_line_no);
+ 
+_at_@ -5071,10 +5071,10 @@
+ 
+   DBG (2, "sanei_lexmark_low_read_scan_data:\n");
+   DBG (2, "    Copying lines from buffer to data\n");
+-  DBG (2, "    bytes_remaining: %lu\n", (u_long) dev->bytes_remaining);
+-  DBG (2, "    bytes_in_buffer: %lu\n", (u_long) dev->bytes_in_buffer);
++  DBG (2, "    bytes_remaining: %lu\n", (unsigned long) dev->bytes_remaining);
++  DBG (2, "    bytes_in_buffer: %lu\n", (unsigned long) dev->bytes_in_buffer);
+   DBG (2, "    read_pointer: %p\n", dev->read_buffer->readptr);
+-  DBG (2, "    bytes_read %lu\n", (u_long) bytes_read);
++  DBG (2, "    bytes_read %lu\n", (unsigned long) bytes_read);
+ 
+   /* if no more bytes to xfer and read buffer empty we're at the end */
+   if ((dev->bytes_remaining == 0) && read_buffer_is_empty (dev->read_buffer))
+--- sane-backends-1.0.24.orig/backend/ma1509.c
++++ sane-backends-1.0.24/backend/ma1509.c
+_at_@ -825,7 +825,7 @@
+     {
+       DBG (1,
+ 	   "calibration: couldn't malloc %lu bytes for calibration buffer\n",
+-	   (u_long) (total_size * 3));
++	   (unsigned long) (total_size * 3));
+       return SANE_STATUS_NO_MEM;
+     }
+   memset (buffer, 0x00, total_size);
+_at_@ -918,7 +918,7 @@
+   if (!buffer)
+     {
+       DBG (1, "send_gamma: couldn't malloc %lu bytes for gamma  buffer\n",
+-	   (u_long) total_size);
++	   (unsigned long) total_size);
+       return SANE_STATUS_NO_MEM;
+     }
+ 
+--- sane-backends-1.0.24.orig/backend/magicolor.c
++++ sane-backends-1.0.24/backend/magicolor.c
+_at_@ -492,7 +492,7 @@
+ static int
+ mc_send(Magicolor_Scanner * s, void *buf, size_t buf_size, SANE_Status * status)
+ {
+-	DBG(15, "%s: size = %lu\n", __func__, (u_long) buf_size);
++	DBG(15, "%s: size = %lu\n", __func__, (unsigned long) buf_size);
+ 
+ 	if (DBG_LEVEL >= 125) {
+ 		const unsigned char *s = buf;
+_at_@ -538,7 +538,7 @@
+ 
+ 	if (n < buf_size) {
+ 		DBG(1, "%s: expected = %lu, got = %ld\n", __func__,
+-		    (u_long) buf_size, (long) n);
++		    (unsigned long) buf_size, (long) n);
+ 		*status = SANE_STATUS_IO_ERROR;
+ 	}
+ 
+--- sane-backends-1.0.24.orig/backend/microtek.c
++++ sane-backends-1.0.24/backend/microtek.c
+_at_@ -258,10 +258,10 @@
+   rb->size += amount;
+ 
+   DBG(23, "ring_expand:  old, new, inc size:  %lu, %lu, %lu\n",
+-      (u_long)oldsize, (u_long)rb->size, (u_long)amount);
++      (unsigned long)oldsize, (unsigned long)rb->size, (unsigned long)amount);
+   DBG(23, "ring_expand:  old  tr: %lu  tg: %lu  tb: %lu  hc: %lu\n",
+-      (u_long)rb->tail_red, (u_long)rb->tail_green, 
+-      (u_long)rb->tail_blue, (u_long)rb->head_complete);
++      (unsigned long)rb->tail_red, (unsigned long)rb->tail_green, 
++      (unsigned long)rb->tail_blue, (unsigned long)rb->head_complete);
+   /* if necessary, move data and fix up them pointers */
+   /* (will break subtly if ring is filled with G or B bytes,
+      and tail_g or tail_b have rolled over...) */
+_at_@ -289,8 +289,8 @@
+     rb->head_complete += amount;
+   }
+   DBG(23, "ring_expand:  new  tr: %lu  tg: %lu  tb: %lu  hc: %lu\n",
+-      (u_long)rb->tail_red, (u_long)rb->tail_green, 
+-      (u_long)rb->tail_blue, (u_long)rb->head_complete);
++      (unsigned long)rb->tail_red, (unsigned long)rb->tail_green, 
++      (unsigned long)rb->tail_blue, (unsigned long)rb->head_complete);
+   return SANE_STATUS_GOOD;
+ }
+ 
+_at_@ -320,7 +320,7 @@
+ /*   typically misinterpreted/munged by the low-level scsi driver)  */
+ /********************************************************************/
+ static SANE_Status
+-sense_handler (int scsi_fd, u_char *sense, void *arg) 
++sense_handler (int scsi_fd, unsigned char *sense, void *arg) 
+ {
+   int *sense_flags = (int *)arg;
+   SANE_Status stat;
+_at_@ -760,7 +760,7 @@
+     *lines = (data[3]) + (data[4] << 8) + (data[5] << 16);
+     
+     DBG(20, "get_scan_status(%lu): %d, %d, %d  -> #%d\n", 
+-	(u_long) lenp, *busy, *bytes_per_line, *lines, retry);
++	(unsigned long) lenp, *busy, *bytes_per_line, *lines, retry);
+     DBG(20, "> %2x %2x %2x %2x %2x %2x\n",
+ 	    data[0], data[1], data[2], data[3], data[4], data[5]);
+     if (*busy != 0) {
+_at_@ -2371,7 +2371,7 @@
+     ntoget = (nleft > nmax) ? nmax : nleft;
+     buffsize = ntoget * 3 * linewidth;
+     DBG(23, "...nleft %d  toget %d  size %lu  spot %d  input+spot %p\n",
+-	nleft, ntoget, (u_long) buffsize, spot, input+spot);
++	nleft, ntoget, (unsigned long) buffsize, spot, input+spot);
+     if ((statusA = read_scan_data(s, ntoget, input+spot, &buffsize)) 
+ 	!= SANE_STATUS_GOOD) {
+       DBG(23, "...read scan failed\n");
+_at_@ -2596,7 +2596,7 @@
+ 
+   if (nbytes > max_xfer) {
+     DBG(23, "pack_flat: must expand ring, %lu + %lu\n",
+-	(u_long)rb->size, (u_long)(nbytes - max_xfer));
++	(unsigned long)rb->size, (unsigned long)(nbytes - max_xfer));
+     status = ring_expand(rb, (nbytes - max_xfer));
+     if (status != SANE_STATUS_GOOD) return status;
+   }
+_at_@ -2694,9 +2694,9 @@
+     ag = rb->size - (rb->complete_count + rb->green_extra * 3);
+     ab = rb->size - (rb->complete_count + rb->blue_extra * 3);
+     DBG(23, "pack_seq:  dr/ar: %lu/%lu  dg/ag: %lu/%lu  db/ab: %lu/%lu\n",
+-	(u_long)dr, (u_long)ar,
+-	(u_long)dg, (u_long)ag,
+-	(u_long)db, (u_long)ab);
++	(unsigned long)dr, (unsigned long)ar,
++	(unsigned long)dg, (unsigned long)ag,
++	(unsigned long)db, (unsigned long)ab);
+     if ((dr > ar) ||
+ 	(dg > ag) ||
+ 	(db > ab)) {
+_at_@ -2705,7 +2705,7 @@
+       if (dg > ag) increase = MAX(increase, (dg - ag));
+       if (db > ab) increase = MAX(increase, (db - ab));
+       DBG(23, "pack_seq: must expand ring, %lu + %lu\n",
+-	  (u_long)rb->size, (u_long)increase);
++	  (unsigned long)rb->size, (unsigned long)increase);
+       status = ring_expand(rb, increase);
+       if (status != SANE_STATUS_GOOD) return status;
+     }
+_at_@ -2758,11 +2758,11 @@
+   rb->blue_extra  -= completed;
+   
+   DBG(18, "pack_seq:  extra r: %lu  g: %lu  b: %lu\n",
+-      (u_long)rb->red_extra, 
+-      (u_long)rb->green_extra,
+-      (u_long)rb->blue_extra);
++      (unsigned long)rb->red_extra, 
++      (unsigned long)rb->green_extra,
++      (unsigned long)rb->blue_extra);
+   DBG(18, "pack_seq:  completed: %lu  complete: %lu\n",
+-      (u_long)completed, (u_long)rb->complete_count);
++      (unsigned long)completed, (unsigned long)rb->complete_count);
+ 
+   return SANE_STATUS_GOOD;
+ }
+_at_@ -2802,9 +2802,9 @@
+     ag = rb->size - (rb->complete_count + rb->green_extra * 3);
+     ab = rb->size - (rb->complete_count + rb->blue_extra * 3);
+     DBG(23, "pack_goofy:  dr/ar: %lu/%lu  dg/ag: %lu/%lu  db/ab: %lu/%lu\n",
+-	(u_long)dr, (u_long)ar,
+-	(u_long)dg, (u_long)ag,
+-	(u_long)db, (u_long)ab);
++	(unsigned long)dr, (unsigned long)ar,
++	(unsigned long)dg, (unsigned long)ag,
++	(unsigned long)db, (unsigned long)ab);
+     /* >, or >= ???????? */
+     if ((dr > ar) ||
+ 	(dg > ag) ||
+_at_@ -2814,7 +2814,7 @@
+       if (dg > ag) increase = MAX(increase, (dg - ag));
+       if (db > ab) increase = MAX(increase, (db - ab));
+       DBG(23, "pack_goofy: must expand ring, %lu + %lu\n",
+-	  (u_long)rb->size, (u_long)increase);
++	  (unsigned long)rb->size, (unsigned long)increase);
+       status = ring_expand(rb, increase);
+       if (status != SANE_STATUS_GOOD) return status;
+     }
+_at_@ -2870,11 +2870,11 @@
+   rb->blue_extra  -= completed;
+   
+   DBG(18, "pack_goofy:  extra r: %lu  g: %lu  b: %lu\n",
+-      (u_long)rb->red_extra, 
+-      (u_long)rb->green_extra,
+-      (u_long)rb->blue_extra);
++      (unsigned long)rb->red_extra, 
++      (unsigned long)rb->green_extra,
++      (unsigned long)rb->blue_extra);
+   DBG(18, "pack_goofy:  completed: %lu  complete: %lu\n",
+-      (u_long)completed, (u_long)rb->complete_count);
++      (unsigned long)completed, (unsigned long)rb->complete_count);
+ 
+   return SANE_STATUS_GOOD;
+ }
+_at_@ -2901,7 +2901,7 @@
+   
+   if (nbytes > max_xfer) {
+     DBG(23, "pack_2r2g2b: must expand ring, %lu + %lu\n",
+-	(u_long)rb->size, (u_long)(nbytes - max_xfer));
++	(unsigned long)rb->size, (unsigned long)(nbytes - max_xfer));
+     status = ring_expand(rb, (nbytes - max_xfer));
+     if (status != SANE_STATUS_GOOD) return status;
+   }
+_at_@ -2983,7 +2983,7 @@
+     }
+     s->unscanned_lines -= *nlines;
+     DBG(18, "sane_read:  buffsize: %lu,  unscanned: %d\n",
+-        (u_long) buffsize, s->unscanned_lines);
++        (unsigned long) buffsize, s->unscanned_lines);
+   }
+   return SANE_STATUS_GOOD;
+ }
+_at_@ -3026,7 +3026,7 @@
+ 
+   DBG(23, "pack_into_dest...\n");
+   DBG(23, "pack_into_dest:  rl: %lu  sz: %lu  hc: %lu\n",
+-      (u_long)ret_length, (u_long)rb->size, (u_long)rb->head_complete);
++      (unsigned long)ret_length, (unsigned long)rb->size, (unsigned long)rb->head_complete);
+   /* adjust for rollover!!! */
+   if ((rb->head_complete + ret_length) < rb->size) {
+     memcpy(dest_buffer, rb->base + rb->head_complete, ret_length);
+_at_@ -3256,7 +3256,7 @@
+     }
+   } else {
+     DBG(23, "sane_open:  NO gamma tables.  (max size = %lu)\n",
+-	(u_long)dev->info.max_lookup_size);
++	(unsigned long)dev->info.max_lookup_size);
+     scanner->gamma_entries = 0;
+     scanner->gray_lut  = NULL;
+     scanner->red_lut   = NULL;
+--- sane-backends-1.0.24.orig/backend/microtek2.c
++++ sane-backends-1.0.24/backend/microtek2.c
+_at_@ -259,7 +259,7 @@
+     sd_list = (const SANE_Device **)
+                malloc( (md_num_devices + 1) * sizeof(SANE_Device **));
+     DBG(100, "sane_get_devices: sd_list=%p, malloc'd %lu bytes\n",
+-	(void *) sd_list, (u_long)  ((md_num_devices + 1) * sizeof(SANE_Device **)));
++	(void *) sd_list, (unsigned long)  ((md_num_devices + 1) * sizeof(SANE_Device **)));
+ 
+     if ( ! sd_list )
+       {
+_at_@ -542,7 +542,7 @@
+ 
+     ms = malloc(sizeof(Microtek2_Scanner));
+     DBG(100, "sane_open: ms=%p, malloc'd %lu bytes\n",
+-	(void *) ms, (u_long) sizeof(Microtek2_Scanner));
++	(void *) ms, (unsigned long) sizeof(Microtek2_Scanner));
+     if ( ms == NULL )
+       {
+         DBG(1, "sane_open: malloc() for ms failed\n");
+_at_@ -720,7 +720,7 @@
+ 
+     md = (Microtek2_Device *) malloc(sizeof(Microtek2_Device));
+     DBG(100, "add_device_list: md=%p, malloc'd %lu bytes\n",
+-                         (void *) md, (u_long) sizeof(Microtek2_Device));
++                         (void *) md, (unsigned long) sizeof(Microtek2_Device));
+     if ( md == NULL )
+       {
+ 	DBG(1, "add_device_list: malloc() for md failed\n");
+_at_@ -2242,7 +2242,7 @@
+         md->custom_gamma_table[color] =
+                               (SANE_Int *) malloc(tablesize * sizeof(SANE_Int));
+         DBG(100, "init_options: md->custom_gamma_table[%d]=%p, malloc'd %lu bytes\n",
+-            color, (void *) md->custom_gamma_table[color], (u_long) (tablesize * sizeof(SANE_Int)));
++            color, (void *) md->custom_gamma_table[color], (unsigned long) (tablesize * sizeof(SANE_Int)));
+         if ( md->custom_gamma_table[color] == NULL )
+           {
+             DBG(1, "init_options: malloc for custom gamma table failed\n");
+_at_@ -4821,7 +4821,7 @@
+ 
+     DBG(100, "scsi_read_shading: sfd=%d, cmd=%p, sizeofcmd=%lu,"
+              "dest=%p, destsize=%lu\n",
+-              ms->sfd, cmd, (u_long) sizeof(cmd), buffer, (u_long) size);
++              ms->sfd, cmd, (unsigned long) sizeof(cmd), buffer, (unsigned long) size);
+ 
+     status = sanei_scsi_cmd(ms->sfd, cmd, sizeof(cmd), buffer, &size);
+     if ( status != SANE_STATUS_GOOD )
+_at_@ -5076,7 +5076,7 @@
+ /* rewritten 19.12.2001 for better SANE_STATUS return codes */
+ 
+ static SANE_Status
+-scsi_sense_handler (int fd, u_char *sense, void *arg)
++scsi_sense_handler (int fd, unsigned char *sense, void *arg)
+ {
+     int as_info_length;
+     uint8_t sense_key;
+_at_@ -5280,7 +5280,7 @@
+         if (ms->control_bytes) free((void *)ms->control_bytes);
+         ms->control_bytes = (uint8_t *) malloc(ms->n_control_bytes);
+         DBG(100, "sane_start: ms->control_bytes=%p, malloc'd %lu bytes\n",
+-                             ms->control_bytes, (u_long) ms->n_control_bytes);
++                             ms->control_bytes, (unsigned long) ms->n_control_bytes);
+         if ( ms->control_bytes == NULL )
+           {
+             DBG(1, "sane_start: malloc() for control bits failed\n");
+_at_@ -6687,7 +6687,7 @@
+ 
+     sortbuf = malloc( md->shading_length * sizeof(float) );
+     DBG(100, "calc_cx_shading: sortbuf= %p, malloc'd %lu Bytes\n",
+-	(void *) sortbuf, (u_long) (md->shading_length * sizeof(float)));
++	(void *) sortbuf, (unsigned long) (md->shading_length * sizeof(float)));
+     if ( sortbuf == NULL )
+       {
+         DBG(1, "calc_cx_shading: malloc for sort buffer failed\n");
+--- sane-backends-1.0.24.orig/backend/microtek2.h
++++ sane-backends-1.0.24/backend/microtek2.h
+_at_@ -1370,7 +1370,7 @@
+ scsi_send_system_status(Microtek2_Device *, int);
+ 
+ static SANE_Status
+-scsi_sense_handler (int, u_char *, void *);
++scsi_sense_handler (int, unsigned char *, void *);
+ 
+ static SANE_Status
+ scsi_test_unit_ready(Microtek2_Device *);
+--- sane-backends-1.0.24.orig/backend/mustek.c
++++ sane-backends-1.0.24/backend/mustek.c
+_at_@ -296,7 +296,7 @@
+ 	  if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME)
+ 	    {
+ 	      DBG (1, "scsi_sense_wait_ready: timed out after %lu seconds\n",
+-		   (u_long) (now.tv_sec - start.tv_sec));
++		   (unsigned long) (now.tv_sec - start.tv_sec));
+ 	      return SANE_STATUS_INVAL;
+ 	    }
+ 	  usleep (100000);	/* retry after 100ms */
+_at_@ -332,7 +332,7 @@
+ 	  if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME)
+ 	    {
+ 	      DBG (1, "scsi_area_wait_ready: timed out after %lu seconds\n",
+-		   (u_long) (now.tv_sec - start.tv_sec));
++		   (unsigned long) (now.tv_sec - start.tv_sec));
+ 	      return SANE_STATUS_INVAL;
+ 	    }
+ 	  usleep (100000);	/* retry after 100ms */
+_at_@ -373,7 +373,7 @@
+ 	  if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME)
+ 	    {
+ 	      DBG (1, "scsi_unit_wait_ready: timed out after %lu seconds\n",
+-		   (u_long) (now.tv_sec - start.tv_sec));
++		   (unsigned long) (now.tv_sec - start.tv_sec));
+ 	      return SANE_STATUS_INVAL;
+ 	    }
+ 	  usleep (100000);	/* retry after 100ms */
+_at_@ -413,7 +413,7 @@
+ 	  if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME)
+ 	    {
+ 	      DBG (1, "scsi_unit_wait_ready: timed out after %lu seconds\n",
+-		   (u_long) (now.tv_sec - start.tv_sec));
++		   (unsigned long) (now.tv_sec - start.tv_sec));
+ 	      return SANE_STATUS_INVAL;
+ 	    }
+ 	  usleep (500000);	/* retry after 500ms */
+_at_@ -445,7 +445,7 @@
+       if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME)
+ 	{
+ 	  DBG (1, "n_wait_ready: timed out after %lu seconds\n",
+-	       (u_long) (now.tv_sec - start.tv_sec));
++	       (unsigned long) (now.tv_sec - start.tv_sec));
+ 	  return SANE_STATUS_INVAL;
+ 	}
+       usleep (100000);		/* retry after 100ms */
+_at_@ -471,7 +471,7 @@
+       if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME)
+ 	{
+ 	  DBG (1, "scsi_pp_wait_ready: timed out after %lu seconds\n",
+-	       (u_long) (now.tv_sec - start.tv_sec));
++	       (unsigned long) (now.tv_sec - start.tv_sec));
+ 	  return SANE_STATUS_INVAL;
+ 	}
+       usleep (100000);		/* retry after 100ms */
+_at_@ -3716,7 +3716,7 @@
+ 		}
+ 	      DBG (5, "fix_line_distance_se: got saved line: %d; line: %d; "
+ 		   "color: %d; raw bytes: %lu; out bytes: %d\n",
+-		   s->ld.saved[color], lines[color], color, (u_long) (ptr - ptr_start),
++		   s->ld.saved[color], lines[color], color, (unsigned long) (ptr - ptr_start),
+ 		   s->params.pixels_per_line);
+ 	      ptr = ptr_start + bpc;
+ 	    }
+_at_@ -3792,7 +3792,7 @@
+ 		      DBG (5,
+ 			   "fix_line_distance_se: got line: %d; color: %d; "
+ 			   "raw bytes: %lu; out bytes: %d\n",
+-			   lines[s->ld.color], s->ld.color, (u_long) (raw - raw_start),
++			   lines[s->ld.color], s->ld.color, (unsigned long) (raw - raw_start),
+ 			   s->params.pixels_per_line);
+ 		      raw = raw_start + bpc;
+ 		    }
+--- sane-backends-1.0.24.orig/backend/mustek_pp.c
++++ sane-backends-1.0.24/backend/mustek_pp.c
+_at_@ -937,7 +937,7 @@
+ 
+ 	  if (!strcmp (optname, "no_epp"))
+ 	    {
+-	      u_int pa4s2_options;
++	      unsigned int pa4s2_options;
+ 	      if (name)
+ 		DBG (2, "sane_init: global option found in local scope, "
+ 			"executing anyway\n");
+--- sane-backends-1.0.24.orig/backend/mustek_pp_ccd300.c
++++ sane-backends-1.0.24/backend/mustek_pp_ccd300.c
+_at_@ -66,13 +66,13 @@
+  *  shared functions end with _101x.
+  */
+ 
+-static const u_char chan_codes_1013[] = { 0x82, 0x42, 0xC2 };
+-static const u_char chan_codes_1015[] = { 0x80, 0x40, 0xC0 };
+-static const u_char fullstep[] = { 0x09, 0x0C, 0x06, 0x03 };
+-static const u_char halfstep[] = { 0x02, 0x03, 0x01, 0x09,
++static const unsigned char chan_codes_1013[] = { 0x82, 0x42, 0xC2 };
++static const unsigned char chan_codes_1015[] = { 0x80, 0x40, 0xC0 };
++static const unsigned char fullstep[] = { 0x09, 0x0C, 0x06, 0x03 };
++static const unsigned char halfstep[] = { 0x02, 0x03, 0x01, 0x09,
+   0x08, 0x0C, 0x04, 0x06
+ };
+-static const u_char voltages[4][3] = { {0x5C, 0x5A, 0x63},
++static const unsigned char voltages[4][3] = { {0x5C, 0x5A, 0x63},
+ {0xE6, 0xB4, 0xBE},
+ {0xB4, 0xB4, 0xB4},
+ {0x64, 0x50, 0x64}
+_at_@ -118,7 +118,7 @@
+ static void
+ get_bank_count (Mustek_pp_Handle * dev)
+ {
+-  u_char val;
++  unsigned char val;
+   mustek_pp_ccd300_priv *priv = dev->priv;
+ 
+   sanei_pa4s2_readbegin (dev->fd, 3);
+_at_@ -166,7 +166,7 @@
+ static void
+ set_dpi_value (Mustek_pp_Handle * dev)
+ {
+-  u_char val = 0;
++  unsigned char val = 0;
+   mustek_pp_ccd300_priv *priv = dev->priv;
+ 
+   sanei_pa4s2_writebyte (dev->fd, 6, 0x80);
+_at_@ -366,7 +366,7 @@
+ {
+ 
+   SANE_Byte *cal = calib;
+-  u_char color;
++  unsigned char color;
+   mustek_pp_ccd300_priv *priv = dev->priv;
+   int ctr, skips = priv->adjustskip + 1, cval;
+ 
+_at_@ -1083,7 +1083,7 @@
+ static void
+ return_home_1013 (Mustek_pp_Handle * dev)
+ {
+-  u_char ishome;
++  unsigned char ishome;
+   int ctr;
+   mustek_pp_ccd300_priv *priv = dev->priv;
+ 
+_at_@ -1205,9 +1205,9 @@
+ 
+ 
+ static void
+-motor_control_1015 (Mustek_pp_Handle * dev, u_char control)
++motor_control_1015 (Mustek_pp_Handle * dev, unsigned char control)
+ {
+-  u_char val;
++  unsigned char val;
+ 
+   DBG (5, "motor_controll_1015: control code 0x%02x\n",
+        (unsigned int) control);
+_at_@ -1233,7 +1233,7 @@
+ return_home_1015 (Mustek_pp_Handle * dev, SANE_Bool nowait)
+ {
+ 
+-  u_char ishome, control = 0xC3;
++  unsigned char ishome, control = 0xC3;
+ 
+   motor_control_1015 (dev, control);
+ 
+_at_@ -1258,7 +1258,7 @@
+ static void
+ motor_forward_1015 (Mustek_pp_Handle * dev)
+ {
+-  u_char control = 0x1B;
++  unsigned char control = 0x1B;
+   mustek_pp_ccd300_priv *priv = dev->priv;
+ 
+   priv->motor_step++;
+_at_@ -1276,7 +1276,7 @@
+ static void
+ motor_backward_1015 (Mustek_pp_Handle * dev)
+ {
+-  u_char control = 0x43;
++  unsigned char control = 0x43;
+   mustek_pp_ccd300_priv *priv = dev->priv;
+ 
+   priv->motor_step++;
+_at_@ -1307,7 +1307,7 @@
+ set_ccd_channel_1015 (Mustek_pp_Handle * dev, int channel)
+ {
+ 
+-  u_char chancode = chan_codes_1015[channel];
++  unsigned char chancode = chan_codes_1015[channel];
+   mustek_pp_ccd300_priv *priv = dev->priv;
+ 
+   priv->channel = channel;
+_at_@ -1327,7 +1327,7 @@
+ config_ccd_1015 (Mustek_pp_Handle * dev)
+ {
+ 
+-  u_char val;
++  unsigned char val;
+   mustek_pp_ccd300_priv *priv = dev->priv;
+ 
+   if (dev->res != 0)
+--- sane-backends-1.0.24.orig/backend/mustek_pp_cis.c
++++ sane-backends-1.0.24/backend/mustek_pp_cis.c
+_at_@ -833,7 +833,7 @@
+   
+   if (dev->bank_count != bankcount && dev->desc->state != STATE_CANCELLED)
+   {
+-     u_char tmp;
++     unsigned char tmp;
+      tmp = Mustek_PP_1015_read_reg(dev, 3);
+      DBG(2, "cis_wait_bank_change: Missed a bank: got %d [%s], "
+             "wanted %d, waited %d msec\n", 
+_at_@ -860,7 +860,7 @@
+ static void
+ cis_set_dpi_value (Mustek_PP_CIS_dev * dev)
+ {
+-   u_char val = 0;
++   unsigned char val = 0;
+   
+    if (dev->model == MUSTEK_PP_CIS1200PLUS)
+    {
+_at_@ -1333,7 +1333,7 @@
+                          SANE_Int pixel, SANE_Byte * calib_low, 
+                          SANE_Byte * calib_hi, SANE_Int * gamma)
+ {
+-   u_char color;
++   unsigned char color;
+    int ctr, skips = dev->CIS.adjustskip, cval;
+    int bpos = 0;
+    SANE_Byte low_val = 0, hi_val = 255;
+_at_@ -2010,7 +2010,7 @@
+ }
+ 
+ static void
+-cis_motor_control (Mustek_PP_CIS_dev * dev, u_char control)
++cis_motor_control (Mustek_PP_CIS_dev * dev, unsigned char control)
+ {
+    cis_wait_motor_stable (dev);
+    Mustek_PP_1015_write_reg(dev, MA1015W_MOTOR_CONTROL, control);
+_at_@ -2198,7 +2198,7 @@
+ {
+    int fd;
+    SANE_Status status;
+-   u_char asic;
++   unsigned char asic;
+ 
+    status = sanei_pa4s2_open (port, &fd);
+ 
+--- sane-backends-1.0.24.orig/backend/mustek_scsi_pp.c
++++ sane-backends-1.0.24/backend/mustek_scsi_pp.c
+_at_@ -92,11 +92,11 @@
+   return retval;
+ }
+ 
+-static u_char mustek_scsi_pp_register = 0;
++static unsigned char mustek_scsi_pp_register = 0;
+ 
+ 
+ static SANE_Status
+-mustek_scsi_pp_select_register (int fd, u_char reg)
++mustek_scsi_pp_select_register (int fd, unsigned char reg)
+ {
+   DBG (5, "mustek_scsi_pp_select_register: selecting register %d on fd %d\n",
+        reg, fd);
+_at_@ -110,7 +110,7 @@
+ mustek_scsi_pp_wait_for_valid_status (int fd)
+ {
+   int start_time;
+-  u_char status;
++  unsigned char status;
+ 
+   DBG (5, "mustek_scsi_pp_wait_for_valid_status: entering\n");
+ 
+_at_@ -144,7 +144,7 @@
+ mustek_scsi_pp_wait_for_status_bit_5_set (int fd)
+ {
+   int t;
+-  u_char status;
++  unsigned char status;
+ 
+   DBG (5, "mustek_scsi_pp_wait_for_status_bit_5_set: entering\n");
+ 
+_at_@ -174,7 +174,7 @@
+ mustek_scsi_pp_wait_for_status_bit_5_clear (int fd)
+ {
+   int t;
+-  u_char status;
++  unsigned char status;
+ 
+   DBG (5, "mustek_scsi_pp_wait_for_status_bit_5_clear: entering\n");
+ 
+_at_@ -205,7 +205,7 @@
+ mustek_scsi_pp_wait_for_status_bit_7_set (int fd)
+ {
+   int t;
+-  u_char status;
++  unsigned char status;
+ 
+   DBG (5, "mustek_scsi_pp_wait_for_status_bit_7_set: entering\n");
+ 
+_at_@ -235,7 +235,7 @@
+ mustek_scsi_pp_wait_for_status_bit_7_clear (int fd)
+ {
+   int t;
+-  u_char status;
++  unsigned char status;
+ 
+   DBG (5, "mustek_scsi_pp_wait_for_status_bit_7_clear: entering\n");
+ 
+_at_@ -265,7 +265,7 @@
+ mustek_scsi_pp_wait_for_status_bit_4_set (int fd)
+ {
+   int t;
+-  u_char status;
++  unsigned char status;
+ 
+   DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_set: entering\n");
+ 
+_at_@ -312,7 +312,7 @@
+ mustek_scsi_pp_wait_for_status_bit_4_clear (int fd)
+ {
+   int t;
+-  u_char status;
++  unsigned char status;
+ 
+   DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_clear: entering\n");
+ 
+_at_@ -355,7 +355,7 @@
+   return SANE_STATUS_DEVICE_BUSY;
+ }
+ 
+-static u_char mustek_scsi_pp_bit_4_state = 0;
++static unsigned char mustek_scsi_pp_bit_4_state = 0;
+ 
+ static SANE_Status
+ mustek_scsi_pp_wait_for_status_bit_4_toggle (int fd)
+_at_@ -383,7 +383,7 @@
+ }
+ 
+ static SANE_Status
+-mustek_scsi_pp_send_command_byte (int fd, u_char cmd)
++mustek_scsi_pp_send_command_byte (int fd, unsigned char cmd)
+ {
+   DBG (5, "mustek_scsi_pp_send_command byte: sending 0x%02X\n", cmd);
+ 
+_at_@ -417,7 +417,7 @@
+ static u_char
+ mustek_scsi_pp_read_response (int fd)
+ {
+-  u_char result;
++  unsigned char result;
+ 
+   DBG (5, "mustek_scsi_pp_read_response: entering\n");
+ 
+_at_@ -470,7 +470,7 @@
+ }
+ 
+ static SANE_Status
+-mustek_scsi_pp_send_command (int fd, const u_char * cmd)
++mustek_scsi_pp_send_command (int fd, const unsigned char * cmd)
+ {
+   int i;
+   signed char checksum;
+_at_@ -528,7 +528,7 @@
+ }
+ 
+ static SANE_Status
+-mustek_scsi_pp_send_data_block (int fd, const u_char * data, int len)
++mustek_scsi_pp_send_data_block (int fd, const unsigned char * data, int len)
+ {
+   int i;
+   signed char checksum;
+_at_@ -566,7 +566,7 @@
+ }
+ 
+ static SANE_Status
+-mustek_scsi_pp_read_data_block (int fd, u_char * buffer, int len)
++mustek_scsi_pp_read_data_block (int fd, unsigned char * buffer, int len)
+ {
+   int i;
+   signed char checksum;
+_at_@ -648,7 +648,7 @@
+ static SANE_Status
+ mustek_scsi_pp_test_ready (int fd)
+ {
+-  u_char status;
++  unsigned char status;
+   SANE_Status retval;
+ 
+   DBG (5, "mustek_scsi_pp_test_ready: entering with fd=%d\n", fd);
+_at_@ -708,14 +708,14 @@
+ {
+   SANE_Status stat;
+   int num_tries = 0;
+-  static u_char scan_options = 0;
+-  const u_char *cmd;
+-  u_char stop_cmd[6] = { 0x1b, 0, 0, 0, 0, 0 };
++  static unsigned char scan_options = 0;
++  const unsigned char *cmd;
++  unsigned char stop_cmd[6] = { 0x1b, 0, 0, 0, 0, 0 };
+   int max_tries;
+ 
+   max_tries = MUSTEK_SCSI_PP_NUM_RETRIES;
+ 
+-  cmd = (const u_char *) src;
++  cmd = (const unsigned char *) src;
+ 
+   DBG (5, "mustek_scsi_pp_cmd: sending command 0x%02X to device %d\n",
+        cmd[0], fd);
+_at_@ -787,7 +787,7 @@
+   if (src_size < 6)
+     {
+       sanei_pa4s2_enable (fd, SANE_FALSE);
+-      DBG (2, "mustek_scsi_pp_cmd: source size is only %lu (<6)\n", (u_long) src_size);
++      DBG (2, "mustek_scsi_pp_cmd: source size is only %lu (<6)\n", (unsigned long) src_size);
+       return SANE_STATUS_INVAL;
+     }
+ 
+_at_@ -812,10 +812,10 @@
+   if (src_size > 6)
+     {
+       DBG (5, "mustek_scsi_pp_cmd: sending data block of length %lu\n",
+-	   (u_long) (src_size - 6));
++	   (unsigned long) (src_size - 6));
+ 
+       stat =
+-	mustek_scsi_pp_send_data_block (fd, ((const u_char *) src) + 6,
++	mustek_scsi_pp_send_data_block (fd, ((const unsigned char *) src) + 6,
+ 					src_size - 6);
+       if (stat != SANE_STATUS_GOOD)
+ 	{
+_at_@ -840,7 +840,7 @@
+ 	  sanei_pa4s2_enable (fd, SANE_FALSE);
+ 	  DBG (2,
+ 	       "mustek_scsi_pp_cmd: buffer (size %lu) not big enough for data (size %d)\n",
+-	       (u_long) *dst_size, length);
++	       (unsigned long) *dst_size, length);
+ 	  return SANE_STATUS_INVAL;
+ 	}
+ 
+--- sane-backends-1.0.24.orig/backend/nec.c
++++ sane-backends-1.0.24/backend/nec.c
+_at_@ -287,7 +287,7 @@
+ #endif
+ 
+ static SANE_Status
+-sense_handler(int fd, u_char *sense_buffer, void *ss)
++sense_handler(int fd, unsigned char *sense_buffer, void *ss)
+ {
+   int sense_key;
+   NEC_Sense_Data *sdat = (NEC_Sense_Data *) ss;
+_at_@ -377,7 +377,7 @@
+ static SANE_Status
+ test_unit_ready (int fd)
+ {
+-  static u_char cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< test_unit_ready ");
+ 
+_at_@ -391,7 +391,7 @@
+ static SANE_Status
+ request_sense (int fd, void *sense_buf, size_t *sense_size)
+ {
+-  static u_char cmd[] = {REQUEST_SENSE, 0, 0, 0, SENSE_LEN, 0};
++  static unsigned char cmd[] = {REQUEST_SENSE, 0, 0, 0, SENSE_LEN, 0};
+   SANE_Status status;
+   DBG (11, "<< request_sense ");
+ 
+_at_@ -405,7 +405,7 @@
+ static SANE_Status
+ inquiry (int fd, void *inq_buf, size_t *inq_size)
+ {
+-  static u_char cmd[] = {INQUIRY, 0, 0, 0, INQUIRY_LEN, 0};
++  static unsigned char cmd[] = {INQUIRY, 0, 0, 0, INQUIRY_LEN, 0};
+   SANE_Status status;
+   DBG (11, "<< inquiry ");
+ 
+_at_@ -418,7 +418,7 @@
+ static SANE_Status
+ mode_select_mud (int fd, int mud)
+ {
+-  static u_char cmd[6 + MODEPARAM_LEN] = 
++  static unsigned char cmd[6 + MODEPARAM_LEN] = 
+   {MODE_SELECT6, 0x10, 0, 0, MODEPARAM_LEN, 0};
+   mode_select_param *mp;
+   SANE_Status status;
+_at_@ -442,7 +442,7 @@
+ static SANE_Status
+ mode_select_adf_fsu (int fd, int mode)
+ {
+-  static u_char cmd[6 + MODE_SUBDEV_LEN] = 
++  static unsigned char cmd[6 + MODE_SUBDEV_LEN] = 
+                         {MODE_SELECT6, 0x10, 0, 0, MODE_SUBDEV_LEN, 0};
+   mode_select_subdevice *mp;
+   SANE_Status status;
+_at_@ -481,7 +481,7 @@
+ mode_sense (int fd, void *modeparam_buf, size_t * modeparam_size, 
+             int page)
+ {
+-  static u_char cmd[6] = {MODE_SENSE6, 0, 0, 0, 0, 0};
++  static unsigned char cmd[6] = {MODE_SENSE6, 0, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< mode_sense ");
+   cmd[0] = 0x1a;
+_at_@ -497,7 +497,7 @@
+ static SANE_Status
+ scan (int fd)
+ {
+-  static u_char cmd[] = {SCAN, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {SCAN, 0, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< scan ");
+ 
+_at_@ -511,7 +511,7 @@
+ static SANE_Status
+ send_diagnostics (int fd)
+ {
+-  static u_char cmd[] = {SEND_DIAGNOSTIC, 0x04, 0, 0, 0, 0};
++  static unsigned char cmd[] = {SEND_DIAGNOSTIC, 0x04, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< send_diagnostics ");
+ 
+_at_@ -525,7 +525,7 @@
+ static SANE_Status
+ set_window (int fd, window_param *wp, int len)
+ {
+-  static u_char cmd[10 + WINDOW_LEN] = 
++  static unsigned char cmd[10 + WINDOW_LEN] = 
+                         {SET_WINDOW, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+   window_param *winp;
+   SANE_Status status;
+_at_@ -545,7 +545,7 @@
+ static SANE_Status
+ get_window (int fd, void *buf, size_t * buf_size)
+ {
+-  static u_char cmd[10] = {GET_WINDOW, 0, 0, 0, 0, 0, 0, 0, WINDOW_LEN, 0};
++  static unsigned char cmd[10] = {GET_WINDOW, 0, 0, 0, 0, 0, 0, 0, WINDOW_LEN, 0};
+   SANE_Status status;
+   DBG (11, "<< get_window ");
+ 
+_at_@ -560,7 +560,7 @@
+ static SANE_Status
+ get_data_buffer_status (int fd, void *buf, size_t *buf_size)
+ {
+-  static u_char cmd[10] = 
++  static unsigned char cmd[10] = 
+                         {GET_DATA_BUFFER_STATUS, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< get_data_buffer_status ");
+_at_@ -619,7 +619,7 @@
+ {
+   SANE_Status status;
+   sigset_t sigterm_set;
+-  static u_char cmd[] = {READ, 0, 0, 0, 0, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {READ, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+   int full_count = 0, counted;
+   size_t waitindex, cmdindex;
+   size_t bytes_to_queue;
+_at_@ -903,7 +903,7 @@
+ static SANE_Status
+ read_data (NEC_Scanner *s, SANE_Byte *buf, size_t * buf_size)
+ {
+-  static u_char cmd[] = {READ, 0, 0, 0, 0, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {READ, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+   SANE_Status status = SANE_STATUS_GOOD;
+   size_t remain = *buf_size;
+   size_t nread;
+_at_@ -2597,7 +2597,7 @@
+       {
+ #ifdef DEBUG_NEC
+ 	int i;
+-	u_char *buf = &bs;
++	unsigned char *buf = &bs;
+ 	DBG(11, "get data buffer status(debug):\n");
+ 	for (i = 0; i < len; i += 16)
+ 	  {
+_at_@ -3416,7 +3416,7 @@
+ 
+   DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, "
+        "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line,
+-       s->params.lines, (u_long) s->bytes_to_read, s->val[OPT_RESOLUTION].w);
++       s->params.lines, (unsigned long) s->bytes_to_read, s->val[OPT_RESOLUTION].w);
+ 
+   s->busy = SANE_FALSE;
+   s->buf_used = 0;
+_at_@ -3451,7 +3451,7 @@
+     DBG (20, "buffer_status: %i ", bs.fdb[0]*256*256 + bs.fdb[1]*256 + bs.fdb[2]); 
+   }
+ #endif
+-  DBG (20, "remaining: %lu ", (u_long)  s->bytes_to_read);
++  DBG (20, "remaining: %lu ", (unsigned long)  s->bytes_to_read);
+   *len = 0;
+ 
+   if (s->bytes_to_read == 0)
+_at_@ -3483,7 +3483,7 @@
+     }
+   *len = nread;
+   s->bytes_to_read -= nread;
+-  DBG (20, "remaining: %lu ", (u_long) s->bytes_to_read);
++  DBG (20, "remaining: %lu ", (unsigned long) s->bytes_to_read);
+ 
+   DBG (10, ">>\n");
+   return (SANE_STATUS_GOOD);
+--- sane-backends-1.0.24.orig/backend/nec.h
++++ sane-backends-1.0.24/backend/nec.h
+_at_@ -199,7 +199,7 @@
+     */
+     int complain_on_adf_error;
+     /* Linux returns only 16 bytes of sense data... */
+-    u_char sb[16]; 
++    unsigned char sb[16]; 
+   }
+ NEC_Sense_Data;
+ 
+_at_@ -284,8 +284,8 @@
+ 
+ typedef struct WPDH
+ {
+-    u_char wpdh[6];
+-    u_char wdl[2];
++    unsigned char wpdh[6];
++    unsigned char wdl[2];
+ } 
+ WPDH;
+ 
+--- sane-backends-1.0.24.orig/backend/net.c
++++ sane-backends-1.0.24/backend/net.c
+_at_@ -2173,7 +2173,7 @@
+ 	      return SANE_STATUS_IO_ERROR;
+ 	    }
+ 	}
+-      DBG (4, "sane_read: read %lu bytes, %d from 4 total\n", (u_long) nread,
++      DBG (4, "sane_read: read %lu bytes, %d from 4 total\n", (unsigned long) nread,
+ 	   s->reclen_buf_offset);
+       s->reclen_buf_offset += nread;
+       if (s->reclen_buf_offset < 4)
+_at_@ -2183,10 +2183,10 @@
+ 	}
+ 
+       s->reclen_buf_offset = 0;
+-      s->bytes_remaining = (((u_long) s->reclen_buf[0] << 24)
+-			    | ((u_long) s->reclen_buf[1] << 16)
+-			    | ((u_long) s->reclen_buf[2] << 8)
+-			    | ((u_long) s->reclen_buf[3] << 0));
++      s->bytes_remaining = (((unsigned long) s->reclen_buf[0] << 24)
++			    | ((unsigned long) s->reclen_buf[1] << 16)
++			    | ((unsigned long) s->reclen_buf[2] << 8)
++			    | ((unsigned long) s->reclen_buf[3] << 0));
+       DBG (3, "sane_read: next record length=%ld bytes\n",
+ 	   (long) s->bytes_remaining);
+       if (s->bytes_remaining == 0xffffffff)
+_at_@ -2317,8 +2317,8 @@
+ 	  *(data + cnt + 1) = swap_buf;
+ 	}
+     }
+-  DBG (3, "sane_read: %lu bytes read, %lu remaining\n", (u_long) nread,
+-       (u_long) s->bytes_remaining);
++  DBG (3, "sane_read: %lu bytes read, %lu remaining\n", (unsigned long) nread,
++       (unsigned long) s->bytes_remaining);
+ 
+   return SANE_STATUS_GOOD;
+ }
+--- sane-backends-1.0.24.orig/backend/net.h
++++ sane-backends-1.0.24/backend/net.h
+_at_@ -77,7 +77,7 @@
+ 
+     int data;			/* data socket descriptor */
+     int reclen_buf_offset;
+-    u_char reclen_buf[4];
++    unsigned char reclen_buf[4];
+     size_t bytes_remaining;	/* how many bytes left in this record? */
+ 
+     /* device (host) info: */
+--- sane-backends-1.0.24.orig/backend/pie.c
++++ sane-backends-1.0.24/backend/pie.c
+_at_@ -1727,7 +1727,7 @@
+       set_read_length (sread.cmd, 1);
+       size = rcv_length;
+ 
+-      DBG (DBG_info, "pie_perform_cal: reading 1 line (%lu bytes)\n", (u_long) size);
++      DBG (DBG_info, "pie_perform_cal: reading 1 line (%lu bytes)\n", (unsigned long) size);
+ 
+       status =
+ 	sanei_scsi_cmd (scanner->sfd, sread.cmd, sread.size, rcv_buffer,
+_at_@ -1901,7 +1901,7 @@
+       return status;
+     }
+ 
+-  DBG (DBG_info, "pie_perform_cal: sending cal data (%lu bytes)\n", (u_long) size);
++  DBG (DBG_info, "pie_perform_cal: sending cal data (%lu bytes)\n", (unsigned long) size);
+   DBG_DUMP (DBG_dump, send_buffer, 64);
+ 
+   status =
+_at_@ -2690,7 +2690,7 @@
+       else
+ 	{
+ 	  DBG (DBG_info2,
+-	       "pie_reader_process_indexed: got a line (%lu bytes)\n", (u_long) size);
++	       "pie_reader_process_indexed: got a line (%lu bytes)\n", (unsigned long) size);
+ 
+ 	  /* just send the data on, assume filter bytes not present as per calibration case */
+ 	  fwrite (buffer, 1, scanner->params.bytes_per_line, fp);
+--- sane-backends-1.0.24.orig/backend/pint.c
++++ sane-backends-1.0.24/backend/pint.c
+_at_@ -810,7 +810,7 @@
+ 
+   if (!s->scanning)
+     {
+-      u_long x0, y0, width, height;
++      unsigned long x0, y0, width, height;
+       const char *mode;
+ 
+       /* Grab the scanio for this device. */
+--- sane-backends-1.0.24.orig/backend/plustek-pp_ptdrv.c
++++ sane-backends-1.0.24/backend/plustek-pp_ptdrv.c
+_at_@ -325,15 +325,15 @@
+ 	switch (size) {
+ #ifdef __KERNEL__
+ 	case sizeof(u_char):
+-		GET_USER_RET(*(u_char *)where, (u_char *) useraddr, -EFAULT);
++		GET_USER_RET(*(unsigned char *)where, (unsigned char *) useraddr, -EFAULT);
+ 		break;
+ 
+-	case sizeof(u_short):
+-		GET_USER_RET(*(u_short *)where, (u_short *) useraddr, -EFAULT);
++	case sizeof(unsigned short):
++		GET_USER_RET(*(unsigned short *)where, (unsigned short *) useraddr, -EFAULT);
+ 		break;
+ 
+-	case sizeof(u_long):
+-		GET_USER_RET(*(u_long *)where, (u_long *) useraddr, -EFAULT);
++	case sizeof(unsigned long):
++		GET_USER_RET(*(unsigned long *)where, (unsigned long *) useraddr, -EFAULT);
+ 		break;
+ 
+ 	default:
+_at_@ -403,13 +403,13 @@
+ 
+ #ifdef __KERNEL__
+ 	case sizeof(u_char):
+-    	PUT_USER_RET((u_char)value, (u_char *) useraddr, -EFAULT);
++    	PUT_USER_RET((u_char)value, (unsigned char *) useraddr, -EFAULT);
+     	break;
+-  	case sizeof(u_short):
+-    	PUT_USER_RET((u_short)value, (u_short *) useraddr, -EFAULT);
++  	case sizeof(unsigned short):
++    	PUT_USER_RET((unsigned short)value, (unsigned short *) useraddr, -EFAULT);
+     	break;
+-  	case sizeof(u_long):
+-    	PUT_USER_RET((u_long)value, (u_long *) useraddr, -EFAULT);
++  	case sizeof(unsigned long):
++    	PUT_USER_RET((unsigned long)value, (unsigned long *) useraddr, -EFAULT);
+     	break;
+ #else
+ 	case sizeof(UChar):
+_at_@ -1126,7 +1126,7 @@
+ 				return _E_FAULT;
+ 
+ 			DBG( DBG_LOW, "maplen=%u, mapid=%u, addr=0x%08lx\n",
+-							map.len, map.map_id, (u_long)map.map );
++							map.len, map.map_id, (unsigned long)map.map );
+ 
+ 			x_len = 256;
+ 			if( _IS_ASIC98(ps->sCaps.AsicID))
+_at_@ -1148,7 +1148,7 @@
+ 				}
+ 			} else {
+ 
+-				u_long idx = 0;
++				unsigned long idx = 0;
+ 				if( map.map_id == _MAP_GREEN )
+ 					idx = 1;
+ 				if( map.map_id == _MAP_BLUE )
+--- sane-backends-1.0.24.orig/backend/plustek-usb.c
++++ sane-backends-1.0.24/backend/plustek-usb.c
+_at_@ -123,7 +123,7 @@
+ 
+ /** remove the slash out of the model-name to obtain a valid filename
+  */
+-static SANE_Bool usb_normFileName( char *fname, char* buffer, u_long max_len )
++static SANE_Bool usb_normFileName( char *fname, char* buffer, unsigned long max_len )
+ {
+ 	char *src, *dst;
+ 
+_at_@ -192,7 +192,7 @@
+ 	char      tmp_str2[PATH_MAX];
+ 	int       i;
+ 	ScanParam sParam;
+-	u_short   tmp = 0;
++	unsigned short   tmp = 0;
+ 
+ 	DBG( _DBG_INFO, "usb_initDev(%d,0x%04x,%i)\n",
+ 	                idx, vendor, dev->initialized );
+_at_@ -332,7 +332,7 @@
+ {
+ 	char   tmp[50];
+ 	char   pcbStr[10];
+-	u_char reg59[3], reg59s[3], pcbID;
++	unsigned char reg59[3], reg59s[3], pcbID;
+ 	int    i, result;
+ 
+ 	/*
+_at_@ -999,33 +999,33 @@
+ 
+ 		dev->usbDev.pSource = &caps->Normal;
+ 		scan->sParam.Origin.x += dev->usbDev.pSource->DataOrigin.x +
+-		                                      (u_long)dev->usbDev.Normal.lLeft;
++		                                      (unsigned long)dev->usbDev.Normal.lLeft;
+ 		scan->sParam.Origin.y += dev->usbDev.pSource->DataOrigin.y +
+-		                                        (u_long)dev->usbDev.Normal.lUp;
++		                                        (unsigned long)dev->usbDev.Normal.lUp;
+ 
+ 	} else if( scan->sParam.bSource == SOURCE_Transparency ) {
+ 
+ 		dev->usbDev.pSource = &caps->Positive;
+ 		scan->sParam.Origin.x += dev->usbDev.pSource->DataOrigin.x +
+-		                                    (u_long)dev->usbDev.Positive.lLeft;
++		                                    (unsigned long)dev->usbDev.Positive.lLeft;
+ 		scan->sParam.Origin.y += dev->usbDev.pSource->DataOrigin.y +
+-		                                      (u_long)dev->usbDev.Positive.lUp;
++		                                      (unsigned long)dev->usbDev.Positive.lUp;
+ 
+ 	} else if( scan->sParam.bSource == SOURCE_Negative ) {
+ 
+ 		dev->usbDev.pSource = &caps->Negative;
+ 		scan->sParam.Origin.x += dev->usbDev.pSource->DataOrigin.x +
+-		                                    (u_long)dev->usbDev.Negative.lLeft;
++		                                    (unsigned long)dev->usbDev.Negative.lLeft;
+ 		scan->sParam.Origin.y += dev->usbDev.pSource->DataOrigin.y +
+-		                                      (u_long)dev->usbDev.Negative.lUp;
++		                                      (unsigned long)dev->usbDev.Negative.lUp;
+ 
+ 	} else {
+ 
+ 		dev->usbDev.pSource = &dev->usbDev.Caps.Adf;
+ 		scan->sParam.Origin.x += dev->usbDev.pSource->DataOrigin.x +
+-		                                      (u_long)dev->usbDev.Normal.lLeft;
++		                                      (unsigned long)dev->usbDev.Normal.lLeft;
+ 		scan->sParam.Origin.y += dev->usbDev.pSource->DataOrigin.y +
+-		                                        (u_long)dev->usbDev.Normal.lUp;
++		                                        (unsigned long)dev->usbDev.Normal.lUp;
+ 	}
+ 
+ 	if( scan->sParam.bSource == SOURCE_ADF ) {
+_at_@ -1181,7 +1181,7 @@
+ 
+ 		scan->dwLinesDiscard = 0;
+ 		if( scan->sParam.bChannels == 3 ) {
+-			scan->dwLinesDiscard = (u_long)scaps->bSensorDistance *
++			scan->dwLinesDiscard = (unsigned long)scaps->bSensorDistance *
+ 			                       scan->sParam.PhyDpi.y / scaps->OpticDpi.y;
+ 			scan->dwLinesDiscard <<= 1;
+ 		}
+_at_@ -1223,7 +1223,7 @@
+ 		/* CCD scanner */
+ 		if( scan->sParam.bChannels == 3 ) {
+ 
+-			scan->dwLinesDiscard = (u_long)scaps->bSensorDistance *
++			scan->dwLinesDiscard = (unsigned long)scaps->bSensorDistance *
+ 			                       scan->sParam.PhyDpi.y / scaps->OpticDpi.y;
+ 
+ 			switch( scaps->bSensorOrder ) {
+_at_@ -1284,7 +1284,7 @@
+ 
+ 			if( scan->dwFlag & SCANFLAG_bgr) {
+ 
+-				u_char *pb = scan->Blue.pb;
++				unsigned char *pb = scan->Blue.pb;
+ 
+ 				scan->Blue.pb = scan->Red.pb;
+ 				scan->Red.pb  = pb;
+_at_@ -1306,8 +1306,8 @@
+ 			if(( scan->sParam.bDataType == SCANDATATYPE_Color ) &&
+ 			   ( hw->bReg_0x26 & _ONE_CH_COLOR )) {
+ 
+-				u_char so;
+-				u_long len = scan->sParam.Size.dwPhyBytes / 3;
++				unsigned char so;
++				unsigned long len = scan->sParam.Size.dwPhyBytes / 3;
+ 
+ 				so = scaps->bSensorOrder;
+ 				if (_WAF_RESET_SO_TO_RGB & scaps->workaroundFlag) {
+_at_@ -1421,7 +1421,7 @@
+ usbDev_ReadLine( Plustek_Device *dev )
+ {
+ 	int      wrap;
+-	u_long   cur;
++	unsigned long   cur;
+ 	ScanDef *scan = &dev->scanning;
+ 	HWDef   *hw   = &dev->usbDev.HwSetting;
+ 
+_at_@ -1493,7 +1493,7 @@
+ 		 */
+ 		if( wrap ) {
+ 
+-			u_long len = scan->sParam.Size.dwPhyBytes;
++			unsigned long len = scan->sParam.Size.dwPhyBytes;
+ 
+ 			if( hw->bReg_0x26 & _ONE_CH_COLOR ) {
+ 
+--- sane-backends-1.0.24.orig/backend/plustek-usb.h
++++ sane-backends-1.0.24/backend/plustek-usb.h
+_at_@ -120,62 +120,62 @@
+ */
+ #define _SWAP(x,y)   { (x)^=(y); (x)^=((y)^=(x));}
+ 
+-#define _LOWORD(x)  ((u_short)(x & 0xffff))
+-#define _HIWORD(x)  ((u_short)(x >> 16))
++#define _LOWORD(x)  ((unsigned short)(x & 0xffff))
++#define _HIWORD(x)  ((unsigned short)(x >> 16))
+ #define _LOBYTE(x)  ((u_char)((x) & 0xFF))
+ #define _HIBYTE(x)  ((u_char)((x) >> 8))
+ 
+-#define _HILO2WORD(x)   ((u_short)x.bHi * 256U + x.bLo)
+-#define _LOHI2WORD(x)   ((u_short)x.bLo * 256U + x.bHi)
++#define _HILO2WORD(x)   ((unsigned short)x.bHi * 256U + x.bLo)
++#define _LOHI2WORD(x)   ((unsigned short)x.bLo * 256U + x.bHi)
+ 
+-#define _PHILO2WORD(x)  ((u_short)x->bHi * 256U + x->bLo)
+-#define _PLOHI2WORD(x)  ((u_short)x->bLo * 256U + x->bHi)
++#define _PHILO2WORD(x)  ((unsigned short)x->bHi * 256U + x->bLo)
++#define _PLOHI2WORD(x)  ((unsigned short)x->bLo * 256U + x->bHi)
+ 
+ #define PACKED8  __attribute__ ((packed,aligned(1)))
+ #define PACKED16 __attribute__ ((packed,aligned(2)))
+ 
+ /* useful for RGB-values */
+ typedef struct {
+-	u_char Red;
+-	u_char Green;
+-	u_char Blue;
++	unsigned char Red;
++	unsigned char Green;
++	unsigned char Blue;
+ } PACKED8 RGBByteDef;
+ 
+ typedef struct {
+-	u_short Red;
+-	u_short Green;
+-	u_short Blue;
++	unsigned short Red;
++	unsigned short Green;
++	unsigned short Blue;
+ } PACKED16 RGBUShortDef;
+ 
+ typedef struct {
+-	u_long Red;
+-	u_long Green;
+-	u_long Blue;
++	unsigned long Red;
++	unsigned long Green;
++	unsigned long Blue;
+ } RGBULongDef;
+ 
+ typedef struct {
+-	u_char a_bColor[3];
++	unsigned char a_bColor[3];
+ } PACKED8 ColorByteDef;
+ 
+ typedef struct {
+-	u_char bHi;
+-	u_char bLo;
++	unsigned char bHi;
++	unsigned char bLo;
+ } PACKED8 HiLoDef;
+ 
+ typedef union {
+ 	HiLoDef HiLo[3];
+-	u_short Colors[3];
++	unsigned short Colors[3];
+ } PACKED16 ColorWordDef;
+ 
+ typedef union {
+ 	HiLoDef HiLo;
+-	u_short Mono;
++	unsigned short Mono;
+ } PACKED16 MonoWordDef;
+ 
+ typedef union {
+ 
+-	u_char       *pb;
+-	u_short      *pw;
++	unsigned char       *pb;
++	unsigned short      *pw;
+ 	MonoWordDef  *pmw;
+ 	ColorByteDef *pcb;
+ 	ColorWordDef *pcw;
+_at_@ -310,7 +310,7 @@
+ };
+ 
+ /** for encoding a misc I/O register as TPA */
+-#define _TPA(register) ((u_long)(register << _TPA_SHIFT))
++#define _TPA(register) ((unsigned long)(register << _TPA_SHIFT))
+ 
+ /** Mask to check for available TPA */
+ #define _HAS_TPA(flag) (flag & _TPA_MASK)
+_at_@ -415,16 +415,16 @@
+ 	SrcAttrDef Negative;        /**< Negative film                           */
+ 	SrcAttrDef Adf;             /**< Adf device                              */
+ 	XY         OpticDpi;        /**< Maximum DPI                             */
+-	u_short    wFlags;          /**< Flag to indicate what kinds of elements */
++	unsigned short    wFlags;          /**< Flag to indicate what kinds of elements */
+ 	                            /*   are available                           */
+-	u_char     bSensorOrder;    /**< CCD color sequences, see _SENSORORDER   */
+-	u_char     bSensorDistance; /**< CCD Color distance                      */
+-	u_char     bButtons;        /**< Number of buttons                       */
+-	u_char     bCCD;            /**< CCD ID                                  */
+-	u_short    bPCB;            /**< PCB ID/or threshold (only CIS)          */
+-	u_long     workaroundFlag;  /**< Flag to allow special work arounds, see */
++	unsigned char     bSensorOrder;    /**< CCD color sequences, see _SENSORORDER   */
++	unsigned char     bSensorDistance; /**< CCD Color distance                      */
++	unsigned char     bButtons;        /**< Number of buttons                       */
++	unsigned char     bCCD;            /**< CCD ID                                  */
++	unsigned short    bPCB;            /**< PCB ID/or threshold (only CIS)          */
++	unsigned long     workaroundFlag;  /**< Flag to allow special work arounds, see */
+ 	                            /*   _WORKAROUNDS                            */
+-	u_long     misc_io;         /**< for lamp, papersense and buttons        */
++	unsigned long     misc_io;         /**< for lamp, papersense and buttons        */
+ 
+ } DCapsDef;
+ 
+_at_@ -433,14 +433,14 @@
+  */
+ typedef struct
+ {
+-	u_char  mode;
++	unsigned char  mode;
+ 
+-	u_short red_lamp_on;
+-	u_short red_lamp_off;
+-	u_short green_lamp_on;
+-	u_short green_lamp_off;
+-	u_short blue_lamp_on;
+-	u_short blue_lamp_off;
++	unsigned short red_lamp_on;
++	unsigned short red_lamp_off;
++	unsigned short green_lamp_on;
++	unsigned short green_lamp_off;
++	unsigned short blue_lamp_on;
++	unsigned short blue_lamp_off;
+ 
+ } IllumiDef;
+ 
+_at_@ -454,72 +454,72 @@
+ 	double              dHighSpeed;        /* for speeding up the sensor     */
+ 	double              dIntegrationTimeLowLamp;
+ 	double              dIntegrationTimeHighLamp;
+-	u_short             wMotorDpi;                      /* Full step DPI */
+-	u_short             wDRAMSize;                      /* in KB         */
++	unsigned short             wMotorDpi;                      /* Full step DPI */
++	unsigned short             wDRAMSize;                      /* in KB         */
+ 	double              dMinIntegrationTimeLowres;      /*in ms.     */
+ 	double              dMinIntegrationTimeHighres;     /* in ms.    */
+-	u_short             wGreenPWMDutyCycleLow;
+-	u_short             wGreenPWMDutyCycleHigh;
++	unsigned short             wGreenPWMDutyCycleLow;
++	unsigned short             wGreenPWMDutyCycleHigh;
+ 	/* Registers */
+-	u_char              bSensorConfiguration;           /* 0x0b */
++	unsigned char              bSensorConfiguration;           /* 0x0b */
+ 	/* Sensor control settings */
+-	u_char              bReg_0x0c;
+-	u_char              bReg_0x0d;
+-	u_char              bReg_0x0e;
+-	u_char              bReg_0x0f_Mono [10];	/* 0x0f to 0x18 */
+-	u_char              bReg_0x0f_Color [10];	/* 0x0f to 0x18 */
++	unsigned char              bReg_0x0c;
++	unsigned char              bReg_0x0d;
++	unsigned char              bReg_0x0e;
++	unsigned char              bReg_0x0f_Mono [10];	/* 0x0f to 0x18 */
++	unsigned char              bReg_0x0f_Color [10];	/* 0x0f to 0x18 */
+ 
+ 	/* color mode settings */	
+-	u_char              bReg_0x26;
+-	u_char              bReg_0x27;
++	unsigned char              bReg_0x26;
++	unsigned char              bReg_0x27;
+ 	
+ 	/* illumination mode reg 0x29 (runtime) */
+-	u_char              bReg_0x29;
++	unsigned char              bReg_0x29;
+ 
+ 	/* initial illumination settings */
+ 	IllumiDef           illu_mono;
+ 	IllumiDef           illu_color;
+ 
+-	/* 0x1a & 0x1b, remember the u_char order is not Intel
++	/* 0x1a & 0x1b, remember the unsigned char order is not Intel
+ 	 * format, you have to pay your attention when you
+ 	 * write this value to register.
+ 	 */
+-	u_short             StepperPhaseCorrection;	
++	unsigned short             StepperPhaseCorrection;	
+ 
+ 	/* Sensor Pixel Configuration
+ 	 * Actually, the wActivePixelsStart will be set to 0 for shading purpose.
+ 	 * We have to keep these values to adjust the origins when user does the
+ 	 * scan. These settings are based on optic resolution.
+ 	 */
+-	u_char              bOpticBlackStart;       /* 0x1c        */
+-	u_char              bOpticBlackEnd;         /* 0x1d        */
+-	u_short             wActivePixelsStart;     /* 0x1e & 0x1f */
+-	u_short             wLineEnd;               /* 0x20 & 0x21 */
++	unsigned char              bOpticBlackStart;       /* 0x1c        */
++	unsigned char              bOpticBlackEnd;         /* 0x1d        */
++	unsigned short             wActivePixelsStart;     /* 0x1e & 0x1f */
++	unsigned short             wLineEnd;               /* 0x20 & 0x21 */
+ 
+ 	/* illumination settings (runtime) */
+-	u_short             red_lamp_on;            /* 0x2c & 0x2d */
+-	u_short             red_lamp_off;           /* 0x2e & 0x2f */
+-	u_short             green_lamp_on;          /* 0x30 & 0x31 */
+-	u_short             green_lamp_off;         /* 0x32 & 0x33 */
+-	u_short             blue_lamp_on;           /* 0x34 & 0x35 */
+-	u_short             blue_lamp_off;          /* 0x36 & 0x37 */
++	unsigned short             red_lamp_on;            /* 0x2c & 0x2d */
++	unsigned short             red_lamp_off;           /* 0x2e & 0x2f */
++	unsigned short             green_lamp_on;          /* 0x30 & 0x31 */
++	unsigned short             green_lamp_off;         /* 0x32 & 0x33 */
++	unsigned short             blue_lamp_on;           /* 0x34 & 0x35 */
++	unsigned short             blue_lamp_off;          /* 0x36 & 0x37 */
+ 
+ 	/* Misc */
+-	u_char              bReg_0x45;
+-	u_short             wStepsAfterPaperSensor2;/* 0x4c & 0x4d */
+-	u_char              bStepsToReverse;        /* 0x50        */
+-	u_char              bReg_0x51;
+-	u_char              bReg_0x54;
+-	u_char              bReg_0x55;
+-	u_char              bReg_0x56;
+-	u_char              bReg_0x57;
+-	u_char              bReg_0x58;
+-	u_char              bReg_0x59;
+-	u_char              bReg_0x5a;
+-	u_char              bReg_0x5b;
+-	u_char              bReg_0x5c;
+-	u_char              bReg_0x5d;
+-	u_char              bReg_0x5e;
++	unsigned char              bReg_0x45;
++	unsigned short             wStepsAfterPaperSensor2;/* 0x4c & 0x4d */
++	unsigned char              bStepsToReverse;        /* 0x50        */
++	unsigned char              bReg_0x51;
++	unsigned char              bReg_0x54;
++	unsigned char              bReg_0x55;
++	unsigned char              bReg_0x56;
++	unsigned char              bReg_0x57;
++	unsigned char              bReg_0x58;
++	unsigned char              bReg_0x59;
++	unsigned char              bReg_0x5a;
++	unsigned char              bReg_0x5b;
++	unsigned char              bReg_0x5c;
++	unsigned char              bReg_0x5d;
++	unsigned char              bReg_0x5e;
+ 
+ 	eChipDef            chip;           /* chiptype               */
+ 	eModelDef           motorModel;     /* to identify used motor */
+_at_@ -541,13 +541,13 @@
+ 	OrgDef      Positive;      /**< Pos film - Pix to adjust scanning orgs   */
+ 	OrgDef      Negative;      /**< Neg film - Pix to adjust scanning orgs   */
+ 	OrgDef      Adf;           /**< Adf - Pixels to adjust scanning origins  */
+-	u_long      dwTicksLampOn; /**< The ticks when lamp turns on             */
+-	u_long      dwLampOnPeriod;/**< How many seconds to keep lamp on         */
++	unsigned long      dwTicksLampOn; /**< The ticks when lamp turns on             */
++	unsigned long      dwLampOnPeriod;/**< How many seconds to keep lamp on         */
+ 	SANE_Bool   bLampOffOnEnd; /**< switch lamp off on end or keep cur. state*/
+ 	int         currentLamp;   /**< The lamp ID of the currently used lamp   */
+ 	SANE_Bool   fModFirstHome; /**<                                          */
+ 	SANE_Bool   fLastScanIsAdf;/**<                                          */
+-	u_char      a_bRegs[0x80]; /**< our global register file                 */
++	unsigned char      a_bRegs[0x80]; /**< our global register file                 */
+ 
+ } DeviceDef;
+ 
+_at_@ -566,17 +566,17 @@
+ typedef struct
+ {
+ 	/** User Information */
+-	u_long dwBytes;       /**< bytes per line  */
+-	u_long dwPixels;      /**< pixels per line */
+-	u_long dwLines;       /**< lines           */
++	unsigned long dwBytes;       /**< bytes per line  */
++	unsigned long dwPixels;      /**< pixels per line */
++	unsigned long dwLines;       /**< lines           */
+ 
+ 	/** Driver Info */
+-	u_long dwValidPixels; /**< only valid pixels, not incl. pad pix(B/W,Gray)*/
+-	u_long dwPhyPixels;   /**< inlcude pad pixels for ASIC (B/W, Gray)       */
+-	u_long dwPhyBytes;    /**< bytes to read from ASIC                       */
+-	u_long dwPhyLines;    /**< should include the extra lines accord to the  */
++	unsigned long dwValidPixels; /**< only valid pixels, not incl. pad pix(B/W,Gray)*/
++	unsigned long dwPhyPixels;   /**< inlcude pad pixels for ASIC (B/W, Gray)       */
++	unsigned long dwPhyBytes;    /**< bytes to read from ASIC                       */
++	unsigned long dwPhyLines;    /**< should include the extra lines accord to the  */
+ 	                      /*   request dpi (CCD lines distance)              */
+-	u_long dwTotalBytes;  /**< Total bytes per scan                          */
++	unsigned long dwTotalBytes;  /**< Total bytes per scan                          */
+ 
+ } WinInfo;
+ 
+_at_@ -587,7 +587,7 @@
+ 	/* OUTPUT - Driver returned area. All are based on physical
+ 	 * scanning conditions. */
+ 	WinInfo Size;                   /* i/p:
+-	                                 * dwPixels, dwBytes(without u_long boundary factor)
++	                                 * dwPixels, dwBytes(without unsigned long boundary factor)
+                                          * dwLines in user specified dpi
+ 	                                 * o/p:
+ 	                                 * dwPhyPixels, dwPhyBytes, dwPhyLines
+_at_@ -601,11 +601,11 @@
+ 	double  dMCLK;        /**< for positive & negative & Adf               */
+ 	short   brightness;
+ 	short   contrast;
+-	u_char  bSource;      /**< Reflection/Positive/Negative/Adf(SOURCE_xxx)*/
+-	u_char  bDataType;    /**< Bw, Gray or Color (see _SCANDATATYPE)       */
+-	u_char  bBitDepth;    /**< 1/8/14                                      */
+-	u_char  bChannels;    /**< Color or Gray                               */
+-	u_char  bCalibration; /**< 1 or 2: the origin.x is from CCD pixel 0 and
++	unsigned char  bSource;      /**< Reflection/Positive/Negative/Adf(SOURCE_xxx)*/
++	unsigned char  bDataType;    /**< Bw, Gray or Color (see _SCANDATATYPE)       */
++	unsigned char  bBitDepth;    /**< 1/8/14                                      */
++	unsigned char  bChannels;    /**< Color or Gray                               */
++	unsigned char  bCalibration; /**< 1 or 2: the origin.x is from CCD pixel 0 and
+ 	                       *           the origin.y is from Top of scanner.
+ 	                       *           In this case, the WININFO.dwPhyLines
+ 	                       *         will not included the extra lines for
+_at_@ -625,33 +625,33 @@
+ {
+ 	SANE_Bool fCalibrated;    /**< calibrated or not              */
+ 	SANE_Bool skipCoarseCalib;/**< skip coarse calibration or not */
+-	u_long    dwFlag;         /**< scan attributes                */
++	unsigned long    dwFlag;         /**< scan attributes                */
+ 
+ 	ScanParam sParam;         /**< all we need to scan            */
+ 
+ 	AnyPtr    UserBuf;        /**< pointer to the user buffer     */
+-	u_long    dwLinesUser;    /**< Number of lines of user buffer */
+-	u_long    dwBytesLine;    /**< Bytes per line of user buffer. */
+-	u_long    dwLinesToProcess;
++	unsigned long    dwLinesUser;    /**< Number of lines of user buffer */
++	unsigned long    dwBytesLine;    /**< Bytes per line of user buffer. */
++	unsigned long    dwLinesToProcess;
+ 
+ 	/** Image processing routine according to the scan mode  */
+ 	void (*pfnProcess)(struct Plustek_Device*);
+ 
+ 	u_long* pScanBuffer;      /**< our scan buffer */
+ 
+-	u_long  dwLinesPerScanBufs;
+-	u_long  dwNumberOfScanBufs;
+-	u_long  dwLinesScanBuf;
++	unsigned long  dwLinesPerScanBufs;
++	unsigned long  dwNumberOfScanBufs;
++	unsigned long  dwLinesScanBuf;
+ 
+ 	u_char* pbScanBufBegin;
+ 	u_char* pbScanBufEnd;
+ 	u_char* pbGetDataBuf;
+-	u_long  dwBytesScanBuf;
+-	u_long  dwLinesDiscard;
++	unsigned long  dwBytesScanBuf;
++	unsigned long  dwLinesDiscard;
+ 
+-	u_long  dwRedShift;
+-	u_long  dwGreenShift;
+-	u_long  dwBlueShift;
++	unsigned long  dwRedShift;
++	unsigned long  dwGreenShift;
++	unsigned long  dwBlueShift;
+ 
+ 	AnyPtr  Green;
+ 	AnyPtr  Red;
+_at_@ -659,12 +659,12 @@
+ 	
+ 	long    lBufAdjust;       /**< bytes to adjust buffer pointer  */
+ 	                          /*   after a image line processed    */
+-	u_short wSumY;            /**<  for line sampling              */
++	unsigned short wSumY;            /**<  for line sampling              */
+ 	
+-	u_char  bLineDistance;    /**< Color offset in specific dpi y  */
++	unsigned char  bLineDistance;    /**< Color offset in specific dpi y  */
+ 	int     fGrayFromColor;   /**< channel to use for gray mode    */
+ 
+-	u_char  bLinesToSkip;     /**< how many lines to skip at start */
++	unsigned char  bLinesToSkip;     /**< how many lines to skip at start */
+ 
+ } ScanDef;
+ 
+_at_@ -676,9 +676,9 @@
+  */
+ typedef struct
+ {
+-	u_char pwm;                 /**< PWM             */
+-	u_char pwm_duty;            /**< PWM duty cycles */
+-	u_char scan_lines_per_line; /**< lines to scan to obtain 1 real line
++	unsigned char pwm;                 /**< PWM             */
++	unsigned char pwm_duty;            /**< PWM duty cycles */
++	unsigned char scan_lines_per_line; /**< lines to scan to obtain 1 real line
+                                       will be used in 16bit color modes only */
+ } MDef;
+ 
+_at_@ -688,12 +688,12 @@
+ 
+ 	eModelDef motorModel;    /**< the motor ID */
+ 
+-	u_char  pwm_fast;       /**< PWM during fast movement      */
+-	u_char  pwm_duty_fast;  /**< PWM duty during fast movement */
+-	u_char  mclk_fast;      /**< MCLK during fast movement     */
++	unsigned char  pwm_fast;       /**< PWM during fast movement      */
++	unsigned char  pwm_duty_fast;  /**< PWM duty during fast movement */
++	unsigned char  mclk_fast;      /**< MCLK during fast movement     */
+ 
+-	u_short dpi_thresh;
+-	u_short lineend;
++	unsigned short dpi_thresh;
++	unsigned short lineend;
+ 
+ 	/**
+ 	 * here we define some ranges for better supporting
+_at_@ -717,7 +717,7 @@
+ #define _SHADING_BUF    (_MAX_SHAD*3)    /**< max size of the shading buffer */
+ 
+ typedef struct {
+-	u_long  transferRate;
++	unsigned long  transferRate;
+ } IPCDef;
+ 
+ #endif /* guard __PLUSTEK_USB_H__ */
+--- sane-backends-1.0.24.orig/backend/plustek-usbcal.c
++++ sane-backends-1.0.24/backend/plustek-usbcal.c
+_at_@ -123,7 +123,7 @@
+ 
+ 			if( goto_shading_pos ) {
+ 				if( !usb_ModuleMove(dev, MOVE_Forward,
+-					(u_long)dev->usbDev.pSource->ShadingOriginY)) {
++					(unsigned long)dev->usbDev.pSource->ShadingOriginY)) {
+ 					DBG( _DBG_ERROR, "cano_PrepareToReadWhiteCal() failed\n" );
+ 					return _E_LAMP_NOT_IN_POS;
+ 				}
+_at_@ -163,7 +163,7 @@
+ 			if( !usb_IsSheetFedDevice(dev))
+ 				usb_ModuleToHome( dev, SANE_TRUE );
+ 			usb_ModuleMove  ( dev, MOVE_Forward,
+-			                       (u_long)dev->usbDev.pSource->DarkShadOrgY );
++			                       (unsigned long)dev->usbDev.pSource->DarkShadOrgY );
+ 			dev->usbDev.a_bRegs[0x45] &= ~0x10;
+ 			strip_state = 0;
+ 
+_at_@ -206,9 +206,9 @@
+  * _at_return returns 0 if the value is fine, 1, if we need to adjust 
+  */
+ static int
+-cano_adjLampSetting( u_short *min, u_short *max, u_short *off, u_short val )
++cano_adjLampSetting( unsigned short *min, unsigned short *max, unsigned short *off, unsigned short val )
+ {
+-	u_long newoff = *off;
++	unsigned long newoff = *off;
+ 
+ 	/* perfect value, no need to adjust
+ 	 * val  [53440..61440] is perfect
+_at_@ -223,8 +223,8 @@
+ 
+ 	} else {
+ 
+-		u_short bisect = (newoff + *max)>>1;
+-		u_short twice  =  newoff*2;
++		unsigned short bisect = (newoff + *max)>>1;
++		unsigned short twice  =  newoff*2;
+ 
+ 		DBG(_DBG_INFO2, "* TOO DARK --> up\n" );
+ 		*min = newoff;
+_at_@ -259,9 +259,9 @@
+ 	char         tmp[40];
+ 	int          i;
+ 	int          res_r, res_g, res_b;
+-	u_long       dw, dwR, dwG, dwB, dwDiv, dwLoop1, dwLoop2;
++	unsigned long       dw, dwR, dwG, dwB, dwDiv, dwLoop1, dwLoop2;
+ 	RGBUShortDef max_rgb, min_rgb, tmp_rgb;
+-	u_long      *scanbuf = dev->scanning.pScanBuffer;
++	unsigned long      *scanbuf = dev->scanning.pScanBuffer;
+ 	DCapsDef    *scaps   = &dev->usbDev.Caps;
+ 	HWDef       *hw      = &dev->usbDev.HwSetting;
+ 
+_at_@ -289,7 +289,7 @@
+ 	if( m_ScanParam.bDataType == SCANDATATYPE_Color )
+ 		m_ScanParam.Size.dwBytes *=3;
+ 
+-	m_ScanParam.Origin.x = (u_short)((u_long) hw->wActivePixelsStart *
++	m_ScanParam.Origin.x = (unsigned short)((unsigned long) hw->wActivePixelsStart *
+ 	                                          300UL / scaps->OpticDpi.x);
+ 	m_ScanParam.bCalibration = PARAM_Gain;
+ 
+_at_@ -341,7 +341,7 @@
+ 		dumpPic(tmp, (u_char*)scanbuf, m_ScanParam.Size.dwPhyBytes, 0);
+ 
+ 		if(usb_HostSwap())
+-			usb_Swap((u_short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
++			usb_Swap((unsigned short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
+ 
+ 		sprintf( tmp, "coarse-lamp-swap%u.raw", i );
+ 
+_at_@ -473,9 +473,9 @@
+ /**
+  */
+ static int
+-cano_adjGainSetting( u_char *min, u_char *max, u_char *gain,u_long val )
++cano_adjGainSetting( unsigned char *min, unsigned char *max, unsigned char *gain,unsigned long val )
+ {
+-	u_long newgain = *gain;
++	unsigned long newgain = *gain;
+ 
+ 	if((val < IDEAL_GainNormal) && (val > (IDEAL_GainNormal-8000)))
+ 		return 0;
+_at_@ -511,8 +511,8 @@
+ {
+ 	char      tmp[40];
+ 	int       i = 0, adj = 1;
+-	u_long    dw;
+-	u_long   *scanbuf = dev->scanning.pScanBuffer;
++	unsigned long    dw;
++	unsigned long   *scanbuf = dev->scanning.pScanBuffer;
+ 	DCapsDef *scaps   = &dev->usbDev.Caps;
+ 	HWDef    *hw      = &dev->usbDev.HwSetting;
+ 
+_at_@ -550,7 +550,7 @@
+ 	if( usb_IsCISDevice(dev) && m_ScanParam.bDataType == SCANDATATYPE_Color)
+ 		m_ScanParam.Size.dwBytes *=3;
+ 
+-	m_ScanParam.Origin.x = (u_short)((u_long) hw->wActivePixelsStart *
++	m_ScanParam.Origin.x = (unsigned short)((unsigned long) hw->wActivePixelsStart *
+ 	                                                300UL / scaps->OpticDpi.x);
+ 	m_ScanParam.bCalibration = PARAM_Gain;
+ 
+_at_@ -583,14 +583,14 @@
+ 		dumpPic(tmp, (u_char*)scanbuf, m_ScanParam.Size.dwPhyBytes, 0);
+ 
+ 		if(usb_HostSwap())
+-			usb_Swap((u_short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
++			usb_Swap((unsigned short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
+ 
+ 		if( m_ScanParam.bDataType == SCANDATATYPE_Color ) {
+ 
+ 			RGBUShortDef max_rgb;
+-			u_long       dwR, dwG, dwB;
+-			u_long       dwDiv = 10;
+-			u_long       dwLoop1 = m_ScanParam.Size.dwPhyPixels/dwDiv, dwLoop2;
++			unsigned long       dwR, dwG, dwB;
++			unsigned long       dwDiv = 10;
++			unsigned long       dwLoop1 = m_ScanParam.Size.dwPhyPixels/dwDiv, dwLoop2;
+ 
+ 			max_rgb.Red = max_rgb.Green = max_rgb.Blue = 0;
+ 
+_at_@ -634,7 +634,7 @@
+ 
+ 	    } else {
+ 
+-			u_short w_max = 0;
++			unsigned short w_max = 0;
+ 
+ 			for( dw = 0; dw < m_ScanParam.Size.dwPhyPixels; dw++ ) {
+ 				if( w_max < ((u_short*)scanbuf)[dw])
+_at_@ -660,8 +660,8 @@
+ /**
+  */
+ static int
+-cano_GetNewOffset(Plustek_Device *dev, u_long *val, int channel, signed char *low,
+-                  signed char *now, signed char *high, u_long *zc)
++cano_GetNewOffset(Plustek_Device *dev, unsigned long *val, int channel, signed char *low,
++                  signed char *now, signed char *high, unsigned long *zc)
+ {
+ 	DCapsDef *scaps = &dev->usbDev.Caps;
+ 
+_at_@ -753,15 +753,15 @@
+ {
+ 	char    tmp[40];
+ 	int     i, adj;
+-	u_short r, g, b;
+-	u_long  dw, dwPixels;
+-	u_long  dwSum[3], zCount[3];
++	unsigned short r, g, b;
++	unsigned long  dw, dwPixels;
++	unsigned long  dwSum[3], zCount[3];
+ 
+ 	signed char low[3]  = {-32,-32,-32 };
+ 	signed char now[3]  = {  0,  0,  0 };
+ 	signed char high[3] = { 31, 31, 31 };
+ 
+-	u_long   *scanbuf = dev->scanning.pScanBuffer;
++	unsigned long   *scanbuf = dev->scanning.pScanBuffer;
+ 	HWDef    *hw      = &dev->usbDev.HwSetting;
+ 	DCapsDef *scaps   = &dev->usbDev.Caps;
+ 	
+_at_@ -786,14 +786,14 @@
+ 	if( usb_IsCISDevice(dev))
+ 		dwPixels = m_ScanParam.Size.dwPixels;
+ 	else
+-		dwPixels = (u_long)(hw->bOpticBlackEnd - hw->bOpticBlackStart);
++		dwPixels = (unsigned long)(hw->bOpticBlackEnd - hw->bOpticBlackStart);
+ 
+ 	m_ScanParam.Size.dwBytes = m_ScanParam.Size.dwPixels * 2;
+ 
+ 	if( usb_IsCISDevice(dev) && m_ScanParam.bDataType == SCANDATATYPE_Color)
+ 		m_ScanParam.Size.dwBytes *= 3;
+ 
+-	m_ScanParam.Origin.x = (u_short)((u_long)hw->bOpticBlackStart * 300UL /
++	m_ScanParam.Origin.x = (unsigned short)((unsigned long)hw->bOpticBlackStart * 300UL /
+ 	                                              dev->usbDev.Caps.OpticDpi.x);
+ 	m_ScanParam.bCalibration = PARAM_Offset;
+ 	m_ScanParam.dMCLK        = dMCLK;
+_at_@ -827,7 +827,7 @@
+ 		dumpPic(tmp, (u_char*)scanbuf, m_ScanParam.Size.dwPhyBytes, 0);
+ 
+ 		if(usb_HostSwap())
+-			usb_Swap((u_short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
++			usb_Swap((unsigned short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
+ 
+ 		if( m_ScanParam.bDataType == SCANDATATYPE_Color ) {
+ 
+_at_@ -940,16 +940,16 @@
+  * fine calibration part 1
+  */
+ static SANE_Bool
+-cano_AdjustDarkShading( Plustek_Device *dev, u_short cal_dpi )
++cano_AdjustDarkShading( Plustek_Device *dev, unsigned short cal_dpi )
+ {
+ 	char         tmp[40];
+ 	ScanParam   *param   = &dev->scanning.sParam;
+ 	ScanDef     *scan    = &dev->scanning;
+-	u_long      *scanbuf = scan->pScanBuffer;
+-	u_short     *bufp;
++	unsigned long      *scanbuf = scan->pScanBuffer;
++	unsigned short     *bufp;
+ 	unsigned int i, j;
+ 	int          step, stepW, val;
+-	u_long       red, green, blue, gray;
++	unsigned long       red, green, blue, gray;
+ 
+ 	DBG( _DBG_INFO, "cano_AdjustDarkShading()\n" );
+ 	if( usb_IsEscPressed())
+_at_@ -968,7 +968,7 @@
+ 		dumpPic(tmp, (u_char*)scanbuf, m_ScanParam.Size.dwTotalBytes, 0);
+ 
+ 		if(usb_HostSwap())
+-			usb_Swap((u_short *)scanbuf, m_ScanParam.Size.dwTotalBytes);
++			usb_Swap((unsigned short *)scanbuf, m_ScanParam.Size.dwTotalBytes);
+ 	}
+ 	if (!usb_ScanEnd( dev )){
+ 		DBG( _DBG_ERROR, "cano_AdjustDarkShading() failed\n" );
+_at_@ -990,9 +990,9 @@
+ 			green = 0;
+ 			blue  = 0;
+ 			if( usb_IsCISDevice(dev))
+-				bufp = ((u_short *)scanbuf)+i;
++				bufp = ((unsigned short *)scanbuf)+i;
+ 			else
+-				bufp = ((u_short *)scanbuf)+(i*3);
++				bufp = ((unsigned short *)scanbuf)+(i*3);
+ 
+ 			for( j=0; j<m_ScanParam.Size.dwPhyLines; j++ ) {
+ 
+_at_@ -1015,21 +1015,21 @@
+ 				DBG( _DBG_INFO, "val < 0!!!!\n" );
+ 				val = 0;
+ 			}
+-			a_wDarkShading[i] = (u_short)val;
++			a_wDarkShading[i] = (unsigned short)val;
+ 
+ 			val = ((int)(green/m_ScanParam.Size.dwPhyLines) + param->swOffset[1]);
+ 			if( val < 0 ) {
+ 				DBG( _DBG_INFO, "val < 0!!!!\n" );
+ 				val = 0;
+ 			}
+-			a_wDarkShading[i+stepW] = (u_short)val;
++			a_wDarkShading[i+stepW] = (unsigned short)val;
+ 
+ 			val = ((int)(blue/m_ScanParam.Size.dwPhyLines) + param->swOffset[2]);
+ 			if( val < 0 ) {
+ 				DBG( _DBG_INFO, "val < 0!!!!\n" );
+ 				val = 0;
+ 			}
+-			a_wDarkShading[i+stepW*2] = (u_short)val;
++			a_wDarkShading[i+stepW*2] = (unsigned short)val;
+ 		}
+ 
+ 	} else {
+_at_@ -1038,7 +1038,7 @@
+ 		for( i=0; i<m_ScanParam.Size.dwPhyPixels; i++ ) {
+ 			
+ 			gray = 0;
+-			bufp = ((u_short *)scanbuf)+i;
++			bufp = ((unsigned short *)scanbuf)+i;
+ 
+ 			for( j=0; j < m_ScanParam.Size.dwPhyLines; j++ ) {
+ 				gray += *bufp;
+_at_@ -1068,16 +1068,16 @@
+  * the gain coefficient for each pixel
+  */
+ static SANE_Bool
+-cano_AdjustWhiteShading( Plustek_Device *dev, u_short cal_dpi )
++cano_AdjustWhiteShading( Plustek_Device *dev, unsigned short cal_dpi )
+ {
+ 	char         tmp[40];
+ 	ScanParam   *param   = &dev->scanning.sParam;
+ 	ScanDef     *scan    = &dev->scanning;
+-	u_long      *scanbuf = scan->pScanBuffer;
+-	u_short     *bufp;
++	unsigned long      *scanbuf = scan->pScanBuffer;
++	unsigned short     *bufp;
+ 	unsigned int i, j;
+ 	int          step, stepW;
+-	u_long       red, green, blue, gray;
++	unsigned long       red, green, blue, gray;
+ 
+ 	DBG( _DBG_INFO, "cano_AdjustWhiteShading()\n" );
+ 	if( usb_IsEscPressed())
+_at_@ -1101,7 +1101,7 @@
+ 		dumpPic(tmp, (u_char*)scanbuf, m_ScanParam.Size.dwTotalBytes, 0);
+ 
+ 		if(usb_HostSwap())
+-			usb_Swap((u_short *)scanbuf, m_ScanParam.Size.dwTotalBytes);
++			usb_Swap((unsigned short *)scanbuf, m_ScanParam.Size.dwTotalBytes);
+ 
+ 		if (!usb_ScanEnd( dev )) {
+ 			DBG( _DBG_ERROR, "cano_AdjustWhiteShading() failed\n" );
+_at_@ -1127,9 +1127,9 @@
+ 			green = 0;
+ 			blue  = 0;
+ 			if( usb_IsCISDevice(dev))
+-				bufp = ((u_short *)scanbuf)+i;
++				bufp = ((unsigned short *)scanbuf)+i;
+ 			else
+-				bufp = ((u_short *)scanbuf)+(i*3);
++				bufp = ((unsigned short *)scanbuf)+(i*3);
+ 
+ 			for( j=0; j<m_ScanParam.Size.dwPhyLines; j++ ) {
+ 
+_at_@ -1160,7 +1160,7 @@
+ 		step = m_ScanParam.Size.dwPhyPixels + 1;
+ 		for( i=0; i<m_ScanParam.Size.dwPhyPixels; i++ ){
+ 			gray = 0;
+-			bufp = ((u_short *)scanbuf)+i;
++			bufp = ((unsigned short *)scanbuf)+i;
+ 
+ 			for( j=0; j<m_ScanParam.Size.dwPhyLines; j++ ) {
+ 				gray += *bufp;
+_at_@ -1195,8 +1195,8 @@
+ static int
+ cano_DoCalibration( Plustek_Device *dev )
+ {
+-	u_short   dpi, idx, idx_end;
+-	u_long    save_waf;
++	unsigned short   dpi, idx, idx_end;
++	unsigned long    save_waf;
+ 	SANE_Bool skip_fine;
+ 	ScanDef  *scan  = &dev->scanning;
+ 	HWDef    *hw    = &dev->usbDev.HwSetting;
+_at_@ -1331,7 +1331,7 @@
+ 					return SANE_FALSE;
+ 
+ 				if( !usb_ModuleMove(dev, MOVE_Forward,
+-					(u_long)dev->usbDev.pSource->ShadingOriginY)) {
++					(unsigned long)dev->usbDev.pSource->ShadingOriginY)) {
+ 					return SANE_FALSE;
+ 				}
+ 			}
+--- sane-backends-1.0.24.orig/backend/plustek-usbcalfile.c
++++ sane-backends-1.0.24/backend/plustek-usbcalfile.c
+_at_@ -60,34 +60,34 @@
+  */
+ 
+ typedef struct {
+-	u_long red_light_on;
+-	u_long red_light_off;
+-	u_long green_light_on;
+-	u_long green_light_off;
+-	u_long blue_light_on;
+-	u_long blue_light_off;
+-	u_long green_pwm_duty;
++	unsigned long red_light_on;
++	unsigned long red_light_off;
++	unsigned long green_light_on;
++	unsigned long green_light_off;
++	unsigned long blue_light_on;
++	unsigned long blue_light_off;
++	unsigned long green_pwm_duty;
+ 	
+ } LightCtrl;
+ 
+ typedef struct {
+-	u_short   version;
++	unsigned short   version;
+ 
+-	u_short   red_gain;
+-	u_short   green_gain;
+-	u_short   blue_gain;
++	unsigned short   red_gain;
++	unsigned short   green_gain;
++	unsigned short   blue_gain;
+ 
+-	u_short   red_offs;
+-	u_short   green_offs;
+-	u_short   blue_offs;
++	unsigned short   red_offs;
++	unsigned short   green_offs;
++	unsigned short   blue_offs;
+ 
+ 	LightCtrl light;
+ 
+ } CalData;
+ 
+ /* our shading buffers */
+-static u_short a_wWhiteShading[_SHADING_BUF] = {0};
+-static u_short a_wDarkShading[_SHADING_BUF]  = {0};
++static unsigned short a_wWhiteShading[_SHADING_BUF] = {0};
++static unsigned short a_wDarkShading[_SHADING_BUF]  = {0};
+ 
+ /* the version the the calibration files */
+ #define _PT_CF_VERSION 0x0002
+_at_@ -202,12 +202,12 @@
+ /**
+  */
+ static SANE_Bool
+-usb_ReadSamples( FILE *fp, char *which, u_long *dim, u_short *buffer )
++usb_ReadSamples( FILE *fp, char *which, unsigned long *dim, unsigned short *buffer )
+ {
+ 	char  *p, *next, *rb;
+ 	char   tmp[1024+30];
+ 	int    ignore, diml, c;
+-	u_long val;
++	unsigned long val;
+ 
+ 	/* rewind file pointer */
+ 	if( 0 != fseek( fp, 0L, SEEK_SET))
+_at_@ -259,7 +259,7 @@
+ 						}
+ 					}
+ 
+-					buffer[c] = (u_short)val;
++					buffer[c] = (unsigned short)val;
+ 
+ 					/* more values? */
+ 					if( *next == ',') {
+_at_@ -298,7 +298,7 @@
+ usb_RestoreCalData( Plustek_Device *dev, CalData *cal )
+ {
+ 	HWDef  *hw   = &dev->usbDev.HwSetting;
+-	u_char *regs = dev->usbDev.a_bRegs;
++	unsigned char *regs = dev->usbDev.a_bRegs;
+ 
+ 	regs[0x3b] = (u_char)cal->red_gain;
+ 	regs[0x3c] = (u_char)cal->green_gain;
+_at_@ -307,30 +307,30 @@
+ 	regs[0x39] = (u_char)cal->green_offs;
+ 	regs[0x3a] = (u_char)cal->blue_offs;
+ 
+-	regs[0x2a] = _HIBYTE((u_short)cal->light.green_pwm_duty);
+-	regs[0x2b] = _LOBYTE((u_short)cal->light.green_pwm_duty);
++	regs[0x2a] = _HIBYTE((unsigned short)cal->light.green_pwm_duty);
++	regs[0x2b] = _LOBYTE((unsigned short)cal->light.green_pwm_duty);
+ 
+-	regs[0x2c] = _HIBYTE((u_short)cal->light.red_light_on);
+-	regs[0x2d] = _LOBYTE((u_short)cal->light.red_light_on);
+-	regs[0x2e] = _HIBYTE((u_short)cal->light.red_light_off);
+-	regs[0x2f] = _LOBYTE((u_short)cal->light.red_light_off);
++	regs[0x2c] = _HIBYTE((unsigned short)cal->light.red_light_on);
++	regs[0x2d] = _LOBYTE((unsigned short)cal->light.red_light_on);
++	regs[0x2e] = _HIBYTE((unsigned short)cal->light.red_light_off);
++	regs[0x2f] = _LOBYTE((unsigned short)cal->light.red_light_off);
+ 
+-	regs[0x30] = _HIBYTE((u_short)cal->light.green_light_on);
+-	regs[0x31] = _LOBYTE((u_short)cal->light.green_light_on);
+-	regs[0x32] = _HIBYTE((u_short)cal->light.green_light_off);
+-	regs[0x33] = _LOBYTE((u_short)cal->light.green_light_off);
++	regs[0x30] = _HIBYTE((unsigned short)cal->light.green_light_on);
++	regs[0x31] = _LOBYTE((unsigned short)cal->light.green_light_on);
++	regs[0x32] = _HIBYTE((unsigned short)cal->light.green_light_off);
++	regs[0x33] = _LOBYTE((unsigned short)cal->light.green_light_off);
+ 
+-	regs[0x34] = _HIBYTE((u_short)cal->light.blue_light_on);
+-	regs[0x35] = _LOBYTE((u_short)cal->light.blue_light_on);
+-	regs[0x36] = _HIBYTE((u_short)cal->light.blue_light_off);
+-	regs[0x37] = _LOBYTE((u_short)cal->light.blue_light_off);
++	regs[0x34] = _HIBYTE((unsigned short)cal->light.blue_light_on);
++	regs[0x35] = _LOBYTE((unsigned short)cal->light.blue_light_on);
++	regs[0x36] = _HIBYTE((unsigned short)cal->light.blue_light_off);
++	regs[0x37] = _LOBYTE((unsigned short)cal->light.blue_light_off);
+ 
+-	hw->red_lamp_on    = (u_short)cal->light.red_light_on;
+-	hw->red_lamp_off   = (u_short)cal->light.red_light_off;
+-	hw->green_lamp_on  = (u_short)cal->light.green_light_on;
+-	hw->green_lamp_off = (u_short)cal->light.green_light_off;
+-	hw->blue_lamp_on   = (u_short)cal->light.blue_light_on;
+-	hw->blue_lamp_off  = (u_short)cal->light.blue_light_off;
++	hw->red_lamp_on    = (unsigned short)cal->light.red_light_on;
++	hw->red_lamp_off   = (unsigned short)cal->light.red_light_off;
++	hw->green_lamp_on  = (unsigned short)cal->light.green_light_on;
++	hw->green_lamp_off = (unsigned short)cal->light.green_light_off;
++	hw->blue_lamp_on   = (unsigned short)cal->light.blue_light_on;
++	hw->blue_lamp_off  = (unsigned short)cal->light.blue_light_off;
+ }
+ 
+ /**
+_at_@ -367,7 +367,7 @@
+ {
+ 	char       pfx[20];
+ 	char       tmp[1024];
+-	u_short    version;
++	unsigned short    version;
+ 	int        res;
+ 	FILE      *fp;
+ 	CalData    cal;
+_at_@ -454,17 +454,17 @@
+ static void
+ usb_PrepCalData( Plustek_Device *dev, CalData *cal )
+ {
+-	u_char *regs = dev->usbDev.a_bRegs;
++	unsigned char *regs = dev->usbDev.a_bRegs;
+ 
+ 	memset( cal, 0, sizeof(CalData));
+ 	cal->version = _PT_CF_VERSION;
+ 
+-	cal->red_gain   = (u_short)regs[0x3b];
+-	cal->green_gain = (u_short)regs[0x3c];
+-	cal->blue_gain  = (u_short)regs[0x3d];
+-	cal->red_offs   = (u_short)regs[0x38];
+-	cal->green_offs = (u_short)regs[0x39];
+-	cal->blue_offs  = (u_short)regs[0x3a];
++	cal->red_gain   = (unsigned short)regs[0x3b];
++	cal->green_gain = (unsigned short)regs[0x3c];
++	cal->blue_gain  = (unsigned short)regs[0x3d];
++	cal->red_offs   = (unsigned short)regs[0x38];
++	cal->green_offs = (unsigned short)regs[0x39];
++	cal->blue_offs  = (unsigned short)regs[0x3a];
+ 
+ 	cal->light.green_pwm_duty  = regs[0x2a] * 256 + regs[0x2b];
+ 
+_at_@ -486,7 +486,7 @@
+ 	char       tmp[1024];
+ 	char       set_tmp[1024];
+ 	char      *other_tmp;
+-	u_short    version;
++	unsigned short    version;
+ 	FILE      *fp;
+ 	CalData    cal;
+ 	ScanDef   *scanning = &dev->scanning;
+_at_@ -575,14 +575,14 @@
+  */
+ static void
+ usb_SaveFineCalData( Plustek_Device *dev, int dpi,
+-                     u_short *dark, u_short *white, u_long vals )
++                     unsigned short *dark, unsigned short *white, unsigned long vals )
+ {
+ 	char     pfx[30];
+ 	char     fn[1024];
+ 	char     tmp[1024];
+ 	char    *other_tmp;
+-	u_short  version;
+-	u_long   i;
++	unsigned short  version;
++	unsigned long   i;
+ 	FILE    *fp;
+ 
+ 	if( NULL == dev->calFile ) {
+_at_@ -657,12 +657,12 @@
+  */
+ static SANE_Bool
+ usb_ReadFineCalData( Plustek_Device *dev, int dpi,
+-                     u_long *dim_d, u_short *dark,
+-                     u_long *dim_w, u_short *white )
++                     unsigned long *dim_d, unsigned short *dark,
++                     unsigned long *dim_w, unsigned short *white )
+ {
+ 	char       pfx[30];
+ 	char       tmp[1024];
+-	u_short    version;
++	unsigned short    version;
+ 	FILE      *fp;
+ 	
+ 	DBG( _DBG_INFO, "usb_ReadFineCalData()\n" );
+_at_@ -731,9 +731,9 @@
+ /**
+  */
+ static void
+-usb_get_shading_part(u_short *buf, u_long offs, u_long src_len, int dst_len)
++usb_get_shading_part(unsigned short *buf, unsigned long offs, unsigned long src_len, int dst_len)
+ {
+-	u_short *p_src, *p_dst;
++	unsigned short *p_src, *p_dst;
+ 	int      i, j;
+ 
+ 	if (src_len == 0 || dst_len == 0)
+_at_@ -762,8 +762,8 @@
+ {
+ 	ScanDef   *scan = &dev->scanning;
+ 	ScanParam *sp   = &scan->sParam;
+-	u_short    xdpi;
+-	u_long     dim_w, dim_d, offs;
++	unsigned short    xdpi;
++	unsigned long     dim_w, dim_d, offs;
+ 
+ 	xdpi = usb_SetAsicDpiX( dev, sp->UserDpi.x );
+ 
+_at_@ -776,7 +776,7 @@
+ 	dim_d /= 3;
+ 	dim_w /= 3;
+ 
+-	offs = ((u_long)sp->Origin.x * xdpi) / 300;
++	offs = ((unsigned long)sp->Origin.x * xdpi) / 300;
+ 
+ 	usb_GetPhyPixels( dev, sp );
+ 
+_at_@ -803,8 +803,8 @@
+ usb_SaveCalSetShading( Plustek_Device *dev, ScanParam *tmp_sp )
+ {
+ 	ScanParam *sp = &dev->scanning.sParam;
+-	u_short    xdpi;
+-	u_long     offs;
++	unsigned short    xdpi;
++	unsigned long     offs;
+ 
+ 	if( !dev->adj.cacheCalData )
+ 		return;
+_at_@ -817,7 +817,7 @@
+ 
+ 	/* now we need to get the correct part of the line... */
+ 	xdpi = usb_SetAsicDpiX( dev, sp->UserDpi.x );
+-	offs = ((u_long)sp->Origin.x * xdpi) / 300;
++	offs = ((unsigned long)sp->Origin.x * xdpi) / 300;
+ 	usb_GetPhyPixels( dev, sp );
+ 
+ 	DBG( _DBG_INFO2, "FINE Calibration area after saving:\n" );
+--- sane-backends-1.0.24.orig/backend/plustek-usbhw.c
++++ sane-backends-1.0.24/backend/plustek-usbhw.c
+_at_@ -116,7 +116,7 @@
+ static SANE_Bool
+ usb_HostSwap( void )
+ {
+-	u_short        pattern  = 0xfeed; /* deadbeef */
++	unsigned short        pattern  = 0xfeed; /* deadbeef */
+ 	unsigned char *bytewise = (unsigned char *)&pattern;
+ 
+ 	if ( bytewise[0] == 0xfe ) {
+_at_@ -131,7 +131,7 @@
+ /** as the name says..
+  */
+ static void
+-usb_Swap( u_short *pw, u_long dwBytes )
++usb_Swap( unsigned short *pw, unsigned long dwBytes )
+ {
+ 	for( dwBytes /= 2; dwBytes--; pw++ )
+ 		_SWAP(((u_char*) pw)[0], ((u_char*)pw)[1]);
+_at_@ -227,7 +227,7 @@
+ static SANE_Bool
+ usb_IsScannerReady( Plustek_Device *dev )
+ {
+-	u_char         value;
++	unsigned char         value;
+ 	double         len;	
+ 	long           timeout;
+ 	struct timeval t;
+_at_@ -279,7 +279,7 @@
+ static SANE_Bool
+ usb_SensorAdf( Plustek_Device *dev )
+ {
+-	u_char value;
++	unsigned char value;
+ 
+ 	if( usb_IsSheetFedDevice(dev))
+ 		return SANE_FALSE;
+_at_@ -295,7 +295,7 @@
+ usb_SensorPaper( Plustek_Device *dev )
+ {
+ 	DCapsDef   *sc   = &dev->usbDev.Caps;
+-	u_char val, mask = 0x02;
++	unsigned char val, mask = 0x02;
+ 
+ 	usbio_ReadReg( dev->fd, 0x02, &val );
+ 
+_at_@ -340,18 +340,18 @@
+  *  the position is reached
+  */
+ static SANE_Bool
+-usb_WaitPos( Plustek_Device *dev, u_long to, SANE_Bool stay )
++usb_WaitPos( Plustek_Device *dev, unsigned long to, SANE_Bool stay )
+ {
+ 	SANE_Bool      retval;
+-	u_char         value, mclk_div, mch;
+-	u_char         r[2];
+-	u_short        ffs, step, min_ffs;
++	unsigned char         value, mclk_div, mch;
++	unsigned char         r[2];
++	unsigned short        ffs, step, min_ffs;
+ 	long           dwTicks;
+ 	double         maxf, fac, speed;
+ 	struct timeval start_time, t2;
+ 
+ 	HWDef         *hw   = &dev->usbDev.HwSetting;
+-	u_char        *regs = dev->usbDev.a_bRegs;
++	unsigned char        *regs = dev->usbDev.a_bRegs;
+ 
+ 	/* get current master clock divider */
+ 	usbio_ReadReg( dev->fd, 0x08, &value );
+_at_@ -363,8 +363,8 @@
+ 
+ 	/* calculate the current speed */
+ 	ffs   = regs[0x48] * 256 + regs[0x49];
+-	speed = ((double)CRYSTAL_FREQ) /(double)((u_long)mclk_div * 32UL *
+-	                                (u_long)mch * (u_long)ffs * hw->wMotorDpi);
++	speed = ((double)CRYSTAL_FREQ) /(double)((unsigned long)mclk_div * 32UL *
++	                                (unsigned long)mch * (unsigned long)ffs * hw->wMotorDpi);
+ 
+ 	/* disabled ? */
+ 	if((hw->dHighSpeed == 0.0) || (dev->adj.disableSpeedup != 0)) {
+_at_@ -374,8 +374,8 @@
+ 			return SANE_TRUE;
+ 
+ 	} else {
+-		min_ffs = (u_short)(CRYSTAL_FREQ /((u_long)mclk_div * 32UL *
+-		                   (u_long)mch * hw->dHighSpeed * hw->wMotorDpi));
++		min_ffs = (unsigned short)(CRYSTAL_FREQ /((unsigned long)mclk_div * 32UL *
++		                   (unsigned long)mch * hw->dHighSpeed * hw->wMotorDpi));
+ 		maxf = (ffs - min_ffs)/4;
+ 		if( maxf > 100.0 )
+ 			maxf = 100.0;
+_at_@ -410,7 +410,7 @@
+ 			
+ 			fac = maxf/step;
+ 			if( ffs ) {
+-				if((u_short)fac < ffs ) {
++				if((unsigned short)fac < ffs ) {
+ 					ffs -= fac;
+ 					if( ffs < min_ffs )
+ 						ffs = min_ffs;
+_at_@ -450,15 +450,15 @@
+  * _at_param steps  - steps to move, based on 300dpi, 0 means move forever
+  */
+ static SANE_Bool
+-usb_ModuleMove( Plustek_Device *dev, u_char action, u_long dwStep )
++usb_ModuleMove( Plustek_Device *dev, unsigned char action, unsigned long dwStep )
+ {
+ 	SANE_Bool    retval, ejected;
+-	u_char       bReg2, reg7, mclk_div;
+-	u_short      wFastFeedStepSize;
++	unsigned char       bReg2, reg7, mclk_div;
++	unsigned short      wFastFeedStepSize;
+ 	double       dMaxMoveSpeed;
+ 	ClkMotorDef *clk;
+ 	HWDef       *hw   = &dev->usbDev.HwSetting;
+-	u_char      *regs = dev->usbDev.a_bRegs;
++	unsigned char      *regs = dev->usbDev.a_bRegs;
+ 
+ 	if( action != MOVE_ToPaperSensor   &&
+ 		action != MOVE_EjectAllPapers  &&
+_at_@ -544,8 +544,8 @@
+ 
+ 	mclk_div = clk->mclk_fast;
+ 
+-	wFastFeedStepSize = (u_short)(CRYSTAL_FREQ /
+-	                    ((u_long)mclk_div * 8UL * 1 *
++	wFastFeedStepSize = (unsigned short)(CRYSTAL_FREQ /
++	                    ((unsigned long)mclk_div * 8UL * 1 *
+ 	                    dMaxMoveSpeed * 4 * hw->wMotorDpi));
+ 
+ 	regs[0x48] = (u_char)(wFastFeedStepSize >> 8);
+_at_@ -671,11 +671,11 @@
+ static SANE_Bool
+ usb_ModuleToHome( Plustek_Device *dev, SANE_Bool fWait )
+ {
+-	u_char    mclk_div;
+-	u_char    value;
++	unsigned char    mclk_div;
++	unsigned char    value;
+ 	DCapsDef *scaps = &dev->usbDev.Caps;
+ 	HWDef    *hw    = &dev->usbDev.HwSetting;
+-	u_char   *regs  = dev->usbDev.a_bRegs;
++	unsigned char   *regs  = dev->usbDev.a_bRegs;
+ 
+ 	if( usb_IsSheetFedDevice(dev)) {
+ 		return usb_ModuleMove( dev, MOVE_EjectAllPapers, 0 );
+_at_@ -700,7 +700,7 @@
+ 	/* if not homing, do it... */
+ 	if( value != 2 ) {
+ 
+-		u_short wFastFeedStepSize;
++		unsigned short wFastFeedStepSize;
+ 
+ 		if( hw->motorModel == MODEL_Tokyo600 ) {
+ 			usbio_WriteReg( dev->fd, 0x07, 0 );
+_at_@ -763,7 +763,7 @@
+ 		/* Compute fast feed step size, use equation 3 and equation 8
+ 		 * assumptions: MCLK = 6, Lineratemode (CM=1)
+ 		 */
+-		wFastFeedStepSize = (u_short)(CRYSTAL_FREQ / (mclk_div * 8 * 1 *
++		wFastFeedStepSize = (unsigned short)(CRYSTAL_FREQ / (mclk_div * 8 * 1 *
+ 		                              hw->dMaxMotorSpeed * 4 * hw->wMotorDpi));
+ 		regs[0x48] = (u_char)(wFastFeedStepSize >> 8);
+ 		regs[0x49] = (u_char)(wFastFeedStepSize & 0xFF);
+_at_@ -851,7 +851,7 @@
+ {
+ 	DCapsDef *sCaps = &dev->usbDev.Caps;
+ 	HWDef    *hw    = &dev->usbDev.HwSetting;
+-	u_char   *regs  = dev->usbDev.a_bRegs;
++	unsigned char   *regs  = dev->usbDev.a_bRegs;
+ 
+ 	if(!_IS_PLUSTEKMOTOR(hw->motorModel)) {
+ 		return SANE_TRUE;
+_at_@ -897,7 +897,7 @@
+ usb_AdjustLamps( Plustek_Device *dev, SANE_Bool on )
+ {
+ 	HWDef  *hw   = &dev->usbDev.HwSetting;
+-	u_char *regs = dev->usbDev.a_bRegs;
++	unsigned char *regs = dev->usbDev.a_bRegs;
+ 
+ 	if( !usb_IsCISDevice(dev))
+ 		return SANE_TRUE;
+_at_@ -954,7 +954,7 @@
+ 		hw->bReg_0x29 = hw->illu_mono.mode;
+ 
+ 		memcpy( &hw->red_lamp_on,
+-				&hw->illu_mono.red_lamp_on, sizeof(u_short) * 6 );
++				&hw->illu_mono.red_lamp_on, sizeof(unsigned short) * 6 );
+ 
+ 	} else {
+ 
+_at_@ -962,7 +962,7 @@
+ 		hw->bReg_0x29 = hw->illu_color.mode;
+ 
+ 		memcpy( &hw->red_lamp_on,
+-				&hw->illu_color.red_lamp_on, sizeof(u_short) * 6 );
++				&hw->illu_color.red_lamp_on, sizeof(unsigned short) * 6 );
+ 	}
+ 
+ 	if( !on ) {
+_at_@ -1015,7 +1015,7 @@
+  * _at_return Nothing
+  */
+ static void
+-usb_GetLampRegAndMask( u_long flag, SANE_Byte *reg, SANE_Byte *msk )
++usb_GetLampRegAndMask( unsigned long flag, SANE_Byte *reg, SANE_Byte *msk )
+ {
+ 	if( _MIO6 == ( _MIO6 & flag )) {
+ 		*reg = 0x5b;
+_at_@ -1060,7 +1060,7 @@
+ usb_GetLampStatus( Plustek_Device *dev )
+ {
+ 	int         iLampStatus = 0;
+-	u_char     *regs = dev->usbDev.a_bRegs;
++	unsigned char     *regs = dev->usbDev.a_bRegs;
+ 	HWDef      *hw   = &dev->usbDev.HwSetting;
+ 	DCapsDef   *sc   = &dev->usbDev.Caps;
+ 	SANE_Byte   reg, msk, val;
+_at_@ -1144,7 +1144,7 @@
+ {
+ 	SANE_Byte reg, msk;
+ 	DCapsDef *sc   = &dev->usbDev.Caps;
+-	u_char   *regs = dev->usbDev.a_bRegs;
++	unsigned char   *regs = dev->usbDev.a_bRegs;
+ 
+ 	if( tpa )
+ 		usb_GetLampRegAndMask( _GET_TPALAMP(sc->misc_io), &reg, &msk );
+_at_@ -1200,7 +1200,7 @@
+ static void
+ usb_LedOn( Plustek_Device *dev, SANE_Bool fOn )
+ {
+-	u_char value;
++	unsigned char value;
+ 
+ 	if( dev->usbDev.HwSetting.motorModel != MODEL_HuaLien )
+ 		return;
+_at_@ -1223,7 +1223,7 @@
+ usb_FillLampRegs( Plustek_Device *dev )
+ {
+ 	HWDef  *hw   = &dev->usbDev.HwSetting;
+-	u_char *regs = dev->usbDev.a_bRegs;
++	unsigned char *regs = dev->usbDev.a_bRegs;
+ 
+ 	regs[0x2a] = _HIBYTE( hw->wGreenPWMDutyCycleLow );
+ 	regs[0x2b] = _LOBYTE( hw->wGreenPWMDutyCycleLow );
+_at_@ -1252,7 +1252,7 @@
+ 	DCapsDef      *sc          = &dev->usbDev.Caps;
+ 	ScanDef       *scanning    = &dev->scanning;
+ 	HWDef         *hw          = &dev->usbDev.HwSetting;
+-	u_char        *regs        = dev->usbDev.a_bRegs;
++	unsigned char        *regs        = dev->usbDev.a_bRegs;
+ 	int            iLampStatus = usb_GetLampStatus( dev );
+ 	int            lampId      = -1;
+ 	struct timeval t;
+_at_@ -1387,7 +1387,7 @@
+ 	int linend;
+ 
+ 	HWDef  *hw   = &dev->usbDev.HwSetting;
+-	u_char *regs = dev->usbDev.a_bRegs;
++	unsigned char *regs = dev->usbDev.a_bRegs;
+ 
+ 	DBG( _DBG_INFO, "RESETTING REGISTERS(%i) - 0x%02x\n", 
+ 	                dev->initialized, (int) sizeof(dev->usbDev.a_bRegs));
+_at_@ -1467,7 +1467,7 @@
+ static SANE_Bool
+ usb_SensorStatus( Plustek_Device *dev )
+ {
+-	u_char value;
++	unsigned char value;
+ 	HWDef *hw = &dev->usbDev.HwSetting;
+ 
+ /* HEINER: Maybe needed to avoid recalibration!!! */
+_at_@ -1625,7 +1625,7 @@
+ static SANE_Bool
+ usb_Wait4Warmup( Plustek_Device *dev )
+ {
+-	u_long         dw;
++	unsigned long         dw;
+ 	struct timeval t;
+ 
+ 	if( usb_IsCISDevice(dev)) {
+_at_@ -1641,7 +1641,7 @@
+ 	 */
+ 	gettimeofday( &t, NULL);
+ 	dw = t.tv_sec - dev->usbDev.dwTicksLampOn;
+-	if( dw < (u_long)dev->adj.warmup )
++	if( dw < (unsigned long)dev->adj.warmup )
+ 		DBG(_DBG_INFO,"Warmup: Waiting %d seconds\n", dev->adj.warmup );
+ 
+ 	do {
+_at_@ -1654,7 +1654,7 @@
+ 			return SANE_FALSE;
+ 		}
+ 
+-	} while( dw < (u_long)dev->adj.warmup );
++	} while( dw < (unsigned long)dev->adj.warmup );
+ 
+ 	return SANE_TRUE;
+ }
+_at_@ -1665,7 +1665,7 @@
+ usb_HasTPA( Plustek_Device *dev )
+ {
+ 	static char model[] = { "3450" };
+-	u_char val;
++	unsigned char val;
+ 
+ 	if( dev->usbDev.vendor == 0x04B8 ) {         /* the EPSON section */
+ 
+_at_@ -1725,7 +1725,7 @@
+ static SANE_Bool
+ usb_UpdateButtonStatus( Plustek_Scanner *s )
+ {
+-	u_char          mio[3];
++	unsigned char          mio[3];
+ 	SANE_Byte       val, mask;
+ 	int             i, j, bc;
+ 	int             handle = -1;
+--- sane-backends-1.0.24.orig/backend/plustek-usbimg.c
++++ sane-backends-1.0.24/backend/plustek-usbimg.c
+_at_@ -77,16 +77,16 @@
+ 
+ #define _SCALER  1000
+ 
+-static u_char   bShift, Shift;
+-static u_short  wSum, Mask;
++static unsigned char   bShift, Shift;
++static unsigned short  wSum, Mask;
+ 
+ /*
+  */
+-static u_char BitTable[8] = {
++static unsigned char BitTable[8] = {
+ 	0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
+ };
+ 
+-static u_char BitsReverseTable[256] = {
++static unsigned char BitsReverseTable[256] = {
+ 	0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 	0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 	0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+_at_@ -123,7 +123,7 @@
+ 
+ /************************ some helper functions ******************************/
+ 
+-static void ReverseBits( int b, u_char **pTar, int *iByte, int *iWeightSum,
++static void ReverseBits( int b, unsigned char **pTar, int *iByte, int *iWeightSum,
+                          int iSrcWeight, int iTarWeight, int cMax )
+ {
+ 	int bit;
+_at_@ -159,7 +159,7 @@
+ 	}
+ }
+ 
+-static void usb_ReverseBitStream( u_char *pSrc, u_char *pTar, int iPixels,
++static void usb_ReverseBitStream( unsigned char *pSrc, unsigned char *pTar, int iPixels,
+                                   int iBufSize, int iSrcWeight/* = 0*/,
+                                   int iTarWeight/* = 0*/, int iPadBit/* = 1*/)
+ {
+_at_@ -167,8 +167,8 @@
+ 	int iByte = 1;
+ 	int cBytes = iPixels / 8;
+ 	int cBits = iPixels % 8;
+-	u_char bPad = iPadBit? 0xff: 0;
+-	u_char *pTarget = pTar;
++	unsigned char bPad = iPadBit? 0xff: 0;
++	unsigned char *pTarget = pTar;
+ 	int iWeightSum = 0;
+ 
+ 	if(iSrcWeight == iTarWeight) {
+_at_@ -219,7 +219,7 @@
+  */
+ static void usb_AverageColorByte( Plustek_Device *dev )
+ {
+-	u_long   dw;
++	unsigned long   dw;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	if((scan->sParam.bSource == SOURCE_Negative ||
+_at_@ -229,16 +229,16 @@
+ 		for (dw = 0; dw < (scan->sParam.Size.dwPhyPixels - 1); dw++)
+ 		{
+ 			scan->Red.pcb[dw].a_bColor[0] =
+-			                 (u_char)(((u_short)scan->Red.pcb[dw].a_bColor[0] +
+-			                 (u_short)scan->Red.pcb[dw + 1].a_bColor[0]) / 2);
++			                 (u_char)(((unsigned short)scan->Red.pcb[dw].a_bColor[0] +
++			                 (unsigned short)scan->Red.pcb[dw + 1].a_bColor[0]) / 2);
+ 
+ 			scan->Green.pcb[dw].a_bColor[0] =
+-			               (u_char)(((u_short)scan->Green.pcb[dw].a_bColor[0] +
+-			               (u_short)scan->Green.pcb[dw + 1].a_bColor[0]) / 2);
++			               (u_char)(((unsigned short)scan->Green.pcb[dw].a_bColor[0] +
++			               (unsigned short)scan->Green.pcb[dw + 1].a_bColor[0]) / 2);
+ 
+ 			scan->Blue.pcb[dw].a_bColor[0] =
+-			               (u_char)(((u_short)scan->Blue.pcb[dw].a_bColor[0] +
+-			               (u_short)scan->Blue.pcb[dw + 1].a_bColor[0]) / 2);
++			               (u_char)(((unsigned short)scan->Blue.pcb[dw].a_bColor[0] +
++			               (unsigned short)scan->Blue.pcb[dw + 1].a_bColor[0]) / 2);
+ 		}
+ 	}
+ }
+_at_@ -247,8 +247,8 @@
+  */
+ static void usb_AverageColorWord( Plustek_Device *dev )
+ {
+-	u_char   ls = 2;
+-	u_long   dw;
++	unsigned char   ls = 2;
++	unsigned long   dw;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	if((scan->sParam.bSource == SOURCE_Negative ||
+_at_@ -265,12 +265,12 @@
+ 			scan->Green.pcw[dw + 1].Colors[0] = _HILO2WORD(scan->Green.pcw[dw + 1].HiLo[0]) >> ls;
+ 			scan->Blue.pcw[dw + 1].Colors[0]  = _HILO2WORD(scan->Blue.pcw[dw + 1].HiLo[0])  >> ls;
+ 
+-			scan->Red.pcw[dw].Colors[0]   = (u_short)(((u_long)scan->Red.pcw[dw].Colors[0] +
+-			                                           (u_long)scan->Red.pcw[dw + 1].Colors[0]) / 2);
+-			scan->Green.pcw[dw].Colors[0] = (u_short)(((u_long)scan->Green.pcw[dw].Colors[0] +
+-			                                           (u_long)scan->Green.pcw[dw + 1].Colors[0]) / 2);
+-			scan->Blue.pcw[dw].Colors[0]  = (u_short)(((u_long)scan->Blue.pcw[dw].Colors[0] +
+-			                                           (u_long)scan->Blue.pcw[dw + 1].Colors[0]) / 2);
++			scan->Red.pcw[dw].Colors[0]   = (unsigned short)(((unsigned long)scan->Red.pcw[dw].Colors[0] +
++			                                           (unsigned long)scan->Red.pcw[dw + 1].Colors[0]) / 2);
++			scan->Green.pcw[dw].Colors[0] = (unsigned short)(((unsigned long)scan->Green.pcw[dw].Colors[0] +
++			                                           (unsigned long)scan->Green.pcw[dw + 1].Colors[0]) / 2);
++			scan->Blue.pcw[dw].Colors[0]  = (unsigned short)(((unsigned long)scan->Blue.pcw[dw].Colors[0] +
++			                                           (unsigned long)scan->Blue.pcw[dw + 1].Colors[0]) / 2);
+ 
+ 			scan->Red.pcw[dw].Colors[0]   = _HILO2WORD(scan->Red.pcw[dw].HiLo[0])   << ls;
+ 			scan->Green.pcw[dw].Colors[0] = _HILO2WORD(scan->Green.pcw[dw].HiLo[0]) << ls;
+_at_@ -287,7 +287,7 @@
+  */
+ static void usb_AverageGrayByte( Plustek_Device *dev )
+ {
+-	u_long   dw;
++	unsigned long   dw;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	if((scan->sParam.bSource == SOURCE_Negative ||
+_at_@ -295,8 +295,8 @@
+ 		scan->sParam.PhyDpi.x > 800)
+ 	{
+ 		for (dw = 0; dw < (scan->sParam.Size.dwPhyPixels - 1); dw++)
+-			scan->Green.pb[dw] = (u_char)(((u_short)scan->Green.pb[dw]+
+-			                           (u_short)scan->Green.pb[dw+1]) / 2);
++			scan->Green.pb[dw] = (u_char)(((unsigned short)scan->Green.pb[dw]+
++			                           (unsigned short)scan->Green.pb[dw+1]) / 2);
+ 	}
+ }
+ 
+_at_@ -304,7 +304,7 @@
+  */
+ static void usb_AverageGrayWord( Plustek_Device *dev )
+ {
+-	u_long   dw;
++	unsigned long   dw;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	if((scan->sParam.bSource == SOURCE_Negative ||
+_at_@ -316,8 +316,8 @@
+ 		for (dw = 0; dw < (scan->sParam.Size.dwPhyPixels - 1); dw++)
+ 		{
+ 			scan->Green.pw[dw + 1] = _HILO2WORD(scan->Green.philo[dw+1]) >> 2;
+-			scan->Green.pw[dw] = (u_short)(((u_long)scan->Green.pw[dw]+
+-			                                (u_long)scan->Green.pw[dw+1]) / 2);
++			scan->Green.pw[dw] = (unsigned short)(((unsigned long)scan->Green.pw[dw]+
++			                                (unsigned long)scan->Green.pw[dw+1]) / 2);
+ 			scan->Green.pw[dw] = _HILO2WORD(scan->Green.philo[dw]) << 2;
+ 		}
+ 
+_at_@ -346,7 +346,7 @@
+ static void usb_ColorDuplicate8( Plustek_Device *dev )
+ {
+ 	int      next;
+-	u_long   dw, pixels;
++	unsigned long   dw, pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageColorByte( dev );
+_at_@ -372,7 +372,7 @@
+ static void usb_ColorDuplicate8_2( Plustek_Device *dev )
+ {
+ 	int      next;
+-	u_long   dw, pixels;
++	unsigned long   dw, pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	if( scan->sParam.bSource == SOURCE_ADF ) {
+_at_@ -396,8 +396,8 @@
+ static void usb_ColorDuplicate16( Plustek_Device *dev )
+ {
+ 	int       next;
+-	u_char    ls;
+-	u_long    dw, pixels;
++	unsigned char    ls;
++	unsigned long    dw, pixels;
+ 	ScanDef  *scan = &dev->scanning;
+ 	SANE_Bool swap = usb_HostSwap();
+ 
+_at_@ -438,9 +438,9 @@
+ static void usb_ColorDuplicate16_2( Plustek_Device *dev )
+ {
+ 	int       next;
+-	u_char    ls;
++	unsigned char    ls;
+ 	HiLoDef   tmp;
+-	u_long    dw, pixels;
++	unsigned long    dw, pixels;
+ 	ScanDef  *scan = &dev->scanning;
+ 	SANE_Bool swap = usb_HostSwap();
+ 
+_at_@ -485,8 +485,8 @@
+ static void usb_ColorDuplicatePseudo16( Plustek_Device *dev )
+ {
+ 	int      next; 
+-	u_short  wR, wG, wB;
+-	u_long   dw, pixels;
++	unsigned short  wR, wG, wB;
++	unsigned long   dw, pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageColorByte( dev );
+_at_@ -499,9 +499,9 @@
+ 		pixels = 0;
+ 	}
+ 
+-	wR = (u_short)scan->Red.pcb[0].a_bColor[0];
+-	wG = (u_short)scan->Green.pcb[0].a_bColor[0];
+-	wB = (u_short)scan->Blue.pcb[0].a_bColor[0];
++	wR = (unsigned short)scan->Red.pcb[0].a_bColor[0];
++	wG = (unsigned short)scan->Green.pcb[0].a_bColor[0];
++	wB = (unsigned short)scan->Blue.pcb[0].a_bColor[0];
+ 
+ 	for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) {
+ 
+_at_@ -512,9 +512,9 @@
+ 		scan->UserBuf.pw_rgb[pixels].Blue  =
+ 		                       (wB + scan->Blue.pcb[dw].a_bColor[0]) << bShift;
+ 
+-		wR = (u_short)scan->Red.pcb[dw].a_bColor[0];
+-		wG = (u_short)scan->Green.pcb[dw].a_bColor[0];
+-		wB = (u_short)scan->Blue.pcb[dw].a_bColor[0];
++		wR = (unsigned short)scan->Red.pcb[dw].a_bColor[0];
++		wG = (unsigned short)scan->Green.pcb[dw].a_bColor[0];
++		wB = (unsigned short)scan->Blue.pcb[dw].a_bColor[0];
+ 	}
+ }
+ 
+_at_@ -523,7 +523,7 @@
+ static void usb_ColorDuplicateGray( Plustek_Device *dev )
+ {
+ 	int      next;
+-	u_long   dw, pixels;
++	unsigned long   dw, pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageColorByte( dev );
+_at_@ -558,7 +558,7 @@
+ static void usb_ColorDuplicateGray_2( Plustek_Device *dev )
+ {
+ 	int      next;
+-	u_long   dw, pixels;
++	unsigned long   dw, pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageColorByte( dev );
+_at_@ -593,8 +593,8 @@
+ static void usb_ColorDuplicateGray16( Plustek_Device *dev )
+ {
+ 	int       next;
+-	u_char    ls;
+-	u_long    dw, pixels;
++	unsigned char    ls;
++	unsigned long    dw, pixels;
+ 	ScanDef  *scan = &dev->scanning;
+ 	SANE_Bool swap = usb_HostSwap();
+ 
+_at_@ -652,8 +652,8 @@
+ static void usb_ColorDuplicateGray16_2( Plustek_Device *dev )
+ {
+ 	int       next;
+-	u_char    ls;
+-	u_long    dw, pixels;
++	unsigned char    ls;
++	unsigned long    dw, pixels;
+ 	HiLoDef   tmp;
+ 	ScanDef  *scan = &dev->scanning;
+ 	SANE_Bool swap = usb_HostSwap();
+_at_@ -716,8 +716,8 @@
+  */
+ static void usb_GrayDuplicate8( Plustek_Device *dev )
+ {
+-	u_char  *dest, *src;
+-	u_long   pixels;
++	unsigned char  *dest, *src;
++	unsigned long   pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageGrayByte( dev );
+_at_@ -740,9 +740,9 @@
+ static void usb_GrayDuplicate16( Plustek_Device *dev )
+ {
+ 	int       next;
+-	u_char    ls;
+-	u_short  *dest;
+-	u_long    pixels;
++	unsigned char    ls;
++	unsigned short  *dest;
++	unsigned long    pixels;
+ 	HiLoDef  *pwm;
+ 	ScanDef  *scan = &dev->scanning;
+ 	SANE_Bool swap = usb_HostSwap();
+_at_@ -775,11 +775,11 @@
+  */
+ static void usb_GrayDuplicatePseudo16( Plustek_Device *dev )
+ {
+-	u_char  *src;
++	unsigned char  *src;
+ 	int      next;
+-	u_short  g;
+-	u_short *dest;
+-	u_long   pixels;
++	unsigned short  g;
++	unsigned short *dest;
++	unsigned long   pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageGrayByte( dev );
+_at_@ -793,12 +793,12 @@
+ 	}
+ 
+ 	src = scan->Green.pb;
+-	g = (u_short)*src;
++	g = (unsigned short)*src;
+ 
+ 	for( pixels=scan->sParam.Size.dwPixels; pixels--; src++, dest += next ) {
+ 
+ 		*dest = (g + *src) << bShift;
+-		g = (u_short)*src;
++		g = (unsigned short)*src;
+ 	}
+ }
+ 
+_at_@ -824,9 +824,9 @@
+ static void usb_BWDuplicateFromColor( Plustek_Device *dev )
+ {
+ 	int           next;
+-	u_char        d, s, *dest;
+-	u_short       j;
+-	u_long        pixels;
++	unsigned char        d, s, *dest;
++	unsigned short       j;
++	unsigned long        pixels;
+ 	ColorByteDef *src;
+ 	ScanDef      *scan = &dev->scanning;
+ 
+_at_@ -866,9 +866,9 @@
+ static void usb_BWDuplicateFromColor_2( Plustek_Device *dev )
+ {
+ 	int      next;
+-	u_char   d, *dest, *src;
+-	u_short  j;
+-	u_long   pixels;
++	unsigned char   d, *dest, *src;
++	unsigned short  j;
++	unsigned long   pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	if( scan->sParam.bSource == SOURCE_ADF ) {
+_at_@ -907,7 +907,7 @@
+ static void usb_ColorScaleGray( Plustek_Device *dev )
+ {
+ 	int           izoom, ddax, next;
+-	u_long        dw, pixels;
++	unsigned long        dw, pixels;
+ 	ColorByteDef *src;
+ 	ScanDef      *scan = &dev->scanning;
+ 
+_at_@ -949,9 +949,9 @@
+  */
+ static void usb_ColorScaleGray_2( Plustek_Device *dev )
+ {
+-	u_char  *src;
++	unsigned char  *src;
+ 	int      izoom, ddax, next;
+-	u_long   dw, pixels;
++	unsigned long   dw, pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageColorByte( dev );
+_at_@ -992,9 +992,9 @@
+  */
+ static void usb_ColorScaleGray16( Plustek_Device *dev )
+ {
+-	u_char    ls;
++	unsigned char    ls;
+ 	int       izoom, ddax, next;
+-	u_long    dw, pixels, bitsput;
++	unsigned long    dw, pixels, bitsput;
+ 	SANE_Bool swap = usb_HostSwap();
+ 	ScanDef  *scan = &dev->scanning;
+ 
+_at_@ -1082,9 +1082,9 @@
+  */
+ static void usb_ColorScaleGray16_2( Plustek_Device *dev )
+ {
+-	u_char    ls;
++	unsigned char    ls;
+ 	int       izoom, ddax, next;
+-	u_long    dw, pixels, bitsput;
++	unsigned long    dw, pixels, bitsput;
+ 	HiLoDef   tmp;
+ 	SANE_Bool swap = usb_HostSwap();
+ 	ScanDef  *scan = &dev->scanning;
+_at_@ -1174,7 +1174,7 @@
+ static void usb_ColorScale8( Plustek_Device *dev )
+ {
+ 	int      izoom, ddax, next;
+-	u_long   dw, pixels, bitsput;
++	unsigned long   dw, pixels, bitsput;
+     ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageColorByte( dev );
+_at_@ -1213,7 +1213,7 @@
+ static void usb_ColorScale8_2( Plustek_Device *dev )
+ {
+ 	int      izoom, ddax, next;
+-	u_long   dw, pixels, bitsput;
++	unsigned long   dw, pixels, bitsput;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	dw = scan->sParam.Size.dwPixels;
+_at_@ -1249,9 +1249,9 @@
+  */
+ static void usb_ColorScale16( Plustek_Device *dev )
+ {
+-	u_char    ls;
++	unsigned char    ls;
+ 	int       izoom, ddax, next;
+-	u_long    dw, pixels, bitsput;
++	unsigned long    dw, pixels, bitsput;
+ 	SANE_Bool swap = usb_HostSwap();
+ 	ScanDef  *scan = &dev->scanning;
+ 
+_at_@ -1308,10 +1308,10 @@
+  */
+ static void usb_ColorScale16_2( Plustek_Device *dev )
+ {
+-	u_char     ls;
++	unsigned char     ls;
+ 	HiLoDef    tmp;
+ 	int        izoom, ddax, next;
+-	u_long     dw, pixels, bitsput;
++	unsigned long     dw, pixels, bitsput;
+ 	SANE_Bool  swap = usb_HostSwap();
+ 	ScanDef   *scan = &dev->scanning;
+ 
+_at_@ -1369,8 +1369,8 @@
+ static void usb_ColorScalePseudo16( Plustek_Device *dev )
+ {
+ 	int      izoom, ddax, next;
+-	u_short  wR, wG, wB;
+-	u_long   dw, pixels, bitsput;
++	unsigned short  wR, wG, wB;
++	unsigned long   dw, pixels, bitsput;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageColorByte( dev );
+_at_@ -1387,9 +1387,9 @@
+ 	
+ 	izoom = usb_GetScaler( scan );
+ 
+-	wR = (u_short)scan->Red.pcb[0].a_bColor[0];
+-	wG = (u_short)scan->Green.pcb[0].a_bColor[1];
+-	wB = (u_short)scan->Blue.pcb[0].a_bColor[2];
++	wR = (unsigned short)scan->Red.pcb[0].a_bColor[0];
++	wG = (unsigned short)scan->Green.pcb[0].a_bColor[1];
++	wB = (unsigned short)scan->Blue.pcb[0].a_bColor[2];
+ 
+ 	for( bitsput = 0, ddax = 0; dw; bitsput++ ) {
+ 
+_at_@ -1411,9 +1411,9 @@
+ 			dw--;
+ 		}
+ 
+-		wR = (u_short)scan->Red.pcb[bitsput].a_bColor[0];
+-		wG = (u_short)scan->Green.pcb[bitsput].a_bColor[0];
+-		wB = (u_short)scan->Blue.pcb[bitsput].a_bColor[0];
++		wR = (unsigned short)scan->Red.pcb[bitsput].a_bColor[0];
++		wG = (unsigned short)scan->Green.pcb[bitsput].a_bColor[0];
++		wB = (unsigned short)scan->Blue.pcb[bitsput].a_bColor[0];
+ 	}
+ }
+ 
+_at_@ -1421,9 +1421,9 @@
+  */
+ static void usb_BWScale( Plustek_Device *dev )
+ {
+-	u_char   tmp, *dest, *src;
++	unsigned char   tmp, *dest, *src;
+ 	int      izoom, ddax;
+-	u_long   i, dw;
++	unsigned long   i, dw;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	src = scan->Green.pb;
+_at_@ -1468,9 +1468,9 @@
+  */
+ static void usb_BWScaleFromColor( Plustek_Device *dev )
+ {
+-	u_char        d, s, *dest;
+-	u_short       j;
+-	u_long        pixels;
++	unsigned char        d, s, *dest;
++	unsigned short       j;
++	unsigned long        pixels;
+ 	int           izoom, ddax, next;
+ 	ColorByteDef *src;
+ 	ScanDef      *scan = &dev->scanning;
+_at_@ -1519,9 +1519,9 @@
+  */
+ static void usb_BWScaleFromColor_2( Plustek_Device *dev )
+ {
+-	u_char        d, *dest, *src;
+-	u_short       j;
+-	u_long        pixels;
++	unsigned char        d, *dest, *src;
++	unsigned short       j;
++	unsigned long        pixels;
+ 	int           izoom, ddax, next;
+ 	ScanDef      *scan = &dev->scanning;
+ 
+_at_@ -1568,9 +1568,9 @@
+  */
+ static void usb_GrayScale8( Plustek_Device *dev )
+ {
+-	u_char  *dest, *src;
++	unsigned char  *dest, *src;
+ 	int      izoom, ddax, next;
+-	u_long   pixels;
++	unsigned long   pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageGrayByte( dev );
+_at_@ -1605,10 +1605,10 @@
+  */
+ static void usb_GrayScale16( Plustek_Device *dev )
+ {
+-	u_char    ls;
++	unsigned char    ls;
+ 	int       izoom, ddax, next;
+-	u_short  *dest;
+-	u_long    pixels;
++	unsigned short  *dest;
++	unsigned long    pixels;
+ 	HiLoDef  *pwm;
+ 	ScanDef  *scan = &dev->scanning;
+ 	SANE_Bool swap = usb_HostSwap();
+_at_@ -1656,10 +1656,10 @@
+  */
+ static void usb_GrayScalePseudo16( Plustek_Device *dev )
+ {
+-	u_char  *src;
++	unsigned char  *src;
+ 	int      izoom, ddax, next;
+-	u_short *dest, g;
+-	u_long   pixels;
++	unsigned short *dest, g;
++	unsigned long   pixels;
+ 	ScanDef *scan = &dev->scanning;
+ 
+ 	usb_AverageGrayByte( dev );
+_at_@ -1673,7 +1673,7 @@
+ 	}
+ 
+ 	src = scan->Green.pb;
+-	g   = (u_short)*src;
++	g   = (unsigned short)*src;
+ 
+ 	izoom = usb_GetScaler( scan );
+ 	ddax  = 0;
+_at_@ -1689,7 +1689,7 @@
+ 			ddax += izoom;
+ 			pixels--;
+ 		}
+-		g = (u_short)*src;
++		g = (unsigned short)*src;
+ 	}
+ }
+ 
+_at_@ -1896,7 +1896,7 @@
+  */
+ static SANE_Int usb_ReadData( Plustek_Device *dev )
+ {
+-	u_long   dw, dwRet, dwBytes, pl;
++	unsigned long   dw, dwRet, dwBytes, pl;
+ 	ScanDef *scan = &dev->scanning;
+ 	HWDef   *hw   = &dev->usbDev.HwSetting;
+ 
+--- sane-backends-1.0.24.orig/backend/plustek-usbio.c
++++ sane-backends-1.0.24/backend/plustek-usbio.c
+_at_@ -88,18 +88,18 @@
+ 
+ typedef struct {
+ 
+-	u_char depth;
+-	u_long x;
+-	u_long y;
++	unsigned char depth;
++	unsigned long x;
++	unsigned long y;
+ } PicDef, *pPicDef;
+ 
+ static PicDef dPix;
+ 
+ /**
+  */
+-static void dumpPic( char* name, SANE_Byte *buffer, u_long len, int is_gray )
++static void dumpPic( char* name, SANE_Byte *buffer, unsigned long len, int is_gray )
+ {
+-	u_short type;
++	unsigned short type;
+ 	FILE   *fp;
+ 
+ 	if( DBG_LEVEL < _DBG_DPIC )
+--- sane-backends-1.0.24.orig/backend/plustek-usbmap.c
++++ sane-backends-1.0.24/backend/plustek-usbmap.c
+_at_@ -185,8 +185,8 @@
+ 
+ 		if( fInverse ) {
+ 		
+-			u_char  map[_MAP_SIZE];
+-			u_char *pMap = a_bMap+color*_MAP_SIZE;
++			unsigned char  map[_MAP_SIZE];
++			unsigned char *pMap = a_bMap+color*_MAP_SIZE;
+ 			
+ 			DBG( _DBG_INFO, "* Inverting Map\n" );
+ 			
+--- sane-backends-1.0.24.orig/backend/plustek-usbscan.c
++++ sane-backends-1.0.24/backend/plustek-usbscan.c
+_at_@ -78,26 +78,26 @@
+  */
+ static int dpi_ranges[] = { 75,100,150,200,300,400,600,800,1200,2400 };
+ 
+-static u_char     bMaxITA;
++static unsigned char     bMaxITA;
+ 
+ static SANE_Bool  m_fAutoPark;
+ static SANE_Bool  m_fFirst;
+ static double     m_dHDPIDivider;
+ static double     m_dMCLKDivider;
+ static ScanParam *m_pParam;
+-static u_char     m_bLineRateColor;
+-static u_char     m_bCM;
++static unsigned char     m_bLineRateColor;
++static unsigned char     m_bCM;
+ static u_char	  m_bIntTimeAdjust;
+ static u_char	  m_bOldScanData;
+-static u_short    m_wFastFeedStepSize;
+-static u_short    m_wLineLength;
++static unsigned short    m_wFastFeedStepSize;
++static unsigned short    m_wLineLength;
+ static u_short	  m_wStepSize;
+-static u_long     m_dwPauseLimit;
++static unsigned long     m_dwPauseLimit;
+ 
+ static SANE_Bool  m_fStart = SANE_FALSE;
+ 
+ /* Prototype... */
+-static SANE_Bool usb_DownloadShadingData( Plustek_Device*, u_char );
++static SANE_Bool usb_DownloadShadingData( Plustek_Device*, unsigned char );
+ 
+ /** returns the min of the two values val1 and val2
+  * _at_param val1 - first parameter
+_at_@ -105,7 +105,7 @@
+  * _at_return val1 if val1 < val2, else val1
+  */
+ static u_long
+-usb_min( u_long val1, u_long val2 )
++usb_min( unsigned long val1, unsigned long val2 )
+ {
+ 	if( val1 > val2 )
+ 		return val2;
+_at_@ -118,7 +118,7 @@
+  * _at_return val1 if val1 > val2, else val2
+  */
+ static u_long
+-usb_max( u_long val1, u_long val2 )
++usb_max( unsigned long val1, unsigned long val2 )
+ {
+ 	if( val1 > val2 )
+ 		return val1;
+_at_@ -131,14 +131,14 @@
+  * _at_param idx  - which divider to use
+  */
+ static u_short
+-usb_get_res( u_short base, u_short idx )
++usb_get_res( unsigned short base, unsigned short idx )
+ {
+ 	double div_list[DIVIDER] = { 12.0, 8.0, 6.0, 4.0, 3.0, 2.0, 1.5, 1.0 };
+ 
+ 	if( idx == 0 || idx > DIVIDER )
+ 		return 0;
+ 
+-	return (u_short)((double)base/div_list[idx-1]);
++	return (unsigned short)((double)base/div_list[idx-1]);
+ }
+ 
+ /** Set the horizontal DPI divider.
+_at_@ -151,12 +151,12 @@
+  * _at_return - the function returns the "normalized" horizontal resolution.
+  */
+ static u_short
+-usb_SetAsicDpiX( Plustek_Device *dev, u_short xdpi )
++usb_SetAsicDpiX( Plustek_Device *dev, unsigned short xdpi )
+ {
+-	u_short   res;
++	unsigned short   res;
+ 	ScanDef  *scanning = &dev->scanning;
+ 	DCapsDef *scaps    = &dev->usbDev.Caps;
+-	u_char   *regs     = dev->usbDev.a_bRegs;
++	unsigned char   *regs     = dev->usbDev.a_bRegs;
+ 
+ 	/* limit xdpi to lower value for certain devices...
+ 	 */
+_at_@ -216,7 +216,7 @@
+ 		regs[0x09] -= ((regs[0x0a] >> 2) + 2);
+ 
+ 	DBG( _DBG_INFO2, "* HDPI: %.3f\n", m_dHDPIDivider );
+-	res = (u_short)((double)scaps->OpticDpi.x / m_dHDPIDivider);
++	res = (unsigned short)((double)scaps->OpticDpi.x / m_dHDPIDivider);
+ 
+ 	DBG( _DBG_INFO2, "* XDPI=%u, HDPI=%.3f\n", res, m_dHDPIDivider );
+ 	return res;
+_at_@ -229,13 +229,13 @@
+  * _at_return -
+  */
+ static u_short
+-usb_SetAsicDpiY( Plustek_Device *dev, u_short ydpi )
++usb_SetAsicDpiY( Plustek_Device *dev, unsigned short ydpi )
+ {
+ 	ScanDef  *scanning = &dev->scanning;
+ 	DCapsDef *sCaps    = &dev->usbDev.Caps;
+ 	HWDef    *hw       = &dev->usbDev.HwSetting;
+ 
+-	u_short wMinDpi, wDpi;
++	unsigned short wMinDpi, wDpi;
+ 
+ 	if(0 != sCaps->bSensorDistance )
+ 		wMinDpi = sCaps->OpticDpi.y / sCaps->bSensorDistance;
+_at_@ -285,7 +285,7 @@
+ usb_SetColorAndBits( Plustek_Device *dev, ScanParam *pParam )
+ {
+ 	HWDef    *hw   = &dev->usbDev.HwSetting;
+-	u_char   *regs = dev->usbDev.a_bRegs;
++	unsigned char   *regs = dev->usbDev.a_bRegs;
+ 
+ 	/* Set pixel packing, data mode and AFE operation */
+ 	switch( pParam->bDataType ) {
+_at_@ -380,11 +380,11 @@
+ static void
+ usb_GetScanRect( Plustek_Device *dev, ScanParam *sp )
+ {
+-	u_short   wDataPixelStart, wLineEnd;
++	unsigned short   wDataPixelStart, wLineEnd;
+ 
+ 	DCapsDef *sCaps = &dev->usbDev.Caps;
+ 	HWDef    *hw    = &dev->usbDev.HwSetting;
+-	u_char   *regs  = dev->usbDev.a_bRegs;
++	unsigned char   *regs  = dev->usbDev.a_bRegs;
+ 
+ 	/* Convert pixels to physical dpi based */
+ 	usb_GetPhyPixels( dev, sp );
+_at_@ -395,10 +395,10 @@
+ 	if(sp->bCalibration != PARAM_Gain &&
+ 		sp->bCalibration != PARAM_Offset && ScanInf.m_fADF)
+ 		wDataPixelStart = 2550 * sCaps->OpticDpi.x / 300UL -
+-				(u_short)(m_dHDPIDivider * sp->Size.dwValidPixels + 0.5);
++				(unsigned short)(m_dHDPIDivider * sp->Size.dwValidPixels + 0.5);
+ 	else
+ #endif
+-		wDataPixelStart = (u_short)((u_long)sp->Origin.x *
++		wDataPixelStart = (unsigned short)((unsigned long)sp->Origin.x *
+ 		                                            sCaps->OpticDpi.x / 300UL);
+ 
+ 	/* during the calibration steps, we read the entire CCD data
+_at_@ -408,13 +408,13 @@
+ #if 0
+ 		if(ScanInf.m_fADF) {
+ 			wDataPixelStart = 2550 * sCaps->OpticDpi.x / 300UL -
+-			    (u_short)(m_dHDPIDivider * sp->Size.dwValidPixels + 0.5);
++			    (unsigned short)(m_dHDPIDivider * sp->Size.dwValidPixels + 0.5);
+ 		}
+ #endif
+ 		wDataPixelStart += hw->wActivePixelsStart;
+ 	}
+ 
+-	wLineEnd = wDataPixelStart + (u_short)(m_dHDPIDivider *
++	wLineEnd = wDataPixelStart + (unsigned short)(m_dHDPIDivider *
+ 	                                               sp->Size.dwPhyPixels + 0.5);
+ 
+ 	DBG( _DBG_INFO2, "* DataPixelStart=%u, LineEnd=%u\n",
+_at_@ -489,11 +489,11 @@
+ 		 * always be RGB or BGR order).
+ 		 */
+ 		if (sp->bDataType != SCANDATATYPE_Color)
+-			sp->Origin.y += (u_long)(300UL *
++			sp->Origin.y += (unsigned long)(300UL *
+ 			           sCaps->bSensorDistance / sCaps->OpticDpi.y);
+ 	}
+ 
+-	sp->Origin.y=(u_short)((u_long)sp->Origin.y * hw->wMotorDpi/300UL);
++	sp->Origin.y=(unsigned short)((unsigned long)sp->Origin.y * hw->wMotorDpi/300UL);
+ 
+ 	/* Something wrong, but I can not find it. */
+ 	if( hw->motorModel == MODEL_HuaLien && sCaps->OpticDpi.x == 600)
+_at_@ -511,12 +511,12 @@
+ static void
+ usb_PresetStepSize( Plustek_Device *dev, ScanParam *pParam )
+ {
+-	u_short ssize;
++	unsigned short ssize;
+ 	double  mclkdiv = pParam->dMCLK;
+ 	HWDef  *hw      = &dev->usbDev.HwSetting;
+-	u_char *regs    = dev->usbDev.a_bRegs;
++	unsigned char *regs    = dev->usbDev.a_bRegs;
+ 
+-	ssize = (u_short)((double)CRYSTAL_FREQ / ( mclkdiv * 8.0 *
++	ssize = (unsigned short)((double)CRYSTAL_FREQ / ( mclkdiv * 8.0 *
+             (double)m_bCM * hw->dMaxMotorSpeed * 4.0 * (double)hw->wMotorDpi));
+ 
+ 	regs[0x46] = _HIBYTE( ssize );
+_at_@ -539,7 +539,7 @@
+ 	int    st;      /* step size reg 46:47                    */
+ 
+ 	HWDef  *hw    = &dev->usbDev.HwSetting;
+-	u_char *regs  = dev->usbDev.a_bRegs;
++	unsigned char *regs  = dev->usbDev.a_bRegs;
+ 
+ 	qtcnt = (regs[0x51] & 0x30) >> 4;  /* quarter speed count */
+ 	hfcnt = (regs[0x51] & 0xc0) >> 6;  /* half speed count    */
+_at_@ -589,7 +589,7 @@
+ 	int     j, pixelbits, pixelsperline, r;
+ 	int     minmclk, maxmclk, mclkdiv;
+ 	double  hdpi, min_int_time;
+-	u_char *regs = dev->usbDev.a_bRegs;
++	unsigned char *regs = dev->usbDev.a_bRegs;
+ 	HWDef  *hw   = &dev->usbDev.HwSetting;
+ 
+ 	DBG( _DBG_INFO, "usb_GetMCLKDiv()\n" );
+_at_@ -663,7 +663,7 @@
+ 
+ 	DCapsDef *sCaps = &dev->usbDev.Caps;
+ 	HWDef    *hw    = &dev->usbDev.HwSetting;
+-	u_char   *regs  = dev->usbDev.a_bRegs;
++	unsigned char   *regs  = dev->usbDev.a_bRegs;
+ 
+ 	DBG( _DBG_INFO, "usb_GetMCLKDivider()\n" );
+ 
+_at_@ -718,7 +718,7 @@
+ 
+ 	if( m_bIntTimeAdjust != 0 ) {
+ 
+-		m_wStepSize = (u_short)((u_long) m_wStepSize *
++		m_wStepSize = (unsigned short)((unsigned long) m_wStepSize *
+ 		                    (m_bIntTimeAdjust + 1) / m_bIntTimeAdjust);
+ 		if( m_wStepSize < 2 )
+ 			m_wStepSize = 2;
+_at_@ -762,15 +762,15 @@
+ usb_GetStepSize( Plustek_Device *dev, ScanParam *pParam )
+ {
+ 	HWDef  *hw  = &dev->usbDev.HwSetting;
+-	u_char *regs = dev->usbDev.a_bRegs;
++	unsigned char *regs = dev->usbDev.a_bRegs;
+ 
+ 	/* Compute step size using equation 1 */
+ 	if (m_bIntTimeAdjust != 0) {
+-		m_wStepSize = (u_short)(((u_long) pParam->PhyDpi.y * m_wLineLength *
++		m_wStepSize = (unsigned short)(((unsigned long) pParam->PhyDpi.y * m_wLineLength *
+ 		              m_bLineRateColor * (m_bIntTimeAdjust + 1)) /
+ 		              (4 * hw->wMotorDpi * m_bIntTimeAdjust));
+ 	} else {
+-		m_wStepSize = (u_short)(((u_long) pParam->PhyDpi.y * m_wLineLength *
++		m_wStepSize = (unsigned short)(((unsigned long) pParam->PhyDpi.y * m_wLineLength *
+ 		               m_bLineRateColor) / (4 * hw->wMotorDpi));
+ 	}
+ 
+_at_@ -810,10 +810,10 @@
+ 	int b;      /* if ctmode=0, (ntr+1)*((2*gbnd)+dur+1), otherwise 1    */
+ 	int tradj;  /* ITA                                                   */
+ 	int en_tradj;
+-	u_short      le;
++	unsigned short      le;
+ 	HWDef       *hw    = &dev->usbDev.HwSetting;
+ 	ClkMotorDef *motor = usb_GetMotorSet( hw->motorModel );
+-	u_char      *regs  = dev->usbDev.a_bRegs;
++	unsigned char      *regs  = dev->usbDev.a_bRegs;
+ 
+ 	tpspd = (regs[0x0a] & 0x0c) >> 2;       /* turbo/preview mode speed  */
+ 	tpsel = regs[0x0a] & 3;                 /* turbo/preview mode select */
+_at_@ -916,7 +916,7 @@
+ 	MDef        *md;
+ 	DCapsDef    *sCaps = &dev->usbDev.Caps;
+ 	HWDef       *hw    = &dev->usbDev.HwSetting;
+-	u_char      *regs  = dev->usbDev.a_bRegs;
++	unsigned char      *regs  = dev->usbDev.a_bRegs;
+ 
+ 	if (!_IS_PLUSTEKMOTOR(hw->motorModel)) {
+ 
+_at_@ -1065,7 +1065,7 @@
+ {
+ 	int     coeffsize, scaler;
+ 	HWDef  *hw   = &dev->usbDev.HwSetting;
+-	u_char *regs = dev->usbDev.a_bRegs;
++	unsigned char *regs = dev->usbDev.a_bRegs;
+ 
+ 	scaler = 1;
+ 	if( hw->bReg_0x26 & _ONE_CH_COLOR ) {
+_at_@ -1088,7 +1088,7 @@
+ 	 * for 512kb this will be 296
+ 	 * for 2Mb   this will be 1832
+ 	 */
+-	m_dwPauseLimit = (u_long)(hw->wDRAMSize - (u_long)(coeffsize));
++	m_dwPauseLimit = (unsigned long)(hw->wDRAMSize - (unsigned long)(coeffsize));
+ 	m_dwPauseLimit -= ((pParam->Size.dwPhyBytes*scaler) / 1024 + 1);
+ 
+ 	/* If not reversing, take into account the steps to reverse */
+_at_@ -1100,7 +1100,7 @@
+ 	                  m_dwPauseLimit, coeffsize, scaler );
+ 
+ 	m_dwPauseLimit = usb_max( usb_min(m_dwPauseLimit,
+-	                  (u_long)ceil(pParam->Size.dwTotalBytes / 1024.0)), 2);
++	                  (unsigned long)ceil(pParam->Size.dwTotalBytes / 1024.0)), 2);
+ 
+ 	regs[0x4e] = (u_char)floor((m_dwPauseLimit*512.0)/(2.0*hw->wDRAMSize));
+ 
+_at_@ -1126,7 +1126,7 @@
+ {
+ 	DCapsDef *sCaps = &dev->usbDev.Caps;
+ 
+-	pParam->Size.dwPhyLines = (u_long)ceil((double) pParam->Size.dwLines *
++	pParam->Size.dwPhyLines = (unsigned long)ceil((double) pParam->Size.dwLines *
+ 	                                     pParam->PhyDpi.y / pParam->UserDpi.y);
+ 
+ 	/* Calculate color offset */
+_at_@ -1151,12 +1151,12 @@
+ static SANE_Bool
+ usb_SetScanParameters( Plustek_Device *dev, ScanParam *pParam )
+ {
+-	static u_char reg8, reg38[6], reg48[2];
++	static unsigned char reg8, reg38[6], reg48[2];
+ 
+ 	ScanDef   *scan    = &dev->scanning;
+ 	ScanParam *pdParam = &dev->scanning.sParam;
+ 	HWDef     *hw      = &dev->usbDev.HwSetting;
+-	u_char    *regs    = dev->usbDev.a_bRegs;
++	unsigned char    *regs    = dev->usbDev.a_bRegs;
+ 
+ 	m_pParam = pParam;
+ 
+_at_@ -1229,7 +1229,7 @@
+ 	if( m_dMCLKDivider < 1.0)
+ 		m_dMCLKDivider = 1.0;
+ 
+-	m_wFastFeedStepSize = (u_short)(CRYSTAL_FREQ /
++	m_wFastFeedStepSize = (unsigned short)(CRYSTAL_FREQ /
+ 	                          (m_dMCLKDivider * 8 * m_bCM * hw->dMaxMoveSpeed *
+ 	                           4 * hw->wMotorDpi));
+ 	/* CIS special ;-) */
+_at_@ -1300,9 +1300,9 @@
+ 		 */
+ 		if(pParam->bCalibration==PARAM_Scan && pParam->bSource!=SOURCE_ADF) {
+ 
+-			u_long  lines     = pParam->Size.dwPhyLines + scan->bLinesToSkip +
++			unsigned long  lines     = pParam->Size.dwPhyLines + scan->bLinesToSkip +
+ 			                                          scan->dwLinesDiscard + 5;
+-			u_short scansteps = (u_short)ceil((double)lines*
++			unsigned short scansteps = (unsigned short)ceil((double)lines*
+ 			                                 hw->wMotorDpi / pParam->PhyDpi.y);
+ 			DBG( _DBG_INFO, "* Scansteps=%u (%lu*%u/%u)\n", scansteps,  lines,
+ 			                hw->wMotorDpi, pParam->PhyDpi.y );
+_at_@ -1329,11 +1329,11 @@
+ static SANE_Bool
+ usb_ScanBegin( Plustek_Device *dev, SANE_Bool auto_park )
+ {
+-	u_char  value;
+-	u_short inches;
++	unsigned char  value;
++	unsigned short inches;
+ 	HWDef       *hw   = &dev->usbDev.HwSetting;
+ 	DCapsDef    *sc   = &dev->usbDev.Caps;
+-	u_char      *regs = dev->usbDev.a_bRegs;
++	unsigned char      *regs = dev->usbDev.a_bRegs;
+ 
+ 	DBG( _DBG_INFO, "usb_ScanBegin()\n" );
+ 
+_at_@ -1367,8 +1367,8 @@
+ 			_UIO(usbio_ReadReg( dev->fd, 0x01, &m_bOldScanData ));
+ 			if( m_bOldScanData ) {
+ 
+-				u_long dwBytesToRead = m_bOldScanData * hw->wDRAMSize * 4;
+-				u_char *pBuffer      = malloc( sizeof(u_char) * dwBytesToRead );
++				unsigned long dwBytesToRead = m_bOldScanData * hw->wDRAMSize * 4;
++				unsigned char *pBuffer      = malloc( sizeof(u_char) * dwBytesToRead );
+ 
+ 				DBG(_DBG_INFO,"Flushing cache - %lu bytes (bOldScanData=%u)\n",
+ 				                                dwBytesToRead, m_bOldScanData );
+_at_@ -1400,7 +1400,7 @@
+ 	DBG( _DBG_DREGS, "Register Dump before reading data:\n" );
+ 	dumpregs( dev->fd, NULL );
+ 
+-	inches = (u_short)((m_pParam->Origin.y *300UL)/hw->wMotorDpi);
++	inches = (unsigned short)((m_pParam->Origin.y *300UL)/hw->wMotorDpi);
+ 	DBG( _DBG_INFO2, ">>> INCH=%u, DOY=%u\n", inches, sc->Normal.DataOrigin.y );
+ 	if( inches > sc->Normal.DataOrigin.y )
+ 		usb_WaitPos( dev, 150, SANE_FALSE );
+_at_@ -1415,7 +1415,7 @@
+ static SANE_Bool
+ usb_ScanEnd( Plustek_Device *dev )
+ {
+-	u_char value;
++	unsigned char value;
+ 
+ 	DBG( _DBG_INFO, "usbDev_ScanEnd(), start=%u, park=%u\n",
+ 	                                                   m_fStart, m_fAutoPark );
+_at_@ -1446,10 +1446,10 @@
+      *  module from top to bottom. Then convert the seconds to miliseconds
+      *  by multiply 1000. We add extra 2 seconds to get some tolerance.
+      */
+-	u_char         a_bBand[3];
++	unsigned char         a_bBand[3];
+ 	long           dwTicks;
+     struct timeval t;
+-	u_char         *regs = dev->usbDev.a_bRegs;
++	unsigned char         *regs = dev->usbDev.a_bRegs;
+ 
+ 	DBG( _DBG_INFO, "usb_IsDataAvailableInDRAM()\n" );
+ 
+_at_@ -1493,9 +1493,9 @@
+ /**
+  */
+ static SANE_Bool
+-usb_ScanReadImage( Plustek_Device *dev, void *pBuf, u_long dwSize )
++usb_ScanReadImage( Plustek_Device *dev, void *pBuf, unsigned long dwSize )
+ {
+-	u_char       *regs = dev->usbDev.a_bRegs;
++	unsigned char       *regs = dev->usbDev.a_bRegs;
+ 	SANE_Status   res;
+ 
+ 	DBG( _DBG_READ, "usb_ScanReadImage(%lu)\n", dwSize );
+_at_@ -1513,7 +1513,7 @@
+ 		/* restore the fast forward stepsize...*/
+ 		sanei_lm983x_write(dev->fd, 0x48, &regs[0x48], 2, SANE_TRUE);
+ 	}
+-	res = sanei_lm983x_read(dev->fd, 0x00, (u_char *)pBuf, dwSize, SANE_FALSE);
++	res = sanei_lm983x_read(dev->fd, 0x00, (unsigned char *)pBuf, dwSize, SANE_FALSE);
+ 
+ 	/* check for pressed ESC button, as sanei_lm983x_read() may take some time
+ 	 */
+_at_@ -1539,8 +1539,8 @@
+ {
+ 	DBG( _DBG_INFO, "usb_GetImageInfo()\n" );
+ 
+-	pSize->dwPixels = (u_long)pInfo->crArea.cx * pInfo->xyDpi.x / 300UL;
+-	pSize->dwLines  = (u_long)pInfo->crArea.cy * pInfo->xyDpi.y / 300UL;
++	pSize->dwPixels = (unsigned long)pInfo->crArea.cx * pInfo->xyDpi.x / 300UL;
++	pSize->dwLines  = (unsigned long)pInfo->crArea.cy * pInfo->xyDpi.y / 300UL;
+ 
+ 	DBG( _DBG_INFO2,"Area: cx=%u, cy=%u\n",pInfo->crArea.cx,pInfo->crArea.cy);
+ 
+--- sane-backends-1.0.24.orig/backend/plustek-usbshading.c
++++ sane-backends-1.0.24/backend/plustek-usbshading.c
+_at_@ -95,9 +95,9 @@
+ static RGBUShortDef Gain_NegHilight;
+ static RGBByteDef   Gain_Reg;
+ 
+-static u_long     m_dwPixels;
++static unsigned long     m_dwPixels;
+ static ScanParam  m_ScanParam;
+-static u_long     m_dwIdealGain;
++static unsigned long     m_dwIdealGain;
+ 
+ static double dMCLK, dExpect, dMax;
+ static double dMCLK_ADF;
+_at_@ -105,12 +105,12 @@
+ /** do some statistics...
+  */
+ static void usb_line_statistics( char *cmt, u_short* buf,
+-                                 u_long dim_x, SANE_Bool color )
++                                 unsigned long dim_x, SANE_Bool color )
+ {
+ 	char         fn[50];
+ 	int          i, channel;
+-	u_long       dw, imad, imid, alld, cld, cud;
+-	u_short      mid, mad, aved, lbd, ubd, tmp;
++	unsigned long       dw, imad, imid, alld, cld, cud;
++	unsigned short      mid, mad, aved, lbd, ubd, tmp;
+ 	MonoWordDef *pvd, *pvd2;
+ 	FILE        *fp;
+ 	SANE_Bool    swap = usb_HostSwap();
+_at_@ -166,7 +166,7 @@
+ 			fclose(fp);
+ 
+ 		/* calculate average and 5% limit */
+-		aved = (u_short)(alld/dim_x);
++		aved = (unsigned short)(alld/dim_x);
+ 		lbd  = aved - 0.05*aved;
+ 		ubd  = aved + 0.05*aved;
+ 		cld  = 0;
+_at_@ -195,7 +195,7 @@
+ /**
+  */
+ static void
+-usb_PrepareFineCal( Plustek_Device *dev, ScanParam *tmp_sp, u_short cal_dpi )
++usb_PrepareFineCal( Plustek_Device *dev, ScanParam *tmp_sp, unsigned short cal_dpi )
+ {
+ 	ScanParam *sp    = &dev->scanning.sParam;
+ 	DCapsDef  *scaps = &dev->usbDev.Caps;
+_at_@ -291,11 +291,11 @@
+ /** usb_SetDarkShading
+  * download the dark shading data to Merlins' DRAM
+  */
+-static SANE_Bool usb_SetDarkShading( Plustek_Device *dev, u_char channel,
+-                                     void *coeff_buffer, u_short wCount )
++static SANE_Bool usb_SetDarkShading( Plustek_Device *dev, unsigned char channel,
++                                     void *coeff_buffer, unsigned short wCount )
+ {
+ 	int     res;
+-	u_char *regs = dev->usbDev.a_bRegs;
++	unsigned char *regs = dev->usbDev.a_bRegs;
+ 
+ 	regs[0x03] = 0;
+ 	if( channel == CHANNEL_green )
+_at_@ -329,11 +329,11 @@
+ /** usb_SetWhiteShading
+  * download the white shading data to Merlins' DRAM
+  */
+-static SANE_Bool usb_SetWhiteShading( Plustek_Device *dev, u_char channel,
+-                                      void *data_buffer, u_short wCount )
++static SANE_Bool usb_SetWhiteShading( Plustek_Device *dev, unsigned char channel,
++                                      void *data_buffer, unsigned short wCount )
+ {
+ 	int     res;
+-	u_char *regs = dev->usbDev.a_bRegs;
++	unsigned char *regs = dev->usbDev.a_bRegs;
+ 
+ 	regs[0x03] = 1;
+ 	if (channel == CHANNEL_green)
+_at_@ -667,11 +667,11 @@
+ 
+ /** according to the pixel values,
+  */
+-static u_char usb_GetNewGain( Plustek_Device *dev, u_short wMax, int channel )
++static unsigned char usb_GetNewGain( Plustek_Device *dev, unsigned short wMax, int channel )
+ {
+ 	double dRatio, dAmp;
+-	u_long dwInc, dwDec;
+-	u_char bGain;
++	unsigned long dwInc, dwDec;
++	unsigned char bGain;
+ 
+ 	if( !wMax )
+ 		wMax = 1;
+_at_@ -684,8 +684,8 @@
+ 		if(ceil(dRatio) > 0x3f)
+ 			return 0x3f;
+ 
+-		dwInc = (u_long)((0.93 + ceil (dRatio) * 0.067) * wMax / dAmp);
+-		dwDec = (u_long)((0.93 + floor (dRatio) * 0.067) * wMax / dAmp);
++		dwInc = (unsigned long)((0.93 + ceil (dRatio) * 0.067) * wMax / dAmp);
++		dwDec = (unsigned long)((0.93 + floor (dRatio) * 0.067) * wMax / dAmp);
+ 		if((dwInc >= 0xff00) ||
+ 		   (labs (dwInc - m_dwIdealGain) > labs(dwDec - m_dwIdealGain))) {
+ 			bGain = (u_char)floor(dRatio);
+_at_@ -715,7 +715,7 @@
+  * _at_param gain -
+  * _at_param reg  -
+  */
+-static void setAdjGain( int gain, u_char *reg )
++static void setAdjGain( int gain, unsigned char *reg )
+ {
+ 	if( gain >= 0 ) {
+ 
+_at_@ -734,11 +734,11 @@
+  * _at_param l_off   -
+  * _at_return
+  */
+-static SANE_Bool adjLampSetting( Plustek_Device *dev, int channel, u_long max,  
+-                                 u_long ideal, u_short l_on, u_short *l_off )
++static SANE_Bool adjLampSetting( Plustek_Device *dev, int channel, unsigned long max,  
++                                 unsigned long ideal, unsigned short l_on, unsigned short *l_off )
+ {
+ 	SANE_Bool adj = SANE_FALSE;
+-	u_long    lamp_on;
++	unsigned long    lamp_on;
+ 
+ 	/* so if the image was too bright, we dim the lamps by 3% */
+ 	if( max > ideal ) {
+_at_@ -784,9 +784,9 @@
+ 	ScanDef  *scanning = &dev->scanning;
+ 	DCapsDef *scaps    = &dev->usbDev.Caps;
+ 	HWDef    *hw       = &dev->usbDev.HwSetting;
+-	u_long   *scanbuf  = scanning->pScanBuffer;
+-	u_char   *regs     = dev->usbDev.a_bRegs;
+-	u_long    dw, start, end, len;
++	unsigned long   *scanbuf  = scanning->pScanBuffer;
++	unsigned char   *regs     = dev->usbDev.a_bRegs;
++	unsigned long    dw, start, end, len;
+ 	SANE_Bool fRepeatITA = SANE_TRUE;
+ 
+ 	if( usb_IsEscPressed())
+_at_@ -817,7 +817,7 @@
+ 	if( usb_IsCISDevice(dev) && m_ScanParam.bDataType == SCANDATATYPE_Color)
+ 		m_ScanParam.Size.dwBytes *= 3;
+ 
+-	m_ScanParam.Origin.x = (u_short)((u_long) hw->wActivePixelsStart *
++	m_ScanParam.Origin.x = (unsigned short)((unsigned long) hw->wActivePixelsStart *
+                                                     300UL / scaps->OpticDpi.x);
+ 	m_ScanParam.bCalibration = PARAM_Gain;
+ 
+_at_@ -834,8 +834,8 @@
+ 	}
+ 	end = start + len;
+ 
+-	start = ((u_long)dev->usbDev.pSource->DataOrigin.x*scaps->OpticDpi.x/300UL);
+-	len   = ((u_long)dev->usbDev.pSource->Size.x * scaps->OpticDpi.x / 300UL);
++	start = ((unsigned long)dev->usbDev.pSource->DataOrigin.x*scaps->OpticDpi.x/300UL);
++	len   = ((unsigned long)dev->usbDev.pSource->Size.x * scaps->OpticDpi.x / 300UL);
+ 
+ 	DBG( _DBG_INFO2, "Coarse Calibration Strip:\n" );
+ 	DBG( _DBG_INFO2, "Lines    = %lu\n", m_ScanParam.Size.dwLines  );
+_at_@ -875,15 +875,15 @@
+ #ifdef SWAP_COARSE
+ 	if(usb_HostSwap())
+ #endif
+-		usb_Swap((u_short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
++		usb_Swap((unsigned short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
+ 
+ 	if( fNegative ) {
+ 
+ 		if( m_ScanParam.bDataType == SCANDATATYPE_Color ) {
+ 
+ 			RGBULongDef rgb, rgbSum;
+-			u_long      dwLoop = len / 20 * 20;
+-			u_long      dw10, dwGray, dwGrayMax;
++			unsigned long      dwLoop = len / 20 * 20;
++			unsigned long      dw10, dwGray, dwGrayMax;
+ 
+ 			rgb.Red = rgb.Green = rgb.Blue = dwGrayMax = 0;
+ 
+_at_@ -891,9 +891,9 @@
+ 
+ 				rgbSum.Red = rgbSum.Green = rgbSum.Blue = 0;
+ 				for( dw10 = 20; dw10--; dw++ ) {
+-					rgbSum.Red   += (u_long)(((RGBULongDef*)scanbuf)[dw].Red);
+-					rgbSum.Green += (u_long)(((RGBULongDef*)scanbuf)[dw].Green);
+-					rgbSum.Blue  += (u_long)(((RGBULongDef*)scanbuf)[dw].Blue);
++					rgbSum.Red   += (unsigned long)(((RGBULongDef*)scanbuf)[dw].Red);
++					rgbSum.Green += (unsigned long)(((RGBULongDef*)scanbuf)[dw].Green);
++					rgbSum.Blue  += (unsigned long)(((RGBULongDef*)scanbuf)[dw].Blue);
+ 				}
+ 
+ 				/* do some weighting of the color planes for negatives */
+_at_@ -909,9 +909,9 @@
+ 				}
+ 			}
+ 
+-			Gain_Hilight.Red   = (u_short)(rgb.Red / 20UL);
+-			Gain_Hilight.Green = (u_short)(rgb.Green / 20UL);
+-			Gain_Hilight.Blue  = (u_short)(rgb.Blue / 20UL);
++			Gain_Hilight.Red   = (unsigned short)(rgb.Red / 20UL);
++			Gain_Hilight.Green = (unsigned short)(rgb.Green / 20UL);
++			Gain_Hilight.Blue  = (unsigned short)(rgb.Blue / 20UL);
+ 			DBG(_DBG_INFO2, "MAX(R,G,B)= 0x%04x(%u), 0x%04x(%u), 0x%04x(%u)\n",
+ 			    Gain_Hilight.Red, Gain_Hilight.Red, Gain_Hilight.Green, 
+ 			    Gain_Hilight.Green, Gain_Hilight.Blue, Gain_Hilight.Blue );
+_at_@ -922,15 +922,15 @@
+ 
+ 		} else {
+ 
+-			u_long dwMax  = 0, dwSum;
+-			u_long dwLoop = len / 20 * 20;
+-			u_long dw10;
++			unsigned long dwMax  = 0, dwSum;
++			unsigned long dwLoop = len / 20 * 20;
++			unsigned long dw10;
+ 
+ 			for( dw = start; dwLoop; dwLoop-- ) {
+ 
+ 				dwSum = 0;
+ 				for( dw10 = 20; dw10--; dw++ )
+-					dwSum += (u_long)((u_short*)scanbuf)[dw];
++					dwSum += (unsigned long)((u_short*)scanbuf)[dw];
+ 
+ 				if((fNegative == 1) || (dwSum < 0x6000 * 20)) {
+ 					if( dwMax < dwSum )
+_at_@ -938,7 +938,7 @@
+ 				}
+ 			}
+ 			Gain_Hilight.Red  = Gain_Hilight.Green =
+-			Gain_Hilight.Blue = (u_short)(dwMax / 20UL);
++			Gain_Hilight.Blue = (unsigned short)(dwMax / 20UL);
+ 
+ 			Gain_Reg.Red  = Gain_Reg.Green =
+ 			Gain_Reg.Blue = regs[0x3b] =
+_at_@ -949,9 +949,9 @@
+ 		if( m_ScanParam.bDataType == SCANDATATYPE_Color ) {
+ 
+ 			RGBUShortDef max_rgb, min_rgb, tmp_rgb;
+-			u_long       dwR, dwG, dwB;
+-			u_long       dwDiv   = 10;
+-			u_long       dwLoop1 = len / dwDiv, dwLoop2;
++			unsigned long       dwR, dwG, dwB;
++			unsigned long       dwDiv   = 10;
++			unsigned long       dwLoop1 = len / dwDiv, dwLoop2;
+ 
+ 			max_rgb.Red = max_rgb.Green = max_rgb.Blue = 0;
+ 			min_rgb.Red = min_rgb.Green = min_rgb.Blue = 0xffff;
+_at_@ -1201,12 +1201,12 @@
+  * _at_param channel  -
+  * _at_param cAdjust  -
+  */
+-static void usb_GetNewOffset( Plustek_Device *dev, u_long *pdwSum, u_long *pdwDiff,
+-                              signed char *pcOffset, u_char *pIdeal,
+-                              u_long channel, signed char cAdjust )
++static void usb_GetNewOffset( Plustek_Device *dev, unsigned long *pdwSum, unsigned long *pdwDiff,
++                              signed char *pcOffset, unsigned char *pIdeal,
++                              unsigned long channel, signed char cAdjust )
+ {
+ 	/* IDEAL_Offset is currently set to 0x1000 = 4096 */
+-	u_long dwIdealOffset = IDEAL_Offset;
++	unsigned long dwIdealOffset = IDEAL_Offset;
+ 
+ 	if( pdwSum[channel] > dwIdealOffset ) {
+ 
+_at_@ -1251,14 +1251,14 @@
+ 	char          tmp[40];
+ 	signed char   cAdjust = 16;
+ 	signed char   cOffset[3];
+-	u_char        bExpect[3];
++	unsigned char        bExpect[3];
+ 	int           i;
+-	u_long        dw, dwPixels;
+-    u_long        dwDiff[3], dwSum[3];
++	unsigned long        dw, dwPixels;
++    unsigned long        dwDiff[3], dwSum[3];
+ 
+ 	HWDef  *hw      = &dev->usbDev.HwSetting;
+-	u_char *regs    = dev->usbDev.a_bRegs;
+-	u_long *scanbuf = dev->scanning.pScanBuffer;
++	unsigned char *regs    = dev->usbDev.a_bRegs;
++	unsigned long *scanbuf = dev->scanning.pScanBuffer;
+ 
+ 	if( usb_IsEscPressed())
+ 		return SANE_FALSE;
+_at_@ -1280,7 +1280,7 @@
+ 	if( usb_IsCISDevice(dev))
+ 		dwPixels = m_ScanParam.Size.dwPixels;
+ 	else
+-		dwPixels = (u_long)(hw->bOpticBlackEnd - hw->bOpticBlackStart );
++		dwPixels = (unsigned long)(hw->bOpticBlackEnd - hw->bOpticBlackStart );
+ 
+ 	m_ScanParam.Size.dwPixels = 2550;
+ 	m_ScanParam.Size.dwBytes  = m_ScanParam.Size.dwPixels * 2 *
+_at_@ -1288,7 +1288,7 @@
+ 	if( usb_IsCISDevice(dev) && m_ScanParam.bDataType == SCANDATATYPE_Color )
+ 		m_ScanParam.Size.dwBytes *= 3;
+ 
+-	m_ScanParam.Origin.x = (u_short)((u_long)hw->bOpticBlackStart * 300UL /
++	m_ScanParam.Origin.x = (unsigned short)((unsigned long)hw->bOpticBlackStart * 300UL /
+ 												  dev->usbDev.Caps.OpticDpi.x);
+ 	m_ScanParam.bCalibration = PARAM_Offset;
+  	m_ScanParam.dMCLK        = dMCLK;
+_at_@ -1308,7 +1308,7 @@
+ 
+ 			usb_ModuleToHome( dev, SANE_TRUE );
+ 			usb_ModuleMove  ( dev, MOVE_Forward,
+-								(u_long)dev->usbDev.pSource->DarkShadOrgY );
++								(unsigned long)dev->usbDev.pSource->DarkShadOrgY );
+ 
+ 			regs[0x45] &= ~0x10;
+ 
+_at_@ -1353,7 +1353,7 @@
+ 		
+ #ifdef SWAP_COARSE
+ 		if(usb_HostSwap())
+-			usb_Swap((u_short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
++			usb_Swap((unsigned short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
+ #endif
+ 		dumpPicInit(&m_ScanParam, tmp);
+ 		dumpPic(tmp, (u_char*)scanbuf, m_ScanParam.Size.dwPhyBytes, 0);
+_at_@ -1364,9 +1364,9 @@
+ 
+ 			for (dw = 0; dw < dwPixels; dw++) {
+ #ifndef SWAP_COARSE
+-				dwSum[0] += (u_long)_HILO2WORD(((ColorWordDef*)scanbuf)[dw].HiLo[0]);
+-				dwSum[1] += (u_long)_HILO2WORD(((ColorWordDef*)scanbuf)[dw].HiLo[1]);
+-				dwSum[2] += (u_long)_HILO2WORD(((ColorWordDef*)scanbuf)[dw].HiLo[2]);
++				dwSum[0] += (unsigned long)_HILO2WORD(((ColorWordDef*)scanbuf)[dw].HiLo[0]);
++				dwSum[1] += (unsigned long)_HILO2WORD(((ColorWordDef*)scanbuf)[dw].HiLo[1]);
++				dwSum[2] += (unsigned long)_HILO2WORD(((ColorWordDef*)scanbuf)[dw].HiLo[2]);
+ #else
+ 				dwSum[0] += ((RGBUShortDef*)scanbuf)[dw].Red;
+ 				dwSum[1] += ((RGBUShortDef*)scanbuf)[dw].Green;
+_at_@ -1399,7 +1399,7 @@
+ 
+ 			for( dw = 0; dw < dwPixels; dw++ ) {
+ #ifndef SWAP_COARSE
+-				dwSum[0] += (u_long)_HILO2WORD(((HiLoDef*)scanbuf)[dw]);
++				dwSum[0] += (unsigned long)_HILO2WORD(((HiLoDef*)scanbuf)[dw]);
+ #else
+ 				dwSum[0] += ((u_short*)scanbuf)[dw];
+ #endif
+_at_@ -1448,18 +1448,18 @@
+  *  the data is simply copied. If not, then the white strip is read 
+  *  with the lamp switched off...
+  */
+-static void usb_GetDarkShading( Plustek_Device *dev, u_short *pwDest,
+-                                HiLoDef *pSrce, u_long dwPixels,
+-                                u_long dwAdd, int iOffset )
++static void usb_GetDarkShading( Plustek_Device *dev, unsigned short *pwDest,
++                                HiLoDef *pSrce, unsigned long dwPixels,
++                                unsigned long dwAdd, int iOffset )
+ {
+-	u_long    dw;
+-	u_long    dwSum[2];
++	unsigned long    dw;
++	unsigned long    dwSum[2];
+ 	DCapsDef *scaps = &dev->usbDev.Caps;
+ 	HWDef    *hw    = &dev->usbDev.HwSetting;
+ 
+ 	if( dev->usbDev.pSource->DarkShadOrgY >= 0 ) {
+ 
+-		u_short w;
++		unsigned short w;
+ 		int     wtmp;
+ 
+ 		/* here we use the source  buffer + a static offset */
+_at_@ -1476,7 +1476,7 @@
+ 			if( wtmp > 0xffff )
+ 				wtmp = 0xffff;
+ 
+-			w = (u_short)wtmp;
++			w = (unsigned short)wtmp;
+ 
+ #ifndef SWAP_FINE
+ 			pwDest[dw] = _LOBYTE(w) * 256 + _HIBYTE(w);
+_at_@ -1493,9 +1493,9 @@
+ 			/* Even/Odd CCD */
+ 			for( dw = 0; dw < dwPixels; dw++, pSrce += dwAdd ) {
+ #ifndef SWAP_FINE
+-				dwSum[dw & 1] += (u_long)_PHILO2WORD(pSrce);
++				dwSum[dw & 1] += (unsigned long)_PHILO2WORD(pSrce);
+ #else
+-				dwSum[dw & 1] += (u_long)_PLOHI2WORD(pSrce);
++				dwSum[dw & 1] += (unsigned long)_PLOHI2WORD(pSrce);
+ #endif
+ 			}
+ 			dwSum[0] /= ((dwPixels + 1UL) >> 1);
+_at_@ -1515,17 +1515,17 @@
+ 			if((int)dwSum[1] < 0)
+ 				dwSum[1] = 0;
+ #ifndef SWAP_FINE
+-			dwSum[0] = (u_long)_LOBYTE(_LOWORD(dwSum[0])) * 256UL +
++			dwSum[0] = (unsigned long)_LOBYTE(_LOWORD(dwSum[0])) * 256UL +
+ 			                             _HIBYTE(_LOWORD(dwSum[0]));
+-			dwSum[1] = (u_long)_LOBYTE(_LOWORD(dwSum[1])) * 256UL +
++			dwSum[1] = (unsigned long)_LOBYTE(_LOWORD(dwSum[1])) * 256UL +
+ 			                             _HIBYTE(_LOWORD(dwSum[1]));
+ #else
+-			dwSum[0] = (u_long)_LOWORD(dwSum[0]);
+-			dwSum[1] = (u_long)_LOWORD(dwSum[1]);
++			dwSum[0] = (unsigned long)_LOWORD(dwSum[0]);
++			dwSum[1] = (unsigned long)_LOWORD(dwSum[1]);
+ #endif
+ 
+ 			for( dw = 0; dw < dwPixels; dw++ )
+-				pwDest[dw] = (u_short)dwSum[dw & 1];
++				pwDest[dw] = (unsigned short)dwSum[dw & 1];
+ 		} else {
+ 			
+ 			/* Standard CCD */
+_at_@ -1533,9 +1533,9 @@
+ 			/* do some averaging on the line */
+ 			for( dw = 0; dw < dwPixels; dw++, pSrce += dwAdd ) {
+ #ifndef SWAP_FINE
+-				dwSum[0] += (u_long)_PHILO2WORD(pSrce);
++				dwSum[0] += (unsigned long)_PHILO2WORD(pSrce);
+ #else
+-				dwSum[0] += (u_long)_PLOHI2WORD(pSrce);
++				dwSum[0] += (unsigned long)_PLOHI2WORD(pSrce);
+ #endif
+ 			}
+ 
+_at_@ -1546,15 +1546,15 @@
+ 			if((int)dwSum[0] < 0)
+ 				dwSum[0] = 0;
+ #ifndef SWAP_FINE
+-			dwSum[0] = (u_long)_LOBYTE(_LOWORD(dwSum[0])) * 256UL +
++			dwSum[0] = (unsigned long)_LOBYTE(_LOWORD(dwSum[0])) * 256UL +
+ 			                             _HIBYTE(_LOWORD(dwSum[0]));
+ #else
+-			dwSum[0] = (u_long)_LOWORD(dwSum[0]);
++			dwSum[0] = (unsigned long)_LOWORD(dwSum[0]);
+ #endif
+ 
+ 			/* fill the shading data */
+ 			for( dw = 0; dw < dwPixels; dw++ )
+-				pwDest[dw] = (u_short)dwSum[0];
++				pwDest[dw] = (unsigned short)dwSum[0];
+ 		}
+ 	}
+ #ifdef SWAP_FINE
+_at_@ -1575,8 +1575,8 @@
+ 	ScanDef  *scanning = &dev->scanning;
+ 	DCapsDef *scaps    = &dev->usbDev.Caps;
+ 	HWDef    *hw       = &dev->usbDev.HwSetting;
+-	u_long   *scanbuf  = scanning->pScanBuffer;
+-	u_char   *regs     = dev->usbDev.a_bRegs;
++	unsigned long   *scanbuf  = scanning->pScanBuffer;
++	unsigned char   *regs     = dev->usbDev.a_bRegs;
+ 
+ 	if( usb_IsEscPressed())
+ 		return SANE_FALSE;
+_at_@ -1602,8 +1602,8 @@
+ 
+ 		/* Now DPI X is physical */
+ 		m_ScanParam.Origin.x      = m_ScanParam.Origin.x %
+-		                            (u_short)m_dHDPIDivider;
+-		m_ScanParam.Size.dwPixels = (u_long)scaps->Normal.Size.x *
++		                            (unsigned short)m_dHDPIDivider;
++		m_ScanParam.Size.dwPixels = (unsigned long)scaps->Normal.Size.x *
+ 		                                    m_ScanParam.UserDpi.x / 300UL;
+ 		m_ScanParam.Size.dwBytes  = m_ScanParam.Size.dwPixels *
+ 		                            2UL * m_ScanParam.bChannels;
+_at_@ -1621,7 +1621,7 @@
+ 
+ 		usb_ModuleToHome( dev, SANE_TRUE );
+ 		usb_ModuleMove  ( dev, MOVE_Forward,
+-		                  (u_long)dev->usbDev.pSource->DarkShadOrgY );
++		                  (unsigned long)dev->usbDev.pSource->DarkShadOrgY );
+ 	} else {
+ 
+ 	 	/* switch lamp off to read dark data... */
+_at_@ -1656,7 +1656,7 @@
+ 
+ #ifdef SWAP_FINE
+ 	if(usb_HostSwap())
+-		usb_Swap((u_short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
++		usb_Swap((unsigned short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
+ #endif
+ 
+ 	sprintf( tmp, "fine-black.raw" );
+_at_@ -1721,11 +1721,11 @@
+  * _at_param shading_lines - defines the overall number of shading lines.
+  */
+ static void usb_CalSortHighlight( Plustek_Device *dev, ScanParam *sp, 
+-                                  u_long hilight, u_long shading_lines )
++                                  unsigned long hilight, unsigned long shading_lines )
+ {
+     ScanDef      *scan = &dev->scanning;
+-	u_short       r, g, b;
+-	u_long        lines, w, x;
++	unsigned short       r, g, b;
++	unsigned long        lines, w, x;
+ 	RGBUShortDef *pw, *rgb;
+ 
+ 	if( hilight == 0 )
+_at_@ -1772,11 +1772,11 @@
+  * _at_param shading_lines - defines the overall number of shading lines.
+  */
+ static void usb_CalSortShadow( Plustek_Device *dev, ScanParam *sp,
+-                               u_long hilight, u_long shadow, u_long shading_lines )
++                               unsigned long hilight, unsigned long shadow, unsigned long shading_lines )
+ {
+ 	ScanDef      *scan = &dev->scanning;
+-	u_short       r, g, b;
+-	u_long        lines, w, x;
++	unsigned short       r, g, b;
++	unsigned long        lines, w, x;
+ 	RGBUShortDef *pw, *rgb;
+ 
+ 	if( shadow == 0 )
+_at_@ -1811,11 +1811,11 @@
+ }
+ 
+ static void usb_procHighlightAndShadow( Plustek_Device *dev, ScanParam *sp,
+-                                        u_long hilight, u_long shadow, u_long shading_lines )
++                                        unsigned long hilight, unsigned long shadow, unsigned long shading_lines )
+ {
+ 	ScanDef      *scan = &dev->scanning;
+-	u_long        lines, x;
+-	u_long       *pr, *pg, *pb;
++	unsigned long        lines, x;
++	unsigned long       *pr, *pg, *pb;
+ 	RGBUShortDef *rgb;
+ 
+ 	pr = (u_long*)((u_char*)scan->pScanBuffer + sp->Size.dwPhyBytes * shading_lines);
+_at_@ -1856,13 +1856,13 @@
+ 	ScanDef      *scan  = &dev->scanning;
+ 	DCapsDef     *scaps = &dev->usbDev.Caps;
+ 	HWDef        *hw    = &dev->usbDev.HwSetting;
+-	u_long       *pBuf  = scan->pScanBuffer;
+-	u_long        dw, dwLines, dwRead;
+-	u_long        shading_lines;
++	unsigned long       *pBuf  = scan->pScanBuffer;
++	unsigned long        dw, dwLines, dwRead;
++	unsigned long        shading_lines;
+ 	MonoWordDef  *pValue;
+-	u_short      *m_pAvMono;
+-	u_long       *pdw, *m_pSum;
+-	u_short       hilight, shadow;
++	unsigned short      *m_pAvMono;
++	unsigned long       *pdw, *m_pSum;
++	unsigned short       hilight, shadow;
+ 	int           i;
+ 	SANE_Bool     swap = usb_HostSwap();
+ 	
+_at_@ -1898,8 +1898,8 @@
+ 			m_ScanParam.UserDpi.x = 150;
+ 
+ 		/* Now DPI X is physical */
+-		m_ScanParam.Origin.x      = m_ScanParam.Origin.x % (u_short)m_dHDPIDivider;
+-		m_ScanParam.Size.dwPixels = (u_long)scaps->Normal.Size.x * m_ScanParam.UserDpi.x / 300UL;
++		m_ScanParam.Origin.x      = m_ScanParam.Origin.x % (unsigned short)m_dHDPIDivider;
++		m_ScanParam.Size.dwPixels = (unsigned long)scaps->Normal.Size.x * m_ScanParam.UserDpi.x / 300UL;
+ 		m_ScanParam.Size.dwBytes  = m_ScanParam.Size.dwPixels * 2UL * m_ScanParam.bChannels;
+ 		if( usb_IsCISDevice(dev) && m_ScanParam.bDataType == SCANDATATYPE_Color )
+ 			m_ScanParam.Size.dwBytes *= 3;
+_at_@ -1907,7 +1907,7 @@
+ 		m_dwPixels = scan->sParam.Size.dwPixels * m_ScanParam.UserDpi.x / 
+ 		             scan->sParam.UserDpi.x;
+ 
+-		dw = (u_long)(hw->wDRAMSize - 196 /*192 KiB*/) * 1024UL;
++		dw = (unsigned long)(hw->wDRAMSize - 196 /*192 KiB*/) * 1024UL;
+ 		for( dwLines = dw / m_ScanParam.Size.dwBytes;
+ 			 dwLines < m_ScanParam.Size.dwLines; m_ScanParam.Size.dwLines>>=1);
+ 	}
+_at_@ -1917,7 +1917,7 @@
+ 
+ 		usb_ModuleToHome( dev, SANE_TRUE );
+ 		usb_ModuleMove  ( dev, MOVE_Forward,
+-		                  (u_long)dev->usbDev.pSource->ShadingOriginY );
++		                  (unsigned long)dev->usbDev.pSource->ShadingOriginY );
+ 	}
+ 
+ 	sprintf( tmp, "fine-white.raw" );
+_at_@ -1973,8 +1973,8 @@
+ 	 */
+ 	if( usb_IsCISDevice(dev)) {
+ 
+-		u_short *dest, *src;
+-		u_long   dww;
++		unsigned short *dest, *src;
++		unsigned long   dww;
+ 
+ 		src = (u_short*)pBuf;
+ 
+_at_@ -2005,11 +2005,11 @@
+ 
+ 	if( _LM9831 == hw->chip ) {
+ 
+-		u_short *pwDest = (u_short*)pBuf;
++		unsigned short *pwDest = (u_short*)pBuf;
+ 		HiLoDef *pwSrce = (HiLoDef*)pBuf;
+ 
+-		pwSrce  += ((u_long)(scan->sParam.Origin.x-m_ScanParam.Origin.x) /
+-		           (u_short)m_dHDPIDivider) *
++		pwSrce  += ((unsigned long)(scan->sParam.Origin.x-m_ScanParam.Origin.x) /
++		           (unsigned short)m_dHDPIDivider) *
+ 		                   (scaps->OpticDpi.x / 300UL) * m_ScanParam.bChannels;
+ 
+ 		for( dwLines = shading_lines; dwLines; dwLines--) {
+_at_@ -2025,14 +2025,14 @@
+ 					pwDest[dw] = _LOHI2WORD(pwSrce[dw]);
+ 			}
+ #endif
+-			pwDest += (u_long)m_dwPixels * m_ScanParam.bChannels;
++			pwDest += (unsigned long)m_dwPixels * m_ScanParam.bChannels;
+ 			pwSrce  = (HiLoDef*)((u_char*)pwSrce + m_ScanParam.Size.dwPhyBytes);
+ 		}
+ 
+ 		_SWAP(m_ScanParam.Size.dwPhyPixels, m_dwPixels);
+ 	} else {
+ 		/* Discard the status word and conv. the hi-lo order to intel format */
+-		u_short *pwDest = (u_short*)pBuf;
++		unsigned short *pwDest = (u_short*)pBuf;
+ 		HiLoDef *pwSrce = (HiLoDef*)pBuf;
+ 
+ 		for( dwLines = shading_lines; dwLines; dwLines-- ) {
+_at_@ -2076,10 +2076,10 @@
+ 					if(*pdw > 65535U)
+ 						pValue->Mono = 65535U;
+ 					else
+-						pValue->Mono = (u_short)*pdw;
++						pValue->Mono = (unsigned short)*pdw;
+ 					
+ 					if (pValue->Mono > 16384U)
+-						pValue->Mono = (u_short)(GAIN_Target * 16384U / pValue->Mono);
++						pValue->Mono = (unsigned short)(GAIN_Target * 16384U / pValue->Mono);
+ 					else
+ 						pValue->Mono = GAIN_Target;
+ 
+_at_@ -2091,15 +2091,15 @@
+ 			}
+ 		} else {
+ 			for( dw = m_ScanParam.Size.dwPhyPixels*3; dw; dw--,pValue++,pdw++)
+-				pValue->Mono=(u_short)(*pdw/(shading_lines-hilight-shadow));
++				pValue->Mono=(unsigned short)(*pdw/(shading_lines-hilight-shadow));
+ 
+ 				/* swapping will be done later in usb_ResizeWhiteShading() */
+ 		}
+ 	} else {
+ 
+ 		/* gray mode */
+-		u_short *pwAv, *pw;
+-		u_short  w, wV;
++		unsigned short *pwAv, *pw;
++		unsigned short  w, wV;
+ 
+ 		memset( m_pSum, 0, m_ScanParam.Size.dwPhyPixels << 2 );
+ 		if( hilight ) {
+_at_@ -2159,10 +2159,10 @@
+ 				if( pdw[dw] > 65535U )
+ 					pValue[dw].Mono = 65535;
+ 				else
+-					pValue[dw].Mono = (u_short)pdw[dw];
++					pValue[dw].Mono = (unsigned short)pdw[dw];
+ 
+ 				if( pValue[dw].Mono > 16384U ) {
+-					pValue[dw].Mono = (u_short)(GAIN_Target * 16384U / pValue[dw].Mono);
++					pValue[dw].Mono = (unsigned short)(GAIN_Target * 16384U / pValue[dw].Mono);
+ 				} else {
+ 					pValue[dw].Mono = GAIN_Target;
+ 				}
+_at_@ -2176,7 +2176,7 @@
+ 		} else{
+ 
+ 			for( dw = 0; dw < m_ScanParam.Size.dwPhyPixels; dw++ ) {
+-				pValue[dw].Mono = (u_short)(pdw[dw] /
++				pValue[dw].Mono = (unsigned short)(pdw[dw] /
+ 				                  (shading_lines - hilight - shadow));
+ 
+ 				/* swapping will be done later in usb_ResizeWhiteShading() */
+_at_@ -2196,25 +2196,25 @@
+ /** for negative film only
+  * we need to resize the gain to obtain bright white...
+  */
+-static void usb_ResizeWhiteShading( double dAmp, u_short *pwShading, int iGain )
++static void usb_ResizeWhiteShading( double dAmp, unsigned short *pwShading, int iGain )
+ {
+-	u_long  dw, dwAmp;
+-	u_short w;
++	unsigned long  dw, dwAmp;
++	unsigned short w;
+ 	
+ 	DBG( _DBG_INFO2, "ResizeWhiteShading: dAmp=%.3f, iGain=%i\n", dAmp, iGain );
+ 
+ 	for( dw = 0; dw < m_ScanParam.Size.dwPhyPixels; dw++ ) {
+ 		
+-		dwAmp = (u_long)(GAIN_Target * 0x4000 /
++		dwAmp = (unsigned long)(GAIN_Target * 0x4000 /
+ 		                            (pwShading[dw] + 1) * dAmp) * iGain / 1000;
+ 
+ 		if( dwAmp <= GAIN_Target)
+-			w = (u_short)dwAmp;
++			w = (unsigned short)dwAmp;
+ 		else 
+ 			w = GAIN_Target;
+ 
+ #ifndef SWAP_FINE
+-		pwShading[dw] = (u_short)_LOBYTE(w) * 256 + _HIBYTE(w);
++		pwShading[dw] = (unsigned short)_LOBYTE(w) * 256 + _HIBYTE(w);
+ #else
+ 		pwShading[dw] = w;
+ #endif
+_at_@ -2233,7 +2233,7 @@
+ {
+ 	ScanDef  *scan  = &dev->scanning;
+ 	DCapsDef *scaps = &dev->usbDev.Caps;
+-	u_char   *regs  = dev->usbDev.a_bRegs;
++	unsigned char   *regs  = dev->usbDev.a_bRegs;
+ 
+ 	usb_GetSWOffsetGain( dev );
+ 
+_at_@ -2308,8 +2308,8 @@
+ 	struct timeval start, end;
+ 	DCapsDef *scaps   = &dev->usbDev.Caps;
+ 	HWDef    *hw      = &dev->usbDev.HwSetting;
+-	u_char   *regs    = dev->usbDev.a_bRegs;
+-	u_long   *scanbuf = dev->scanning.pScanBuffer;
++	unsigned char   *regs    = dev->usbDev.a_bRegs;
++	unsigned long   *scanbuf = dev->scanning.pScanBuffer;
+ 
+ 	if( usb_IsEscPressed())
+ 		return SANE_FALSE;
+_at_@ -2344,7 +2344,7 @@
+ 	if( usb_IsCISDevice(dev))
+ 		m_ScanParam.Size.dwBytes *= 3;
+ 
+-	m_ScanParam.Origin.x = (u_short)((u_long) hw->wActivePixelsStart *
++	m_ScanParam.Origin.x = (unsigned short)((unsigned long) hw->wActivePixelsStart *
+ 	                                                300UL / scaps->OpticDpi.x);
+ 	r = 0.0;
+ 	dev->transferRate = 2000000;
+_at_@ -2376,7 +2376,7 @@
+ 	}
+ 
+ 	tr = ((double)m_ScanParam.Size.dwPhyBytes * _TLOOPS * 1000000.0)/r;
+-	dev->transferRate = (u_long)tr;
++	dev->transferRate = (unsigned long)tr;
+ 	DBG( 1, "usb_SpeedTest() done - %u loops, %.4fus --> %.4f B/s, %lu\n", 
+ 	        _TLOOPS, r, tr, dev->transferRate );
+ 	return SANE_TRUE;
+_at_@ -2392,11 +2392,11 @@
+ 	ScanDef  *scanning = &dev->scanning;
+ 	DCapsDef *scaps    = &dev->usbDev.Caps;
+ 	HWDef    *hw       = &dev->usbDev.HwSetting;
+-	u_long   *scanbuf  = scanning->pScanBuffer;
+-	u_char   *regs     = dev->usbDev.a_bRegs;
+-	u_long    dw, start, end, len;
+-	u_long    curR,   curG,  curB;
+-	u_long    lastR, lastG, lastB;
++	unsigned long   *scanbuf  = scanning->pScanBuffer;
++	unsigned char   *regs     = dev->usbDev.a_bRegs;
++	unsigned long    dw, start, end, len;
++	unsigned long    curR,   curG,  curB;
++	unsigned long    lastR, lastG, lastB;
+ 	long      diffR, diffG, diffB;
+ 	long      thresh = _AUTO_THRESH;
+ 
+_at_@ -2441,7 +2441,7 @@
+ 	if( usb_IsCISDevice(dev))
+ 		m_ScanParam.Size.dwBytes *= 3;
+ 
+-	m_ScanParam.Origin.x = (u_short)((u_long) hw->wActivePixelsStart *
++	m_ScanParam.Origin.x = (unsigned short)((unsigned long) hw->wActivePixelsStart *
+ 	                                                300UL / scaps->OpticDpi.x);
+ 
+ 	stable_count = 0;
+_at_@ -2478,7 +2478,7 @@
+ #ifdef SWAP_COARSE
+ 		if(usb_HostSwap())
+ #endif
+-			usb_Swap((u_short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
++			usb_Swap((unsigned short *)scanbuf, m_ScanParam.Size.dwPhyBytes );
+ 
+ 		if( end > m_ScanParam.Size.dwPhyPixels )
+ 			end = m_ScanParam.Size.dwPhyPixels;
+_at_@ -2593,7 +2593,7 @@
+ 	ScanDef  *scanning = &dev->scanning;
+ 	DCapsDef *scaps    = &dev->usbDev.Caps;
+ 	HWDef    *hw       = &dev->usbDev.HwSetting;
+-	u_char   *regs     = dev->usbDev.a_bRegs;
++	unsigned char   *regs     = dev->usbDev.a_bRegs;
+ 	double    dRed, dGreen, dBlue;
+ 
+ 	DBG( _DBG_INFO, "usb_DoCalibration()\n" );
+_at_@ -2623,16 +2623,16 @@
+ 	} else {
+ #endif
+ 		DBG( _DBG_INFO, "ShadingOriginY=%lu\n",
+-				(u_long)dev->usbDev.pSource->ShadingOriginY );
++				(unsigned long)dev->usbDev.pSource->ShadingOriginY );
+ 
+ 		if((hw->motorModel == MODEL_HuaLien) && (scaps->OpticDpi.x==600)) {
+ 			if (!usb_ModuleMove(dev, MOVE_ToShading,
+-			                    (u_long)dev->usbDev.pSource->ShadingOriginY)) {
++			                    (unsigned long)dev->usbDev.pSource->ShadingOriginY)) {
+ 				return _E_LAMP_NOT_IN_POS;
+ 			}
+ 		} else {
+ 			if( !usb_ModuleMove(dev, MOVE_Forward,
+-			                    (u_long)dev->usbDev.pSource->ShadingOriginY)) {
++			                    (unsigned long)dev->usbDev.pSource->ShadingOriginY)) {
+ 				return _E_LAMP_NOT_IN_POS;
+ 			}
+ 		}
+_at_@ -3004,12 +3004,12 @@
+  * pointer, otherwise we correct the wrong channels
+  */
+ static void
+-get_ptrs(Plustek_Device *dev, u_short *buf, u_long offs,
+-         u_short **r, u_short **g, u_short **b)
++get_ptrs(Plustek_Device *dev, unsigned short *buf, unsigned long offs,
++         unsigned short **r, unsigned short **g, unsigned short **b)
+ {
+ 	ScanDef  *scan  = &dev->scanning;
+ 	DCapsDef *scaps = &dev->usbDev.Caps;
+-	u_char so = scaps->bSensorOrder;
++	unsigned char so = scaps->bSensorOrder;
+ 
+ 	if (_WAF_RESET_SO_TO_RGB & scaps->workaroundFlag) {
+ 		if (scaps->bPCB != 0) {
+_at_@ -3045,15 +3045,15 @@
+  * in preparation for calibration or scanning
+  */
+ static SANE_Bool
+-usb_DownloadShadingData( Plustek_Device *dev, u_char what )
++usb_DownloadShadingData( Plustek_Device *dev, unsigned char what )
+ {
+-	u_char    channel;
+-	u_short   *r, *g, *b;
++	unsigned char    channel;
++	unsigned short   *r, *g, *b;
+ 	DCapsDef  *scaps = &dev->usbDev.Caps;
+ 	ScanDef   *scan  = &dev->scanning;
+ 	HWDef     *hw    = &dev->usbDev.HwSetting;
+ 	ScanParam *param = &dev->scanning.sParam;
+-	u_char    *regs  = dev->usbDev.a_bRegs;
++	unsigned char    *regs  = dev->usbDev.a_bRegs;
+ 
+ 	DBG( _DBG_INFO, "usb_DownloadShadingData(%u)\n", what );
+ 
+_at_@ -3067,17 +3067,17 @@
+ 			if( m_ScanParam.bDataType == SCANDATATYPE_Color ) {
+ 
+ 				usb_SetDarkShading( dev, CHANNEL_red, a_wDarkShading,
+-				                    (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++				                    (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 				usb_SetDarkShading( dev, CHANNEL_green, a_wDarkShading +
+ 				                    m_ScanParam.Size.dwPhyPixels,
+-				                    (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++				                    (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 				usb_SetDarkShading( dev, CHANNEL_blue, a_wDarkShading +
+ 				                    m_ScanParam.Size.dwPhyPixels * 2,
+-				                    (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++				                    (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 			} else {
+ 				usb_SetDarkShading( dev, channel, a_wDarkShading +
+ 				                    m_ScanParam.Size.dwPhyPixels,
+-				                    (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++				                    (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 			}
+ 			regs[0x40] = 0x40;
+ 			regs[0x41] = 0x00;
+_at_@ -3149,15 +3149,15 @@
+ 					get_ptrs(dev, a_wDarkShading, m_dwPixels, &r, &g, &b);
+ 
+ 					usb_SetDarkShading( dev, CHANNEL_red, r,
+-					                (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++					                (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 					usb_SetDarkShading( dev, CHANNEL_green, g,
+-					                (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++					                (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 					usb_SetDarkShading( dev, CHANNEL_blue, b,
+-					                (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++					                (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 				} else {
+ 					usb_SetDarkShading( dev, channel,
+ 					                    a_wDarkShading + m_dwPixels,
+-					                (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++					                (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 				}
+ 				if( param->bDataType == SCANDATATYPE_Color ) {
+ 
+_at_@ -3165,14 +3165,14 @@
+ 					         m_ScanParam.Size.dwPhyPixels, &r, &g, &b);
+ 
+ 					usb_SetWhiteShading( dev, CHANNEL_red, r,
+-					                (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++					                (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 					usb_SetWhiteShading( dev, CHANNEL_green, g,
+-					                (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++					                (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 					usb_SetWhiteShading( dev, CHANNEL_blue, b,
+-					                (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++					                (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 				} else {
+ 					usb_SetWhiteShading( dev, channel, a_wWhiteShading,
+-					                (u_short)m_ScanParam.Size.dwPhyPixels * 2);
++					                (unsigned short)m_ScanParam.Size.dwPhyPixels * 2);
+ 				}
+ 
+ 				/* set RAM configuration AND
+--- sane-backends-1.0.24.orig/backend/plustek.c
++++ sane-backends-1.0.24/backend/plustek.c
+_at_@ -1135,7 +1135,7 @@
+ 		DBG( _DBG_SANE_INIT, "next device uses autodetection\n" );
+ 	} else {
+ 			
+-		u_short pi = 0, vi = 0;
++		unsigned short pi = 0, vi = 0;
+ 
+ 		if( *name ) {
+ 	
+--- sane-backends-1.0.24.orig/backend/qcam.c
++++ sane-backends-1.0.24/backend/qcam.c
+_at_@ -463,10 +463,10 @@
+ }
+ 
+ static void
+-qc_setscanmode (QC_Scanner * s, u_int * modep)
++qc_setscanmode (QC_Scanner * s, unsigned int * modep)
+ {
+   QC_Device *q = s->hw;
+-  u_int mode = 0;
++  unsigned int mode = 0;
+ 
+   if (q->version != QC_COLOR)
+     {
+_at_@ -867,7 +867,7 @@
+       num_bytes = req.num_bytes;
+ 
+       DBG (3, "reader_process: got request for %lu bytes\n",
+-	   (u_long) num_bytes);
++	   (unsigned long) num_bytes);
+ 
+       /* Don't do this in sane_start() since there may be a long
+          timespan between it and the first sane_read(), which would
+_at_@ -925,7 +925,7 @@
+ 	  /* strange -- should be 15:63 below, but 4bpp is odd */
+ 	  int shift, invert;
+ 	  unsigned int i;
+-	  u_char val;
++	  unsigned char val;
+ 
+ 	  switch (s->val[OPT_DEPTH].w)
+ 	    {
+--- sane-backends-1.0.24.orig/backend/qcam.h
++++ sane-backends-1.0.24/backend/qcam.h
+_at_@ -143,7 +143,7 @@
+     size_t num_bytes;		/* # of bytes to read */
+     QC_Resolution resolution;	/* high-resolution? */
+     SANE_Parameters params;	/* other parameters */
+-    u_int mode;			/* qcam scan code (get video data command) */
++    unsigned int mode;			/* qcam scan code (get video data command) */
+     int despeckle;		/* apply despeckling filter? */
+   }
+ QC_Scan_Request;
+--- sane-backends-1.0.24.orig/backend/ricoh-scsi.c
++++ sane-backends-1.0.24/backend/ricoh-scsi.c
+_at_@ -356,7 +356,7 @@
+           if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME)
+             {
+               DBG(1, "ricoh_wait_ready: timed out after %lu seconds\n",
+-                  (u_long) (now.tv_sec - start.tv_sec));
++                  (unsigned long) (now.tv_sec - start.tv_sec));
+               return SANE_STATUS_INVAL;
+             }
+           usleep (100000);      /* retry after 100ms */
+_at_@ -397,7 +397,7 @@
+           if (now - start >= MAX_WAITING_TIME)
+             {
+               DBG(1, "ricoh_wait_ready: timed out after %lu seconds\n",
+-                  (u_long) (now - start));
++                  (unsigned long) (now - start));
+               return SANE_STATUS_INVAL;
+             }
+           break;
+--- sane-backends-1.0.24.orig/backend/ricoh.c
++++ sane-backends-1.0.24/backend/ricoh.c
+_at_@ -777,7 +777,7 @@
+ 
+   DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, "
+        "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line,
+-       s->params.lines, (u_long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w);
++       s->params.lines, (unsigned long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w);
+ 
+   DBG (11, "<< sane_get_parameters\n");
+   return (SANE_STATUS_GOOD);
+_at_@ -938,7 +938,7 @@
+ 
+   DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, "
+        "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line,
+-       s->params.lines, (u_long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w);
++       s->params.lines, (unsigned long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w);
+  
+   s->scanning = SANE_TRUE;
+ 
+_at_@ -957,7 +957,7 @@
+ 
+   *len = 0;
+ 
+-  DBG (11, "sane_read: bytes left to read: %ld\n", (u_long) s->bytes_to_read);
++  DBG (11, "sane_read: bytes left to read: %ld\n", (unsigned long) s->bytes_to_read);
+   
+   if (s->bytes_to_read == 0)
+     {
+_at_@ -974,7 +974,7 @@
+   if (nread > s->bytes_to_read)
+     nread = s->bytes_to_read;
+ 
+-  DBG (11, "sane_read: read %ld bytes\n", (u_long) nread);
++  DBG (11, "sane_read: read %ld bytes\n", (unsigned long) nread);
+   status = read_data (s->fd, buf, &nread);
+   if (status != SANE_STATUS_GOOD)
+     {
+--- sane-backends-1.0.24.orig/backend/rts8891.c
++++ sane-backends-1.0.24/backend/rts8891.c
+_at_@ -816,7 +816,7 @@
+ 	  s->val[option].wa = s->dev->model->gamma;
+ 	  DBG (DBG_error0,
+ 	       "set_option_value: not enough memory for %lu bytes!\n",
+-	       (u_long) (256 * sizeof (SANE_Word)));
++	       (unsigned long) (256 * sizeof (SANE_Word)));
+ 	  return SANE_STATUS_NO_MEM;
+ 	}
+ 
+--- sane-backends-1.0.24.orig/backend/rts88xx_lib.c
++++ sane-backends-1.0.24/backend/rts88xx_lib.c
+_at_@ -284,7 +284,7 @@
+   if (size != (size_t) length)
+     {
+       DBG (DBG_warn, "sanei_rts88xx_read_regs: read got only %lu bytes\n",
+-           (u_long) size);
++           (unsigned long) size);
+     }
+   if (DBG_LEVEL >= DBG_io)
+     {
+_at_@ -488,7 +488,7 @@
+     {
+       DBG (DBG_error,
+            "sanei_rts88xx_write_mem: only wrote %lu bytes out of %d\n",
+-           (u_long) size, length + 4);
++           (unsigned long) size, length + 4);
+       status = SANE_STATUS_IO_ERROR;
+     }
+   return status;
+_at_@ -559,7 +559,7 @@
+         {
+           DBG (DBG_error,
+                "sanei_rts88xx_read_mem: only read %lu bytes out of %lu\n",
+-               (u_long) size, (u_long) want);
++               (unsigned long) size, (unsigned long) want);
+           status = SANE_STATUS_IO_ERROR;
+         }
+       length -= size;
+_at_@ -843,7 +843,7 @@
+           return status;
+         }
+       DBG (DBG_io2, "sanei_rts88xx_read_data: read %lu bytes\n",
+-           (u_long) size);
++           (unsigned long) size);
+       read += size;
+     }
+ 
+_at_@ -858,13 +858,13 @@
+           return status;
+         }
+       DBG (DBG_io2, "sanei_rts88xx_read_data: read %lu bytes\n",
+-           (u_long) remain);
++           (unsigned long) remain);
+       read += remain;
+     }
+ 
+   /* update actual read length */
+   DBG (DBG_io, "sanei_rts88xx_read_data: read %lu bytes, %d required\n",
+-       (u_long) read, *length);
++       (unsigned long) read, *length);
+   *length = read;
+   return status;
+ }
+--- sane-backends-1.0.24.orig/backend/s9036.c
++++ sane-backends-1.0.24/backend/s9036.c
+_at_@ -121,7 +121,7 @@
+ }
+ 
+ static SANE_Status
+-sense_handler (int scsi_fd, u_char *result, void *arg)
++sense_handler (int scsi_fd, unsigned char *result, void *arg)
+ {
+   scsi_fd = scsi_fd;
+   arg = arg; /* silence compilation warnings */
+_at_@ -502,11 +502,11 @@
+       if (size != (unsigned int) lines_read * s->params.bytes_per_line)
+ 	{
+ 	  DBG (1, "sanei_scsi_cmd(): got %lu bytes, expected %d\n",
+-	       (u_long) size, lines_read * s->params.bytes_per_line);
++	       (unsigned long) size, lines_read * s->params.bytes_per_line);
+ 	  return SANE_STATUS_INVAL;
+ 	}
+ 
+-      DBG (1, "Got %lu bytes\n", (u_long) size);
++      DBG (1, "Got %lu bytes\n", (unsigned long) size);
+       break;
+     }
+ 
+_at_@ -1223,7 +1223,7 @@
+ 
+     if (!s->buffer)
+       {
+-	DBG (1, "open  malloc(%lu) failed.\n", (u_long) s->bufsize);
++	DBG (1, "open  malloc(%lu) failed.\n", (unsigned long) s->bufsize);
+ 	do_cancel (s);
+ 	return SANE_STATUS_NO_MEM;
+       }
+--- sane-backends-1.0.24.orig/backend/sharp.c
++++ sane-backends-1.0.24/backend/sharp.c
+_at_@ -322,7 +322,7 @@
+ #endif
+ 
+ static SANE_Status
+-sense_handler(int __sane_unused__ fd, u_char *sense_buffer, void *s)
++sense_handler(int __sane_unused__ fd, unsigned char *sense_buffer, void *s)
+ {
+   int sense_key;
+   SHARP_Sense_Data *sdat = (SHARP_Sense_Data *) s;
+_at_@ -520,7 +520,7 @@
+ static SANE_Status
+ test_unit_ready (int fd)
+ {
+-  static u_char cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< test_unit_ready ");
+ 
+_at_@ -534,7 +534,7 @@
+ static SANE_Status
+ request_sense (int fd, void *sense_buf, size_t *sense_size)
+ {
+-  static u_char cmd[] = {REQUEST_SENSE, 0, 0, 0, SENSE_LEN, 0};
++  static unsigned char cmd[] = {REQUEST_SENSE, 0, 0, 0, SENSE_LEN, 0};
+   SANE_Status status;
+   DBG (11, "<< request_sense ");
+ 
+_at_@ -548,7 +548,7 @@
+ static SANE_Status
+ inquiry (int fd, void *inq_buf, size_t *inq_size)
+ {
+-  static u_char cmd[] = {INQUIRY, 0, 0, 0, INQUIRY_LEN, 0};
++  static unsigned char cmd[] = {INQUIRY, 0, 0, 0, INQUIRY_LEN, 0};
+   SANE_Status status;
+   DBG (11, "<< inquiry ");
+ 
+_at_@ -561,7 +561,7 @@
+ static SANE_Status
+ mode_select_mud (int fd, int mud)
+ {
+-  static u_char cmd[6 + MODEPARAM_LEN] = 
++  static unsigned char cmd[6 + MODEPARAM_LEN] = 
+                         {MODE_SELECT6, 0x10, 0, 0, MODEPARAM_LEN, 0};
+   mode_select_param *mp;
+   SANE_Status status;
+_at_@ -583,7 +583,7 @@
+ static SANE_Status
+ mode_select_adf_fsu (int fd, int mode)
+ {
+-  static u_char cmd[6 + MODE_SUBDEV_LEN] = 
++  static unsigned char cmd[6 + MODE_SUBDEV_LEN] = 
+                         {MODE_SELECT6, 0x10, 0, 0, MODE_SUBDEV_LEN, 0};
+   mode_select_subdevice *mp;
+   SANE_Status status;
+_at_@ -626,7 +626,7 @@
+ static SANE_Status
+ object_position(int fd, int load)
+ {
+-  static u_char cmd[] = {OBJECT_POSITION, 0, 0, 0, 0, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {OBJECT_POSITION, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< object_position ");
+ 
+_at_@ -643,7 +643,7 @@
+ static SANE_Status
+ reserve_unit (int fd)
+ {
+-  static u_char cmd[] = {RESERVE_UNIT, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {RESERVE_UNIT, 0, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< reserve_unit ");
+ 
+_at_@ -658,7 +658,7 @@
+ static SANE_Status
+ release_unit (int fd)
+ {
+-  static u_char cmd[] = {RELEASE_UNIT, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {RELEASE_UNIT, 0, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< release_unit ");
+ 
+_at_@ -673,7 +673,7 @@
+ mode_sense (int fd, void *modeparam_buf, size_t * modeparam_size, 
+             int page)
+ {
+-  static u_char cmd[6];
++  static unsigned char cmd[6];
+   SANE_Status status;
+   DBG (11, "<< mode_sense ");
+ 
+_at_@ -691,7 +691,7 @@
+ static SANE_Status
+ scan (int fd)
+ {
+-  static u_char cmd[] = {SCAN, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {SCAN, 0, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< scan ");
+ 
+_at_@ -705,7 +705,7 @@
+ static SANE_Status
+ send_diagnostics (int fd)
+ {
+-  static u_char cmd[] = {SEND_DIAGNOSTIC, 0x04, 0, 0, 0, 0};
++  static unsigned char cmd[] = {SEND_DIAGNOSTIC, 0x04, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< send_diagnostics ");
+ 
+_at_@ -719,7 +719,7 @@
+ static SANE_Status
+ send (int fd, SHARP_Send * ss)
+ {
+-  static u_char cmd[] = {SEND, 0, 0, 0, 0, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {SEND, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+   SANE_Status status;
+   DBG (11, "<< send ");
+ 
+_at_@ -740,7 +740,7 @@
+ static SANE_Status
+ set_window (int fd, window_param *wp, int len)
+ {
+-  static u_char cmd[10 + WINDOW_LEN] = 
++  static unsigned char cmd[10 + WINDOW_LEN] = 
+                         {SET_WINDOW, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+   window_param *winp;
+   SANE_Status status;
+_at_@ -761,7 +761,7 @@
+ get_window (int fd, void *buf, size_t * buf_size)
+ {
+ 
+-  static u_char cmd[10] = {GET_WINDOW, 0, 0, 0, 0, 0, 0, 0, WINDOW_LEN, 0};
++  static unsigned char cmd[10] = {GET_WINDOW, 0, 0, 0, 0, 0, 0, 0, WINDOW_LEN, 0};
+   SANE_Status status;
+   DBG (11, "<< get_window ");
+ 
+_at_@ -818,7 +818,7 @@
+ {
+   SANE_Status status;
+   sigset_t sigterm_set;
+-  static u_char cmd[] = {READ, 0, 0, 0, 0, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {READ, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+   int full_count = 0, counted;
+   size_t waitindex, cmdindex;
+   size_t bytes_to_queue;
+_at_@ -1130,7 +1130,7 @@
+ static SANE_Status
+ read_data (SHARP_Scanner *s, SANE_Byte *buf, size_t * buf_size)
+ {
+-  static u_char cmd[] = {READ, 0, 0, 0, 0, 0, 0, 0, 0, 0};
++  static unsigned char cmd[] = {READ, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+   SANE_Status status = SANE_STATUS_GOOD;
+   size_t remain = *buf_size;
+   size_t nread;
+_at_@ -2228,7 +2228,7 @@
+ static SANE_Status
+ do_cancel (SHARP_Scanner * s)
+ {
+-  static u_char cmd[] = {READ, 0, 0, 0, 0, 2, 0, 0, 0, 0};
++  static unsigned char cmd[] = {READ, 0, 0, 0, 0, 2, 0, 0, 0, 0};
+ 
+   DBG (10, "<< do_cancel ");
+ 
+_at_@ -3070,8 +3070,8 @@
+     }
+   else
+     {
+-      static u_char cmd[] = {READ, 0, 0x81, 0, 0, 0, 0, 0, 4, 0};
+-      static u_char buf[4];
++      static unsigned char cmd[] = {READ, 0, 0x81, 0, 0, 0, 0, 0, 4, 0};
++      static unsigned char buf[4];
+       size_t len = 4;
+       SANE_Status status;
+ 
+_at_@ -3934,7 +3934,7 @@
+ 
+   DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, "
+        "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line,
+-       s->params.lines, (u_long) s->bytes_to_read, s->val[OPT_X_RESOLUTION].w);
++       s->params.lines, (unsigned long) s->bytes_to_read, s->val[OPT_X_RESOLUTION].w);
+ 
+   s->busy = SANE_FALSE;
+   s->buf_used = 0;
+_at_@ -3961,7 +3961,7 @@
+   size_t nread;
+   DBG (10, "<< sane_read_direct ");
+ 
+-  DBG (20, "remaining: %lu ", (u_long) s->bytes_to_read);
++  DBG (20, "remaining: %lu ", (unsigned long) s->bytes_to_read);
+   *len = 0;
+ 
+   if (s->bytes_to_read == 0)
+_at_@ -3990,7 +3990,7 @@
+     }
+   *len = nread;
+   s->bytes_to_read -= nread;
+-  DBG (20, "remaining: %lu ", (u_long) s->bytes_to_read);
++  DBG (20, "remaining: %lu ", (unsigned long) s->bytes_to_read);
+ 
+   DBG (10, ">>\n");
+   return (SANE_STATUS_GOOD);
+--- sane-backends-1.0.24.orig/backend/sharp.h
++++ sane-backends-1.0.24/backend/sharp.h
+_at_@ -208,7 +208,7 @@
+     */
+     int complain_on_errors;
+     /* Linux returns only 16 bytes of sense data... */
+-    u_char sb[16]; 
++    unsigned char sb[16]; 
+   }
+ SHARP_Sense_Data;
+ 
+_at_@ -290,8 +290,8 @@
+ 
+ typedef struct WPDH
+ {
+-    u_char wpdh[6];
+-    u_char wdl[2];
++    unsigned char wpdh[6];
++    unsigned char wdl[2];
+ } 
+ WPDH;
+ 
+--- sane-backends-1.0.24.orig/backend/sm3840.c
++++ sane-backends-1.0.24/backend/sm3840.c
+_at_@ -151,7 +151,7 @@
+        (unsigned char *) len);
+   DBG (2,
+        "+sane-read:remain:%lu offset:%lu linesleft:%d linebuff:%p linesread:%d\n",
+-       (u_long)s->remaining, (u_long)s->offset, s->linesleft, s->line_buffer, s->linesread);
++       (unsigned long)s->remaining, (unsigned long)s->offset, s->linesleft, s->line_buffer, s->linesread);
+ 
+   if (!s->scanning)
+     return SANE_STATUS_INVAL;
+--- sane-backends-1.0.24.orig/backend/snapscan-scsi.c
++++ sane-backends-1.0.24/backend/snapscan-scsi.c
+_at_@ -100,11 +100,11 @@
+ /* a sensible sense handler, courtesy of Franck;
+    the last argument is expected to be a pointer to the associated
+    SnapScan_Scanner structure */
+-static SANE_Status sense_handler (int scsi_fd, u_char * result, void *arg)
++static SANE_Status sense_handler (int scsi_fd, unsigned char * result, void *arg)
+ {
+     static char me[] = "sense_handler";
+     SnapScan_Scanner *pss = (SnapScan_Scanner *) arg;
+-    u_char sense, asc, ascq;
++    unsigned char sense, asc, ascq;
+     char *sense_str = NULL, *as_str = NULL;
+     SANE_Status status = SANE_STATUS_GOOD;
+ 
+_at_@ -297,7 +297,7 @@
+ 
+ /*  buffer tools */
+ 
+-static void zero_buf (u_char * buf, size_t len)
++static void zero_buf (unsigned char * buf, size_t len)
+ {
+     size_t i;
+ 
+_at_@ -308,29 +308,29 @@
+ 
+ #define BYTE_SIZE 8
+ 
+-static u_short u_char_to_u_short (u_char * pc)
++static unsigned short u_char_to_u_short (unsigned char * pc)
+ {
+-    u_short r = 0;
++    unsigned short r = 0;
+     r |= pc[0];
+     r = r << BYTE_SIZE;
+     r |= pc[1];
+     return r;
+ }
+ 
+-static void u_short_to_u_charp (u_short x, u_char * pc)
++static void u_short_to_u_charp (unsigned short x, unsigned char * pc)
+ {
+     pc[0] = (0xFF00 & x) >> BYTE_SIZE;
+     pc[1] = (0x00FF & x);
+ }
+ 
+-static void u_int_to_u_char3p (u_int x, u_char * pc)
++static void u_int_to_u_char3p (unsigned int x, unsigned char * pc)
+ {
+     pc[0] = (0xFF0000 & x) >> 2 * BYTE_SIZE;
+     pc[1] = (0x00FF00 & x) >> BYTE_SIZE;
+     pc[2] = (0x0000FF & x);
+ }
+ 
+-static void u_int_to_u_char4p (u_int x, u_char * pc)
++static void u_int_to_u_char4p (unsigned int x, unsigned char * pc)
+ {
+     pc[0] = (0xFF000000 & x) >> 3 * BYTE_SIZE;
+     pc[1] = (0x00FF0000 & x) >> 2 * BYTE_SIZE;
+_at_@ -502,16 +502,16 @@
+     default:
+     {
+         signed char min_diff;
+-        u_char r_off, g_off, b_off;
++        unsigned char r_off, g_off, b_off;
+         signed char g = (pss->buf[INQUIRY_G2R_DIFF] & 0x80) ? -(pss->buf[INQUIRY_G2R_DIFF] & 0x7F) : pss->buf[INQUIRY_G2R_DIFF];
+         signed char b = (pss->buf[INQUIRY_B2R_DIFF] & 0x80) ? -(pss->buf[INQUIRY_B2R_DIFF] & 0x7F) : pss->buf[INQUIRY_B2R_DIFF];
+         DBG (DL_DATA_TRACE, "%s: G2R_DIFF: %d\n", me, pss->buf[INQUIRY_G2R_DIFF]);
+         DBG (DL_DATA_TRACE, "%s: B2R_DIFF: %d\n", me, pss->buf[INQUIRY_B2R_DIFF]);
+ 
+         min_diff = MIN (MIN (b, g), 0);
+-        r_off = (u_char) (0 - min_diff);
+-        g_off = (u_char) (g - min_diff);
+-        b_off = (u_char) (b - min_diff);
++        r_off = (unsigned char) (0 - min_diff);
++        g_off = (unsigned char) (g - min_diff);
++        b_off = (unsigned char) (b - min_diff);
+         pss->chroma_offset[R_CHAN] = r_off;
+         pss->chroma_offset[G_CHAN] = g_off;
+         pss->chroma_offset[B_CHAN] = b_off;
+_at_@ -578,28 +578,28 @@
+     DBG (DL_DATA_TRACE,
+         "%s: bits per pixel = %lu\n",
+         me,
+-        (u_long) pss->bpp);
++        (unsigned long) pss->bpp);
+     DBG (DL_DATA_TRACE,
+         "%s: pixels per scan line = %lu\n",
+         me,
+-        (u_long) pss->pixels_per_line);
++        (unsigned long) pss->pixels_per_line);
+     DBG (DL_DATA_TRACE,
+         "%s: bytes per scan line = %lu\n",
+         me,
+-        (u_long) pss->bytes_per_line);
++        (unsigned long) pss->bytes_per_line);
+     DBG (DL_DATA_TRACE,
+         "%s: number of scan lines = %lu\n",
+         me,
+-        (u_long) pss->lines);
++        (unsigned long) pss->lines);
+     DBG (DL_DATA_TRACE,
+          "%s: effective buffer size = %lu bytes, %lu lines\n",
+          me,
+-        (u_long) pss->buf_sz,
+-        (u_long) (pss->lines ? pss->buf_sz / pss->lines : 0));
++        (unsigned long) pss->buf_sz,
++        (unsigned long) (pss->lines ? pss->buf_sz / pss->lines : 0));
+     DBG (DL_DATA_TRACE,
+         "%s: expected total scan data: %lu bytes\n",
+         me,
+-        (u_long) pss->bytes_remaining);
++        (unsigned long) pss->bytes_remaining);
+ 
+     return status;
+ }
+_at_@ -685,11 +685,11 @@
+ #define DTCQ_GAMMA_GREEN14_16BIT 0xa7
+ #define DTCQ_GAMMA_BLUE14_16BIT 0xa8
+ 
+-static SANE_Status send (SnapScan_Scanner *pss, u_char dtc, u_char dtcq)
++static SANE_Status send (SnapScan_Scanner *pss, unsigned char dtc, unsigned char dtcq)
+ {
+     static char me[] = "send";
+     SANE_Status status;
+-    u_short tl;            /* transfer length */
++    unsigned short tl;            /* transfer length */
+ 
+     DBG (DL_CALL_TRACE, "%s\n", me);
+ 
+_at_@ -847,7 +847,7 @@
+ static SANE_Status prepare_set_window (SnapScan_Scanner *pss)
+ {
+     static const char *me = "prepare_set_window";
+-    u_char *pc;
++    unsigned char *pc;
+ 
+     DBG (DL_CALL_TRACE, "%s\n", me);
+     zero_buf (pss->cmd, MAX_SCSI_CMD_LEN);
+_at_@ -871,7 +871,7 @@
+ 
+     pc[SET_WINDOW_P_BRIGHTNESS] = 128;
+     pc[SET_WINDOW_P_THRESHOLD] =
+-        (u_char) (255.0*(pss->threshold / 100.0));
++        (unsigned char) (255.0*(pss->threshold / 100.0));
+     pc[SET_WINDOW_P_CONTRAST] = 128;
+ 
+     {
+_at_@ -954,7 +954,7 @@
+     static const char *me = "set_window";
+     SANE_Status status;
+     unsigned char source;
+-    u_char *pc;
++    unsigned char *pc;
+     int pos_factor;
+ 
+     DBG (DL_CALL_TRACE, "%s\n", me);
+_at_@ -1115,19 +1115,19 @@
+     return status;
+ }
+ 
+-static SANE_Int get_8 (u_char *p)
++static SANE_Int get_8 (unsigned char *p)
+ {
+     SANE_Int b;
+     b = p[0] | (p[1] << 8);
+     return b;
+ }
+ 
+-static double get_val (u_char *p, SANE_Int len, SANE_Int x)
++static double get_val (unsigned char *p, SANE_Int len, SANE_Int x)
+ {
+ 	return get_8 (p + ((x + len) << 1)) / 255.0;
+ }
+ 
+-static double sum_pixel_differences (u_char *p, int len)
++static double sum_pixel_differences (unsigned char *p, int len)
+ {
+ 	double v, m, s;
+ 	SANE_Int i;
+_at_@ -1160,7 +1160,7 @@
+ #define READ_TRANSTIME 0x80
+ 
+ /* number of bytes expected must be in pss->expected_read_bytes */
+-static SANE_Status scsi_read (SnapScan_Scanner *pss, u_char read_type)
++static SANE_Status scsi_read (SnapScan_Scanner *pss, unsigned char read_type)
+ {
+     static const char *me = "scsi_read";
+     SANE_Status status;
+_at_@ -1241,8 +1241,8 @@
+ {
+     static const char *me = "request_sense";
+     size_t read_bytes = 0;
+-    u_char cmd[] = {REQUEST_SENSE, 0, 0, 0, 20, 0};
+-    u_char data[20];
++    unsigned char cmd[] = {REQUEST_SENSE, 0, 0, 0, 20, 0};
++    unsigned char data[20];
+     SANE_Status status;
+ 
+     read_bytes = 20;
+_at_@ -1266,7 +1266,7 @@
+ static SANE_Status send_diagnostic (SnapScan_Scanner *pss)
+ {
+     static const char *me = "send_diagnostic";
+-    u_char cmd[] = {SEND_DIAGNOSTIC, 0x04, 0, 0, 0, 0};    /* self-test */
++    unsigned char cmd[] = {SEND_DIAGNOSTIC, 0x04, 0, 0, 0, 0};    /* self-test */
+     SANE_Status status;
+ 
+     if (pss->pdev->model == PRISA620
+_at_@ -1353,7 +1353,7 @@
+ 
+ static SANE_Status calibrate_epson (SnapScan_Scanner *pss)
+ {
+-    u_char *buf, *pbuf;
++    unsigned char *buf, *pbuf;
+     int *bins;
+     static const char *me = "calibrate_epson";
+     /* pixels_per_line = 8.5 inch * resolution of one sensor */
+_at_@ -1386,15 +1386,15 @@
+     /* allocate memory for bins, all the red, then green, then blue */
+     bins = (int *) malloc (num_bins * sizeof (int));
+     if (!bins) {
+-        DBG (DL_MAJOR_ERROR, "%s: out of memory allocating bins, %ld bytes.", me, (u_long)num_bins * sizeof (int));
++        DBG (DL_MAJOR_ERROR, "%s: out of memory allocating bins, %ld bytes.", me, (unsigned long)num_bins * sizeof (int));
+         return SANE_STATUS_NO_MEM;
+     }
+ 
+     /* allocate buffer for receive data */
+     expected_read_bytes = pixels_per_line * 3 * 4;
+-    buf = (u_char *) malloc (expected_read_bytes);
++    buf = (unsigned char *) malloc (expected_read_bytes);
+     if (!buf) {
+-        DBG (DL_MAJOR_ERROR, "%s: out of memory allocating calibration, %ld bytes.", me, (u_long)expected_read_bytes);
++        DBG (DL_MAJOR_ERROR, "%s: out of memory allocating calibration, %ld bytes.", me, (unsigned long)expected_read_bytes);
+         free (bins);
+         return SANE_STATUS_NO_MEM;
+     }
+_at_@ -1441,7 +1441,7 @@
+             }
+ 
+             if (read_bytes != expected_read_bytes) {
+-                DBG (DL_MAJOR_ERROR, "%s: read %lu of %lu calibration data\n", me, (u_long) read_bytes, (u_long) expected_read_bytes);
++                DBG (DL_MAJOR_ERROR, "%s: read %lu of %lu calibration data\n", me, (unsigned long) read_bytes, (unsigned long) expected_read_bytes);
+                 free (bins);
+                 free (buf);
+                 return SANE_STATUS_IO_ERROR;
+_at_@ -1510,7 +1510,7 @@
+     return SANE_STATUS_GOOD;
+ }
+ 
+-static SANE_Status read_calibration_data (SnapScan_Scanner *pss, void *buf, u_char num_lines)
++static SANE_Status read_calibration_data (SnapScan_Scanner *pss, void *buf, unsigned char num_lines)
+ {
+     static const char *me = "read_calibration_data";
+     SANE_Status status;
+_at_@ -1530,7 +1530,7 @@
+     CHECK_STATUS (status, me, "snapscan_cmd");
+ 
+     if(read_bytes != expected_read_bytes) {
+-    DBG (DL_MAJOR_ERROR, "%s: read %lu of %lu calibration data\n", me, (u_long) read_bytes, (u_long) expected_read_bytes);
++    DBG (DL_MAJOR_ERROR, "%s: read %lu of %lu calibration data\n", me, (unsigned long) read_bytes, (unsigned long) expected_read_bytes);
+     return SANE_STATUS_IO_ERROR;
+     }
+ 
+_at_@ -1541,7 +1541,7 @@
+ {
+     int r;
+     int c;
+-    u_char *buf;
++    unsigned char *buf;
+     static const char *me = "calibrate";
+     SANE_Status status;
+     int line_length = calibration_line_length(pss);
+_at_@ -1568,7 +1568,7 @@
+             DBG(DL_MAJOR_ERROR, "%s: scsi request size underflow (< %d bytes)", me, line_length);
+             return SANE_STATUS_IO_ERROR;
+         }
+-        buf = (u_char *) malloc(num_lines * line_length);
++        buf = (unsigned char *) malloc(num_lines * line_length);
+         if (!buf)
+         {
+             DBG (DL_MAJOR_ERROR, "%s: out of memory allocating calibration, %d bytes.", me, num_lines * line_length);
+_at_@ -1580,7 +1580,7 @@
+         CHECK_STATUS(status, me, "read_calibration_data");
+ 
+         for(c=0; c < line_length; c++) {
+-            u_int sum = 0;
++            unsigned int sum = 0;
+             for(r=0; r < num_lines; r++) {
+                 sum += buf[c + r * line_length];
+             }
+_at_@ -1686,7 +1686,7 @@
+                 break;
+             }
+ 
+-            DBG(DL_INFO, "Size of firmware: %lu\n", (u_long) bufLength);
++            DBG(DL_INFO, "Size of firmware: %lu\n", (unsigned long) bufLength);
+             pCDB = (unsigned char *)malloc(bufLength + cdbLength);
+             pFwBuf = pCDB + cdbLength;
+             zero_buf (pCDB, cdbLength);
+--- sane-backends-1.0.24.orig/backend/snapscan-sources.c
++++ sane-backends-1.0.24/backend/snapscan-sources.c
+_at_@ -193,8 +193,8 @@
+             ndata = ps->pss->read_bytes;
+             ps->pss->bytes_remaining -= ps->pss->read_bytes;
+             DBG (DL_DATA_TRACE, "%s: pos: %d; max: %d; expected: %lu; read: %lu\n",
+-                me, ps->scsi_buf_pos, ps->scsi_buf_max, (u_long) ps->pss->expected_read_bytes,
+-                (u_long) ps->pss->read_bytes);
++                me, ps->scsi_buf_pos, ps->scsi_buf_max, (unsigned long) ps->pss->expected_read_bytes,
++                (unsigned long) ps->pss->read_bytes);
+         }
+         ndata = MIN(ndata, remaining);
+         memcpy (pbuf, ps->pss->buf + ps->scsi_buf_pos, (size_t)ndata);
+_at_@ -819,7 +819,7 @@
+         pself->remaining(pself),
+         *plen,
+         TxSource_remaining(pself),
+-        (u_long) ps->pss->bytes_remaining);    
++        (unsigned long) ps->pss->bytes_remaining);    
+     return status;
+ }
+ 
+_at_@ -932,7 +932,7 @@
+     SANE_Int round_read;
+ } RGBRouter;
+ 
+-static void put_int16r (int n, u_char *p)
++static void put_int16r (int n, unsigned char *p)
+ {
+ 	p[0] = (n & 0x00ff);
+ 	p[1] = (n & 0xff00) >> 8;
+_at_@ -1057,7 +1057,7 @@
+         pself->remaining(pself),
+         *plen,
+         TxSource_remaining(pself),
+-        (u_long) ps->pss->bytes_remaining);
++        (unsigned long) ps->pss->bytes_remaining);
+     return status;
+ }
+ 
+--- sane-backends-1.0.24.orig/backend/snapscan-usb.c
++++ sane-backends-1.0.24/backend/snapscan-usb.c
+_at_@ -105,7 +105,7 @@
+     int status;
+ 
+     DBG (DL_CALL_TRACE, "%s(%d,0x%lx,%lu,0x%lx,0x%lx (%lu))\n", me,
+-         fd, (u_long) src,(u_long) src_size,(u_long) dst, (u_long) dst_size,(u_long) (dst_size ? *dst_size : 0));
++         fd, (unsigned long) src,(unsigned long) src_size,(unsigned long) dst, (unsigned long) dst_size,(unsigned long) (dst_size ? *dst_size : 0));
+ 
+     while(bqhead) {
+         status = atomic_usb_cmd(fd, bqhead->src, bqhead->src_size, NULL, NULL);
+_at_@ -140,7 +140,7 @@
+     sigset_t all,oldset;
+ 
+     DBG (DL_CALL_TRACE, "%s(%d,0x%lx,%lu,0x%lx,0x%lx (%lu))\n", me,
+-         fd, (u_long) src,(u_long) src_size,(u_long) dst, (u_long) dst_size,(u_long) (dst_size ? *dst_size : 0));
++         fd, (unsigned long) src,(unsigned long) src_size,(unsigned long) dst, (unsigned long) dst_size,(unsigned long) (dst_size ? *dst_size : 0));
+ 
+     /* Prevent the calling process from being killed */
+     sigfillset(&all);
+_at_@ -283,11 +283,11 @@
+ 
+     status = sanei_usb_write_bulk(fd, (const SANE_Byte*)buf, &bytes_written);
+     if(bytes_written != n) {
+-      DBG (DL_MAJOR_ERROR, "%s Only %lu bytes written\n",me, (u_long) bytes_written);
++      DBG (DL_MAJOR_ERROR, "%s Only %lu bytes written\n",me, (unsigned long) bytes_written);
+         status = SANE_STATUS_IO_ERROR;
+     }
+     urb_counters->write_urbs += (bytes_written + 7) / 8;
+-    DBG (DL_DATA_TRACE, "Written %lu bytes\n", (u_long) bytes_written);
++    DBG (DL_DATA_TRACE, "Written %lu bytes\n", (unsigned long) bytes_written);
+     return status;
+ }
+ 
+_at_@ -299,12 +299,12 @@
+ 
+     status = sanei_usb_read_bulk(fd, (SANE_Byte*)buf, &bytes_read);
+     if (bytes_read != n) {
+-        DBG (DL_MAJOR_ERROR, "%s Only %lu bytes read\n",me, (u_long) bytes_read);
++        DBG (DL_MAJOR_ERROR, "%s Only %lu bytes read\n",me, (unsigned long) bytes_read);
+         status = SANE_STATUS_IO_ERROR;
+     }
+     urb_counters->read_urbs += ((63 + bytes_read) / 64); 
+     DBG(DL_DATA_TRACE, "%s: reading: %s\n",me,usb_debug_data(dbgmsg,buf,n));
+-    DBG(DL_DATA_TRACE, "Read %lu bytes\n", (u_long) bytes_read);
++    DBG(DL_DATA_TRACE, "Read %lu bytes\n", (unsigned long) bytes_read);
+     return status;
+ }
+ 
+_at_@ -361,7 +361,7 @@
+   char command;
+ 
+   DBG (DL_CALL_TRACE, "%s(%d,0x%lx,%lu,0x%lx,0x%lx (%lu))\n", me,
+-       fd, (u_long) src,(u_long) src_size,(u_long) dst, (u_long) dst_size,(u_long) (dst_size ? *dst_size : 0));
++       fd, (unsigned long) src,(unsigned long) src_size,(unsigned long) dst, (unsigned long) dst_size,(unsigned long) (dst_size ? *dst_size : 0));
+ 
+   /* Since the  "Send Diagnostic" command isn't supported by
+      all Snapscan USB-scanners it's disabled .
+_at_@ -433,7 +433,7 @@
+     static const char me[] = "enqueue_bq";
+     struct usb_busy_queue *bqe;
+ 
+-    DBG (DL_CALL_TRACE, "%s(%d,%p,%lu)\n", me, fd,src, (u_long) src_size);
++    DBG (DL_CALL_TRACE, "%s(%d,%p,%lu)\n", me, fd,src, (unsigned long) src_size);
+ 
+     if((bqe = malloc(sizeof(struct usb_busy_queue))) == NULL)
+         return -1;
+_at_@ -485,8 +485,8 @@
+ static SANE_Status usb_request_sense(SnapScan_Scanner *pss) {
+     static const char *me = "usb_request_sense";
+     size_t read_bytes = 0;
+-    u_char cmd[] = {REQUEST_SENSE, 0, 0, 0, 20, 0};
+-    u_char data[20];
++    unsigned char cmd[] = {REQUEST_SENSE, 0, 0, 0, 20, 0};
++    unsigned char data[20];
+     SANE_Status status;
+ 
+     read_bytes = 20;
+--- sane-backends-1.0.24.orig/backend/snapscan-usb.h
++++ sane-backends-1.0.24/backend/snapscan-usb.h
+_at_@ -51,7 +51,7 @@
+ #ifndef snapscan_usb_h
+ #define snapscan_usb_h
+ 
+-typedef SANE_Status (*sense_handler_type)(int fd, u_char *sense_buffer, void *arg);
++typedef SANE_Status (*sense_handler_type)(int fd, unsigned char *sense_buffer, void *arg);
+ 
+ static SANE_Status snapscani_usb_cmd(int fd, const void *src, size_t src_size,
+                          void *dst, size_t * dst_size);
+--- sane-backends-1.0.24.orig/backend/snapscan.c
++++ sane-backends-1.0.24/backend/snapscan.c
+_at_@ -152,8 +152,8 @@
+ /* function prototypes */
+ 
+ static void gamma_n (double gamma, int brightness, int contrast,
+-                     u_char *buf, int length, int gamma_mode);
+-static void gamma_to_sane (int length, u_char *in, SANE_Int *out);
++                     unsigned char *buf, int length, int gamma_mode);
++static void gamma_to_sane (int length, unsigned char *in, SANE_Int *out);
+ 
+ static size_t max_string_size(SANE_String_Const strings[]);
+ 
+_at_@ -250,7 +250,7 @@
+ 
+ static SANE_Status init_gamma(SnapScan_Scanner * ps)
+ {
+-    u_char *gamma;
++    unsigned char *gamma;
+ 
+     gamma = (u_char*) malloc(ps->gamma_length * sizeof(u_char) * 2);
+ 
+_at_@ -295,7 +295,7 @@
+ 
+ /* gamma table computation */
+ static void gamma_n (double gamma, int brightness, int contrast,
+-                      u_char *buf, int bpp, int gamma_mode)
++                      unsigned char *buf, int bpp, int gamma_mode)
+ {
+     int i;
+     double i_gamma = 1.0/gamma;
+_at_@ -331,7 +331,7 @@
+     }
+ }
+ 
+-static void gamma_from_sane (int length, SANE_Int *in, u_char *out, int gamma_mode)
++static void gamma_from_sane (int length, SANE_Int *in, unsigned char *out, int gamma_mode)
+ {
+     int i;
+     for (i = 0; i < length; i++)
+_at_@ -344,7 +344,7 @@
+             out[i] = (u_char) LIMIT(in[i] / 256, 0, 255);
+ }
+ 
+-static void gamma_to_sane (int length, u_char *in, SANE_Int *out)
++static void gamma_to_sane (int length, unsigned char *in, SANE_Int *out)
+ {
+     int i;
+     for (i = 0; i < length; i++)
+_at_@ -360,11 +360,11 @@
+    are the matrices of interest to us, since the SnapScan supports
+    only 8x8 and 16x16 dither matrices. */
+ 
+-static u_char D2[] ={0, 2, 3, 1};
++static unsigned char D2[] ={0, 2, 3, 1};
+ 
+-static u_char D4[16], D8[64], D16[256];
++static unsigned char D4[16], D8[64], D16[256];
+ 
+-static void mkDn (u_char *Dn, u_char *Dn_half, unsigned n)
++static void mkDn (unsigned char *Dn, unsigned char *Dn_half, unsigned n)
+ {
+     unsigned int x, y;
+     for (y = 0; y < n; y++) {
+_at_@ -781,7 +781,7 @@
+     mkDn (D16, D8, 16);
+     /* scale the D8 matrix from 0..63 to 0..255 */
+     {
+-        u_char i;
++        unsigned char i;
+         for (i = 0;  i < 64;  i++)
+             D8[i] = (u_char) (4 * D8[i] + 2);
+     }
+_at_@ -913,8 +913,8 @@
+             }
+             DBG (DL_DATA_TRACE,
+                 "%s: Allocating %lu bytes as scanner buffer.\n",
+-                me, (u_long) pss->phys_buf_sz);
+-            pss->buf = (u_char *) malloc(pss->phys_buf_sz);
++                me, (unsigned long) pss->phys_buf_sz);
++            pss->buf = (unsigned char *) malloc(pss->phys_buf_sz);
+             if (!pss->buf) {
+                 DBG (DL_MAJOR_ERROR,
+                 "%s: out of memory creating scanner buffer.\n",
+_at_@ -1322,7 +1322,7 @@
+     return status;
+ }
+ 
+-static SANE_Status send_gamma_table (SnapScan_Scanner *pss, u_char dtc, u_char dtcq)
++static SANE_Status send_gamma_table (SnapScan_Scanner *pss, unsigned char dtc, unsigned char dtcq)
+ {
+     static char me[] = "send_gamma_table";
+     SANE_Status status = SANE_STATUS_GOOD;
+_at_@ -1548,9 +1548,9 @@
+     if ((pss->halftone) &&
+         ((actual_mode(pss) == MD_LINEART) || (actual_mode(pss) == MD_BILEVELCOLOUR)))
+     {
+-        u_char *matrix;
++        unsigned char *matrix;
+         size_t matrix_sz;
+-        u_char dtcq;
++        unsigned char dtcq;
+ 
+         if (pss->dither_matrix == dm_dd8x8)
+         {
+_at_@ -1733,7 +1733,7 @@
+          "%s: after measuring speed:\n\t%lu bytes per scan line\n"
+          "\t%f milliseconds per scan line.\n\t==>%f bytes per millisecond\n",
+          me,
+-         (u_long) pss->bytes_per_line,
++         (unsigned long) pss->bytes_per_line,
+          pss->ms_per_line,
+          pss->bytes_per_line/pss->ms_per_line);
+ 
+--- sane-backends-1.0.24.orig/backend/snapscan.h
++++ sane-backends-1.0.24/backend/snapscan.h
+_at_@ -368,8 +368,8 @@
+     SnapScan_Mode preview_mode;   /* preview mode */
+     SnapScan_Source source;       /* scanning source */
+     SnapScan_State state;         /* scanner state */
+-    u_char cmd[MAX_SCSI_CMD_LEN]; /* scsi command buffer */
+-    u_char *buf;                  /* data buffer */
++    unsigned char cmd[MAX_SCSI_CMD_LEN]; /* scsi command buffer */
++    unsigned char *buf;                  /* data buffer */
+     size_t phys_buf_sz;           /* physical buffer size */
+     size_t buf_sz;                /* effective buffer size */
+     size_t expected_read_bytes;   /* expected amount of data in a single read */
+_at_@ -379,15 +379,15 @@
+     size_t lines;                 /* number of scan lines */
+     size_t bytes_per_line;        /* bytes per scan line */
+     size_t pixels_per_line;       /* pixels per scan line */
+-    u_char hconfig;               /* hardware configuration byte */
+-    u_char hconfig_epson;         /* additional hw configuration for some Epson scanners */
+-    u_char hwst;                  /* hardware status byte */
++    unsigned char hconfig;               /* hardware configuration byte */
++    unsigned char hconfig_epson;         /* additional hw configuration for some Epson scanners */
++    unsigned char hwst;                  /* hardware status byte */
+     float ms_per_line;            /* speed: milliseconds per scan line */
+     SANE_Bool nonblocking;        /* wait on reads for data? */
+     char *sense_str;              /* sense string */
+     char *as_str;                 /* additional sense string */
+-    u_char asi1;                  /* first additional sense info byte */
+-    u_char asi2;                  /* second additional sense info byte */
++    unsigned char asi1;                  /* first additional sense info byte */
++    unsigned char asi2;                  /* second additional sense info byte */
+     SANE_Byte chroma_offset[3];   /* chroma offsets */
+     SANE_Int chroma;
+     Source *psrc;                 /* data source */
+--- sane-backends-1.0.24.orig/backend/sp15c.c
++++ sane-backends-1.0.24/backend/sp15c.c
+_at_@ -1080,7 +1080,7 @@
+ }                               /* attach_one */
+ 
+ static SANE_Status
+-sense_handler (int scsi_fd, u_char * result, void *arg)
++sense_handler (int scsi_fd, unsigned char * result, void *arg)
+ {
+   scsi_fd = scsi_fd;
+   arg = arg; /* silence compilation warnings */
+_at_@ -1089,7 +1089,7 @@
+ }                               /* sense_handler */
+ 
+ static int
+-request_sense_parse (u_char * sensed_data)
++request_sense_parse (unsigned char * sensed_data)
+ {
+   unsigned int ret, sense, asc, ascq;
+   sense = get_RS_sense_key (sensed_data);
+_at_@ -1342,13 +1342,13 @@
+   if ((out_len != 0) && (out_len != ol))
+     {
+       DBG (1, "sanei_scsi_cmd: asked %lu bytes, got %lu\n",
+-           (u_long) out_len, (u_long) ol);
++           (unsigned long) out_len, (unsigned long) ol);
+     }
+   if (ret)
+     {
+       DBG (1, "sanei_scsi_cmd: returning 0x%08x\n", ret);
+     }
+-  DBG (10, "sanei_scsi_cmd: returning %lu bytes:\n", (u_long) ol);
++  DBG (10, "sanei_scsi_cmd: returning %lu bytes:\n", (unsigned long) ol);
+   if (out != NULL && out_len != 0)
+     hexdump (15, ">rslt>", out, (out_len > 0x60) ? 0x60 : out_len);
+ 
+--- sane-backends-1.0.24.orig/backend/sp15c.h
++++ sane-backends-1.0.24/backend/sp15c.h
+_at_@ -246,10 +246,10 @@
+   attach_scanner (const char *devicename, struct sp15c **devp);
+ 
+ static SANE_Status
+-  sense_handler (int scsi_fd, u_char * result, void *arg);
++  sense_handler (int scsi_fd, unsigned char * result, void *arg);
+ 
+ static int
+-  request_sense_parse (u_char * sensed_data);
++  request_sense_parse (unsigned char * sensed_data);
+ 
+ static SANE_Status
+   sp15c_identify_scanner (struct sp15c *s);
+--- sane-backends-1.0.24.orig/backend/st400.c
++++ sane-backends-1.0.24/backend/st400.c
+_at_@ -205,9 +205,9 @@
+ 	scsi_cmd.cmd = CMD_INQUIRY;
+ 	scsi_cmd.tr_len = inqlen;
+ 
+-	DBG(DSCSI, "SCSI: sending INQUIRY (%lu bytes)\n", (u_long)inqlen);
++	DBG(DSCSI, "SCSI: sending INQUIRY (%lu bytes)\n", (unsigned long)inqlen);
+ 	status = sanei_scsi_cmd(fd, &scsi_cmd, sizeof(scsi_cmd), &inqdata, &inqlen);
+-	DBG(DSCSI, "SCSI: result=%s (%lu bytes)\n", sane_strstatus(status), (u_long)inqlen);
++	DBG(DSCSI, "SCSI: result=%s (%lu bytes)\n", sane_strstatus(status), (unsigned long)inqlen);
+ 	if( status != SANE_STATUS_GOOD )
+ 		return status;
+ 
+_at_@ -368,9 +368,9 @@
+ 	scsi_cmd.cmd = CMD_READ10;
+ 	set24(scsi_cmd.tr_len, *lenP);
+ 
+-	DBG(DSCSI, "SCSI: sending READ10 (%lu bytes)\n", (u_long)(*lenP));
++	DBG(DSCSI, "SCSI: sending READ10 (%lu bytes)\n", (unsigned long)(*lenP));
+ 	status = sanei_scsi_cmd(fd, &scsi_cmd, sizeof(scsi_cmd), buf, lenP);
+-	DBG(DSCSI, "SCSI: result=%s (%lu bytes)\n", sane_strstatus(status), (u_long)(*lenP));
++	DBG(DSCSI, "SCSI: result=%s (%lu bytes)\n", sane_strstatus(status), (unsigned long)(*lenP));
+ 
+ 	return status;
+ }
+_at_@ -587,11 +587,11 @@
+ 		if( *opt == '\0' )
+ 			return SANE_STATUS_GOOD;
+ 		else {
+-			DBG(DERR, "extraneous arguments at line %lu: %s\n", (u_long)linenum, opt);
++			DBG(DERR, "extraneous arguments at line %lu: %s\n", (unsigned long)linenum, opt);
+ 			return SANE_STATUS_INVAL;
+ 		}
+ 	}
+-	DBG(DERR, "invalid option argument at line %lu: %s\n", (u_long)linenum, opt);
++	DBG(DERR, "invalid option argument at line %lu: %s\n", (unsigned long)linenum, opt);
+ 	return SANE_STATUS_INVAL;
+ }
+ 
+_at_@ -1135,7 +1135,7 @@
+ 			dev->bufsize = min(dev->model->maxread, (unsigned int) sanei_scsi_max_request_size);
+ 		else
+ 			dev->bufsize = sanei_scsi_max_request_size;
+-		DBG(DVAR, "allocating %lu bytes buffer\n", (u_long)dev->bufsize);
++		DBG(DVAR, "allocating %lu bytes buffer\n", (unsigned long)dev->bufsize);
+ 		dev->buffer = malloc(dev->bufsize);
+ 		if( !dev->buffer )
+ 			return SANE_STATUS_NO_MEM;
+--- sane-backends-1.0.24.orig/backend/tamarack.c
++++ sane-backends-1.0.24/backend/tamarack.c
+_at_@ -179,7 +179,7 @@
+ 
+ 
+ static SANE_Status
+-sense_handler (int scsi_fd, u_char *result, void *arg)
++sense_handler (int scsi_fd, unsigned char *result, void *arg)
+ {
+   scsi_fd = scsi_fd;
+   arg = arg; /* silence compilation warnings */
+--- sane-backends-1.0.24.orig/backend/teco3.c
++++ sane-backends-1.0.24/backend/teco3.c
+_at_@ -1358,7 +1358,7 @@
+       MKSCSI_READ_10 (cdb, 0, 0, size);
+ 
+       hexdump (DBG_info2, "teco_fill_image: READ_10 CDB", cdb.data, 10);
+-      DBG (DBG_info, "  image_end=%lu\n", (u_long) dev->image_end);
++      DBG (DBG_info, "  image_end=%lu\n", (unsigned long) dev->image_end);
+ 
+       if (dev->scan_mode == TECO_COLOR && dev->does_color_shift)
+ 	{
+--- sane-backends-1.0.24.orig/backend/test.c
++++ sane-backends-1.0.24/backend/test.c
+_at_@ -1262,7 +1262,7 @@
+     return status;
+ 
+   DBG (2, "(child) reader_process: buffer=%p, buffersize=%lu\n",
+-       buffer, (u_long) buffer_size);
++       buffer, (unsigned long) buffer_size);
+ 
+   while (byte_count < bytes_total)
+     {
+_at_@ -1284,7 +1284,7 @@
+ 	}
+       byte_count += bytes_written;
+       DBG (4, "(child) reader_process: wrote %ld bytes of %lu (%d total)\n",
+-	   (long) bytes_written, (u_long) write_count, byte_count);
++	   (long) bytes_written, (unsigned long) write_count, byte_count);
+       write_count -= bytes_written;
+     }
+ 
+--- sane-backends-1.0.24.orig/backend/u12-ccd.c
++++ sane-backends-1.0.24/backend/u12-ccd.c
+_at_@ -718,7 +718,7 @@
+ /**
+  */
+ static void
+-fnDarkOffsetWolfson3797( U12_Device *dev, ShadingVarDef *sTbl, u_long dwCh )
++fnDarkOffsetWolfson3797( U12_Device *dev, ShadingVarDef *sTbl, unsigned long dwCh )
+ {
+ 	if(( dev->shade.DarkOffset.wColors[dwCh] -=
+                 sTbl->DarkOffSub.wColors[dwCh]) > 0xfff ) {
+_at_@ -729,7 +729,7 @@
+ /**
+  */
+ static void
+-fnDarkOffsetSamsung3777( U12_Device *dev, ShadingVarDef *sTbl, u_long dwCh )
++fnDarkOffsetSamsung3777( U12_Device *dev, ShadingVarDef *sTbl, unsigned long dwCh )
+ {
+ 	dev->shade.DarkOffset.wColors[dwCh] += sTbl->DarkOffSub.wColors [dwCh];
+ }
+_at_@ -737,7 +737,7 @@
+ /**
+  */
+ static void
+-fnDarkOffsetSamsung3797( U12_Device *dev, ShadingVarDef *sTbl, u_long dwCh )
++fnDarkOffsetSamsung3797( U12_Device *dev, ShadingVarDef *sTbl, unsigned long dwCh )
+ {
+ 	if( dev->shade.DarkOffset.wColors[dwCh] > sTbl->DarkOffSub.wColors[dwCh] )
+ 		dev->shade.DarkOffset.wColors[dwCh] -= sTbl->DarkOffSub.wColors[dwCh];
+_at_@ -748,7 +748,7 @@
+ /**
+  */
+ static void
+-fnDarkOffsetSamsung3799( U12_Device *dev, ShadingVarDef *sTbl, u_long dwCh )
++fnDarkOffsetSamsung3799( U12_Device *dev, ShadingVarDef *sTbl, unsigned long dwCh )
+ {
+ 	if( dev->shade.DarkOffset.wColors[dwCh] > sTbl->DarkOffSub.wColors[dwCh])
+ 		dev->shade.DarkOffset.wColors[dwCh] -= sTbl->DarkOffSub.wColors[dwCh];
+_at_@ -759,22 +759,22 @@
+ /**
+  */
+ static void fnDACDarkWolfson( U12_Device *dev, ShadingVarDef *sTbl,
+-                              u_long dwCh, u_short wDarkest )
++                              unsigned long dwCh, unsigned short wDarkest )
+ {
+-	u_short w = dev->shade.DarkDAC.bColors[dwCh];
++	unsigned short w = dev->shade.DarkDAC.bColors[dwCh];
+ 
+ 	if( wDarkest > sTbl->DarkCmpHi.wColors[dwCh] ) {
+ 
+ 		wDarkest -= sTbl->DarkCmpHi.wColors[dwCh];
+ 		if( wDarkest > dev->shade.wDarkLevels)
+-	        w += (u_short)wDarkest / dev->shade.wDarkLevels;
++	        w += (unsigned short)wDarkest / dev->shade.wDarkLevels;
+ 		else
+ 			w++;
+ 
+ 		if (w > 0xff)
+ 			w = 0xff;
+ 
+-		if(w != (u_short)dev->shade.DarkDAC.bColors[dwCh] ) {
++		if(w != (unsigned short)dev->shade.DarkDAC.bColors[dwCh] ) {
+ 			dev->shade.DarkDAC.bColors[dwCh] = (SANE_Byte)w;
+ 			dev->shade.fStop                 = SANE_FALSE;
+ 		}
+_at_@ -782,14 +782,14 @@
+ 		if((wDarkest < sTbl->DarkCmpLo.wColors[dwCh]) &&
+                                 	        dev->shade.DarkDAC.bColors[dwCh]) {
+ 			if( wDarkest )
+-				w = (u_short)dev->shade.DarkDAC.bColors[dwCh] - 2U;
++				w = (unsigned short)dev->shade.DarkDAC.bColors[dwCh] - 2U;
+ 			else
+-				w = (u_short)dev->shade.DarkDAC.bColors[dwCh] - dev->shade.wDarkLevels;
++				w = (unsigned short)dev->shade.DarkDAC.bColors[dwCh] - dev->shade.wDarkLevels;
+ 
+ 			if ((short) w < 0)
+ 				w = 0;
+ 				
+-			if( w != (u_short)dev->shade.DarkDAC.bColors[dwCh] ) {
++			if( w != (unsigned short)dev->shade.DarkDAC.bColors[dwCh] ) {
+ 				dev->shade.DarkDAC.bColors [dwCh] = (SANE_Byte)w;
+ 				dev->shade.fStop                  = SANE_FALSE;
+ 			}
+_at_@ -800,23 +800,23 @@
+ /**
+  */
+ static void fnDACDarkSamsung( U12_Device *dev, ShadingVarDef *sTbl,
+-                              u_long dwCh, u_short wDarkest )
++                              unsigned long dwCh, unsigned short wDarkest )
+ {
+-	u_short w;
++	unsigned short w;
+ 
+ 	if( wDarkest > sTbl->DarkCmpHi.wColors[dwCh] ) {
+ 
+ 		wDarkest -= sTbl->DarkCmpHi.wColors[dwCh];
+ 		if( wDarkest > dev->shade.wDarkLevels )
+-			w = (u_short)dev->shade.DarkDAC.bColors[dwCh] -
++			w = (unsigned short)dev->shade.DarkDAC.bColors[dwCh] -
+ 	                                        wDarkest / dev->shade.wDarkLevels;
+ 		else
+-			w = (u_short)dev->shade.DarkDAC.bColors[dwCh] - 1U;
++			w = (unsigned short)dev->shade.DarkDAC.bColors[dwCh] - 1U;
+ 
+ 		if((short) w < 0)
+ 			w = 0;
+ 
+-		if(w != (u_short)dev->shade.DarkDAC.bColors[dwCh]) {
++		if(w != (unsigned short)dev->shade.DarkDAC.bColors[dwCh]) {
+ 			dev->shade.DarkDAC.bColors [dwCh] = (SANE_Byte)w;
+ 	        dev->shade.fStop                  = SANE_FALSE;
+ 		}
+_at_@ -824,14 +824,14 @@
+ 		if((wDarkest < sTbl->DarkCmpLo.wColors[dwCh]) &&
+ 		                                    dev->shade.DarkDAC.bColors[dwCh]) {
+ 			if( wDarkest )
+-				w = (u_short)dev->shade.DarkDAC.bColors[dwCh] + 2U;
++				w = (unsigned short)dev->shade.DarkDAC.bColors[dwCh] + 2U;
+ 			else
+-				w = dev->shade.wDarkLevels + (u_short)dev->shade.DarkDAC.bColors[dwCh];
++				w = dev->shade.wDarkLevels + (unsigned short)dev->shade.DarkDAC.bColors[dwCh];
+ 
+ 			if (w > 0xff)
+ 				w = 0xff;
+ 
+-			if(w != (u_short)dev->shade.DarkDAC.bColors[dwCh]) {
++			if(w != (unsigned short)dev->shade.DarkDAC.bColors[dwCh]) {
+ 				dev->shade.DarkDAC.bColors[dwCh] = (SANE_Byte)w;
+ 				dev->shade.fStop                 = SANE_FALSE;
+ 			}
+_at_@ -846,7 +846,7 @@
+  */
+ static void u12ccd_InitCCDandDAC( U12_Device *dev, SANE_Bool shading )
+ {
+-	u_short        w;
++	unsigned short        w;
+ 	ShadingVarDef *pDAC_CCD;
+ 
+ 	DBG( _DBG_INFO, "CCD & DAC init\n" );
+--- sane-backends-1.0.24.orig/backend/u12-hw.c
++++ sane-backends-1.0.24/backend/u12-hw.c
+_at_@ -103,14 +103,14 @@
+ 	SANE_Byte *reg_val;
+ 
+ 	DBG( _DBG_INFO, "u12hw_ProgramCCD: 0x%08lx[%lu]\n",
+-	                (u_long)dev->CCDRegs,
+-	                ((u_long)dev->numCCDRegs * dev->shade.intermediate));
++	                (unsigned long)dev->CCDRegs,
++	                ((unsigned long)dev->numCCDRegs * dev->shade.intermediate));
+ 
+ 	DBG( _DBG_INFO, " * %u regs * %u (intermediate)\n",
+ 	                dev->numCCDRegs, dev->shade.intermediate );
+ 
+ 	reg_val = (SANE_Byte*)(dev->CCDRegs +
+-	                       (u_long)dev->numCCDRegs * dev->shade.intermediate);
++	                       (unsigned long)dev->numCCDRegs * dev->shade.intermediate);
+ 
+ 	u12io_DataToRegs( dev, reg_val, dev->numCCDRegs );
+ }
+_at_@ -338,7 +338,7 @@
+ static void u12hw_SetupPreviewCondition( U12_Device *dev )
+ {
+ 	int       i, c;
+-	u_long    channel;
++	unsigned long    channel;
+ 	SANE_Byte rb[100];
+ 
+ 	DBG( _DBG_INFO, "u12_SetupPreviewCondition()\n" );
+_at_@ -357,14 +357,14 @@
+ 
+ 	} else if( dev->DataInf.xyAppDpi.x >= 19 ) { /* 19 <= x <= 30(37) */
+ 
+-		u_short *pState = (u_short*)dev->scanStates;
++		unsigned short *pState = (u_short*)dev->scanStates;
+ 
+ 		for( i = 0; i < (_SCANSTATE_BYTES / 2); i++ )
+ 			pState[i] = 0x89ac;
+ 
+ 	} else {    /* 16 <= x <= 18 */
+ 
+-		u_long *pState = (u_long*)dev->scanStates;
++		unsigned long *pState = (u_long*)dev->scanStates;
+ 
+ 		for(i = 0; i < (_SCANSTATE_BYTES / 4); i++)
+ 			pState[i] = 0x888889ac;
+_at_@ -423,7 +423,7 @@
+ 
+ 	dev->regs.RD_Dpi = dev->DataInf.xyPhyDpi.x;
+ 
+-	dev->regs.RD_Origin  = (u_short)(dev->adj.leftNormal*2+_DATA_ORIGIN_X);
++	dev->regs.RD_Origin  = (unsigned short)(dev->adj.leftNormal*2+_DATA_ORIGIN_X);
+ 	dev->regs.RD_Origin += dev->DataInf.crImage.x;
+ 
+ 	if( dev->shade.intermediate & _ScanMode_AverageOut )
+_at_@ -476,7 +476,7 @@
+ static void u12hw_SetupScanningCondition( U12_Device *dev )
+ {
+ 	TimerDef   timer;
+-	u_long     channel;
++	unsigned long     channel;
+ 	int        c;
+ 	SANE_Byte  state;
+ 	SANE_Byte  rb[100];
+_at_@ -532,13 +532,13 @@
+ 					dev->regs.RD_BufFullSize = _SIZE_GREENFIFO;
+ 				}
+ 
+-				lGreen = (u_long)(-lGreen * dev->DataInf.dwAsicBytesPerPlane);
++				lGreen = (unsigned long)(-lGreen * dev->DataInf.dwAsicBytesPerPlane);
+ 
+ 				if(  dev->DataInf.wPhyDataType > COLOR_TRUE24 )
+ 					lGreen >>= 1;
+ 
+-				dev->scan.dwMinReadFifo += (u_long)lGreen;
+-				dev->scan.dwMaxReadFifo += (u_long)lGreen;
++				dev->scan.dwMinReadFifo += (unsigned long)lGreen;
++				dev->scan.dwMaxReadFifo += (unsigned long)lGreen;
+ 
+ 			} else {
+ 				channel = _BLUE_FULLSIZE << 16;
+_at_@ -602,12 +602,12 @@
+ 	dev->regs.RD_Dpi = dev->DataInf.xyPhyDpi.x;
+ 
+ 	if(!(dev->DataInf.dwScanFlag & _SCANDEF_TPA )) {
+-		dev->regs.RD_Origin = (u_short)(dev->adj.leftNormal*2+_DATA_ORIGIN_X);
++		dev->regs.RD_Origin = (unsigned short)(dev->adj.leftNormal*2+_DATA_ORIGIN_X);
+ 
+ 	} else if( dev->DataInf.dwScanFlag & _SCANDEF_Transparency ) {
+-		dev->regs.RD_Origin = (u_short)dev->scan.posBegin;
++		dev->regs.RD_Origin = (unsigned short)dev->scan.posBegin;
+ 	} else {
+-		dev->regs.RD_Origin = (u_short)dev->scan.negBegin;
++		dev->regs.RD_Origin = (unsigned short)dev->scan.negBegin;
+ 	}
+ 	dev->regs.RD_Origin += dev->DataInf.crImage.x;
+ 
+_at_@ -615,9 +615,9 @@
+ 		dev->regs.RD_Origin >>= 1;
+ 
+ 	if( dev->DataInf.wPhyDataType == COLOR_BW )
+-		dev->regs.RD_Pixels = (u_short)dev->DataInf.dwAsicBytesPerPlane;
++		dev->regs.RD_Pixels = (unsigned short)dev->DataInf.dwAsicBytesPerPlane;
+     else
+-		dev->regs.RD_Pixels = (u_short)dev->DataInf.dwAppPixelsPerLine;
++		dev->regs.RD_Pixels = (unsigned short)dev->DataInf.dwAppPixelsPerLine;
+ 
+ 	DBG( _DBG_INFO, "* RD_Origin = %u, RD_Pixels = %u\n",
+ 	                         dev->regs.RD_Origin, dev->regs.RD_Pixels );
+--- sane-backends-1.0.24.orig/backend/u12-hwdef.h
++++ sane-backends-1.0.24/backend/u12-hwdef.h
+_at_@ -50,8 +50,8 @@
+ #ifndef __U12_HWDEF_H__
+ #define __U12_HWDEF_H__
+ 
+-#define _LOWORD(x)	((u_short)(x & 0xffff))
+-#define _HIWORD(x)	((u_short)(x >> 16))
++#define _LOWORD(x)	((unsigned short)(x & 0xffff))
++#define _HIWORD(x)	((unsigned short)(x >> 16))
+ #define _LOBYTE(x)  ((SANE_Byte)((x) & 0xFF))
+ #define _HIBYTE(x)  ((SANE_Byte)((x) >> 8))
+ 
+_at_@ -347,11 +347,11 @@
+ 
+ /** buffer sizes */
+ #define _BYTES_PER_CHANNEL    5500UL
+-#define _SIZE_DATA_BUF        (u_long)(_BYTES_PER_CHANNEL * 3 * 2)
+-#define _SIZE_TPA_DATA_BUF    (u_long)(_BYTES_PER_CHANNEL * 3 * 2)
+-#define _SIZE_SHADING_SUM_BUF (u_long)(_BYTES_PER_CHANNEL * 3 * 4)
+-#define _SIZE_TOTAL_BUF       (u_long)(_SIZE_DATA_BUF + _SIZE_SHADING_SUM_BUF)
+-#define _SIZE_TOTAL_BUF_TPA   (u_long)(_SIZE_TOTAL_BUF + _SIZE_TPA_DATA_BUF)
++#define _SIZE_DATA_BUF        (unsigned long)(_BYTES_PER_CHANNEL * 3 * 2)
++#define _SIZE_TPA_DATA_BUF    (unsigned long)(_BYTES_PER_CHANNEL * 3 * 2)
++#define _SIZE_SHADING_SUM_BUF (unsigned long)(_BYTES_PER_CHANNEL * 3 * 4)
++#define _SIZE_TOTAL_BUF       (unsigned long)(_SIZE_DATA_BUF + _SIZE_SHADING_SUM_BUF)
++#define _SIZE_TOTAL_BUF_TPA   (unsigned long)(_SIZE_TOTAL_BUF + _SIZE_TPA_DATA_BUF)
+ 
+ /** internal FIFO buffers */
+ #define _SIZE_REDFIFO   196608UL    /* 192k */
+_at_@ -408,17 +408,17 @@
+ 	SANE_Byte RD_ScanControl;       /* 0x1d, init = 5 */
+ 	SANE_Byte RD_ModelControl;      /* 0x1f           */
+ 	SANE_Byte RD_Model1Control;     /* 0x20           */
+-	u_short   RD_Dpi;               /* 0x21           */
+-	u_short   RD_Origin;            /* 0x23           */
+-	u_short   RD_Pixels;            /* 0x25           */
+-	u_short   RD_ThresholdControl;  /* 0x27           */
++	unsigned short   RD_Dpi;               /* 0x21           */
++	unsigned short   RD_Origin;            /* 0x23           */
++	unsigned short   RD_Pixels;            /* 0x25           */
++	unsigned short   RD_ThresholdControl;  /* 0x27           */
+ 	SANE_Byte RD_ThresholdGapCtrl;  /* 0x29           */
+-	u_short   RD_RedDarkOff;        /* 0x33           */
+-	u_short   RD_GreenDarkOff;      /* 0x35           */
+-	u_short   RD_BlueDarkOff;       /* 0x37           */
++	unsigned short   RD_RedDarkOff;        /* 0x33           */
++	unsigned short   RD_GreenDarkOff;      /* 0x35           */
++	unsigned short   RD_BlueDarkOff;       /* 0x37           */
+ 
+-	u_long    RD_BufFullSize;       /* 0x54   */
+-	u_short   RD_MotorTotalSteps;   /* 0x57   */
++	unsigned long    RD_BufFullSize;       /* 0x54   */
++	unsigned short   RD_MotorTotalSteps;   /* 0x57   */
+ 
+ 	SANE_Byte RD_ScanControl1;      /* 0x5b   */
+ 	SANE_Byte RD_MotorDriverType;   /* 0x64   */
+_at_@ -444,10 +444,10 @@
+ 	ShadingVarDef *pCcdDac;
+ 	ColorByte      DarkDAC;
+ 	ColorWord      DarkOffset;
+-	u_short        wDarkLevels;
++	unsigned short        wDarkLevels;
+ 	SANE_Byte      intermediate;
+ 
+-	u_long         dwDiv;
++	unsigned long         dwDiv;
+ 	SANE_Byte      skipShadow;
+ 
+ 	SANE_Byte      skipHilight;
+_at_@ -463,8 +463,8 @@
+ 
+ 	SANE_Bool      fStop;
+ 
+-	u_short        wExposure;
+-	u_short        wXStep;
++	unsigned short        wExposure;
++	unsigned short        wXStep;
+ 
+ } ShadingDef;
+ 
+--- sane-backends-1.0.24.orig/backend/u12-if.c
++++ sane-backends-1.0.24/backend/u12-if.c
+_at_@ -586,13 +586,13 @@
+ 
+ 	if( dev->shade.skipHilight && dev->shade.skipShadow ) {
+ 
+-		u_long skipSize;
++		unsigned long skipSize;
+ 
+-		skipSize = (u_long)((dev->shade.skipHilight + dev->shade.skipShadow)
++		skipSize = (unsigned long)((dev->shade.skipHilight + dev->shade.skipShadow)
+ 		                                                 * _SIZE_DATA_BUF * 3);
+ 		dev->shade.pHilight = (RGBUShortDef*)malloc( skipSize );
+ 		if( NULL != dev->shade.pHilight ) {
+-			dev->shade.dwDiv = (u_long)(32UL - dev->shade.skipHilight -
++			dev->shade.dwDiv = (unsigned long)(32UL - dev->shade.skipHilight -
+ 			                                            dev->shade.skipShadow);
+ 		}
+ 	}
+--- sane-backends-1.0.24.orig/backend/u12-image.c
++++ sane-backends-1.0.24/backend/u12-image.c
+_at_@ -53,7 +53,7 @@
+ 
+ /*************************** local vars **************************************/
+ 
+-static u_short wPreviewScanned = 0;
++static unsigned short wPreviewScanned = 0;
+ 
+ static ExpXStepDef negScan[5] = {
+ 	{128, 8}, {96, 12}, {96, 24}, {96, 48}, {96, 96}
+_at_@ -185,7 +185,7 @@
+  * - the required horizontal resolution doesn't exceed the optic spec.
+  * - the required vertical resolution exceeds the optic spec.
+  */
+-static void fnDataDirect( U12_Device *dev, void *src, void *dest, u_long len )
++static void fnDataDirect( U12_Device *dev, void *src, void *dest, unsigned long len )
+ {
+ 	_VAR_NOT_USED( dev );
+ 	memcpy( dest, src, len );
+_at_@ -193,7 +193,7 @@
+ 
+ /** merges the color planes to pixels style without enlarge operation.
+  */
+-static void fnColorDirect( U12_Device *dev, void *pb, void *img, u_long len )
++static void fnColorDirect( U12_Device *dev, void *pb, void *img, unsigned long len )
+ {
+ 	SANE_Byte  *src;
+ 	RGBByteDef *dest;
+_at_@ -213,12 +213,12 @@
+  *  The scanner returns the pixel data in Motorola-Format, so we have to swap
+  *  (at least on x86)
+  */
+-static void fnColor42( U12_Device *dev, void *pb, void *img, u_long len )
++static void fnColor42( U12_Device *dev, void *pb, void *img, unsigned long len )
+ {
+-	u_short      *src;
++	unsigned short      *src;
+ 	RGBUShortDef *dest;
+     
+-	register u_long i;
++	register unsigned long i;
+ 
+ 	_VAR_NOT_USED( len );
+ 	src  = (u_short*)img;
+_at_@ -234,7 +234,7 @@
+ 
+ /**
+  */
+-static void u12image_SetupScanStateVariables( U12_Device *dev, u_long index )
++static void u12image_SetupScanStateVariables( U12_Device *dev, unsigned long index )
+ {
+ 	DataType var;
+ 
+_at_@ -347,13 +347,13 @@
+ 	dev->DataInf.xyRatio = (double)dev->DataInf.xyPhyDpi.y/
+ 	                       (double)dev->DataInf.xyPhyDpi.x;
+ 
+-	dev->DataInf.dwAppLinesPerArea = (u_long)image->crArea.cy *
++	dev->DataInf.dwAppLinesPerArea = (unsigned long)image->crArea.cy *
+ 									  image->xyDpi.y / _MEASURE_BASE;
+ 
+-    dev->DataInf.dwAppPixelsPerLine = (u_long)image->crArea.cx *
++    dev->DataInf.dwAppPixelsPerLine = (unsigned long)image->crArea.cx *
+ 									   image->xyDpi.x / _MEASURE_BASE;
+ 
+-	dev->DataInf.dwPhysBytesPerLine = (u_long)image->crArea.cx *
++	dev->DataInf.dwPhysBytesPerLine = (unsigned long)image->crArea.cx *
+ 									   dev->DataInf.xyPhyDpi.x / _MEASURE_BASE;
+ 
+     if( image->wDataType <= COLOR_BW ) {
+_at_@ -422,7 +422,7 @@
+  */
+ static int imageSetupScanSettings( U12_Device *dev, ImgDef *img )
+ {
+-	u_short brightness;
++	unsigned short brightness;
+ 
+ 	DBG( _DBG_INFO, "imageSetupScanSettings()\n" );
+ 
+_at_@ -462,10 +462,10 @@
+ */
+ 	DBG( _DBG_INFO, "* brightness = %i\n", dev->DataInf.siBrightness );
+ 	if ( dev->DataInf.siBrightness < 0) {
+-		brightness = (u_short)(_DEF_BW_THRESHOLD -
++		brightness = (unsigned short)(_DEF_BW_THRESHOLD -
+ 			       (255 - _DEF_BW_THRESHOLD) * dev->DataInf.siBrightness /127);
+ 	} else {
+-		brightness = (u_short)(_DEF_BW_THRESHOLD -
++		brightness = (unsigned short)(_DEF_BW_THRESHOLD -
+ 					       _DEF_BW_THRESHOLD * dev->DataInf.siBrightness /127);
+ 	}
+ 
+_at_@ -595,16 +595,16 @@
+ 
+ 	if( dev->DataInf.wPhyDataType >= COLOR_TRUE24 ) {
+ 
+-		u_long r, g, b;
++		unsigned long r, g, b;
+ 
+-		r = (u_long)_SIZE_REDFIFO /
++		r = (unsigned long)_SIZE_REDFIFO /
+ 			dev->DataInf.dwAsicBytesPerPlane - dev->scan.bd_rk.wRedKeep;
+-		g = (u_long)_SIZE_GREENFIFO /
++		g = (unsigned long)_SIZE_GREENFIFO /
+ 			dev->DataInf.dwAsicBytesPerPlane - dev->scan.gd_gk.wGreenKeep;
+ 
+ 		if((int)r < 16 || (int)g < 16) {
+ 
+-			b = (u_long)(dev->scan.bd_rk.wRedKeep +
++			b = (unsigned long)(dev->scan.bd_rk.wRedKeep +
+ 			             dev->scan.gd_gk.wGreenKeep + 2U) *
+ 			             dev->DataInf.dwAsicBytesPerPlane;
+ 
+_at_@ -847,7 +847,7 @@
+ {
+ 	SANE_Byte tmp;
+ 	int       ddax;
+-	u_long    i, j, x;
++	unsigned long    i, j, x;
+ 
+ 	/* when not supported, only copy the data */
+ 	if( 99 == dev->scaleStep ) {
+_at_@ -892,7 +892,7 @@
+ 
+ 			while( ddax < 0 ) {
+ 
+-				for( j = 0; j < (u_long)dev->scaleStep; j++ ) {
++				for( j = 0; j < (unsigned long)dev->scaleStep; j++ ) {
+ 
+ 					if((x+j) < dev->DataInf.dwAppBytesPerLine ) {
+ 						ob[x+j] = ib[i+j];
+--- sane-backends-1.0.24.orig/backend/u12-io.c
++++ sane-backends-1.0.24/backend/u12-io.c
+_at_@ -170,7 +170,7 @@
+ /** Write to the usb-parallel port bridge.
+  */
+ static SANE_Status
+-gl640WriteControl(int fd, GL640_Request req, u_char * data, unsigned int size)
++gl640WriteControl(int fd, GL640_Request req, unsigned char * data, unsigned int size)
+ {
+ 	SANE_Status status;
+ 
+_at_@ -192,7 +192,7 @@
+ /** Read from the usb-parallel port bridge.
+  */
+ static SANE_Status
+-gl640ReadControl( int fd, GL640_Request req, u_char *data, unsigned int size )
++gl640ReadControl( int fd, GL640_Request req, unsigned char *data, unsigned int size )
+ {
+ 	SANE_Status status;
+ 
+_at_@ -213,14 +213,14 @@
+ 
+ /** Wrappers to write a single byte to the bridge */
+ static inline SANE_Status
+-gl640WriteReq( int fd, GL640_Request req, u_char data )
++gl640WriteReq( int fd, GL640_Request req, unsigned char data )
+ {
+ 	return gl640WriteControl( fd, req, &data, 1);
+ }
+ 
+ /** Wrappers to read a single byte from the bridge */
+ static inline SANE_Status
+-gl640ReadReq( int fd, GL640_Request req, u_char *data )
++gl640ReadReq( int fd, GL640_Request req, unsigned char *data )
+ {
+ 	return gl640ReadControl( fd, req, data, 1 );
+ }
+_at_@ -232,7 +232,7 @@
+  * setup[1] = 0x01 --> data to scanner memory
+  */
+ static SANE_Status
+-gl640WriteBulk( int fd, u_char *setup, u_char *data, size_t size )
++gl640WriteBulk( int fd, unsigned char *setup, unsigned char *data, size_t size )
+ {
+ 	SANE_Status status;
+ 
+_at_@ -257,7 +257,7 @@
+  * setup[1] = 0x0c --> data from scanner fifo?
+  */
+ static SANE_Status
+-gl640ReadBulk( int fd, u_char *setup, u_char *data, size_t size, int mod )
++gl640ReadBulk( int fd, unsigned char *setup, unsigned char *data, size_t size, int mod )
+ {
+ 	SANE_Byte  *len_info;
+ 	size_t      complete, current, toget;
+_at_@ -301,7 +301,7 @@
+ static SANE_Byte
+ inb_status( int fd )
+ {
+-	u_char data = 0xff;
++	unsigned char data = 0xff;
+ 
+ 	gl640ReadReq( fd, GL640_SPP_STATUS, &data );
+ 	return data;
+_at_@ -309,14 +309,14 @@
+ 
+ /** write a byte to the SPP data port */
+ static SANE_Status
+-outb_data( int fd, u_char data )
++outb_data( int fd, unsigned char data )
+ {
+ 	return gl640WriteReq( fd, GL640_SPP_DATA, data);
+ }
+ 
+ /** write to the parport control register */
+ static SANE_Status
+-outb_ctrl( int fd, u_char data )
++outb_ctrl( int fd, unsigned char data )
+ {
+ 	return gl640WriteReq( fd, GL640_SPP_CONTROL, data);
+ }
+_at_@ -415,7 +415,7 @@
+  */
+ static SANE_Bool u12io_OpenScanPath( U12_Device *dev )
+ {
+-	u_char tmp;
++	unsigned char tmp;
+ 
+ 	DBG( _DBG_INFO, "u12io_OpenScanPath()\n" );
+ 
+_at_@ -640,7 +640,7 @@
+ 
+ /**
+  */
+-static SANE_Status u12io_ReadMonoData( U12_Device *dev, SANE_Byte *buf, u_long len )
++static SANE_Status u12io_ReadMonoData( U12_Device *dev, SANE_Byte *buf, unsigned long len )
+ {
+ 	SANE_Status status;
+ 
+_at_@ -657,7 +657,7 @@
+ /**
+  */
+ static SANE_Status
+-u12io_ReadColorData( U12_Device *dev, SANE_Byte *buf, u_long len )
++u12io_ReadColorData( U12_Device *dev, SANE_Byte *buf, unsigned long len )
+ {
+ 	SANE_Status status;
+ 
+_at_@ -768,12 +768,12 @@
+ 
+ /**
+  */
+-static u_long u12io_GetFifoLength( U12_Device *dev )
++static unsigned long u12io_GetFifoLength( U12_Device *dev )
+ {
+ 	SANE_Status status;
+ 	size_t      toget;
+ 	SANE_Byte   data[64];
+-	u_long      len, len_r, len_g, len_b;
++	unsigned long      len, len_r, len_g, len_b;
+ 
+ 	if( cacheLen[0] == 0x83 ) {
+ 
+_at_@ -798,9 +798,9 @@
+ 
+ 		memcpy( cacheLen, data, 13 );
+ 	}
+-	len_r = (u_long)data[5]  * 256 + (u_long)data[4];
+-	len_g = (u_long)data[8]  * 256 + (u_long)data[7];
+-	len_b = (u_long)data[11] * 256 + (u_long)data[10];
++	len_r = (unsigned long)data[5]  * 256 + (unsigned long)data[4];
++	len_g = (unsigned long)data[8]  * 256 + (unsigned long)data[7];
++	len_b = (unsigned long)data[11] * 256 + (unsigned long)data[10];
+ 
+ 	if( dev->DataInf.wPhyDataType < COLOR_TRUE24 ) {
+ 		len = len_g;
+_at_@ -820,7 +820,7 @@
+ /**
+  */
+ static SANE_Bool
+-u12io_ReadOneShadingLine( U12_Device *dev, SANE_Byte *buf, u_long len )
++u12io_ReadOneShadingLine( U12_Device *dev, SANE_Byte *buf, unsigned long len )
+ {
+ 	TimerDef    timer;
+ 	SANE_Status status;
+--- sane-backends-1.0.24.orig/backend/u12-map.c
++++ sane-backends-1.0.24/backend/u12-map.c
+_at_@ -113,7 +113,7 @@
+ static void u12map_Adjust( U12_Device *dev, int which, SANE_Byte *buf )
+ {
+ 	int     i;
+-	u_long *pdw;
++	unsigned long *pdw;
+ 	double  b, c, tmp;
+ 
+ 	DBG( _DBG_INFO, "u12map_Adjust(%u)\n", which );
+--- sane-backends-1.0.24.orig/backend/u12-motor.c
++++ sane-backends-1.0.24/backend/u12-motor.c
+_at_@ -73,7 +73,7 @@
+  */
+ static void u12motor_Force16Steps( U12_Device *dev, int dir )
+ {
+-	u_long dw;
++	unsigned long dw;
+ 
+ 	if( dir == _DIR_FW )
+ 		u12io_DataToRegister( dev, REG_MOTOR0CONTROL, _FORWARD_MOTOR );
+_at_@ -88,7 +88,7 @@
+ 
+ /**
+  */
+-static void u12motor_ModuleFreeRun( U12_Device *dev, u_long steps )
++static void u12motor_ModuleFreeRun( U12_Device *dev, unsigned long steps )
+ {
+ 	SANE_Byte rb[6];
+ 	
+_at_@ -101,7 +101,7 @@
+ 
+ /**
+  */
+-static SANE_Status u12motor_PositionYProc( U12_Device *dev, u_long steps )
++static SANE_Status u12motor_PositionYProc( U12_Device *dev, unsigned long steps )
+ {
+ 	TimerDef timer;
+ 
+_at_@ -308,10 +308,10 @@
+ 	SANE_Status res;
+ 	SANE_Byte   bXStep;
+ 	int         c;
+-	u_long      dwBeginY;
++	unsigned long      dwBeginY;
+ 
+ 	c        = 0;
+-	dwBeginY = (u_long)dev->DataInf.crImage.y * 4 + dev->scan.dwScanOrigin;
++	dwBeginY = (unsigned long)dev->DataInf.crImage.y * 4 + dev->scan.dwScanOrigin;
+ 
+ 	if( dev->DataInf.wPhyDataType <= COLOR_256GRAY ) {
+ 		if( dev->f0_8_16 )
+--- sane-backends-1.0.24.orig/backend/u12-scanner.h
++++ sane-backends-1.0.24/backend/u12-scanner.h
+_at_@ -91,15 +91,15 @@
+ } RGBByteDef;
+ 
+ typedef struct {
+-	u_short Red;
+-	u_short Green;
+-	u_short Blue;
++	unsigned short Red;
++	unsigned short Green;
++	unsigned short Blue;
+ } RGBUShortDef;
+ 
+ typedef struct {
+-	u_long Red;
+-	u_long Green;
+-	u_long Blue;
++	unsigned long Red;
++	unsigned long Green;
++	unsigned long Blue;
+ } RGBULongDef;
+ 
+ typedef union {
+_at_@ -109,13 +109,13 @@
+ 
+ typedef union {
+ 	RGBUShortDef Colors;
+-	u_short      wColors[3];
++	unsigned short      wColors[3];
+ } ColorWord;
+ 
+ typedef union {
+ 	SANE_Byte     *pb;
+-	u_short       *pw;
+-	u_long        *pdw;
++	unsigned short       *pw;
++	unsigned long        *pdw;
+ 	RGBUShortDef  *pusrgb;
+ 	RGBULongDef   *pulrgb;
+ 	RGBByteDef    *pbrgb;
+_at_@ -125,18 +125,18 @@
+ {
+ 	union {
+ 		SANE_Byte *bp;
+-		u_short   *usp;
+-		u_long    *ulp;
++		unsigned short   *usp;
++		unsigned long    *ulp;
+ 	} red;
+ 	union {
+ 		SANE_Byte *bp;
+-		u_short   *usp;
+-		u_long    *ulp;
++		unsigned short   *usp;
++		unsigned long    *ulp;
+ 	} green;
+ 	union {
+ 		SANE_Byte *bp;
+-		u_short   *usp;
+-		u_long    *ulp;
++		unsigned short   *usp;
++		unsigned long    *ulp;
+ 	} blue;
+ 
+ } RBGPtrDef;
+_at_@ -155,14 +155,14 @@
+ typedef union {
+ 	WordVal   wOverlap;
+ 	DWordVal  dwOverlap;
+-	u_long    dwValue;
+-	u_short   wValue;
++	unsigned long    dwValue;
++	unsigned short   wValue;
+ 	SANE_Byte bValue;
+ } DataType;
+ 
+ typedef struct {
+-	u_short exposureTime;
+-	u_short xStepTime;
++	unsigned short exposureTime;
++	unsigned short xStepTime;
+ } ExpXStepDef;
+ 
+ typedef struct {
+_at_@ -173,34 +173,34 @@
+ /** for defining a point
+  */
+ typedef struct {
+-	u_short x;
+-	u_short y;
++	unsigned short x;
++	unsigned short y;
+ } XY;
+ 
+ /** for defining a crop area, all is 300DPI based
+  */
+ typedef struct {
+-	u_short x;      /**< x-pos of top-left corner */
+-	u_short y;      /**< y-pos of top-left corner */
+-	u_short cx;     /**< width                    */
+-	u_short cy;     /**< height                   */
++	unsigned short x;      /**< x-pos of top-left corner */
++	unsigned short y;      /**< y-pos of top-left corner */
++	unsigned short cx;     /**< width                    */
++	unsigned short cy;     /**< height                   */
+ } CropRect;
+ 
+ /** for defining an image
+  */
+ typedef struct {
+-	u_long   dwFlag;      /**< i.e. image source           */
++	unsigned long   dwFlag;      /**< i.e. image source           */
+ 	CropRect crArea;      /**< the image size and position */
+ 	XY       xyDpi;       /**< the resolution              */
+-	u_short  wDataType;   /**< and the data type           */
++	unsigned short  wDataType;   /**< and the data type           */
+ } ImgDef;
+ 
+ /**
+  */
+ typedef struct {
+-	u_long dwPixelsPerLine;
+-	u_long dwBytesPerLine;
+-	u_long dwLinesPerArea;
++	unsigned long dwPixelsPerLine;
++	unsigned long dwBytesPerLine;
++	unsigned long dwLinesPerArea;
+ 	ImgDef image;
+ } CropInfo;
+ 
+_at_@ -208,24 +208,24 @@
+  */
+ typedef struct
+ {
+-	u_long  dwScanFlag;
++	unsigned long  dwScanFlag;
+ 	double  xyRatio;  /**< for scaling */
+-	u_short wYSum;
++	unsigned short wYSum;
+ 
+ 	XY      xyPhyDpi; /**< physical resolution of a scan */
+-	u_long  dwPhysBytesPerLine;
+-	u_long  wPhyDataType;         /**< how the scanner should scan */
++	unsigned long  dwPhysBytesPerLine;
++	unsigned long  wPhyDataType;         /**< how the scanner should scan */
+ 
+-	u_long  dwAsicPixelsPerPlane;
+-	u_long  dwAsicBytesPerPlane;
+-	u_long  dwAsicBytesPerLine;
++	unsigned long  dwAsicPixelsPerPlane;
++	unsigned long  dwAsicBytesPerPlane;
++	unsigned long  dwAsicBytesPerLine;
+ 
+ 	XY      xyAppDpi;
+-	u_long  dwAppLinesPerArea;
+-	u_long  dwAppPixelsPerLine;
+-	u_long  dwAppPhyBytesPerLine;
+-	u_long  dwAppBytesPerLine;
+-	u_short wAppDataType;
++	unsigned long  dwAppLinesPerArea;
++	unsigned long  dwAppPixelsPerLine;
++	unsigned long  dwAppPhyBytesPerLine;
++	unsigned long  dwAppBytesPerLine;
++	unsigned short wAppDataType;
+ 
+ 	short   siBrightness;
+ 	short   siContrast;
+_at_@ -242,21 +242,21 @@
+ 	pFnBool         DataRead;       /* function to get data from scanner    */
+ 
+ 	long            lBufferAdjust;
+-	u_long          dwScanOrigin;   /* where to start the scan              */
+-	u_long          negBegin;       /* used while scanning in TPA modes     */
+-	u_long          posBegin;
++	unsigned long          dwScanOrigin;   /* where to start the scan              */
++	unsigned long          negBegin;       /* used while scanning in TPA modes     */
++	unsigned long          posBegin;
+ 	SANE_Byte       bDiscardAll;
+ 
+ 	union {
+-		u_short     wGreenDiscard;
+-		u_short     wGreenKeep;
++		unsigned short     wGreenDiscard;
++		unsigned short     wGreenKeep;
+ 	} gd_gk;
+ 	union {
+-		u_short     wBlueDiscard;
+-		u_short     wRedKeep;
++		unsigned short     wBlueDiscard;
++		unsigned short     wRedKeep;
+ 	} bd_rk;
+ 
+-	u_long          dpiIdx;         /* index to get/set values in the table */
++	unsigned long          dpiIdx;         /* index to get/set values in the table */
+ 	ExpXStepDef    *negScan;        /* reference to exposure/xtep table     */
+ 
+ 	DataPointer     p48BitBuf;      /* for handling 48-bit data             */
+_at_@ -267,7 +267,7 @@
+ 	RBGPtrDef       BufPut;
+ 
+ 	/* motor movement stuff */
+-	u_long          dwInterval;
++	unsigned long          dwInterval;
+ 	SANE_Bool       refreshState;
+ 	SANE_Bool       motorBackward;
+ 	SANE_Byte       oldScanState;
+_at_@ -276,8 +276,8 @@
+ 	SANE_Byte       bNowScanState;
+ 
+ 	/* internal FIFO management */
+-	u_long          dwMinReadFifo;
+-	u_long          dwMaxReadFifo;
++	unsigned long          dwMinReadFifo;
++	unsigned long          dwMaxReadFifo;
+ 	SANE_Byte       bFifoSelect;    /* defines which FIFO to use            */
+ 
+ } ScanInfo;
+_at_@ -289,7 +289,7 @@
+ 	union {
+ 		SANE_Byte   *pReadBuf;
+ 		SANE_Byte   *pShadingMap;
+-		u_short     *pShadingRam;
++		unsigned short     *pShadingRam;
+ 		DataPointer  Buf;
+ 	} b1;
+ 
+--- sane-backends-1.0.24.orig/backend/u12-shading.c
++++ sane-backends-1.0.24/backend/u12-shading.c
+_at_@ -71,7 +71,7 @@
+ /**
+  */
+ static void
+-u12shading_DownloadShadingTable( U12_Device *dev, SANE_Byte *buf, u_long len )
++u12shading_DownloadShadingTable( U12_Device *dev, SANE_Byte *buf, unsigned long len )
+ {
+ 	SANE_Byte *val, *rb;
+ 	SANE_Byte  reg, regs[20];
+_at_@ -115,12 +115,12 @@
+ static SANE_Status u12shadingAdjustShadingWaveform( U12_Device *dev )
+ {
+ 	SANE_Byte     b;
+-	u_short       count, wR, wG, wB, tmp;
++	unsigned short       count, wR, wG, wB, tmp;
+ 	DataType      var;
+ 	DataPointer   pvar, psum;
+ 	RBGPtrDef     cp;
+ 	RGBUShortDef *pRGB, *pwsum;
+-	u_long        shadingBytes;
++	unsigned long        shadingBytes;
+ 
+ 	DBG( _DBG_INFO, "u12shading_AdjustShadingWaveForm()\n" );
+ 
+_at_@ -284,12 +284,12 @@
+ 
+ 			pvar.pulrgb = (RGBULongDef*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX;
+ 
+-			for( var.dwValue = (u_long)dev->regs.RD_Pixels - _SHADING_BEGINX;
++			for( var.dwValue = (unsigned long)dev->regs.RD_Pixels - _SHADING_BEGINX;
+ 			     var.dwValue--;
+ 			     pvar.pulrgb++, cp.red.usp++, cp.green.usp++, cp.blue.usp++) {
+-				pvar.pulrgb->Red   += (u_long)*cp.red.usp;
+-				pvar.pulrgb->Green += (u_long)*cp.green.usp;
+-				pvar.pulrgb->Blue  += (u_long)*cp.blue.usp;
++				pvar.pulrgb->Red   += (unsigned long)*cp.red.usp;
++				pvar.pulrgb->Green += (unsigned long)*cp.green.usp;
++				pvar.pulrgb->Blue  += (unsigned long)*cp.blue.usp;
+ 			}
+ 
+ 		} else {
+_at_@ -297,9 +297,9 @@
+ 			cp.green.usp = dev->bufs.b1.pShadingRam +
+ 			               dev->regs.RD_Pixels +  _SHADING_BEGINX;
+ 			pvar.pdw  = (u_long*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX;
+-			for( var.dwValue = (u_long)dev->regs.RD_Pixels - _SHADING_BEGINX;
++			for( var.dwValue = (unsigned long)dev->regs.RD_Pixels - _SHADING_BEGINX;
+ 			     var.dwValue--; pvar.pdw++, cp.green.usp++) {
+-				*pvar.pdw += (u_long)*cp.green.usp;
++				*pvar.pdw += (unsigned long)*cp.green.usp;
+ 			}
+ 		}
+ 
+_at_@ -323,14 +323,14 @@
+ 				for( b = dev->shade.skipHilight + dev->shade.skipShadow;
+ 				                           b--; pRGB += dev->regs.RD_Pixels ) {
+ 
+-					psum.pulrgb->Red   -= (u_long)pRGB->Red;
+-					psum.pulrgb->Green -= (u_long)pRGB->Green;
+-					psum.pulrgb->Blue  -= (u_long)pRGB->Blue;
++					psum.pulrgb->Red   -= (unsigned long)pRGB->Red;
++					psum.pulrgb->Green -= (unsigned long)pRGB->Green;
++					psum.pulrgb->Blue  -= (unsigned long)pRGB->Blue;
+ 				}
+ 
+-				pwsum->Red   = (u_short)(psum.pulrgb->Red   / dev->shade.dwDiv);
+-				pwsum->Green = (u_short)(psum.pulrgb->Green / dev->shade.dwDiv);
+-				pwsum->Blue  = (u_short)(psum.pulrgb->Blue  / dev->shade.dwDiv);
++				pwsum->Red   = (unsigned short)(psum.pulrgb->Red   / dev->shade.dwDiv);
++				pwsum->Green = (unsigned short)(psum.pulrgb->Green / dev->shade.dwDiv);
++				pwsum->Blue  = (unsigned short)(psum.pulrgb->Blue  / dev->shade.dwDiv);
+ 				psum.pulrgb++;
+ 				pwsum++;
+ 			}
+_at_@ -347,7 +347,7 @@
+ 				                       b--; cp.red.usp += dev->regs.RD_Pixels )
+ 					*cp.green.ulp -= *cp.red.usp;
+ 
+-				*cp.blue.usp = (u_short)(*cp.green.ulp / dev->shade.dwDiv);
++				*cp.blue.usp = (unsigned short)(*cp.green.ulp / dev->shade.dwDiv);
+ 				cp.blue.usp++;
+ 				cp.green.ulp++;
+ 			}
+_at_@ -361,9 +361,9 @@
+ 
+ 			for( var.dwValue = dev->regs.RD_Pixels - _SHADING_BEGINX;
+ 			                                                  var.dwValue--;) {
+-				pwsum->Red   = (u_short)(psum.pulrgb->Red   >> 5);
+-				pwsum->Green = (u_short)(psum.pulrgb->Green >> 5);
+-				pwsum->Blue  = (u_short)(psum.pulrgb->Blue  >> 5);
++				pwsum->Red   = (unsigned short)(psum.pulrgb->Red   >> 5);
++				pwsum->Green = (unsigned short)(psum.pulrgb->Green >> 5);
++				pwsum->Blue  = (unsigned short)(psum.pulrgb->Blue  >> 5);
+ 				psum.pulrgb++;
+ 				pwsum++;
+ 			}
+_at_@ -373,7 +373,7 @@
+ 
+ 			for( var.dwValue = dev->regs.RD_Pixels - _SHADING_BEGINX;
+ 			                                                  var.dwValue--;) {
+-				*cp.blue.usp = (u_short)(*cp.green.ulp >> 5);
++				*cp.blue.usp = (unsigned short)(*cp.green.ulp >> 5);
+ 				cp.blue.usp++;
+ 				cp.green.ulp++;
+ 			}
+_at_@ -417,13 +417,13 @@
+ 			} else
+ 				pwsum->Blue = 0;
+ 
+-			wR = (u_short)(pwsum->Red >> 4);
++			wR = (unsigned short)(pwsum->Red >> 4);
+ 			pwsum->Red <<= 12;
+ 			pwsum->Red |= wR;
+-			wR = (u_short)(pwsum->Green >> 4);
++			wR = (unsigned short)(pwsum->Green >> 4);
+ 			pwsum->Green <<= 12;
+ 			pwsum->Green |= wR;
+-			wR = (u_short)(pwsum->Blue>> 4);
++			wR = (unsigned short)(pwsum->Blue>> 4);
+ 			pwsum->Blue <<= 12;
+ 			pwsum->Blue |= wR;
+ 			pwsum++;
+_at_@ -443,7 +443,7 @@
+ 			} else
+ 				*cp.green.usp = 0;
+ 
+-			wR = (u_short)(*cp.green.usp >> 4);
++			wR = (unsigned short)(*cp.green.usp >> 4);
+ 			*cp.green.usp <<= 12;
+ 			*cp.green.usp |= wR;
+ 
+_at_@ -486,17 +486,17 @@
+ 
+ /**
+  */
+-static SANE_Byte u12shading_SumGains( SANE_Byte *pb, u_long pixelsLine )
++static SANE_Byte u12shading_SumGains( SANE_Byte *pb, unsigned long pixelsLine )
+ {
+ 	SANE_Byte hilight, tmp;
+-	u_long    dwPixels, dwAve;
+-	u_short   sum;
++	unsigned long    dwPixels, dwAve;
++	unsigned short   sum;
+ 
+ 	hilight = 0;
+ 	for( dwPixels = pixelsLine >> 4; dwPixels--; ) {
+ 
+ 		for( sum = 0, dwAve = 16; dwAve--; pb++ )
+-			sum += (u_short)*pb;
++			sum += (unsigned short)*pb;
+ 
+ 		sum >>= 4;
+ 		tmp = (SANE_Byte)sum;
+_at_@ -510,7 +510,7 @@
+ /**
+  */
+ static void
+-u12shading_AdjustGain( U12_Device *dev, u_long color, SANE_Byte hilight )
++u12shading_AdjustGain( U12_Device *dev, unsigned long color, SANE_Byte hilight )
+ {
+ 	if( hilight < dev->shade.bGainLow ) {
+ 
+_at_@ -583,9 +583,9 @@
+ 		dev->regs.RD_Motor0Control = _FORWARD_MOTOR;
+ 
+ 		if( dev->shade.intermediate & _ScanMode_AverageOut )
+-			dev->regs.RD_Origin = (u_short)_DATA_ORIGIN_X >> 1;
++			dev->regs.RD_Origin = (unsigned short)_DATA_ORIGIN_X >> 1;
+ 		else
+-			dev->regs.RD_Origin = (u_short)_DATA_ORIGIN_X;
++			dev->regs.RD_Origin = (unsigned short)_DATA_ORIGIN_X;
+ 
+ 		dev->regs.RD_Dpi    = 300;
+ 		dev->regs.RD_Pixels = 2560;
+_at_@ -638,9 +638,9 @@
+ 
+ /**
+  */
+-static u_short u12shading_SumDarks( U12_Device *dev, u_short *data )
++static unsigned short u12shading_SumDarks( U12_Device *dev, unsigned short *data )
+ {
+-	u_short i, loop;
++	unsigned short i, loop;
+ 
+ 	if( dev->CCDID == _CCD_3799 ) {
+ 		if( dev->shade.intermediate & _ScanMode_AverageOut )
+_at_@ -665,8 +665,8 @@
+  */
+ static SANE_Status u12shadingAdjustDark( U12_Device *dev )
+ {
+-	u_long  i;
+-	u_short wDarks[3];
++	unsigned long  i;
++	unsigned short wDarks[3];
+ 
+ 	DBG( _DBG_INFO, "u12shadingAdjustDark()\n" );
+ 	dev->shade.DarkDAC.Colors = dev->shade.pCcdDac->DarkDAC.Colors;
+_at_@ -791,7 +791,7 @@
+ static SANE_Status u12shading_DoCalibration( U12_Device *dev )
+ {
+ 	SANE_Byte   tb[4096*3];
+-	u_long      i, tmp;
++	unsigned long      i, tmp;
+ 	SANE_Byte   bScanControl, rb[20];
+ 	SANE_Status res;
+ 	int         c;
+--- sane-backends-1.0.24.orig/backend/u12-tpa.c
++++ sane-backends-1.0.24/backend/u12-tpa.c
+_at_@ -55,8 +55,8 @@
+ static void u12tpa_Reshading( U12_Device *dev )
+ {
+ 	SANE_Byte   bHi[3], bHiLeft[3], bHiRight[3];
+-	u_long      i, dwR, dwG, dwB, dwSum;
+-	u_long      dwIndex, dwIndexRight, dwIndexLeft;
++	unsigned long      i, dwR, dwG, dwB, dwSum;
++	unsigned long      dwIndex, dwIndexRight, dwIndexLeft;
+ 	DataPointer RedPtr, GreenPtr, BluePtr;
+ 	TimerDef    timer;
+ 
+_at_@ -100,7 +100,7 @@
+ 	dev->regs.RD_ModeControl    = _ModeScan;
+ 	dev->regs.RD_Motor0Control  = _FORWARD_MOTOR;
+ 
+-	dev->regs.RD_Origin = (u_short)dev->scan.negBegin;
++	dev->regs.RD_Origin = (unsigned short)dev->scan.negBegin;
+ 	dev->regs.RD_Pixels = _NEG_PAGEWIDTH600;
+ 
+ 	memset( dev->scanStates, 0, _SCANSTATE_BYTES );
+_at_@ -140,54 +140,54 @@
+ 	for( bHiRight[1] = 0, i = dwIndexRight = 0;
+ 	                                     i < _NEG_PAGEWIDTH600 / 2; i += 16 ) {
+ 		bHiRight [0] =
+-	       (SANE_Byte)(((((u_long) RedPtr.pbrgb [i].Red +
+-		     (u_long) RedPtr.pbrgb[i + 1].Red +
+-		     (u_long) RedPtr.pbrgb[i + 2].Red +
+-		     (u_long) RedPtr.pbrgb[i + 3].Red +
+-		     (u_long) RedPtr.pbrgb[i + 4].Red +
+-		     (u_long) RedPtr.pbrgb[i + 5].Red +
+-		     (u_long) RedPtr.pbrgb[i + 6].Red +
+-		     (u_long) RedPtr.pbrgb[i + 7].Red +
+-		     (u_long) RedPtr.pbrgb[i + 8].Red +
+-		     (u_long) RedPtr.pbrgb[i + 9].Red +
+-		     (u_long) RedPtr.pbrgb[i + 10].Red +
+-		     (u_long) RedPtr.pbrgb[i + 11].Red +
+-		     (u_long) RedPtr.pbrgb[i + 12].Red +
+-		     (u_long) RedPtr.pbrgb[i + 13].Red +
+-		     (u_long) RedPtr.pbrgb[i + 14].Red +
+-		     (u_long) RedPtr.pbrgb[i + 15].Red) >> 4) * 30UL +
+-		   (((u_long) RedPtr.pbrgb[i].Green +
+-		     (u_long) RedPtr.pbrgb[i + 1].Green +
+-		     (u_long) RedPtr.pbrgb[i + 2].Green +
+-		     (u_long) RedPtr.pbrgb[i + 3].Green +
+-		     (u_long) RedPtr.pbrgb[i + 4].Green +
+-		     (u_long) RedPtr.pbrgb[i + 5].Green +
+-		     (u_long) RedPtr.pbrgb[i + 6].Green +
+-		     (u_long) RedPtr.pbrgb[i + 7].Green +
+-		     (u_long) RedPtr.pbrgb[i + 8].Green +
+-		     (u_long) RedPtr.pbrgb[i + 9].Green +
+-		     (u_long) RedPtr.pbrgb[i + 10].Green +
+-		     (u_long) RedPtr.pbrgb[i + 11].Green +
+-		     (u_long) RedPtr.pbrgb[i + 12].Green +
+-		     (u_long) RedPtr.pbrgb[i + 13].Green +
+-		     (u_long) RedPtr.pbrgb[i + 14].Green +
+-		     (u_long) RedPtr.pbrgb[i + 15].Green) >> 4) * 59UL +
+-		   (((u_long) RedPtr.pbrgb[i].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 1].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 2].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 3].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 4].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 5].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 6].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 7].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 8].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 9].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 10].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 11].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 12].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 13].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 14].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 15].Blue) >> 4) * 11UL) / 100UL);
++	       (SANE_Byte)(((((unsigned long) RedPtr.pbrgb [i].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 1].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 2].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 3].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 4].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 5].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 6].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 7].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 8].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 9].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 10].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 11].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 12].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 13].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 14].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 15].Red) >> 4) * 30UL +
++		   (((unsigned long) RedPtr.pbrgb[i].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 1].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 2].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 3].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 4].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 5].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 6].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 7].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 8].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 9].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 10].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 11].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 12].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 13].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 14].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 15].Green) >> 4) * 59UL +
++		   (((unsigned long) RedPtr.pbrgb[i].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 1].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 2].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 3].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 4].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 5].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 6].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 7].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 8].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 9].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 10].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 11].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 12].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 13].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 14].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 15].Blue) >> 4) * 11UL) / 100UL);
+ 
+ 		if( bHiRight[1] < bHiRight[0] ) {
+ 			 bHiRight[1] = bHiRight[0];
+_at_@ -199,54 +199,54 @@
+ 	for( bHiLeft[1] = 0, i = dwIndexLeft = _NEG_PAGEWIDTH / 2;
+ 	                                         i < _NEG_PAGEWIDTH600; i += 16 ) {
+ 		bHiLeft [0] =
+-	       (SANE_Byte)(((((u_long) RedPtr.pbrgb[i].Red +
+-		     (u_long) RedPtr.pbrgb[i + 1].Red +
+-		     (u_long) RedPtr.pbrgb[i + 2].Red +
+-		     (u_long) RedPtr.pbrgb[i + 3].Red +
+-		     (u_long) RedPtr.pbrgb[i + 4].Red +
+-		     (u_long) RedPtr.pbrgb[i + 5].Red +
+-		     (u_long) RedPtr.pbrgb[i + 6].Red +
+-		     (u_long) RedPtr.pbrgb[i + 7].Red +
+-		     (u_long) RedPtr.pbrgb[i + 8].Red +
+-		     (u_long) RedPtr.pbrgb[i + 9].Red +
+-		     (u_long) RedPtr.pbrgb[i + 10].Red +
+-		     (u_long) RedPtr.pbrgb[i + 11].Red +
+-		     (u_long) RedPtr.pbrgb[i + 12].Red +
+-		     (u_long) RedPtr.pbrgb[i + 13].Red +
+-		     (u_long) RedPtr.pbrgb[i + 14].Red +
+-		     (u_long) RedPtr.pbrgb[i + 15].Red) >> 4) * 30UL +
+-		   (((u_long) RedPtr.pbrgb[i].Green +
+-		     (u_long) RedPtr.pbrgb[i + 1].Green +
+-		     (u_long) RedPtr.pbrgb[i + 2].Green +
+-		     (u_long) RedPtr.pbrgb[i + 3].Green +
+-		     (u_long) RedPtr.pbrgb[i + 4].Green +
+-		     (u_long) RedPtr.pbrgb[i + 5].Green +
+-		     (u_long) RedPtr.pbrgb[i + 6].Green +
+-		     (u_long) RedPtr.pbrgb[i + 7].Green +
+-		     (u_long) RedPtr.pbrgb[i + 8].Green +
+-		     (u_long) RedPtr.pbrgb[i + 9].Green +
+-		     (u_long) RedPtr.pbrgb[i + 10].Green +
+-		     (u_long) RedPtr.pbrgb[i + 11].Green +
+-		     (u_long) RedPtr.pbrgb[i + 12].Green +
+-		     (u_long) RedPtr.pbrgb[i + 13].Green +
+-		     (u_long) RedPtr.pbrgb[i + 14].Green +
+-		     (u_long) RedPtr.pbrgb[i + 15].Green) >> 4) * 59UL +
+-		   (((u_long) RedPtr.pbrgb[i].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 1].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 2].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 3].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 4].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 5].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 6].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 7].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 8].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 9].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 10].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 11].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 12].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 13].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 14].Blue +
+-		     (u_long) RedPtr.pbrgb[i + 15].Blue) >> 4) * 11UL) / 100UL);
++	       (SANE_Byte)(((((unsigned long) RedPtr.pbrgb[i].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 1].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 2].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 3].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 4].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 5].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 6].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 7].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 8].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 9].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 10].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 11].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 12].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 13].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 14].Red +
++		     (unsigned long) RedPtr.pbrgb[i + 15].Red) >> 4) * 30UL +
++		   (((unsigned long) RedPtr.pbrgb[i].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 1].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 2].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 3].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 4].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 5].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 6].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 7].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 8].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 9].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 10].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 11].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 12].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 13].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 14].Green +
++		     (unsigned long) RedPtr.pbrgb[i + 15].Green) >> 4) * 59UL +
++		   (((unsigned long) RedPtr.pbrgb[i].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 1].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 2].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 3].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 4].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 5].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 6].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 7].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 8].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 9].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 10].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 11].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 12].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 13].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 14].Blue +
++		     (unsigned long) RedPtr.pbrgb[i + 15].Blue) >> 4) * 11UL) / 100UL);
+ 
+ 		if( bHiLeft[1] < bHiLeft[0] ) {
+ 			bHiLeft[1] = bHiLeft[0];
+_at_@ -354,36 +354,36 @@
+ 
+ 		if(dev->CCDID == _CCD_3797 || dev->DACType == _DA_ESIC ) {
+ 			dev->shade.pCcdDac->GainResize.Colors.Red =
+-			                           (u_short)((u_long)bHi[0] * 100UL / dwR);
++			                           (unsigned short)((unsigned long)bHi[0] * 100UL / dwR);
+ 			dev->shade.pCcdDac->GainResize.Colors.Green =
+-			                           (u_short)((u_long)bHi[1] * 100UL / dwG);
++			                           (unsigned short)((unsigned long)bHi[1] * 100UL / dwG);
+ 			dev->shade.pCcdDac->GainResize.Colors.Blue =
+-			                           (u_short)((u_long)bHi[2] * 100UL / dwB);
++			                           (unsigned short)((unsigned long)bHi[2] * 100UL / dwB);
+ 		} else {
+ 			dev->shade.pCcdDac->GainResize.Colors.Red =
+-			                            (u_short)((u_long)bHi[0] * 90UL / dwR);
++			                            (unsigned short)((unsigned long)bHi[0] * 90UL / dwR);
+ 			dev->shade.pCcdDac->GainResize.Colors.Green =
+-			                            (u_short)((u_long)bHi[1] * 77UL / dwG);
++			                            (unsigned short)((unsigned long)bHi[1] * 77UL / dwG);
+ 			dev->shade.pCcdDac->GainResize.Colors.Blue =
+-			                            (u_short)((u_long)bHi[2] * 73UL / dwB);
++			                            (unsigned short)((unsigned long)bHi[2] * 73UL / dwB);
+ 		}
+ 
+ 		dev->shade.DarkOffset.Colors.Red +=
+-		                          (u_short)((dwR > bHi[0]) ? dwR - bHi[0] : 0);
++		                          (unsigned short)((dwR > bHi[0]) ? dwR - bHi[0] : 0);
+ 		dev->shade.DarkOffset.Colors.Green +=
+-		                          (u_short)((dwG > bHi[1]) ? dwG - bHi[1] : 0);
++		                          (unsigned short)((dwG > bHi[1]) ? dwG - bHi[1] : 0);
+ 		dev->shade.DarkOffset.Colors.Blue +=
+-		                          (u_short)((dwB > bHi[2]) ? dwB - bHi[2] : 0);
++		                          (unsigned short)((dwB > bHi[2]) ? dwB - bHi[2] : 0);
+ 
+ 		if( dev->DACType != _DA_ESIC && dev->CCDID != _CCD_3799 ) {
+ 			dev->shade.DarkOffset.Colors.Red =
+-			                       (u_short)(dev->shade.DarkOffset.Colors.Red *
++			                       (unsigned short)(dev->shade.DarkOffset.Colors.Red *
+ 			                dev->shade.pCcdDac->GainResize.Colors.Red / 100UL);
+ 			dev->shade.DarkOffset.Colors.Green =
+-			                     (u_short)(dev->shade.DarkOffset.Colors.Green *
++			                     (unsigned short)(dev->shade.DarkOffset.Colors.Green *
+ 			              dev->shade.pCcdDac->GainResize.Colors.Green / 100UL);
+ 			dev->shade.DarkOffset.Colors.Blue =
+-			                      (u_short)(dev->shade.DarkOffset.Colors.Blue *
++			                      (unsigned short)(dev->shade.DarkOffset.Colors.Blue *
+ 			               dev->shade.pCcdDac->GainResize.Colors.Blue / 100UL);
+ 		}
+ 	}
+_at_@ -397,10 +397,10 @@
+  */
+ static void u12tpa_FindCenterPointer( U12_Device *dev )
+ {
+-	u_long        i;
+-	u_long        width;
+-	u_long        left;
+-	u_long        right;
++	unsigned long        i;
++	unsigned long        width;
++	unsigned long        left;
++	unsigned long        right;
+ 	RGBUShortDef *pwSum = dev->bufs.b2.pSumRGB;
+ 
+ 	if( dev->DataInf.dwScanFlag & _SCANDEF_Negative )
+--- sane-backends-1.0.24.orig/backend/u12.c
++++ sane-backends-1.0.24/backend/u12.c
+_at_@ -678,7 +678,7 @@
+ 		DBG( _DBG_SANE_INIT, "next device uses autodetection\n" );
+ 	} else {
+ 			
+-		u_short pi = 0, vi = 0;
++		unsigned short pi = 0, vi = 0;
+ 
+ 		if( *name ) {
+ 	
+--- sane-backends-1.0.24.orig/backend/u12.h
++++ sane-backends-1.0.24/backend/u12.h
+_at_@ -268,12 +268,12 @@
+ 	/* CCD section */
+ 	SANE_Byte    CCDID;         /**< what CCD do we have              */
+ 	RegDef      *CCDRegs;       /**< pointer to the register descr    */
+-	u_short      numCCDRegs;    /**< number of values to write        */
++	unsigned short      numCCDRegs;    /**< number of values to write        */
+ 
+ 	/* DAC section */
+ 	SANE_Byte    DACType;       /**< what DAC do we have              */
+ 	RegDef      *DACRegs;       /**< pointer to DAC reg descr.        */
+-	u_short      numDACRegs;    /**< number of values to write        */
++	unsigned short      numDACRegs;    /**< number of values to write        */
+ 	pFnDACDark   fnDACDark;     /**<                                  */
+ 	RGBByteDef   RegDACOffset;
+ 	RGBByteDef   RegDACGain;
+_at_@ -286,7 +286,7 @@
+ 	int          scaleStep;  /**< step size for line scaling */
+ 	int          scaleIzoom; /**< factor for line scaling    */
+ 
+-	u_long       ModelOriginY;
++	unsigned long       ModelOriginY;
+ 	SANE_Byte    ModelCtrl;
+ 
+ 	SANE_Bool    Tpa;           /**< do we have a TPA                 */
+--- sane-backends-1.0.24.orig/backend/umax-usb.c
++++ sane-backends-1.0.24/backend/umax-usb.c
+_at_@ -70,7 +70,7 @@
+ 
+ /* Length of the CDB given the SCSI command. The last two are not
+    correct (vendor reserved). */
+-static u_char cdb_sizes[8] = {
++static unsigned char cdb_sizes[8] = {
+     6, 10, 10, 6, 16, 12, 0, 0
+ };
+ #define CDB_SIZE(opcode)	cdb_sizes[(((opcode) >> 5) & 7)]
+_at_@ -149,7 +149,7 @@
+ 		sanei_pv8630_prep_bulkread(fd, *dst_size);
+ 		sanei_pv8630_bulkread(fd, dst, dst_size);
+ 
+-		DBG(DBG_info, "  SCSI cmd returned %lu bytes\n", (u_long) *dst_size);
++		DBG(DBG_info, "  SCSI cmd returned %lu bytes\n", (unsigned long) *dst_size);
+ 
+ 		sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf8, 0xff, 1000);
+ 
+--- sane-backends-1.0.24.orig/backend/umax1220u-common.c
++++ sane-backends-1.0.24/backend/umax1220u-common.c
+_at_@ -452,7 +452,7 @@
+   static unsigned char *escaped = NULL;
+   static size_t escaped_size = 0;
+ 
+-  DBG (80, "cwrite: cmd = %d, len = %lu\n", cmd, (u_long) len);
++  DBG (80, "cwrite: cmd = %d, len = %lu\n", cmd, (unsigned long) len);
+ 
+   CHK (usync (scan, cmd | CMD_WRITE, len));
+ 
+_at_@ -498,7 +498,7 @@
+   SANE_Status res;
+   UMAX_Status_Byte s0, s4;
+ 
+-  DBG (80, "cread: cmd = %d, len = %lu\n", cmd, (u_long) len);
++  DBG (80, "cread: cmd = %d, len = %lu\n", cmd, (unsigned long) len);
+ 
+   CHK (usync (scan, cmd | CMD_READ, len));
+ 
+_at_@ -517,7 +517,7 @@
+           CHK (sanei_pv8630_bulkread (scan->fd, data, &n));
+           if (n < req)
+             {
+-              DBG (1, "qread: Expecting to read %lu, only got %lu\n", (u_long) req, (u_long) n);
++              DBG (1, "qread: Expecting to read %lu, only got %lu\n", (unsigned long) req, (unsigned long) n);
+               return SANE_STATUS_IO_ERROR;
+             }
+           data += n;
+--- sane-backends-1.0.24.orig/backend/umax_pp.h
++++ sane-backends-1.0.24/backend/umax_pp.h
+_at_@ -106,7 +106,7 @@
+   SANE_Int max_h_size;
+   SANE_Int max_v_size;
+   long int buf_size;
+-  u_char revision;
++  unsigned char revision;
+ 
+   /* default values */
+   SANE_Int gray_gain;
+--- sane-backends-1.0.24.orig/backend/xerox_mfp-tcp.c
++++ sane-backends-1.0.24/backend/xerox_mfp-tcp.c
+_at_@ -61,7 +61,7 @@
+ 	len = (size_t)sanei_tcp_write(dev->dn, cmd, cmdlen);
+ 	if (len != cmdlen) {
+ 	    DBG (1, "%s: sent only %lu bytes of %lu\n",
+-		__FUNCTION__, (u_long)len, (u_long)cmdlen);
++		__FUNCTION__, (unsigned long)len, (unsigned long)cmdlen);
+     	    return SANE_STATUS_IO_ERROR;
+ 	}
+     }
+--- sane-backends-1.0.24.orig/backend/xerox_mfp.c
++++ sane-backends-1.0.24/backend/xerox_mfp.c
+_at_@ -103,7 +103,7 @@
+   for (i = 0; i < dlen; i++, dptr += 3)
+     sprintf(dptr, " %02x", dev->res[i]);
+ 
+-  DBG (5, "[%lu]%s%s\n", (u_long)dev->reslen, dbuf,
++  DBG (5, "[%lu]%s%s\n", (unsigned long)dev->reslen, dbuf,
+        (dlen < (int)dev->reslen)? "..." : "");
+ }
+ 
+_at_@ -131,7 +131,7 @@
+ 
+   dev->state = 0;
+   DBG (4, ":: dev_command(%s[%#x], %lu)\n", str_cmd(cmd[2]), cmd[2],
+-       (u_long)reqlen);
++       (unsigned long)reqlen);
+   status = dev->io->dev_request(dev, cmd, sendlen, res, &dev->reslen);
+   if (status != SANE_STATUS_GOOD) {
+     DBG (1, "%s: dev_request: %s\n", __FUNCTION__, sane_strstatus (status));
+_at_@ -147,7 +147,7 @@
+   /* normal command reply, some sanity checking */
+   if (dev->reslen < reqlen) {
+     DBG (1, "%s: illegal response len %lu, need %lu\n",
+-	 __FUNCTION__, (u_long)dev->reslen, (u_long)reqlen);
++	 __FUNCTION__, (unsigned long)dev->reslen, (unsigned long)reqlen);
+     dev->state = SANE_STATUS_IO_ERROR;
+     return 0;
+   } else {
+_at_@ -164,13 +164,13 @@
+     pktlen = dev->res[2] + 3;
+     if (dev->reslen != pktlen) {
+       DBG (2, "%s: illegal response len %lu, should be %lu\n",
+-	   __FUNCTION__, (u_long)pktlen, (u_long)dev->reslen);
++	   __FUNCTION__, (unsigned long)pktlen, (unsigned long)dev->reslen);
+       dev->state = SANE_STATUS_IO_ERROR;
+       return 0;
+     }
+     if (dev->reslen > reqlen)
+       DBG (2, "%s: too big packet len %lu, need %lu\n",
+-	   __FUNCTION__, (u_long)dev->reslen, (u_long)reqlen);
++	   __FUNCTION__, (unsigned long)dev->reslen, (unsigned long)reqlen);
+   }
+ 
+   dev->state = 0;
+_at_@ -1191,14 +1191,14 @@
+       SANE_Byte *rbuf = dev->data + DATATAIL(dev);
+ 
+       DBG (9, "<> request len: %lu, [%d, %d; %d]\n",
+-	   (u_long)datalen, dev->dataoff, DATATAIL(dev), dev->datalen);
++	   (unsigned long)datalen, dev->dataoff, DATATAIL(dev), dev->datalen);
+       if ((status = dev->io->dev_request(dev, NULL, 0, rbuf, &datalen)) !=
+ 	  SANE_STATUS_GOOD)
+ 	return status;
+       dev->datalen += datalen;
+       dev->blocklen -= datalen;
+       DBG (9, "<> got %lu, [%d, %d; %d]\n",
+-	   (u_long)datalen, dev->dataoff, DATATAIL(dev), dev->datalen);
++	   (unsigned long)datalen, dev->dataoff, DATATAIL(dev), dev->datalen);
+       if (dev->blocklen < 0)
+ 	return ret_cancel(dev, SANE_STATUS_IO_ERROR);
+ 
+--- sane-backends-1.0.24.orig/include/sane/config.h.in
++++ sane-backends-1.0.24/include/sane/config.h.in
+_at_@ -609,16 +609,16 @@
+ #endif
+ 
+ #ifndef HAVE_U_CHAR
+-#define u_char unsigned char
++#define unsigned char unsigned char
+ #endif
+ #ifndef HAVE_U_SHORT
+-#define u_short unsigned short
++#define unsigned short unsigned short
+ #endif
+ #ifndef HAVE_U_INT
+-#define u_int unsigned int
++#define unsigned int unsigned int
+ #endif
+ #ifndef HAVE_U_LONG
+-#define u_long unsigned long
++#define unsigned long unsigned long
+ #endif
+ 
+ /* Prototype for getenv */
+--- sane-backends-1.0.24.orig/include/sane/sanei_pa4s2.h
++++ sane-backends-1.0.24/include/sane/sanei_pa4s2.h
+_at_@ -121,7 +121,7 @@
+  * _at_return
+  * - SANE_STATUS_GOOD - on success
+  */
+-extern SANE_Status sanei_pa4s2_options (u_int * options, int set);
++extern SANE_Status sanei_pa4s2_options (unsigned int * options, int set);
+ 
+ /** Enables/disable device
+  *
+_at_@ -151,7 +151,7 @@
+  *
+  * _at_sa sanei_pa4s2_readbyte(), sanei_pa4s2_readend()
+  */
+-extern SANE_Status sanei_pa4s2_readbegin (int fd, u_char reg);
++extern SANE_Status sanei_pa4s2_readbegin (int fd, unsigned char reg);
+ 
+ /** Return port status information
+  *
+_at_@ -162,7 +162,7 @@
+  * - SANE_STATUS_GOOD - on success
+  * - SANE_STATUS_INVAL - if fd is invalid or device not in use
+  */
+-extern SANE_Status sanei_pa4s2_scsi_pp_get_status (int fd, u_char *status);
++extern SANE_Status sanei_pa4s2_scsi_pp_get_status (int fd, unsigned char *status);
+ 
+ /** Selects a register number on a SCSI-over-parallel scanner
+  *
+_at_@ -189,7 +189,7 @@
+  *
+  * _at_sa sanei_pa4s2_readbegin(), sanei_pa4s2_readend()
+  */
+-extern SANE_Status sanei_pa4s2_readbyte (int fd, u_char * val);
++extern SANE_Status sanei_pa4s2_readbyte (int fd, unsigned char * val);
+ 
+ /** Terminate reading sequence 
+  *
+_at_@ -215,6 +215,6 @@
+  * - SANE_STATUS_GOOD - on success
+  * - SANE_STATUS_INVAL - if fd is invalid or device not in use
+  */
+-extern SANE_Status sanei_pa4s2_writebyte (int fd, u_char reg, u_char val);
++extern SANE_Status sanei_pa4s2_writebyte (int fd, unsigned char reg, unsigned char val);
+ 
+ #endif
+--- sane-backends-1.0.24.orig/include/sane/sanei_pio.h
++++ sane-backends-1.0.24/include/sane/sanei_pio.h
+_at_@ -48,8 +48,8 @@
+ 
+ extern SANE_Status	sanei_pio_open  (const char * dev, int * fd);
+ extern void		sanei_pio_close (int fd);
+-extern int		sanei_pio_read  (int fd, u_char * buf, int n);
+-extern int		sanei_pio_write (int fd, const u_char * buf, int n);
++extern int		sanei_pio_read  (int fd, unsigned char * buf, int n);
++extern int		sanei_pio_write (int fd, const unsigned char * buf, int n);
+ 
+ #endif /* sanei_pio_h */
+ 
+--- sane-backends-1.0.24.orig/include/sane/sanei_scsi.h
++++ sane-backends-1.0.24/include/sane/sanei_scsi.h
+_at_@ -66,7 +66,7 @@
+  * - any other status if sense code is regarded as error
+  */
+ typedef SANE_Status (*SANEI_SCSI_Sense_Handler) (int fd,
+-						 u_char *sense_buffer,
++						 unsigned char *sense_buffer,
+ 						 void *arg);
+ /** Maximum size of a SCSI request
+  */
+--- sane-backends-1.0.24.orig/include/sane/sanei_tcp.h
++++ sane-backends-1.0.24/include/sane/sanei_tcp.h
+_at_@ -31,7 +31,7 @@
+ 
+ extern SANE_Status sanei_tcp_open(const char *host, int port, int *fdp);
+ extern void sanei_tcp_close(int fd);
+-extern ssize_t sanei_tcp_write(int fd, const u_char * buf, int count);
+-extern ssize_t sanei_tcp_read(int fd, u_char * buf, int count);
++extern ssize_t sanei_tcp_write(int fd, const unsigned char * buf, int count);
++extern ssize_t sanei_tcp_read(int fd, unsigned char * buf, int count);
+ 
+ #endif /* sanei_tcp_h */
+--- sane-backends-1.0.24.orig/include/sane/sanei_udp.h
++++ sane-backends-1.0.24/include/sane/sanei_udp.h
+_at_@ -32,9 +32,9 @@
+ extern SANE_Status sanei_udp_open_broadcast(int *fdp);
+ extern void sanei_udp_close(int fd);
+ extern void sanei_udp_set_nonblock(int fd, SANE_Bool nonblock);
+-extern ssize_t sanei_udp_write(int fd, const u_char * buf, int count);
+-extern ssize_t sanei_udp_read(int fd, u_char * buf, int count);
+-extern ssize_t sanei_udp_write_broadcast(int fd, int port, const u_char * buf, int count);
+-extern ssize_t sanei_udp_recvfrom(int fd, u_char * buf, int count, char **fromp);
++extern ssize_t sanei_udp_write(int fd, const unsigned char * buf, int count);
++extern ssize_t sanei_udp_read(int fd, unsigned char * buf, int count);
++extern ssize_t sanei_udp_write_broadcast(int fd, int port, const unsigned char * buf, int count);
++extern ssize_t sanei_udp_recvfrom(int fd, unsigned char * buf, int count, char **fromp);
+ 
+ #endif /* sanei_udp_h */
+Only in sane-backends-1.0.24.orig: po/sane-backends.pot
+--- sane-backends-1.0.24.orig/sanei/sanei_DomainOS.c
++++ sane-backends-1.0.24/sanei/sanei_DomainOS.c
+_at_@ -106,8 +106,8 @@
+    {
+    void *DomainSCSIPtr;         /* Pointer to the data block for this device */
+    void *DomainSensePtr;        /* Pointer to the sense area for this device */
+-   u_int in_use  : 1;           /* is this DomainFdInfo in use? */
+-   u_int fake_fd : 1;           /* is this a fake file descriptor? */
++   unsigned int in_use  : 1;           /* is this DomainFdInfo in use? */
++   unsigned int fake_fd : 1;           /* is this a fake file descriptor? */
+    scsi_$handle_t scsi_handle;  /* SCSI handle */
+    scsi_$operation_id_t op_id;  /* op_id of current request */
+    } *DomainFdInfo;
+_at_@ -334,10 +334,10 @@
+                      DomainErrorCheck(sense_status, "Executing sense command");
+                      scsi_$wait(DomainFdInfo[com->fd].scsi_handle, DomainScsiTimeout, true, sense_op_id, 1, status_list, &sense_return_count, &sense_status);
+                      /* The following debug output is scanner specific */
+-                     DBG(2, "Sense information:  Error code=%02x, ASC=%02x, ASCQ=%02x\n", ((u_char *)DomainFdInfo[com->fd].DomainSensePtr)[0], ((char *)DomainFdInfo[com->fd].DomainSensePtr)[0xc], ((char *)DomainFdInfo[com->fd].DomainSensePtr)[0xd]);
++                     DBG(2, "Sense information:  Error code=%02x, ASC=%02x, ASCQ=%02x\n", ((unsigned char *)DomainFdInfo[com->fd].DomainSensePtr)[0], ((char *)DomainFdInfo[com->fd].DomainSensePtr)[0xc], ((char *)DomainFdInfo[com->fd].DomainSensePtr)[0xd]);
+                      DBG(2, " Sense dump:\n");
+                      for (temp = 0; temp < DomainSenseSize; temp++)
+-                        DBG(2, " %02x", ((u_char *)DomainFdInfo[com->fd].DomainSensePtr)[temp]);
++                        DBG(2, " %02x", ((unsigned char *)DomainFdInfo[com->fd].DomainSensePtr)[temp]);
+                      DBG(2, "\n");
+                      /* see if buffer underrun - ILI/Valid are set, and command was a read */
+                      /* Warning - this might be UMAX specific */
+--- sane-backends-1.0.24.orig/sanei/sanei_ab306.c
++++ sane-backends-1.0.24/sanei/sanei_ab306.c
+_at_@ -56,17 +56,17 @@
+ #elif defined (__i386__)  && defined (__GNUC__)
+ 
+ static __inline__ void
+-outb (u_char value, u_long port)
++outb (unsigned char value, unsigned long port)
+ {
+-  __asm__ __volatile__ ("outb %0,%1" : : "a" (value), "d" ((u_short) port));
++  __asm__ __volatile__ ("outb %0,%1" : : "a" (value), "d" ((unsigned short) port));
+ }
+ 
+ static __inline__ u_char
+-inb (u_long port)
++inb (unsigned long port)
+ {
+-  u_char value;
++  unsigned char value;
+ 
+-  __asm__ __volatile__ ("inb %1,%0" : "=a" (value) : "d" ((u_short)port));
++  __asm__ __volatile__ ("inb %1,%0" : "=a" (value) : "d" ((unsigned short)port));
+   return value;
+ }
+ 
+_at_@ -130,19 +130,19 @@
+     0x47, 0x55, 0x54, 0x53, 0x02, 0x01, 0x80
+   };
+ 
+-static u_char cdb_sizes[8] =
++static unsigned char cdb_sizes[8] =
+   {
+     6, 10, 10, 12, 12, 12, 10, 10
+   };
+ #define CDB_SIZE(opcode)	cdb_sizes[(((opcode) >> 5) & 7)]
+ 
+ static void
+-ab306_outb (Port *p, u_long addr, u_char val)
++ab306_outb (Port *p, unsigned long addr, unsigned char val)
+ {
+ 
+   if (p->port_fd >= 0)
+     {
+-      if ((u_long) lseek (p->port_fd, addr, SEEK_SET) != addr)
++      if ((unsigned long) lseek (p->port_fd, addr, SEEK_SET) != addr)
+ 	return;
+       if (write (p->port_fd, &val, 1) != 1)
+ 	return;
+_at_@ -152,13 +152,13 @@
+ }
+ 
+ static int
+-ab306_inb (Port *p, u_long addr)
++ab306_inb (Port *p, unsigned long addr)
+ {
+-  u_char ch;
++  unsigned char ch;
+ 
+   if (p->port_fd >= 0)
+     {
+-      if ((u_long) lseek (p->port_fd, addr, SEEK_SET) != addr)
++      if ((unsigned long) lseek (p->port_fd, addr, SEEK_SET) != addr)
+ 	return -1;
+       if (read (p->port_fd, &ch, 1) != 1)
+ 	return -1;
+_at_@ -172,7 +172,7 @@
+ static void
+ ab306_cout (Port *p, int val)
+ {
+-  u_long base = p->base;
++  unsigned long base = p->base;
+ 
+   while ((ab306_inb (p, base + 1) & 0x80));	/* wait for dir flag */
+   ab306_outb (p, base, val);
+_at_@ -185,8 +185,8 @@
+ static int
+ ab306_cin (Port *p)
+ {
+-  u_long base = p->base;
+-  u_char val;
++  unsigned long base = p->base;
++  unsigned char val;
+ 
+   while ((ab306_inb (p, base + 1) & 0x80) == 0);	/* wait for dir flag */
+   val = ab306_inb (p, base);
+_at_@ -199,8 +199,8 @@
+ static SANE_Status
+ ab306_write (Port *p, const void *buf, size_t len)
+ {
+-  u_long base = p->base;
+-  u_int i;
++  unsigned long base = p->base;
++  unsigned int i;
+   int cksum = 0;
+ 
+   DBG(3, "ab306_write: waiting for scanner to be ready %02x\n",
+_at_@ -211,8 +211,8 @@
+   DBG(4, "ab306_write: writing data\n");
+   for (i = 0; i < len; ++i)
+     {
+-      ab306_cout (p, ((const u_char *) buf)[i]);
+-      cksum += ((const u_char *) buf)[i];
++      ab306_cout (p, ((const unsigned char *) buf)[i]);
++      cksum += ((const unsigned char *) buf)[i];
+     }
+ 
+   DBG(4, "ab306_write: writing checksum\n");
+_at_@ -251,8 +251,8 @@
+ {
+   static int first_time = 1;
+   SANE_Status status;
+-  u_char byte;
+-  u_long base;
++  unsigned char byte;
++  unsigned long base;
+   char *end;
+   int i, j;
+ 
+_at_@ -386,10 +386,10 @@
+ 		 void *dst, size_t * dst_size)
+ {
+   Port *p = port + fd;
+-  const u_char *cp = src;
++  const unsigned char *cp = src;
+   size_t cdb_size = CDB_SIZE(cp[0]);
+   SANE_Status status;
+-  u_char byte;
++  unsigned char byte;
+ 
+   /* If this is a READ_SCANNED_DATA command, reset lstat: */
+   switch (cp[0])
+_at_@ -426,7 +426,7 @@
+ 
+   if (dst && *dst_size > 0)
+     {
+-      u_int i, cksum = 0;
++      unsigned int i, cksum = 0;
+ 
+       DBG(3, "sanei_ab306_cmd: waiting for scanner to be NOT ready %02x\n",
+ 	  ab306_inb (p, p->base + 1));
+_at_@ -436,7 +436,7 @@
+ 	{
+ 	  byte = ab306_cin (p);
+ 	  cksum += byte;
+-	  ((u_char *) dst)[i] = byte;
++	  ((unsigned char *) dst)[i] = byte;
+ 	}
+       cksum += ab306_cin (p);		/* add in checksum */
+ 
+_at_@ -482,7 +482,7 @@
+ 	      /* the pixel-loop: */
+ 	      for (bcnt = 0; bcnt < xmax; bcnt++)
+ 		{
+-		  if ((u_long) lseek (p->port_fd, p->base, SEEK_SET) != p->base)
++		  if ((unsigned long) lseek (p->port_fd, p->base, SEEK_SET) != p->base)
+ 		    return SANE_STATUS_IO_ERROR;
+ 		  if (read (p->port_fd, buf, 1) != 1)
+ 		    return SANE_STATUS_IO_ERROR;
+_at_@ -494,7 +494,7 @@
+ 	      /* the pixel-loop: */
+ 	      for (bcnt = 0; bcnt < xmax; bcnt++)
+ 		{
+-		  *(u_char *) buf = inb (p->base);
++		  *(unsigned char *) buf = inb (p->base);
+ 		  ++buf;
+ 		}
+ 	    }
+_at_@ -527,7 +527,7 @@
+ sanei_ab306_test_ready (int fd)
+ {
+   Port *p = port + fd;
+-  u_char byte;
++  unsigned char byte;
+ 
+   byte = ab306_inb (p, p->base + 1);
+   if (byte & 0x20)
+--- sane-backends-1.0.24.orig/sanei/sanei_lm983x.c
++++ sane-backends-1.0.24/sanei/sanei_lm983x.c
+_at_@ -201,7 +201,7 @@
+ 				return result;
+ 
+ 			read_bytes += size;
+-			DBG( 15, "sanei_lm983x_read: read %lu bytes\n", (u_long) size );
++			DBG( 15, "sanei_lm983x_read: read %lu bytes\n", (unsigned long) size );
+ 
+ 			if( read_bytes != max_len ) {
+ 				DBG( 2, "sanei_lm983x_read: short read (%d/%d)\n",
+--- sane-backends-1.0.24.orig/sanei/sanei_pa4s2.c
++++ sane-backends-1.0.24/sanei/sanei_pa4s2.c
+_at_@ -85,17 +85,17 @@
+ # elif defined(__i386__)  && ( defined (__GNUC__) || defined (__ICC) )
+ 
+ static __inline__ void
+-outb (u_char value, u_long port)
++outb (unsigned char value, unsigned long port)
+ {
+-  __asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((u_short) port));
++  __asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((unsigned short) port));
+ }
+ 
+ static __inline__ u_char
+-inb (u_long port)
++inb (unsigned long port)
+ {
+-  u_char value;
++  unsigned char value;
+ 
+-  __asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((u_short) port));
++  __asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((unsigned short) port));
+   return value;
+ }
+ 
+_at_@ -195,12 +195,12 @@
+   {
+ #ifndef HAVE_LIBIEEE1284
+     const char name[6];
+-    u_long base;		/* i/o base address */
++    unsigned long base;		/* i/o base address */
+ #endif
+-    u_int in_use;		/* port in use? */
+-    u_int enabled;		/* port enabled? */
+-    u_int mode;			/* protocoll */
+-    u_char prelock[3];		/* state of port */
++    unsigned int in_use;		/* port in use? */
++    unsigned int enabled;		/* port enabled? */
++    unsigned int mode;			/* protocoll */
++    unsigned char prelock[3];		/* state of port */
+ #ifdef HAVE_LIBIEEE1284
+     int caps;
+ #endif
+_at_@ -226,23 +226,23 @@
+ 
+ #endif
+ 
+-static u_int sanei_pa4s2_interface_options = SANEI_PA4S2_OPT_DEFAULT;
++static unsigned int sanei_pa4s2_interface_options = SANEI_PA4S2_OPT_DEFAULT;
+ 
+ extern int setuid (uid_t);	/* should also be in unistd.h */
+ 
+ static int pa4s2_open (const char *dev, SANE_Status * status);
+-static void pa4s2_readbegin_epp (int fd, u_char reg);
+-static u_char pa4s2_readbyte_epp (int fd);
++static void pa4s2_readbegin_epp (int fd, unsigned char reg);
++static unsigned char pa4s2_readbyte_epp (int fd);
+ static void pa4s2_readend_epp (int fd);
+-static void pa4s2_readbegin_uni (int fd, u_char reg);
+-static u_char pa4s2_readbyte_uni (int fd);
++static void pa4s2_readbegin_uni (int fd, unsigned char reg);
++static unsigned char pa4s2_readbyte_uni (int fd);
+ static void pa4s2_readend_uni (int fd);
+-static void pa4s2_readbegin_nib (int fd, u_char reg);
+-static u_char pa4s2_readbyte_nib (int fd);
++static void pa4s2_readbegin_nib (int fd, unsigned char reg);
++static unsigned char pa4s2_readbyte_nib (int fd);
+ static void pa4s2_readend_nib (int fd);
+-static void pa4s2_writebyte_any (int fd, u_char reg, u_char val);
+-static int pa4s2_enable (int fd, u_char * prelock);
+-static int pa4s2_disable (int fd, u_char * prelock);
++static void pa4s2_writebyte_any (int fd, unsigned char reg, unsigned char val);
++static int pa4s2_enable (int fd, unsigned char * prelock);
++static int pa4s2_disable (int fd, unsigned char * prelock);
+ static int pa4s2_close (int fd, SANE_Status * status);
+ 
+ #if defined (HAVE_LIBIEEE1284)
+_at_@ -383,7 +383,7 @@
+ 
+   int n, result;
+ #if !defined (HAVE_LIBIEEE1284)
+-  u_long base;
++  unsigned long base;
+ #endif
+   
+   DBG (4, "pa4s2_open: trying to attach dev `%s`\n", dev);
+_at_@ -554,7 +554,7 @@
+ #define inbyte0(fd)	ieee1284_read_data(pplist.portv[fd]);
+ #define inbyte1(fd)	(ieee1284_read_status(pplist.portv[fd]) ^ S1284_INVERTED)
+ #define inbyte2(fd)	(ieee1284_read_control(pplist.portv[fd]) ^ C1284_INVERTED)
+-static u_char inbyte4(int fd)
++static unsigned char inbyte4(int fd)
+ {
+   char val;
+   ieee1284_epp_read_data(pplist.portv[fd], 0, &val, 1);
+_at_@ -565,7 +565,7 @@
+ #define outbyte1(fd,val)	/* ieee1284_write_status(pplist.portv[fd], (val) ^ S1284_INVERTED) */
+ #define outbyte2(fd,val)	ieee1284_write_control(pplist.portv[fd], (val) ^ C1284_INVERTED)
+ 
+-static void outbyte3(int fd, u_char val)
++static void outbyte3(int fd, unsigned char val)
+ {
+   ieee1284_epp_write_addr (pplist.portv[fd], 0, (char *)&val, 1);
+ }
+_at_@ -586,7 +586,7 @@
+ 
+ 
+ static void
+-pa4s2_readbegin_epp (int fd, u_char reg)
++pa4s2_readbegin_epp (int fd, unsigned char reg)
+ {
+ 
+ #if defined(HAVE_LIBIEEE1284)
+_at_@ -609,7 +609,7 @@
+ pa4s2_readbyte_epp (int fd)
+ {
+ 
+-  u_char val = inbyte4 (fd);
++  unsigned char val = inbyte4 (fd);
+ 
+ #if defined(HAVE_LIBIEEE1284)
+   DBG (6, "pa4s2_readbyte_epp: reading value 0x%02x from '%s'\n",
+_at_@ -636,7 +636,7 @@
+ }
+ 
+ static void
+-pa4s2_readbegin_uni (int fd, u_char reg)
++pa4s2_readbegin_uni (int fd, unsigned char reg)
+ {
+ 
+ #if defined(HAVE_LIBIEEE1284)
+_at_@ -658,7 +658,7 @@
+ static u_char
+ pa4s2_readbyte_uni (int fd)
+ {
+-  u_char val;
++  unsigned char val;
+ 
+   outbyte2 (fd, 0x05);
+   val = inbyte2(fd);
+_at_@ -687,7 +687,7 @@
+ }
+ 
+ static void
+-pa4s2_readbegin_nib (int fd, u_char reg)
++pa4s2_readbegin_nib (int fd, unsigned char reg)
+ {
+ 
+ #if defined(HAVE_LIBIEEE1284)
+_at_@ -711,7 +711,7 @@
+ pa4s2_readbyte_nib (int fd)
+ {
+ 
+-  u_char val;
++  unsigned char val;
+   
+   outbyte2 (fd, 0x05);
+   val = inbyte1(fd);
+_at_@ -741,7 +741,7 @@
+ }
+ 
+ static void
+-pa4s2_writebyte_any (int fd, u_char reg, u_char val)
++pa4s2_writebyte_any (int fd, unsigned char reg, unsigned char val)
+ {
+ 
+   /* somebody from Mustek asked me once, why I was writing the same
+_at_@ -776,7 +776,7 @@
+ }
+ 
+ static int
+-pa4s2_enable (int fd, u_char * prelock)
++pa4s2_enable (int fd, unsigned char * prelock)
+ {
+ #if defined (HAVE_LIBIEEE1284)
+   int result;
+_at_@ -813,7 +813,7 @@
+ }
+ 
+ static int
+-pa4s2_disable (int fd, u_char * prelock)
++pa4s2_disable (int fd, unsigned char * prelock)
+ {
+ 
+   if ((sanei_pa4s2_interface_options & SANEI_PA4S2_OPT_ALT_LOCK) != 0)
+_at_@ -962,9 +962,9 @@
+  * Needed for SCSI-over-parallel scanners (Paragon 600 II EP)
+  */
+ SANE_Status
+-sanei_pa4s2_scsi_pp_get_status(int fd, u_char *status)
++sanei_pa4s2_scsi_pp_get_status(int fd, unsigned char *status)
+ {
+-  u_char stat;
++  unsigned char stat;
+ 
+   TEST_DBG_INIT ();
+ 
+_at_@ -1090,7 +1090,7 @@
+        (int) reg, pplist.portv[fd]->name);
+ #else
+   DBG (6, "sanei_pa4s2_scsi_pp_reg_select: selecting register %u at 0x%03lx\n",
+-       (int) reg, (u_long)port[fd].base);
++       (int) reg, (unsigned long)port[fd].base);
+ #endif
+ 
+   outbyte0 (fd, reg | 0x58);
+_at_@ -1111,7 +1111,7 @@
+ sanei_pa4s2_scsi_pp_open (const char *dev, int *fd)
+ {
+ 
+-  u_char val;
++  unsigned char val;
+   SANE_Status status;
+ 
+   TEST_DBG_INIT ();
+_at_@ -1174,7 +1174,7 @@
+ sanei_pa4s2_open (const char *dev, int *fd)
+ {
+ 
+-  u_char asic, val;
++  unsigned char asic, val;
+   SANE_Status status;
+ 
+   TEST_DBG_INIT ();
+_at_@ -1472,7 +1472,7 @@
+ }
+ 
+ SANE_Status
+-sanei_pa4s2_readbegin (int fd, u_char reg)
++sanei_pa4s2_readbegin (int fd, unsigned char reg)
+ {
+ 
+   TEST_DBG_INIT ();
+_at_@ -1566,7 +1566,7 @@
+ }
+ 
+ SANE_Status
+-sanei_pa4s2_readbyte (int fd, u_char * val)
++sanei_pa4s2_readbyte (int fd, unsigned char * val)
+ {
+ 
+   TEST_DBG_INIT ();
+_at_@ -1782,7 +1782,7 @@
+ }
+ 
+ SANE_Status
+-sanei_pa4s2_writebyte (int fd, u_char reg, u_char val)
++sanei_pa4s2_writebyte (int fd, unsigned char reg, unsigned char val)
+ {
+ 
+   TEST_DBG_INIT ();
+_at_@ -1864,7 +1864,7 @@
+ }
+ 
+ SANE_Status
+-sanei_pa4s2_options (u_int * options, int set)
++sanei_pa4s2_options (unsigned int * options, int set)
+ {
+ 
+   TEST_DBG_INIT ();
+_at_@ -1966,7 +1966,7 @@
+ }
+ 
+ SANE_Status
+-sanei_pa4s2_readbegin (int fd, u_char reg)
++sanei_pa4s2_readbegin (int fd, unsigned char reg)
+ {
+ 
+   TEST_DBG_INIT ();
+_at_@ -1985,7 +1985,7 @@
+ }
+ 
+ SANE_Status
+-sanei_pa4s2_readbyte (int fd, u_char * val)
++sanei_pa4s2_readbyte (int fd, unsigned char * val)
+ {
+ 
+   TEST_DBG_INIT ();
+_at_@ -2019,7 +2019,7 @@
+ }
+ 
+ SANE_Status
+-sanei_pa4s2_writebyte (int fd, u_char reg, u_char val)
++sanei_pa4s2_writebyte (int fd, unsigned char reg, unsigned char val)
+ {
+ 
+   TEST_DBG_INIT ();
+_at_@ -2037,7 +2037,7 @@
+ }
+ 
+ SANE_Status
+-sanei_pa4s2_options (u_int * options, int set)
++sanei_pa4s2_options (unsigned int * options, int set)
+ {
+ 
+   TEST_DBG_INIT ();
+_at_@ -2071,7 +2071,7 @@
+ }
+ 
+ SANE_Status
+-sanei_pa4s2_scsi_pp_get_status(int fd, u_char *status)
++sanei_pa4s2_scsi_pp_get_status(int fd, unsigned char *status)
+ {
+   TEST_DBG_INIT ();
+   DBG (4, "sanei_pa4s2_scsi_pp_get_status: fd=%d, status=%p\n",
+--- sane-backends-1.0.24.orig/sanei/sanei_pio.c
++++ sane-backends-1.0.24/sanei/sanei_pio.c
+_at_@ -68,17 +68,17 @@
+ #elif defined(__i386__)  && defined (__GNUC__)
+ 
+ static __inline__ void
+-outb (u_char value, u_long port)
++outb (unsigned char value, unsigned long port)
+ {
+-  __asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((u_short) port));
++  __asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((unsigned short) port));
+ }
+ 
+ static __inline__ u_char
+-inb (u_long port)
++inb (unsigned long port)
+ {
+-  u_char value;
++  unsigned char value;
+ 
+-  __asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((u_short) port));
++  __asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((unsigned short) port));
+   return value;
+ }
+ 
+_at_@ -145,10 +145,10 @@
+ 
+ typedef struct
+   {
+-    u_long base;		/* i/o base address */
++    unsigned long base;		/* i/o base address */
+     int fd;			/* >= 0 when using /dev/port */
+     int max_time_seconds;/* forever if <= 0 */
+-    u_int in_use;		/* port in use? */
++    unsigned int in_use;		/* port in use? */
+   }
+ PortRec, *Port;
+ 
+_at_@ -160,26 +160,26 @@
+ 
+ extern int setuid (uid_t);
+ 
+-static inline int pio_outb (const Port port, u_char val, u_long addr);
+-static inline int pio_inb (const Port port, u_char * val, u_long addr);
+-static inline int pio_wait (const Port port, u_char val, u_char mask);
+-static inline void pio_ctrl (const Port port, u_char val);
++static inline int pio_outb (const Port port, unsigned char val, unsigned long addr);
++static inline int pio_inb (const Port port, unsigned char * val, unsigned long addr);
++static inline int pio_wait (const Port port, unsigned char val, unsigned char mask);
++static inline void pio_ctrl (const Port port, unsigned char val);
+ static inline void pio_delay (const Port port);
+ static inline void pio_init (const Port port);
+ static void pio_reset (const Port port);
+-static int pio_write (const Port port, const u_char * buf, int n);
+-static int pio_read (const Port port, u_char * buf, int n);
++static int pio_write (const Port port, const unsigned char * buf, int n);
++static int pio_read (const Port port, unsigned char * buf, int n);
+ static int pio_open (const char *dev, SANE_Status * status);
+ 
+ static inline int 
+-pio_outb (const Port port, u_char val, u_long addr)
++pio_outb (const Port port, unsigned char val, unsigned long addr)
+ {
+ 
+   if (-1 == port->fd)
+     outb (val, addr);
+   else
+     {
+-      if (addr != (u_long)lseek (port->fd, addr, SEEK_SET))
++      if (addr != (unsigned long)lseek (port->fd, addr, SEEK_SET))
+ 	return -1;
+       if (1 != write (port->fd, &val, 1))
+ 	return -1;
+_at_@ -188,14 +188,14 @@
+ }
+ 
+ static inline int 
+-pio_inb (const Port port, u_char * val, u_long addr)
++pio_inb (const Port port, unsigned char * val, unsigned long addr)
+ {
+ 
+   if (-1 == port->fd)
+     *val = inb (addr);
+   else
+     {
+-      if (addr != (u_long)lseek (port->fd, addr, SEEK_SET))
++      if (addr != (unsigned long)lseek (port->fd, addr, SEEK_SET))
+ 	return -1;
+       if (1 != read (port->fd, val, 1))
+ 	return -1;
+_at_@ -204,7 +204,7 @@
+ }
+ 
+ static inline int 
+-pio_wait (const Port port, u_char val, u_char mask)
++pio_wait (const Port port, unsigned char val, unsigned char mask)
+ {
+   int stat = 0;
+   long poll_count = 0;
+_at_@ -246,7 +246,7 @@
+ }
+ 
+ static inline void
+-pio_ctrl (const Port port, u_char val)
++pio_ctrl (const Port port, unsigned char val)
+ {
+   DBG (DL60, "ctrl on port 0x%03lx %02x %02x\n",
+        port->base, (int) val, (int) val ^ PIO_CTRL_NINIT);
+_at_@ -300,7 +300,7 @@
+ }
+ 
+ static int 
+-pio_write (const Port port, const u_char * buf, int n)
++pio_write (const Port port, const unsigned char * buf, int n)
+ {
+   int k;
+ 
+_at_@ -354,7 +354,7 @@
+ }
+ 
+ static int 
+-pio_read (const Port port, u_char * buf, int n)
++pio_read (const Port port, unsigned char * buf, int n)
+ {
+   int k;
+ 
+_at_@ -405,7 +405,7 @@
+ pio_open (const char *dev, SANE_Status * status)
+ {
+   static int first_time = 1;
+-  u_long base;
++  unsigned long base;
+   int n;
+ 
+   if (first_time)
+_at_@ -510,7 +510,7 @@
+ }
+ 
+ int 
+-sanei_pio_read (int fd, u_char * buf, int n)
++sanei_pio_read (int fd, unsigned char * buf, int n)
+ {
+   if ((0 > fd) && (NELEMS (port) <= fd))
+     return -1;
+_at_@ -522,7 +522,7 @@
+ }
+ 
+ int 
+-sanei_pio_write (int fd, const u_char * buf, int n)
++sanei_pio_write (int fd, const unsigned char * buf, int n)
+ {
+   if ((0 > fd) && (NELEMS (port) <= fd))
+     return -1;
+_at_@ -561,13 +561,13 @@
+ }
+ 
+ int 
+-sanei_pio_read (int fd, u_char * buf, int n)
++sanei_pio_read (int fd, unsigned char * buf, int n)
+ {
+ 	return(read(fd,buf,n));
+ }
+ 
+ int 
+-sanei_pio_write (int fd, const u_char * buf, int n)
++sanei_pio_write (int fd, const unsigned char * buf, int n)
+ {
+   	return(write(fd,buf,n));
+ }
+_at_@ -589,13 +589,13 @@
+ }
+ 
+ int 
+-sanei_pio_read (int fd, u_char * buf, int n)
++sanei_pio_read (int fd, unsigned char * buf, int n)
+ {
+   return -1;
+ }
+ 
+ int 
+-sanei_pio_write (int fd, const u_char * buf, int n)
++sanei_pio_write (int fd, const unsigned char * buf, int n)
+ {
+   return -1;
+ }
+--- sane-backends-1.0.24.orig/sanei/sanei_pp.c
++++ sane-backends-1.0.24/sanei/sanei_pp.c
+_at_@ -106,17 +106,17 @@
+ # elif defined(__i386__)  && ( defined (__GNUC__) || defined (__ICC) )
+ 
+ static __inline__ void
+-outb( u_char value, u_long port )
++outb( unsigned char value, unsigned long port )
+ {
+-  __asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((u_short) port));
++  __asm__ __volatile__ ("outb %0,%1"::"a" (value), "d" ((unsigned short) port));
+ }
+ 
+ static __inline__ u_char
+-inb( u_long port )
++inb( unsigned long port )
+ {
+-  u_char value;
++  unsigned char value;
+ 
+-  __asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((u_short) port));
++  __asm__ __volatile__ ("inb %1,%0":"=a" (value):"d" ((unsigned short) port));
+   return value;
+ }
+ # endif
+_at_@ -158,13 +158,13 @@
+ 	
+ #ifndef HAVE_LIBIEEE1284
+ 	const char name[6];
+-	u_long     base;        /**< i/o base address                */
+-	u_char     ctrl;        /**< for restoring CTRL register     */
+-	u_char     ecp_ctrl;    /**< for restoring ECP-CTRL register */
++	unsigned long     base;        /**< i/o base address                */
++	unsigned char     ctrl;        /**< for restoring CTRL register     */
++	unsigned char     ecp_ctrl;    /**< for restoring ECP-CTRL register */
+ #endif
+ 
+-	u_int in_use;           /**< port in use?      */
+-	u_int claimed;          /**< port claimed?     */
++	unsigned int in_use;           /**< port in use?      */
++	unsigned int claimed;          /**< port claimed?     */
+ 	
+ 	int caps;               /**< port capabilities */
+ 
+_at_@ -209,14 +209,14 @@
+ #define inb_stat(fd) (ieee1284_read_status(pplist.portv[fd]) ^ S1284_INVERTED)
+ #define inb_ctrl(fd) (ieee1284_read_control(pplist.portv[fd]) ^ C1284_INVERTED)
+ 
+-static inline u_char inb_eppdata(int fd)
++static inline unsigned char inb_eppdata(int fd)
+ {
+-	u_char val;
++	unsigned char val;
+ 	ieee1284_epp_read_data(pplist.portv[fd], 0, (char *)&val, 1);
+ 	return val;
+ }
+ 
+-static inline void outb_eppdata(int fd, u_char val)
++static inline void outb_eppdata(int fd, unsigned char val)
+ {
+ 	ieee1284_epp_write_data(pplist.portv[fd], 0, (const char *)&val, 1);
+ }
+_at_@ -224,7 +224,7 @@
+ #define outb_data(fd,val) ieee1284_write_data(pplist.portv[fd], val)
+ #define outb_ctrl(fd,val) ieee1284_write_control(pplist.portv[fd], \
+                                                    (val) ^ C1284_INVERTED)
+-static inline void outb_addr(int fd, u_char val)
++static inline void outb_addr(int fd, unsigned char val)
+ {
+ 	ieee1284_epp_write_addr (pplist.portv[fd], 0, (char *)&val, 1);
+ }
+_at_@ -754,7 +754,7 @@
+ {
+ 	int i;
+ #if !defined (HAVE_LIBIEEE1284)
+-	u_long base;
++	unsigned long base;
+ #else
+ 	int result;
+ #endif
+--- sane-backends-1.0.24.orig/sanei/sanei_scsi.c
++++ sane-backends-1.0.24/sanei/sanei_scsi.c
+_at_@ -370,7 +370,7 @@
+ {
+   struct req *next;
+   int fd;
+-  u_int running:1, done:1;
++  unsigned int running:1, done:1;
+   SANE_Status status;
+   size_t *dst_len;
+   void *dst;
+_at_@ -397,7 +397,7 @@
+     struct
+     {
+       struct sg_io_hdr hdr;
+-      u_char sense_buffer[SENSE_MAX];
++      unsigned char sense_buffer[SENSE_MAX];
+       u_int8_t data[1];
+     }
+     sg3;
+_at_@ -424,16 +424,16 @@
+ 
+ static struct
+ {
+-  u_int in_use:1;		/* is this fd_info in use? */
+-  u_int fake_fd:1;		/* is this a fake file descriptor? */
+-  u_int bus, target, lun;	/* nexus info; used for some interfaces only */
++  unsigned int in_use:1;		/* is this fd_info in use? */
++  unsigned int fake_fd:1;		/* is this a fake file descriptor? */
++  unsigned int bus, target, lun;	/* nexus info; used for some interfaces only */
+   SANEI_SCSI_Sense_Handler sense_handler;
+   void *sense_handler_arg;
+   void *pdata;			/* platform-specific data */
+ }
+  *fd_info;
+ 
+-static u_char cdb_sizes[8] = {
++static unsigned char cdb_sizes[8] = {
+   6, 10, 10, 12, 12, 12, 10, 10
+ };
+ #define CDB_SIZE(opcode)	cdb_sizes[(((opcode) >> 5) & 7)]
+_at_@ -868,7 +868,7 @@
+ 		 SANEI_SCSI_Sense_Handler handler, void *handler_arg)
+ #endif
+ {
+-  u_int bus = 0, target = 0, lun = 0, fake_fd = 0;
++  unsigned int bus = 0, target = 0, lun = 0, fake_fd = 0;
+   char *real_dev = 0;
+   void *pdata = 0;
+   char *cc, *cc1;
+_at_@ -878,7 +878,7 @@
+ #elif USE == MACOSX_INTERFACE  
+   UInt8 *guid;
+   int len;
+-  u_int d;
++  unsigned int d;
+ #endif
+ 
+   cc = getenv ("SANE_SCSICMD_TIMEOUT");
+_at_@ -1221,7 +1221,7 @@
+ #elif USE == WIN32_INTERFACE
+   {
+ 	  char scsi_hca_name[20];
+-	  u_int hca = 0;
++	  unsigned int hca = 0;
+  
+ 	  if (sscanf (dev, "h%ub%ut%ul%u", &hca, &bus, &target, &lun) != 4)
+ 		  {
+_at_@ -1773,7 +1773,7 @@
+ 	  /* Call the sense handler, if defined */
+ 	  handler = fd_info[com->fd].sense_handler;
+ 	  if (handler)
+-	    (*handler) (fd, ((u_char *) fd_info[fd].pdata
++	    (*handler) (fd, ((unsigned char *) fd_info[fd].pdata
+ 			     + DomainMaxDataSize),
+ 			fd_info[com->fd].sense_handler_arg);
+ 	  sane_status = SANE_STATUS_IO_ERROR;
+_at_@ -2110,7 +2110,7 @@
+ 	if (!req)
+ 	  {
+ 	    DBG (1, "sanei_scsi_req_enter: failed to malloc %lu bytes\n",
+-		 (u_long) size);
++		 (unsigned long) size);
+ 	    return SANE_STATUS_NO_MEM;
+ 	  }
+       }
+_at_@ -2132,7 +2132,7 @@
+ 	  + sizeof (req->sgdata.cdb.hdr);
+ 	memcpy (&req->sgdata.cdb.data, cmd, cmd_size);
+ 	memcpy (&req->sgdata.cdb.data[cmd_size], src, src_size);
+-	if (CDB_SIZE (*(const u_char *) cmd) != cmd_size)
++	if (CDB_SIZE (*(const unsigned char *) cmd) != cmd_size)
+ 	  {
+ 	    if (ioctl (fd, SG_NEXT_CMD_LEN, &cmd_size))
+ 	      {
+_at_@ -3180,7 +3180,7 @@
+     int result;
+ 
+ /* xxx obsolete: 
+-  cdb_size = CDB_SIZE (*(u_char *) src);
++  cdb_size = CDB_SIZE (*(unsigned char *) src);
+ */
+ 
+     memset (&hdr, 0, sizeof (hdr));
+_at_@ -3339,7 +3339,7 @@
+ 	if (handler && (ccb->ccb_h.status & CAM_AUTOSNS_VALID))
+ 	  {
+ 	    SANE_Status st = (*handler)
+-	      (fd, ((u_char *) (&ccb->csio.sense_data)),
++	      (fd, ((unsigned char *) (&ccb->csio.sense_data)),
+ 	       fd_info[fd].sense_handler_arg);
+ 	    cam_freeccb (ccb);
+ 	    return st;
+_at_@ -3548,7 +3548,7 @@
+     struct sctl_io hdr;
+     /* xxx obsolete size_t cdb_size;
+ 
+-       cdb_size = CDB_SIZE (*(u_char *) src);
++       cdb_size = CDB_SIZE (*(unsigned char *) src);
+      */
+ 
+     memset (&hdr, 0, sizeof (hdr));
+_at_@ -3601,7 +3601,7 @@
+     struct scsi_req hdr;
+     /* xxx obsolete size_t cdb_size;
+ 
+-       cdb_size = CDB_SIZE (*(u_char *) src);
++       cdb_size = CDB_SIZE (*(unsigned char *) src);
+      */
+ 
+     memset (&hdr, 0, sizeof (hdr));
+_at_@ -3667,7 +3667,7 @@
+ 	    sr.sr_esense = sense_reply;
+ 	    if (fd_info[fd].sense_handler)
+ 	      return (*fd_info[fd].sense_handler)
+-		(fd, (u_char *) & sr.sr_esense,
++		(fd, (unsigned char *) & sr.sr_esense,
+ 		 fd_info[fd].sense_handler_arg);
+ 	  }
+ 
+_at_@ -3676,7 +3676,7 @@
+       }
+ 
+     if (hdr.sr_scsi_status == SR_IOST_CHKSV && fd_info[fd].sense_handler)
+-      return (*fd_info[fd].sense_handler) (fd, (u_char *) & hdr.sr_esense,
++      return (*fd_info[fd].sense_handler) (fd, (unsigned char *) & hdr.sr_esense,
+ 					   fd_info[fd].sense_handler_arg);
+     if (dst_size)
+       *dst_size = hdr.sr_dma_xfr;
+_at_@ -3692,12 +3692,12 @@
+ 		     const void *src, size_t src_size,
+ 		     void *dst, size_t * dst_size)
+   {
+-    u_char sense[64];
++    unsigned char sense[64];
+     UAGT_CAM_CCB hdr;
+     CCB_SCSIIO ccb;
+     /* xxx obsolete size_t cdb_size;
+ 
+-       cdb_size = CDB_SIZE (*(u_char *) src);
++       cdb_size = CDB_SIZE (*(unsigned char *) src);
+      */
+ 
+     memset (&ccb, 0, sizeof (ccb));
+_at_@ -3714,7 +3714,7 @@
+ 	/* xxx obsolete assert (cdb_size == src_size);
+ 	 */
+ 	ccb.cam_ch.cam_flags |= CAM_DIR_IN;
+-	ccb.cam_data_ptr = (u_char *) dst;
++	ccb.cam_data_ptr = (unsigned char *) dst;
+ 	ccb.cam_dxfer_len = *dst_size;
+       }
+     else
+_at_@ -3725,7 +3725,7 @@
+ 	  ccb.cam_ch.cam_flags |= CAM_DIR_NONE;
+ 	else
+ 	  ccb.cam_ch.cam_flags |= CAM_DIR_OUT;
+-	ccb.cam_data_ptr = (u_char *) src;
++	ccb.cam_data_ptr = (unsigned char *) src;
+ 	ccb.cam_dxfer_len = src_size;
+       }
+     ccb.cam_timeout = sane_scsicmd_timeout;
+_at_@ -3774,7 +3774,7 @@
+ 		     const void *src, size_t src_size,
+ 		     void *dst, size_t * dst_size)
+   {
+-    static u_char sense_buffer[256];
++    static unsigned char sense_buffer[256];
+     struct scsicmd2 sc2;
+     struct scsicmd *sc;
+     /* xxx obsolete int cdb_size;
+_at_@ -3790,7 +3790,7 @@
+     sc2.sense_len = sizeof (sense_buffer);
+     sc2.sense_ptr = sense_buffer;
+ 
+-    /* xxx obsolete cdb_size = CDB_SIZE (*(u_char *) src);
++    /* xxx obsolete cdb_size = CDB_SIZE (*(unsigned char *) src);
+      */
+     if (dst_size && *dst_size)
+       {
+_at_@ -3857,7 +3857,7 @@
+ 
+     /* xxx obsolete size_t cdb_size;
+ 
+-       cdb_size = CDB_SIZE (*(u_char *) src);
++       cdb_size = CDB_SIZE (*(unsigned char *) src);
+      */
+     memset (&cmd, 0, 16);
+     sb_ptr = &sb;
+_at_@ -3986,7 +3986,7 @@
+ 		  {
+ 		    void *arg = fd_info[fd].sense_handler_arg;
+ 		    return (*fd_info[fd].sense_handler) (fd,
+-							 (u_char *) & sb_ptr->
++							 (unsigned char *) & sb_ptr->
+ 							 SCB.sc_link, arg);
+ 		  }
+ 	      return SANE_STATUS_IO_ERROR;
+_at_@ -4005,7 +4005,7 @@
+ 		     const void *src, size_t src_size,
+ 		     void *dst, size_t * dst_size)
+   {
+-    static u_char sense_buffer[24];
++    static unsigned char sense_buffer[24];
+     struct scb cmdblk;
+     time_t elapsed;
+     uint_t compcode, status;
+_at_@ -4018,7 +4018,7 @@
+       return SANE_STATUS_IO_ERROR;
+ 
+     cmdblk.sc_cmdpt = (caddr_t) cmd;
+-    /* xxx obsolete cdb_size = CDB_SIZE (*(u_char *) src);
++    /* xxx obsolete cdb_size = CDB_SIZE (*(unsigned char *) src);
+      */
+     cmdblk.sc_cmdsz = cmd_size;
+     cmdblk.sc_time = 60000;	/* 60 secs */
+_at_@ -4382,7 +4382,7 @@
+   {
+     dsreq_t scsi_req;		/* SCSI request */
+ /* xxx obsolete size_t  cdb_size; *//* Size of SCSI command */
+-    static u_char *cmdbuf = NULL,	/* Command buffer */
++    static unsigned char *cmdbuf = NULL,	/* Command buffer */
+      *sensebuf = NULL,		/* Request sense buffer */
+      *databuf = NULL;		/* Data buffer */
+ 
+_at_@ -4404,7 +4404,7 @@
+     /*
+      * Build the SCSI request...
+      */
+-    /* xxx obsolete cdb_size = CDB_SIZE (*(u_char *) src);
++    /* xxx obsolete cdb_size = CDB_SIZE (*(unsigned char *) src);
+      */
+ 
+     DBG (1, "sanei_scsi_cmd: cmd_size = %d\n", cmd_size);
+_at_@ -4445,8 +4445,8 @@
+ 	/*
+ 	 * Copy command and data to local buffers to ensure 32-bit alignment...
+ 	 */
+-	memcpy (cmdbuf, (u_char *) cmd, cmd_size);
+-	memcpy (databuf, (u_char *) src, src_size);
++	memcpy (cmdbuf, (unsigned char *) cmd, cmd_size);
++	memcpy (databuf, (unsigned char *) src, src_size);
+       }
+ 
+     bzero (sensebuf, 128);
+_at_@ -4507,7 +4507,7 @@
+     size_t inqsize;		/* Size of returned inquiry data */
+     char vendor[9],		/* Vendor name */
+       model[17];		/* Model/product name */
+-    u_char inqdata[128],	/* Inquiry data buffer */
++    unsigned char inqdata[128],	/* Inquiry data buffer */
+       inqcommand[6];		/* Inquiry command (0x12) buffer */
+ 
+     DBG_INIT ();
+_at_@ -4633,7 +4633,7 @@
+     char sense_buf[32];
+     char status;
+ 
+-    /* xxx obsolete cdb_size = CDB_SIZE (*(u_char *) src);
++    /* xxx obsolete cdb_size = CDB_SIZE (*(unsigned char *) src);
+      */
+ 
+     memset (&scmd, 0, sizeof (scmd));
+_at_@ -4682,7 +4682,7 @@
+ 
+     if (scmd.senselen > 0
+ 	&& (scmd.sense_buf[0] & 0x80) && fd_info[fd].sense_handler)
+-      return (*fd_info[fd].sense_handler) (fd, (u_char *) scmd.sense_buf,
++      return (*fd_info[fd].sense_handler) (fd, (unsigned char *) scmd.sense_buf,
+ 					   fd_info[fd].sense_handler_arg);
+     return SANE_STATUS_GOOD;
+   }
+_at_@ -4705,7 +4705,7 @@
+      */
+     char sensebf[CCS_SENSE_LEN];
+ 
+-    /* xxx obsolete cdb_size = CDB_SIZE (*(u_char *) src);
++    /* xxx obsolete cdb_size = CDB_SIZE (*(unsigned char *) src);
+      */
+ 
+     /* first put the user scsi structure together.  */
+_at_@ -4777,7 +4777,7 @@
+      */
+     SANEI_SCSI_Sense_Handler handler;
+ 
+-    /* xxx obsolete cdb_size = CDB_SIZE (*(u_char *) src);
++    /* xxx obsolete cdb_size = CDB_SIZE (*(unsigned char *) src);
+      */
+ 
+     memset (&scmd, 0, sizeof (scmd));
+_at_@ -4808,7 +4808,7 @@
+       return SANE_STATUS_IO_ERROR;
+     if (dst_size)
+       *dst_size = scmd.size - scmd.resid;
+-    if (scmd.error == 0 && scmd.errno == 0 && *(u_char *) & scmd.scb == 0)
++    if (scmd.error == 0 && scmd.errno == 0 && *(unsigned char *) & scmd.scb == 0)
+       return SANE_STATUS_GOOD;
+ 
+     if (scmd.error == SCG_TIMEOUT)
+_at_@ -4860,7 +4860,7 @@
+ 	  }
+ 	if (scmd.u_scb.cmd_scb[0] == SC_BUSY)
+ 	  return SANE_STATUS_DEVICE_BUSY;
+-	if (*(u_char *) & scmd.sense && handler)
++	if (*(unsigned char *) & scmd.sense && handler)
+ 	  {
+ 	    rv = (*handler) (fd, scmd.u_sense.cmd_sense,
+ 			     fd_info[fd].sense_handler_arg);
+_at_@ -4882,7 +4882,7 @@
+ 
+   static int unit_ready (int fd)
+   {
+-    static const u_char test_unit_ready[] = { 0, 0, 0, 0, 0, 0 };
++    static const unsigned char test_unit_ready[] = { 0, 0, 0, 0, 0, 0 };
+     int status;
+ 
+     status = scsi_cmd (fd, test_unit_ready, sizeof (test_unit_ready),
+_at_@ -5001,7 +5001,7 @@
+ 
+   static int unit_ready (int fd)
+   {
+-    static const u_char test_unit_ready[] = { 0, 0, 0, 0, 0, 0 };
++    static const unsigned char test_unit_ready[] = { 0, 0, 0, 0, 0, 0 };
+     int status;
+ 
+     status = scsi_cmd (fd, test_unit_ready, sizeof (test_unit_ready),
+--- sane-backends-1.0.24.orig/sanei/sanei_tcp.c
++++ sane-backends-1.0.24/sanei/sanei_tcp.c
+_at_@ -116,13 +116,13 @@
+ }
+ 
+ ssize_t
+-sanei_tcp_write(int fd, const u_char * buf, int count)
++sanei_tcp_write(int fd, const unsigned char * buf, int count)
+ {
+ 	return send(fd, buf, count, 0);
+ }
+ 
+ ssize_t
+-sanei_tcp_read(int fd, u_char * buf, int count)
++sanei_tcp_read(int fd, unsigned char * buf, int count)
+ {
+     ssize_t bytes_recv = 0, rc = 1;
+ 	int retry = 5;
+--- sane-backends-1.0.24.orig/sanei/sanei_udp.c
++++ sane-backends-1.0.24/sanei/sanei_udp.c
+_at_@ -167,13 +167,13 @@
+ }
+ 
+ ssize_t
+-sanei_udp_write(int fd, const u_char * buf, int count)
++sanei_udp_write(int fd, const unsigned char * buf, int count)
+ {
+ 	return send(fd, buf, count, 0);
+ }
+ 
+ ssize_t
+-sanei_udp_write_broadcast(int fd, int port, const u_char * buf, int count)
++sanei_udp_write_broadcast(int fd, int port, const unsigned char * buf, int count)
+ {
+ 	struct sockaddr_in saddr;
+ 
+_at_@ -191,7 +191,7 @@
+ sanei_udp_set_nonblock(int fd, SANE_Bool nonblock)
+ {
+ #ifdef HAVE_WINSOCK2_H
+-	u_long mode=nonblock;
++	unsigned long mode=nonblock;
+ 
+ 	ioctlsocket(fd, FIONBIO, &mode);
+ #else
+_at_@ -207,13 +207,13 @@
+ }
+ 
+ ssize_t
+-sanei_udp_read(int fd, u_char * buf, int count)
++sanei_udp_read(int fd, unsigned char * buf, int count)
+ {
+ 	return recv(fd, buf, count, 0);
+ }
+ 
+ ssize_t
+-sanei_udp_recvfrom(int fd, u_char * buf, int count, char **fromp)
++sanei_udp_recvfrom(int fd, unsigned char * buf, int count, char **fromp)
+ {
+ 	ssize_t l;
+ 	socklen_t fl;
+--- sane-backends-1.0.24.orig/sanei/sanei_wire.c
++++ sane-backends-1.0.24/sanei/sanei_wire.c
+_at_@ -59,11 +59,11 @@
+   int fd = w->io.fd;
+   ssize_t nread, nwritten;
+ 
+-  DBG (3, "sanei_w_space: %lu bytes for wire %d\n", (u_long) howmuch, fd);
++  DBG (3, "sanei_w_space: %lu bytes for wire %d\n", (unsigned long) howmuch, fd);
+ 
+   if (howmuch > w->buffer.size)
+     DBG (2, "sanei_w_space: bigger than buffer (%lu bytes), "
+-	 "may be flush()\n", (u_long) w->buffer.size);
++	 "may be flush()\n", (unsigned long) w->buffer.size);
+ 
+   if (w->status != 0)
+     {
+_at_@ -75,14 +75,14 @@
+   if (w->buffer.curr + howmuch > w->buffer.end)
+     {
+       DBG (4, "sanei_w_space: free buffer size is %lu\n",
+-	   (u_long) (w->buffer.end - w->buffer.curr));
++	   (unsigned long) (w->buffer.end - w->buffer.curr));
+       switch (w->direction)
+ 	{
+ 	case WIRE_ENCODE:
+ 	  nbytes = w->buffer.curr - w->buffer.start;
+ 	  w->buffer.curr = w->buffer.start;
+ 	  DBG (4, "sanei_w_space: ENCODE: sending %lu bytes\n", 
+-	       (u_long) nbytes);
++	       (unsigned long) nbytes);
+ 	  while (nbytes > 0)
+ 	    {
+ 	      nwritten = (*w->io.write) (fd, w->buffer.curr, nbytes);
+_at_@ -98,7 +98,7 @@
+ 	  w->buffer.curr = w->buffer.start;
+ 	  w->buffer.end = w->buffer.start + w->buffer.size;
+ 	  DBG (4, "sanei_w_space: ENCODE: free buffer is now %lu\n",
+-	       (u_long) w->buffer.size);
++	       (unsigned long) w->buffer.size);
+ 	  break;
+ 
+ 	case WIRE_DECODE:
+_at_@ -113,7 +113,7 @@
+ 	  if (left_over)
+ 	    {
+ 	      DBG (4, "sanei_w_space: DECODE: %lu bytes left in buffer\n",
+-		   (u_long) left_over);
++		   (unsigned long) left_over);
+ 	      memmove (w->buffer.start, w->buffer.curr, left_over);
+ 	    }
+ 	  w->buffer.curr = w->buffer.start;
+_at_@ -138,7 +138,7 @@
+ 	    }
+ 	  while (left_over < howmuch);
+ 	  DBG (4, "sanei_w_space: DECODE: %lu bytes read\n",
+-	       (u_long) (w->buffer.end - w->buffer.start));
++	       (unsigned long) (w->buffer.end - w->buffer.start));
+ 	  break;
+ 
+ 	case WIRE_FREE:
+_at_@ -164,7 +164,7 @@
+   int i;
+ 
+   DBG (3, "sanei_w_array: wire %d, elements of size %lu\n", w->io.fd,
+-       (u_long) element_size);
++       (unsigned long) element_size);
+ 
+   if (w->direction == WIRE_FREE)
+     {
+_at_@ -253,7 +253,7 @@
+   SANE_Word is_null;
+ 
+   DBG (3, "sanei_w_ptr: wire %d, value pointer at is %lu bytes\n", w->io.fd,
+-       (u_long) value_size);
++       (unsigned long) value_size);
+ 
+   if (w->direction == WIRE_FREE)
+     {
+_at_@ -586,7 +586,7 @@
+        (w->direction == WIRE_DECODE ? "DECODE" : "FREE"));
+   if (w->direction == WIRE_DECODE && w->buffer.curr != w->buffer.end)
+     DBG (1, "sanei_w_set_dir: WARNING: will delete %lu bytes from buffer\n",
+-	 (u_long) (w->buffer.end - w->buffer.curr));
++	 (unsigned long) (w->buffer.end - w->buffer.curr));
+   flush (w);
+   w->direction = dir;
+   DBG (4, "sanei_w_set_dir: direction changed\n");
diff --git a/testing/sane/APKBUILD b/testing/sane/APKBUILD
new file mode 100644
index 0000000..62e7184
--- /dev/null
+++ b/testing/sane/APKBUILD
_at_@ -0,0 +1,75 @@
+# Contributor: Fabio Riga <rifabio_at_dpersonam.me>
+# Maintainer:
+pkgname=sane
+pkgver=1.0.24
+pkgrel=0
+pkgdesc="Scanner Access Now Easy"
+url="http://www.sane-project.org/"
+arch="all"
+license="GPL"
+depends="" # "tiff libgphoto2 libjpeg libusb cups v4l-utils avahi bash net-snmp"
+depends_dev="tiff-dev libjpeg-turbo-dev libgphoto2-dev libusb-dev cups-dev v4l-utils-dev avahi-dev bash net-snmp-dev"
+makedepends="$depends_dev"
+install=""
+subpackages="$pkgname-dev $pkgname-doc"
+source="https://alioth.debian.org/frs/download.php/file/3958/$pkgname-backends-$pkgver.tar.gz
+   10-network.patch
+   20-segfault-avahi-fix-kodakio.patch
+   30-musl.patch"
+
+_builddir="${srcdir}/${pkgname}-backends-${pkgver}"
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+}
+
+build() {
+	cd "$_builddir"
+        ./configure --prefix=/usr --sbindir=/usr/bin \
+          --sysconfdir=/etc \
+          --localstatedir=/var \
+          --with-docdir=/usr/share/doc/sane \
+          --enable-avahi \
+          --enable-pthread \
+          --disable-rpath \
+          --disable-latex \
+          --enable-libusb_1_0 \
+          --disable-locking
+          make
+}
+
+package() {
+	cd "$_builddir"
+        make DESTDIR="${pkgdir}" install
+        # fix hp officejets
+        echo "#hpaio" >> "${pkgdir}/etc/sane.d/dll.conf"
+        # install udev files
+        install -D -m0644 tools/udev/libsane.rules \
+          "${pkgdir}/usr/lib/udev/rules.d/49-sane.rules"
+        # fix udev rules
+        sed -i 's|NAME="%k", ||g' "${pkgdir}/usr/lib/udev/rules.d/49-sane.rules"
+        # Install the pkg-config file
+        install -D -m644 tools/sane-backends.pc \
+            "${pkgdir}/usr/lib/pkgconfig/sane-backends.pc"
+        # Remove libtool files
+        rm "$pkgdir"/usr/lib/*.la
+        rm "$pkgdir"/usr/lib/sane/*.la
+}
+
+md5sums="1ca68e536cd7c1852322822f5f6ac3a4  sane-backends-1.0.24.tar.gz
+44e77692c52db15b0f530a1d9a8e1296  10-network.patch
+039524a38af8721f2e97d45e889295ca  20-segfault-avahi-fix-kodakio.patch
+8a43596a2548af2aad80e6517592cc73  30-musl.patch"
+sha256sums="27c7085a54f1505d8b551e6f1e69d30e1ee57328b18429bb2225dabf4c45462d  sane-backends-1.0.24.tar.gz
+23785948c7d9dc071fcc066754001dc2c1bd17a904051ed3ae6ec7f4e3b8e66b  10-network.patch
+91e01450f87d52fa82e5e0e112a3ac7f5355f5a133467b8a38d0e1f52e94d25a  20-segfault-avahi-fix-kodakio.patch
+33241f8d7c19545f83175e8d92f737051c9355c4c19fd085dc2579367d7bc916  30-musl.patch"
+sha512sums="1e9f962bb9d27f17067eb662dabfc0a1aa0d06e16bec4bd28868124b468578d82f14f6d2c1f5de63d2cec57ca4584ec12d3b2c2b1de20f1199aece581453ebc5  sane-backends-1.0.24.tar.gz
+04b65a06d2c76dde6fce501ba823e999eb89ea41573f887f9e7d5347f3aa5e35310fad69313e99f873640e29a9849372d2ff995678593a0781fba73b464bec0d  10-network.patch
+43e91fe2452eca4fbfbd256aae3f44a28674af7210f59b60b34c1149f0cd208318678a810313aabff84f18bb712982e10ae320ef3179b6437e413adda6298fbe  20-segfault-avahi-fix-kodakio.patch
+64f79bd375a326d6e1cf35f1485174897506d8c5d2ebd77d95a74b25ed7c817927f1e4545aa72312e8dd2e97a24520254446992cbe94fc5003d845e8ea80e84e  30-musl.patch"
-- 
2.2.2
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Fri Feb 27 2015 - 17:27:16 GMT