[sane-devel] Patches for SANE 1.0.9 be/fe compiled on IRIX

Andrea Suatoni a.suatoni@telefonica.net
Sun, 29 Dec 2002 01:54:41 +0100


This is a multi-part message in MIME format.
--------------51C5D120C92EF56773C45A8D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi there!

I have packaged the SANE 1.0.9 backends / frontends for IRIX, using the SGI
MIPSpro C compiler. The packages should upgrade the 1.0.8 versions currently
available on http://freeware.sgi.com/

In order to compile properly the two packages, I have produced two set of
patches which affect some backends (trivial corrections, for the most). Some
of the patches are only relevant to the way the SGI freeware is built (path
names and compilation flags). You may want to skip them and rework the code
I've added, eventually flagging it with #ifdef __sgi

If the maintainers of a specific backend/frontend need further explaination of
the changed I've introduced, they are welcome in getting in contact with me.

Hope it helps, and Happy New Year to all.
Andrea
--------------51C5D120C92EF56773C45A8D
Content-Type: text/plain; charset=us-ascii;
 name="patches-sane-backends"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patches-sane-backends"

diff -ruN sane-backends-1.0.9/acinclude.m4 sane-backends-1.0.9-patched/acinclude.m4
--- sane-backends-1.0.9/acinclude.m4	Tue Oct  1 10:33:57 2002
+++ sane-backends-1.0.9-patched/acinclude.m4	Thu Dec 12 21:54:00 2002
@@ -234,8 +234,9 @@
 		 ) 
 			CPPFLAGS="${CPPFLAGS} `gphoto2-config --cflags`"
 			GPHOTO2_LIBS="`gphoto2-config --libs`"
-			SANE_EXTRACT_LDFLAGS(LDFLAGS, GPHOTO2_LIBS)
-			LIBS="${LIBS} ${GPHOTO2_LIBS}"
+			AC_SUBST(GPHOTO2_LIBS)
+			dnl SANE_EXTRACT_LDFLAGS(LDFLAGS, GPHOTO2_LIBS)
+			dnl LIBS="${LIBS} ${GPHOTO2_LIBS}"
 			;;
 		* ) 
 			echo 
diff -ruN sane-backends-1.0.9/backend/Makefile.in sane-backends-1.0.9-patched/backend/Makefile.in
--- sane-backends-1.0.9/backend/Makefile.in	Sun Sep  1 15:46:53 2002
+++ sane-backends-1.0.9-patched/backend/Makefile.in	Thu Dec 12 21:55:32 2002
@@ -46,6 +46,7 @@
 CFLAGS = @CFLAGS@
 LDFLAGS = @LDFLAGS@
 BACKENDLIBS = @LIBS@ @DL_LIB@
+GPHOTO2_LIBS = @GPHOTO2_LIBS@
 DEFS = @DEFS@
 
 LIBTOOL = ../libtool
@@ -135,6 +136,11 @@
 
 
 .PHONY: all clean depend dist distclean install uninstall
+
+libsane-gphoto2.la: gphoto2.lo gphoto2-s.lo $(EXTRA) $(LIBOBJS)
+	@$(LIBTOOL) $(MLINK) $(CC) -export-dynamic -o $@ $($*_LIBS) \
+	$(LDFLAGS) $(GPHOTO2_LIBS) $(BACKENDLIBS) $^ -rpath $(libsanedir) \
+	-version-info $(V_MAJOR):$(V_REV):$(V_MINOR)
 
 libsane-%.la: %.lo %-s.lo $(EXTRA) $(LIBOBJS)
 	@$(LIBTOOL) $(MLINK) $(CC) -export-dynamic -o $@ $($*_LIBS) \
diff -ruN sane-backends-1.0.9/backend/as6e.c sane-backends-1.0.9-patched/backend/as6e.c
--- sane-backends-1.0.9/backend/as6e.c	Tue Dec  5 20:10:20 2000
+++ sane-backends-1.0.9-patched/backend/as6e.c	Thu Dec 12 21:56:54 2002
@@ -604,8 +604,7 @@
 	  return (SANE_STATUS_GOOD);
 	}			/*else */
     }
-  else
-    return (SANE_STATUS_IO_ERROR);
+  return (SANE_STATUS_IO_ERROR);
 }
 
 
diff -ruN sane-backends-1.0.9/backend/bh.c sane-backends-1.0.9-patched/backend/bh.c
--- sane-backends-1.0.9/backend/bh.c	Fri Jan 11 17:16:07 2002
+++ sane-backends-1.0.9-patched/backend/bh.c	Thu Dec 12 21:57:55 2002
@@ -135,7 +135,7 @@
 {
   return (i > 0 && i < NELEMS(barcode_search_bar_list)) ? 
     barcode_search_bar_list[i] : 
-    (const SANE_String) "unknown";
+    (SANE_String_Const) "unknown";
 }
 
 static SANE_String_Const
diff -ruN sane-backends-1.0.9/backend/canon-sane.c sane-backends-1.0.9-patched/backend/canon-sane.c
--- sane-backends-1.0.9/backend/canon-sane.c	Sun Apr 21 12:35:24 2002
+++ sane-backends-1.0.9-patched/backend/canon-sane.c	Thu Dec 12 21:58:46 2002
@@ -1798,7 +1798,7 @@
   SANE_Status status;
   SANE_Byte *out, *red, *green, *blue;
   SANE_Int ncopy;
-  size_t nread, i, pixel_per_line;
+  size_t nread = 0, i, pixel_per_line;
 
   DBG (21, ">> read_fb620\n");
 
diff -ruN sane-backends-1.0.9/backend/coolscan.c sane-backends-1.0.9-patched/backend/coolscan.c
--- sane-backends-1.0.9/backend/coolscan.c	Thu Oct 10 18:29:29 2002
+++ sane-backends-1.0.9-patched/backend/coolscan.c	Thu Dec 12 21:59:33 2002
@@ -1700,7 +1700,7 @@
 
   DBG (10, "get_inquiry_values\n");
 
-  inquiry_block = s->buffer;
+  inquiry_block = (char *) s->buffer;
   s->inquiry_len = 36;
 
   get_inquiry_vendor (inquiry_block, s->vendor);
diff -ruN sane-backends-1.0.9/backend/dc210.c sane-backends-1.0.9-patched/backend/dc210.c
--- sane-backends-1.0.9/backend/dc210.c	Wed Oct 10 21:47:56 2001
+++ sane-backends-1.0.9-patched/backend/dc210.c	Thu Dec 12 22:04:23 2002
@@ -358,10 +358,28 @@
 #ifdef HAVE_CFMAKERAW
   cfmakeraw (&tty_new);
 #else
-  tty_new.c_lflag &= ~(ICANON | ECHO | ISIG);
+  /* Modified to set the port REALLY as required. Code inspired by
+     the gPhoto2 serial port setup */
+
+  /* input control settings */
+  tty_new.c_iflag &= ~(IGNBRK | IGNCR | INLCR | ICRNL | IUCLC |
+                      IXANY | IXON | IXOFF | INPCK | ISTRIP);
+  tty_new.c_iflag |= (BRKINT | IGNPAR);
+  /* output control settings */
+  tty_new.c_oflag &= ~OPOST;
+  /* hardware control settings */
+  tty_new.c_cflag = (tty_new.c_cflag & ~CSIZE) | CS8;
+  tty_new.c_cflag &= ~(PARENB | PARODD | CSTOPB);
+# if defined(__sgi)
+  tty_new.c_cflag &= ~CNEW_RTSCTS;
+# else
+  tty_new.c_cflag &= ~CRTSCTS;
+# endif
+  tty_new.c_cflag |= CLOCAL | CREAD;
 #endif
-  tty_new.c_oflag &= ~CSTOPB;
-  tty_new.c_lflag = 0;
+  /* line discipline settings */
+  tty_new.c_lflag &= ~(ICANON | ISIG | ECHO | ECHONL | ECHOE |
+                       ECHOK | IEXTEN);
   tty_new.c_cc[VMIN] = 0;
   tty_new.c_cc[VTIME] = 5;
   cfsetospeed (&tty_new, B9600);
@@ -375,7 +393,15 @@
 
   /* send a break to get it back to a known state */
 #ifdef HAVE_TCSENDBREAK
+# if defined(__sgi)
+  /* Maybe you should consider the following for all the platforms, not just
+     IRIX. Again, inspired by the gPhoto2 DC210 camera library setup */
+
+  ioctl (camera->fd, TCSBRK, 0);
+  ioctl (camera->fd, TCSBRK, 1);
+# else
   tcsendbreak (camera->fd, 4);
+# endif
 #else
 # if defined(TCSBRKP)
   ioctl (camera->fd, TCSBRKP, 4);
@@ -383,8 +409,14 @@
   ioctl (camera->fd, TCSBRK, 4);
 # endif
 #endif
-  /* and wait for it to recover from the break */
-  usleep (breakpause);
+
+   /* and wait for it to recover from the break */
+
+#ifdef HAVE_USLEEP
+   usleep (breakpause);
+#else
++  sleep (1);
+#endif
 
   if (send_pck (camera->fd, init_pck) == -1)
     {
diff -ruN sane-backends-1.0.9/backend/dc210.conf sane-backends-1.0.9-patched/backend/dc210.conf
--- sane-backends-1.0.9/backend/dc210.conf	Mon Aug  9 20:05:57 1999
+++ sane-backends-1.0.9-patched/backend/dc210.conf	Thu Dec 12 22:05:50 2002
@@ -1,8 +1,8 @@
 # Serial port where the camera is connected
 ## Linux
-port=/dev/ttyS0
+#port=/dev/ttyS0
 ## IRIX
-#port=/dev/ttyd1
+port=/dev/ttyd1
 ## Solaris
 #port=/dev/term/a
 ## HP-UX
@@ -11,10 +11,12 @@
 #port=/dev/tty01
 # Max baud rate for download.  Camera always starts at 9600 baud, then
 # switches to the higher rate
-## This works for Linux and some versions of IRIX (6.3 or higher)
-baud=115200
+## This works for Linux. Also works for IRIX (6.3 or higher), providing that
+## the host is an O2, OCTANE, Origin2000/200, Onyx2, Origin3000/300, Onyx3 or
+## a newer SGI hardware [see serial(7)].
+#baud=115200
 ## This works for most UNIX's
-#baud=38400
+baud=38400
 # Prints some extra information during the init phase.  This can be
 # handy, but note that printing anything to stderr breaks the saned 
 # network scanning.
diff -ruN sane-backends-1.0.9/backend/dc240.c sane-backends-1.0.9-patched/backend/dc240.c
--- sane-backends-1.0.9/backend/dc240.c	Tue Oct 15 09:59:18 2002
+++ sane-backends-1.0.9-patched/backend/dc240.c	Thu Dec 12 22:08:53 2002
@@ -403,10 +403,28 @@
 #ifdef HAVE_CFMAKERAW
   cfmakeraw (&tty_new);
 #else
-  tty_new.c_lflag &= ~(ICANON | ECHO | ISIG);
+  /* Modified to set the port REALLY as required (9600, 8b, 1sb, NO parity).
+     Code inspired by the gPhoto2 serial port setup */
+
+  /* input control settings */
+  tty_new.c_iflag &= ~(IGNBRK | IGNCR | INLCR | ICRNL | IUCLC |
+                      IXANY | IXON | IXOFF | INPCK | ISTRIP);
+  tty_new.c_iflag |= (BRKINT | IGNPAR);
+  /* output control settings */
+  tty_new.c_oflag &= ~OPOST;
+  /* hardware control settings */
+  tty_new.c_cflag = (tty_new.c_cflag & ~CSIZE) | CS8;
+  tty_new.c_cflag &= ~(PARENB | PARODD | CSTOPB);
+# if defined(__sgi)
+  tty_new.c_cflag &= ~CNEW_RTSCTS;
+# else
+  tty_new.c_cflag &= ~CRTSCTS;
+# endif
+  tty_new.c_cflag |= CLOCAL | CREAD;
 #endif
-  tty_new.c_oflag &= ~CSTOPB;
-  tty_new.c_lflag = 0;
+  /* line discipline settings */
+  tty_new.c_lflag &= ~(ICANON | ISIG | ECHO | ECHONL | ECHOE |
+                       ECHOK | IEXTEN);
   tty_new.c_cc[VMIN] = 0;
   tty_new.c_cc[VTIME] = 5;
   cfsetospeed (&tty_new, B9600);
@@ -421,7 +439,15 @@
   /* send a break to get it back to a known state */
 
 #ifdef HAVE_TCSENDBREAK
+# if defined(__sgi)
+  /* Maybe you should consider the following for all the platforms, not just
+     IRIX. Again, inspired by the gPhoto2 DC240 camera library setup */
+
+  ioctl (camera->fd, TCSBRK, 0);
+  ioctl (camera->fd, TCSBRK, 1);
+# else
   tcsendbreak (camera->fd, 4);
+# endif
 #else
 # if defined(TCSBRKP)
   ioctl (camera->fd, TCSBRKP, 4);
@@ -429,6 +455,7 @@
   ioctl (camera->fd, TCSBRK, 4);
 # endif
 #endif
+
   /* and wait for it to recover from the break */
 
 #ifdef HAVE_USLEEP
diff -ruN sane-backends-1.0.9/backend/dc240.conf sane-backends-1.0.9-patched/backend/dc240.conf
--- sane-backends-1.0.9/backend/dc240.conf	Sat Apr  7 20:03:19 2001
+++ sane-backends-1.0.9-patched/backend/dc240.conf	Thu Dec 12 22:09:33 2002
@@ -1,8 +1,8 @@
 # Serial port where the camera is connected
 ## Linux
-port=/dev/ttyS0
+#port=/dev/ttyS0
 ## IRIX
-#port=/dev/ttyd1
+port=/dev/ttyd1
 ## Solaris
 #port=/dev/term/a
 ## HP-UX
@@ -11,10 +11,12 @@
 #port=/dev/tty01
 # Max baud rate for download.  Camera always starts at 9600 baud, then
 # switches to the higher rate
-## This works for Linux and some versions of IRIX (6.3 or higher)
-baud=115200
+## This works for Linux. Also works for IRIX (6.3 or higher), providing that
+## the host is an O2, OCTANE, Origin2000/200, Onyx2, Origin3000/300, Onyx3 or
+## a newer SGI hardware [see serial(7)].
+#baud=115200
 ## This works for most UNIX's
-#baud=38400
+baud=38400
 # Prints some extra information during the init phase.  This can be
 # handy, but note that printing anything to stderr breaks the saned 
 # network scanning.
diff -ruN sane-backends-1.0.9/backend/dc240.h sane-backends-1.0.9-patched/backend/dc240.h
--- sane-backends-1.0.9/backend/dc240.h	Tue Oct 15 09:59:18 2002
+++ sane-backends-1.0.9-patched/backend/dc240.h	Thu Dec 12 22:15:16 2002
@@ -211,6 +211,11 @@
 
 #ifdef OLD
 
+# if defined(__sgi)
+# define PACKED
+# pragma pack 1
+# endif
+
 /* This is the layout of the directory in the camera - Unfortunately,
  * this only works in gcc.
  */
@@ -220,6 +225,11 @@
   SANE_Byte entries_lsb PACKED;
   struct cam_dirent entry[1000] PACKED;
 };
+
+# if defined(__sgi)
+# pragma pack 0
+# endif
+
 #else
 
 /* So, we have to do it the hard way...  */
diff -ruN sane-backends-1.0.9/backend/dc25.c sane-backends-1.0.9-patched/backend/dc25.c
--- sane-backends-1.0.9/backend/dc25.c	Sat Oct 19 20:58:25 2002
+++ sane-backends-1.0.9-patched/backend/dc25.c	Thu Dec 12 22:16:08 2002
@@ -2128,7 +2128,7 @@
 	       * thumbnails are color.
 	       */
 	      parms.format =
-		(CameraInfo.model = 0x25) ? SANE_FRAME_RGB : SANE_FRAME_GRAY;
+		(CameraInfo.model == 0x25) ? SANE_FRAME_RGB : SANE_FRAME_GRAY;
 	      parms.bytes_per_line = 80 * 3;
 	      parms.pixels_per_line = 80;
 	      parms.lines = 60;
@@ -2428,7 +2428,7 @@
        * thumbnails are color.
        */
       parms.format =
-	(CameraInfo.model = 0x25) ? SANE_FRAME_RGB : SANE_FRAME_GRAY;
+	(CameraInfo.model == 0x25) ? SANE_FRAME_RGB : SANE_FRAME_GRAY;
       parms.bytes_per_line = 80 * 3;	/* 80 pixels, 3 colors */
       parms.pixels_per_line = 80;
       parms.lines = 60;
diff -ruN sane-backends-1.0.9/backend/dc25.conf sane-backends-1.0.9-patched/backend/dc25.conf
--- sane-backends-1.0.9/backend/dc25.conf	Mon Aug  9 20:05:55 1999
+++ sane-backends-1.0.9-patched/backend/dc25.conf	Thu Dec 12 22:16:42 2002
@@ -1,8 +1,8 @@
 # Serial port where the camera is connected
 ## Linux
-port=/dev/ttyS0
+#port=/dev/ttyS0
 ## IRIX
-#port=/dev/ttyd1
+port=/dev/ttyd1
 ## Solaris
 #port=/dev/term/a
 ## HP-UX
@@ -11,10 +11,12 @@
 #port=/dev/tty01
 # Max baud rate for download.  Camera always starts at 9600 baud, then
 # switches to the higher rate
-## This works for Linux and some versions of IRIX (6.3 or higher)
-baud=115200
+## This works for Linux. Also works for IRIX (6.3 or higher), providing that
+## the host is an O2, OCTANE, Origin2000/200, Onyx2, Origin3000/300, Onyx3 or
+## a newer SGI hardware [see serial(7)].
+#baud=115200
 ## This works for most UNIX's
-#baud=38400
+baud=38400
 # Prints some extra information during the init phase.  This can be
 # handy, but note that printing anything to stderr breaks the saned 
 # network scanning.
diff -ruN sane-backends-1.0.9/backend/gphoto2.conf sane-backends-1.0.9-patched/backend/gphoto2.conf
--- sane-backends-1.0.9/backend/gphoto2.conf	Mon Oct 29 22:08:48 2001
+++ sane-backends-1.0.9-patched/backend/gphoto2.conf	Thu Dec 12 22:17:46 2002
@@ -1,7 +1,7 @@
 # Interface port where the camera is connected
 # This should be one of the values returned by "gphoto2 --list-ports", 
 # such # as serial:/dev/ttyS6 or usb:
-port=usb:
+port=serial:/dev/ttyd1
 
 # Port speed.  This should be one of the values returned by 
 # "gphoto2 --abilities"
diff -ruN sane-backends-1.0.9/doc/Makefile.in sane-backends-1.0.9-patched/doc/Makefile.in
--- sane-backends-1.0.9/doc/Makefile.in	Tue Oct 15 13:52:38 2002
+++ sane-backends-1.0.9-patched/doc/Makefile.in	Thu Dec 12 22:19:00 2002
@@ -24,7 +24,7 @@
 includedir = @includedir@
 oldincludedir = /usr/include
 configdir = ${sysconfdir}/sane.d
-docdir=$(prefix)/doc/sane-@VERSION@
+docdir=$(prefix)/doc/sane
 
 MKDIR = $(top_srcdir)/mkinstalldirs
 INSTALL = @INSTALL@
diff -ruN sane-backends-1.0.9/doc/sane-umax_pp.man sane-backends-1.0.9-patched/doc/sane-umax_pp.man
--- sane-backends-1.0.9/doc/sane-umax_pp.man	Fri Feb 15 18:01:34 2002
+++ sane-backends-1.0.9-patched/doc/sane-umax_pp.man	Thu Dec 12 22:19:40 2002
@@ -139,7 +139,7 @@
 and 2000. It is usefull only autodetection fails to detect properly your scanner 
 model. If your scanner work properly but is reported wrongly, let it be that way. 
 The only valid case to change the model is when your scanner produces 'black' or 
-'inverted' scans.  In this case you can put the model. Be aware that it will 
+ 'inverted' scans.  In this case you can put the model. Be aware that it will 
 prevent autodetection.
 .PP
 
diff -ruN sane-backends-1.0.9/include/sane/config.h.in sane-backends-1.0.9-patched/include/sane/config.h.in
--- sane-backends-1.0.9/include/sane/config.h.in	Sat Jul  6 23:49:45 2002
+++ sane-backends-1.0.9-patched/include/sane/config.h.in	Thu Dec 12 23:36:53 2002
@@ -393,3 +393,13 @@
 
 /* Define to `unsigned long' if <sys/types.h> does not define. */
 #undef u_long
+
+/* Define a the function prototypes if these function are missing. */
+#ifndef HAVE_STRSEP
+char *strsep(char **stringp, const char *delim);
+#endif
+
+#ifndef HAVE_STRNDUP
+#include <sys/types.h>
+char *strndup(const char * s, size_t n);
+#endif

--------------51C5D120C92EF56773C45A8D
Content-Type: text/plain; charset=us-ascii;
 name="patches-sane-frontends"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patches-sane-frontends"

diff -ruN sane-frontends-1.0.9/doc/Makefile.in sane-frontends-1.0.9-patched/doc/Makefile.in
--- sane-frontends-1.0.9/doc/Makefile.in	Thu Mar 28 20:15:27 2002
+++ sane-frontends-1.0.9-patched/doc/Makefile.in	Fri Dec 13 00:25:41 2002
@@ -25,7 +25,7 @@
 oldincludedir = /usr/include
 configdir = ${sysconfdir}/sane.d
 sanedatadir = ${datadir}/sane
-docdir=$(prefix)/doc/sane-@VERSION@
+docdir=$(prefix)/doc/sane
 
 MKDIR = $(top_srcdir)/mkinstalldirs
 INSTALL = @INSTALL@
diff -ruN sane-frontends-1.0.9/src/Makefile.in sane-frontends-1.0.9-patched/src/Makefile.in
--- sane-frontends-1.0.9/src/Makefile.in	Thu Mar 28 20:16:45 2002
+++ sane-frontends-1.0.9-patched/src/Makefile.in	Fri Dec 13 00:39:37 2002
@@ -83,7 +83,7 @@
 	    $(DESTDIR)$(bindir)/$${program}; \
 	done
 	$(INSTALL_DATA) $(srcdir)/sane-style.rc \
-          $(DESTDIR)$(datadir)/sane-style.rc
+          $(DESTDIR)$(sanedatadir)/sane-style.rc
 
 uninstall:
 	@for program in $(BINPROGS); do \
@@ -90,7 +90,7 @@
 	  echo removing $(bindir)/$${program}...; \
 	  rm -f $(bindir)/$${program}; \
 	done
-	rm -f $(datadir)/sane-style.rc
+	rm -f $(sanedatadir)/sane-style.rc
 
 xscanimage: $(XSCANIMAGE_OBJS) $(LIBSANEI) $(LIBLIB)
 	$(LINK) $(XSCANIMAGE_OBJS) $(LIBSANEI) \
diff -ruN sane-frontends-1.0.9/src/xcam.c sane-frontends-1.0.9-patched/src/xcam.c
--- sane-frontends-1.0.9/src/xcam.c	Sat Jun  9 14:52:05 2001
+++ sane-frontends-1.0.9-patched/src/xcam.c	Fri Dec 13 00:41:42 2002
@@ -56,8 +56,6 @@
   }
 Canvas;
 
-Preferences preferences;
-
 static const char *prog_name;
 static const SANE_Device **device;
 static GSGDialog *dialog;
@@ -672,13 +670,29 @@
 									\
     case 24:								\
       /* Is this correctly handling all byte order cases? */		\
-      if ((endian) == GDK_LSB_FIRST)					\
+      if ((endian) != GDK_LSB_FIRST)					\
 	{								\
-	  buf[0] = (b) >> 8; buf[1] = (g) >> 8; buf[2] = (r) >> 8;	\
+	  if (bpp == 4)							\
+	    {								\
+	      buf[1] = (b) >> 8; buf[2] = (g) >> 8; buf[3] = (r) >> 8;	\
+	      buf[0] = 0;						\
+	    }								\
+	    else							\
+	    {								\
+	      buf[0] = (b) >> 8; buf[1] = (g) >> 8; buf[2] = (r) >> 8;	\
+	    }								\
 	}								\
       else								\
 	{								\
-	  buf[0] = (r) >> 8; buf[1] = (g) >> 8; buf[2] = (b) >> 8;	\
+	  if (bpp == 4)							\
+	    {								\
+	      buf[1] = (r) >> 8; buf[2] = (g) >> 8; buf[3] = (b) >> 8;	\
+	      buf[0] = 0;						\
+	    }								\
+	    else							\
+	    {								\
+	      buf[0] = (r) >> 8; buf[1] = (g) >> 8; buf[2] = (b) >> 8;	\
+	    }								\
 	}								\
       buf += (bpp);							\
       break;								\
@@ -687,7 +701,7 @@
       /* Is this correctly handling all byte order cases?  It assumes	\
 	 the byte order of the host is the same as that of the		\
 	 pixmap. */							\
-      rgb = (((r) >> 8) << 16) | (((g) >> 8) << 8) | ((b) >> 8);	\
+      rgb = (((b) >> 8) << 16) | (((g) >> 8) << 8) | ((r) >> 8);	\
       ((guint32 *)buf)[0] = rgb;					\
       buf += (bpp);							\
       break;								\

--------------51C5D120C92EF56773C45A8D--