Blob Blame History Raw
#! /bin/sh -e
## 02_png-support.dpatch by Yoshida Hiroshi <BXH04165@nifty.ne.jp>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Add support for PNG images and other misc fixes.

if [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
       -patch) patch -f --no-backup-if-mismatch -p1 < $0;;
       -unpatch) patch -f --no-backup-if-mismatch -R -p1 < $0;;
	*)
		echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
		exit 1;;
esac

exit 0

@DPATCH@
diff -urNad xloadimage-4.1~/Makefile.in xloadimage-4.1/Makefile.in
--- xloadimage-4.1~/Makefile.in	2005-12-06 02:59:07.000000000 +0000
+++ xloadimage-4.1/Makefile.in	2005-12-06 02:59:07.000000000 +0000
@@ -5,7 +5,7 @@
 CC = @CC@
 DEFS = @DEFS@
 CFLAGS = @CFLAGS@
-XLIB = @X_LIBS@ @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@
+XLIB = @X_LIBS@ -lX11 @X_EXTRA_LIBS@
 LDFLAGS = @LDFLAGS@
 LIBS = @LIBS@
 
@@ -14,7 +14,7 @@
 mac.c mc_tables.c mcidas.c merge.c misc.c new.c niff.c options.c \
 pbm.c pcx.c pdsuncomp.c reduce.c rle.c rlelib.c root.c rotate.c \
 send.c smooth.c sunraster.c tiff.c undither.c value.c vff.c \
-vicar.c window.c xbitmap.c xloadimage.c xpixmap.c xwd.c zio.c zoom.c
+vicar.c window.c xbitmap.c xloadimage.c xpixmap.c xwd.c zio.c zoom.c png.c
 
 OBJS = $(SRCS:.c=.o)
 PROG = xloadimage
@@ -24,7 +24,7 @@
 $(PROG): $(OBJS)
 	./build-info
 	$(CC) $(CFLAGS) -c $(DEFS) build.c 
-	$(CC) -o $@ $(OBJS) build.o$(LDFLAGS) $(XLIB) $(LIBS)
+	$(CC) -o $@ $(OBJS) build.o $(LDFLAGS) $(XLIB) $(LIBS)
 
 uufilter: uufilter.c
 	$(CC) $(CFLAGS) $(DEFS) uufilter.c -o $@
@@ -34,8 +34,13 @@
 
 build.c:
 	./build-info
+
 clean:
-	rm -f $(PROG) uufilter build.c *.o
+	rm -f autoconfig build.c err
+#	cd jpeg ; make clean
+#	cd tiff ; make clean
+	rm -f *.o *~ xloadimage uufilter autoconfig libconfig packtar \
+	  buildshar doshar shar.* *.tar *.tar.Z *.tc
 
 distclean:
 	make clean
diff -urNad xloadimage-4.1~/bright.c xloadimage-4.1/bright.c
--- xloadimage-4.1~/bright.c	2005-12-06 02:59:04.000000000 +0000
+++ xloadimage-4.1/bright.c	2005-12-06 02:59:07.000000000 +0000
@@ -73,9 +73,10 @@
      double disp_gam;
      unsigned int verbose;
 { int          a;
-  int gammamap[256];
-  unsigned int size;
+  static int gammamap[256];
   byte        *destptr;
+  const byte  *endptr, *srcptr;
+  static double old_gamma = -1.0;
 
   goodImage(image, "gammacorrect");
   if (BITMAPP(image)) /* we're AT&T */
@@ -86,7 +87,9 @@
     fflush(stdout);
   }
 
-  make_gamma(disp_gam,gammamap);
+  if( disp_gam != old_gamma)
+    make_gamma(disp_gam,gammamap);
+  old_gamma = disp_gam;
 
   switch (image->type) {
   case IRGB:
@@ -98,12 +101,13 @@
     break;
 
   case ITRUE:
-    size= image->width * image->height * 3;
-    destptr= image->data;
-    for (a= 0; a < size; a++) {
-      *destptr= gammamap[*destptr];
-      destptr++;
-    }
+    srcptr = destptr = image->data;
+    endptr = destptr + image->width * image->height * 3;
+    do {
+      *destptr++ = gammamap[*srcptr++];
+      *destptr++ = gammamap[*srcptr++];
+      *destptr++ = gammamap[*srcptr++];
+    } while (srcptr < endptr);
     break;
   }
 
diff -urNad xloadimage-4.1~/compress.c xloadimage-4.1/compress.c
--- xloadimage-4.1~/compress.c	2005-12-06 02:59:04.000000000 +0000
+++ xloadimage-4.1/compress.c	2005-12-06 02:59:07.000000000 +0000
@@ -30,7 +30,7 @@
 
 #define NIL_PIXEL 0xffffffff
 
-void compress(image, verbose)
+void compress_cmap(image, verbose)
      Image        *image;
      unsigned int  verbose;
 { Pixel         hash_table[32768];
diff -urNad xloadimage-4.1~/config.c xloadimage-4.1/config.c
--- xloadimage-4.1~/config.c	2005-12-06 02:59:04.000000000 +0000
+++ xloadimage-4.1/config.c	2005-12-06 02:59:07.000000000 +0000
@@ -17,7 +17,7 @@
 #include <pwd.h>
 #endif
 #include <errno.h>
-#ifndef IS_BSD
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
diff -urNad xloadimage-4.1~/config.h.in xloadimage-4.1/config.h.in
--- xloadimage-4.1~/config.h.in	2005-12-06 02:59:07.000000000 +0000
+++ xloadimage-4.1/config.h.in	2005-12-06 02:59:07.000000000 +0000
@@ -9,9 +9,6 @@
 /* Define if the X Window System is missing or not being used.  */
 #undef X_DISPLAY_MISSING
 
-/* Define if you have the mkdir function.  */
-#undef HAVE_MKDIR
-
 /* Define if you have the select function.  */
 #undef HAVE_SELECT
 
@@ -27,14 +24,17 @@
 /* Define if you have the <unistd.h> header file.  */
 #undef HAVE_UNISTD_H
 
-/* Define if you have the jpeg library (-ljpeg).  */
-#undef HAVE_LIBJPEG
-
 /* Define if you have the m library (-lm).  */
 #undef HAVE_LIBM
 
+/* Define if you have the jpeg library (-ljpeg).  */
+#undef HAVE_LIBJPEG
+
 /* Define if you have the tiff library (-ltiff).  */
 #undef HAVE_LIBTIFF
 
+/* Define if you have the png library (-lpng).  */
+#undef HAVE_LIBPNG
+
 /* Define if you have the z library (-lz).  */
 #undef HAVE_LIBZ
diff -urNad xloadimage-4.1~/configure xloadimage-4.1/configure
--- xloadimage-4.1~/configure	2005-12-06 02:59:07.000000000 +0000
+++ xloadimage-4.1/configure	2005-12-06 02:59:07.000000000 +0000
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12 
+# Generated automatically using autoconf version 2.13 
 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 #
 # This configure script is free software; the Free Software Foundation
@@ -51,6 +51,7 @@
 # Initialize some other variables.
 subdirs=
 MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
 # Maximum number of lines to put in a shell here document.
 ac_max_here_lines=12
 
@@ -334,7 +335,7 @@
     verbose=yes ;;
 
   -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.12"
+    echo "configure generated by autoconf version 2.13"
     exit 0 ;;
 
   -with-* | --with-*)
@@ -504,9 +505,11 @@
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
+ac_exeext=
+ac_objext=o
 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
@@ -525,15 +528,16 @@
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:529: checking for $ac_word" >&5
+echo "configure:532: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_CC="gcc"
@@ -554,16 +558,17 @@
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:558: checking for $ac_word" >&5
+echo "configure:562: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
-  for ac_dir in $PATH; do
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -598,25 +603,61 @@
   echo "$ac_t""no" 1>&6
 fi
 
+  if test -z "$CC"; then
+    case "`uname -s`" in
+    *win32* | *WIN32*)
+      # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:613: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="cl"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+ ;;
+    esac
+  fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:606: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:645: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
-cat > conftest.$ac_ext <<EOF
-#line 616 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 656 "configure"
 #include "confdefs.h"
+
 main(){return(0);}
 EOF
-if { (eval echo configure:620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -630,18 +671,24 @@
   ac_cv_prog_cc_works=no
 fi
 rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:640: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:687: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:645: checking whether we are using GNU C" >&5
+echo "configure:692: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -650,7 +697,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:654: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:701: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -661,11 +708,15 @@
 
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
-  ac_test_CFLAGS="${CFLAGS+set}"
-  ac_save_CFLAGS="$CFLAGS"
-  CFLAGS=
-  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:669: checking whether ${CC-cc} accepts -g" >&5
+else
+  GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:720: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -680,21 +731,25 @@
 fi
 
 echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-  if test "$ac_test_CFLAGS" = set; then
-    CFLAGS="$ac_save_CFLAGS"
-  elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
     CFLAGS="-g -O2"
   else
-    CFLAGS="-O2"
+    CFLAGS="-g"
   fi
 else
-  GCC=
-  test "${CFLAGS+set}" = set || CFLAGS="-g"
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
 fi
 
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:698: checking how to run the C preprocessor" >&5
+echo "configure:753: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -709,14 +764,14 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 713 "configure"
+#line 768 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:719: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:774: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
@@ -726,14 +781,31 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 730 "configure"
+#line 785 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:736: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:791: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP="${CC-cc} -nologo -E"
+  cat > conftest.$ac_ext <<EOF
+#line 802 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:808: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
@@ -746,6 +818,8 @@
 rm -f conftest*
 fi
 rm -f conftest*
+fi
+rm -f conftest*
   ac_cv_prog_CPP="$CPP"
 fi
   CPP="$ac_cv_prog_CPP"
@@ -759,7 +833,7 @@
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:763: checking for X" >&5
+echo "configure:837: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -821,13 +895,13 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 825 "configure"
+#line 899 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:830: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:904: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   # We can compile using X headers with no special include directory.
@@ -895,14 +969,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 899 "configure"
+#line 973 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -1008,17 +1082,17 @@
     case "`(uname -sr) 2>/dev/null`" in
     "SunOS 5"*)
       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:1012: checking whether -R must be followed by a space" >&5
+echo "configure:1086: checking whether -R must be followed by a space" >&5
       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
       cat > conftest.$ac_ext <<EOF
-#line 1015 "configure"
+#line 1089 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -1034,14 +1108,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 1038 "configure"
+#line 1112 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1119: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -1073,7 +1147,7 @@
     # libraries were built with DECnet support.  And karl@cs.umb.edu says
     # the Alpha needs dnet_stub (dnet does not exist).
     echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:1077: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:1151: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1081,7 +1155,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1085 "configure"
+#line 1159 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1092,7 +1166,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:1096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1114,7 +1188,7 @@
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:1118: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:1192: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1122,7 +1196,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1126 "configure"
+#line 1200 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1133,7 +1207,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:1137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1162,12 +1236,12 @@
     # The nsl library prevents programs from opening the X display
     # on Irix 5.2, according to dickey@clark.net.
     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:1166: checking for gethostbyname" >&5
+echo "configure:1240: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1171 "configure"
+#line 1245 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -1190,7 +1264,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -1211,7 +1285,7 @@
 
     if test $ac_cv_func_gethostbyname = no; then
       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:1215: checking for gethostbyname in -lnsl" >&5
+echo "configure:1289: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1219,7 +1293,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1223 "configure"
+#line 1297 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1230,7 +1304,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:1234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1260,12 +1334,12 @@
     # -lsocket must be given before -lnsl if both are needed.
     # We assume that if connect needs -lnsl, so does gethostbyname.
     echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:1264: checking for connect" >&5
+echo "configure:1338: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1269 "configure"
+#line 1343 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -1288,7 +1362,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -1309,7 +1383,7 @@
 
     if test $ac_cv_func_connect = no; then
       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:1313: checking for connect in -lsocket" >&5
+echo "configure:1387: checking for connect in -lsocket" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1317,7 +1391,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1321 "configure"
+#line 1395 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1328,7 +1402,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:1332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1352,12 +1426,12 @@
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:1356: checking for remove" >&5
+echo "configure:1430: checking for remove" >&5
 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1361 "configure"
+#line 1435 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -1380,7 +1454,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1384: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -1401,7 +1475,7 @@
 
     if test $ac_cv_func_remove = no; then
       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:1405: checking for remove in -lposix" >&5
+echo "configure:1479: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1409,7 +1483,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lposix  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1413 "configure"
+#line 1487 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1420,7 +1494,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:1424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1444,12 +1518,12 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:1448: checking for shmat" >&5
+echo "configure:1522: checking for shmat" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1453 "configure"
+#line 1527 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -1472,7 +1546,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -1493,7 +1567,7 @@
 
     if test $ac_cv_func_shmat = no; then
       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:1497: checking for shmat in -lipc" >&5
+echo "configure:1571: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1501,7 +1575,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lipc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1505 "configure"
+#line 1579 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1512,7 +1586,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:1516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1545,15 +1619,15 @@
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:1549: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:1623: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lICE  $LIBS"
+LIBS="-lICE $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1557 "configure"
+#line 1631 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1564,7 +1638,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:1568: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1589,12 +1663,12 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1593: checking for ANSI C header files" >&5
+echo "configure:1667: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1598 "configure"
+#line 1672 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1602,8 +1676,8 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1606: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   ac_cv_header_stdc=yes
@@ -1619,7 +1693,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1623 "configure"
+#line 1697 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1637,7 +1711,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1641 "configure"
+#line 1715 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1658,7 +1732,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1662 "configure"
+#line 1736 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1669,7 +1743,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:1673: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1696,18 +1770,18 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1700: checking for $ac_hdr" >&5
+echo "configure:1774: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1705 "configure"
+#line 1779 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1710: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1784: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
@@ -1734,7 +1808,7 @@
 
 
 echo $ac_n "checking for main in -lm""... $ac_c" 1>&6
-echo "configure:1738: checking for main in -lm" >&5
+echo "configure:1812: checking for main in -lm" >&5
 ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1742,14 +1816,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1746 "configure"
+#line 1820 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1777,7 +1851,7 @@
 fi
 
 echo $ac_n "checking for main in -lz""... $ac_c" 1>&6
-echo "configure:1781: checking for main in -lz" >&5
+echo "configure:1855: checking for main in -lz" >&5
 ac_lib_var=`echo z'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1785,14 +1859,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lz  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1789 "configure"
+#line 1863 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1819,8 +1893,51 @@
   echo "$ac_t""no" 1>&6
 fi
 
+echo $ac_n "checking for main in -lpng""... $ac_c" 1>&6
+echo "configure:1898: checking for main in -lpng" >&5
+ac_lib_var=`echo png'_'main | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lpng  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1906 "configure"
+#include "confdefs.h"
+
+int main() {
+main()
+; return 0; }
+EOF
+if { (eval echo configure:1913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo png | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+  LIBS="-lpng $LIBS"
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
 echo $ac_n "checking for main in -ljpeg""... $ac_c" 1>&6
-echo "configure:1824: checking for main in -ljpeg" >&5
+echo "configure:1941: checking for main in -ljpeg" >&5
 ac_lib_var=`echo jpeg'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1828,14 +1945,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ljpeg  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1832 "configure"
+#line 1949 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1863,7 +1980,7 @@
 fi
 
 echo $ac_n "checking for main in -ltiff""... $ac_c" 1>&6
-echo "configure:1867: checking for main in -ltiff" >&5
+echo "configure:1984: checking for main in -ltiff" >&5
 ac_lib_var=`echo tiff'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1871,14 +1988,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ltiff  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1875 "configure"
+#line 1992 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:1882: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1909,12 +2026,12 @@
 
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1913: checking return type of signal handlers" >&5
+echo "configure:2030: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1918 "configure"
+#line 2035 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -1931,7 +2048,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:1935: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2052: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -1952,12 +2069,12 @@
 for ac_func in mkdir select
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1956: checking for $ac_func" >&5
+echo "configure:2073: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1961 "configure"
+#line 2078 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1980,7 +2097,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2028,7 +2145,7 @@
 # Ultrix sh set writes to stderr and can't be redirected directly,
 # and sets the high bit in the cache file unless we assign to the vars.
 (set) 2>&1 |
-  case `(ac_space=' '; set) 2>&1` in
+  case `(ac_space=' '; set | grep ac_space) 2>&1` in
   *ac_space=\ *)
     # `set' does not quote correctly, so add quotes (double-quote substitution
     # turns \\\\ into \\, and sed turns \\ into \).
@@ -2095,7 +2212,7 @@
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.12"
+    echo "$CONFIG_STATUS generated by autoconf version 2.13"
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
@@ -2114,9 +2231,11 @@
  s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
+s%@SHELL@%$SHELL%g
 s%@CFLAGS@%$CFLAGS%g
 s%@CPPFLAGS@%$CPPFLAGS%g
 s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
 s%@DEFS@%$DEFS%g
 s%@LDFLAGS@%$LDFLAGS%g
 s%@LIBS@%$LIBS%g
diff -urNad xloadimage-4.1~/configure.in xloadimage-4.1/configure.in
--- xloadimage-4.1~/configure.in	2005-12-06 02:59:07.000000000 +0000
+++ xloadimage-4.1/configure.in	2005-12-06 02:59:07.000000000 +0000
@@ -15,6 +15,8 @@
 AC_CHECK_LIB(m, main)
 dnl Replace `main' with a function in -lz:
 AC_CHECK_LIB(z, main)
+dnl Replace `main' with a function in -lpng:
+AC_CHECK_LIB(png, main)
 dnl Replace `main' with a function in -ljpeg:
 AC_CHECK_LIB(jpeg, main)
 dnl Replace `main' with a function in -ltiff:
@@ -25,6 +27,6 @@
 
 dnl Checks for library functions.
 AC_TYPE_SIGNAL
-AC_CHECK_FUNCS(mkdir select)
+AC_CHECK_FUNCS(select)
 
 AC_OUTPUT(Makefile)
diff -urNad xloadimage-4.1~/image.h xloadimage-4.1/image.h
--- xloadimage-4.1~/image.h	2005-12-06 02:59:07.000000000 +0000
+++ xloadimage-4.1/image.h	2005-12-06 02:59:07.000000000 +0000
@@ -18,15 +18,12 @@
 
 /* ANSI-C stuff
  */
-#if defined(__STDC__)
-
+#ifdef STDC_HEADERS
 #if !defined(_ArgProto)
 #define _ArgProto(ARGS) ARGS
 #endif
-
 #include <stdlib.h>
-
-#else /* !__STDC__ */
+#else /* !STDC_HEADERS */
 
 #if !defined(const) /* "const" is an ANSI thing */
 #define const
@@ -35,26 +32,14 @@
 #define _ArgProto(ARGS) ()
 #endif
 
-#endif /* !__STDC__ */
+#endif /* !STDC_HEADERS */
 
 /* handle strings stuff that varies between BSD and ANSI/SYSV
  */
-#if defined(IS_BSD) && !defined(__STDC__)
-#include <strings.h>
-#if !defined(strchr) && !defined(index)
-#define strchr index
-#endif
-#if !defined(strrchr) && !defined(rindex)
-#define strrchr rindex
-#endif
-#if !defined(memcpy) && !defined(bcopy)
-#define memcpy(D,S,L) bcopy((char *)(S),(char *)(D),(L))
-#endif
-#if !defined(memset) && !defined(bzero)
-/* #define memset(D,V,L) bzero(D,L) */
-#endif
-#else /* !IS_BSD || __STDC__ */
 #include <string.h>
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#else /* !HAVE_STRINGS_H */
 #if !defined(index) && !defined(strchr)
 #define index strchr
 #endif
@@ -67,7 +52,7 @@
 #if !defined(bzero) && !defined(memset)
 #define bzero(D,L) memset((void *)(D),0,(L))
 #endif
-#endif /* !IS_BSD || __STDC__ */
+#endif /* !HAVE_STRINGS_H */
 
 #ifdef VMS
 #define R_OK 4
@@ -234,7 +219,7 @@
 Image *normalize _ArgProto((Image *image, unsigned int verbose));
 
 /* compress.c */
-void compress _ArgProto((Image *image, unsigned int verbose));
+void compress_cmap _ArgProto((Image *image, unsigned int verbose));
 
 /* dither.c */
 Image *dither _ArgProto((Image *image, unsigned int verbose));
diff -urNad xloadimage-4.1~/imagetypes.h xloadimage-4.1/imagetypes.h
--- xloadimage-4.1~/imagetypes.h	2005-12-06 02:59:07.000000000 +0000
+++ xloadimage-4.1/imagetypes.h	2005-12-06 02:59:07.000000000 +0000
@@ -34,6 +34,9 @@
 #ifdef HAVE_LIBTIFF
 Image *tiffLoad();
 #endif
+#ifdef HAVE_LIBPNG
+Image *pngLoad();
+#endif
 
 int niffIdent();
 int facesIdent();
@@ -62,6 +65,9 @@
 #ifdef HAVE_LIBTIFF
 int tiffIdent();
 #endif
+#ifdef HAVE_LIBPNG
+int pngIdent();
+#endif
 
 void niffDump();
 #ifdef HAVE_LIBJPEG
@@ -91,6 +97,9 @@
 #ifdef HAVE_LIBTIFF
   tiffIdent,      tiffLoad,      tiffDump,    "tiff",      "TIFF image",
 #endif
+#ifdef HAVE_LIBPNG
+  pngIdent,       pngLoad,       NULL,        "png",       "PNG image",
+#endif
   fbmIdent,       fbmLoad,       NULL,        "fbm",       "FBM Image",
   cmuwmIdent,     cmuwmLoad,     NULL,        "cmuraster", "CMU WM Raster",
   pbmIdent,       pbmLoad,       pbmDump,     "pbm",       "Portable Bit Map (PBM, PGM, PPM)",
diff -urNad xloadimage-4.1~/new.c xloadimage-4.1/new.c
--- xloadimage-4.1~/new.c	2005-12-06 02:59:04.000000000 +0000
+++ xloadimage-4.1/new.c	2005-12-06 02:59:07.000000000 +0000
@@ -10,6 +10,9 @@
 
 #include "copyright.h"
 #include "image.h"
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 
 extern int _Xdebug;
 
diff -urNad xloadimage-4.1~/niff.c xloadimage-4.1/niff.c
--- xloadimage-4.1~/niff.c	2005-12-06 02:59:07.000000000 +0000
+++ xloadimage-4.1/niff.c	2005-12-06 02:59:07.000000000 +0000
@@ -8,8 +8,10 @@
  * this is in the public domain.
  */
 
-#include <unistd.h>
 #include "image.h"
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include "niff.h"
 
 static void babble(name, header, title)
diff -urNad xloadimage-4.1~/options.c xloadimage-4.1/options.c
--- xloadimage-4.1~/options.c	2005-12-06 02:59:04.000000000 +0000
+++ xloadimage-4.1/options.c	2005-12-06 02:59:07.000000000 +0000
@@ -731,6 +731,11 @@
       if (++a >= argc)
 	optionUsage(GAMMA);
       newopt->info.gamma= getFloat(GAMMA, argv[a]);
+      if (newopt->info.gamma < 0.0) {
+	fprintf(stderr, "Argument to %s must be over 0.0 (ignored)\n",
+		optionName(GAMMA));
+	newopt->type= OPT_IGNORE;
+      }
       break;
 
     case GOTO:
diff -urNad xloadimage-4.1~/png.c xloadimage-4.1/png.c
--- xloadimage-4.1~/png.c	1970-01-01 00:00:00.000000000 +0000
+++ xloadimage-4.1/png.c	2005-12-06 02:59:07.000000000 +0000
@@ -0,0 +1,350 @@
+/*
+ * PNG - Portable Network Graphics
+ *
+ * Alpha channle is linear.
+ * Color   \   Bit Depth      1   2   4   8  16  palette  bKGD
+ * PNG_COLOR_TYPE_PALETTE     O   O   O   O      must      8 bit
+ * PNG_COLOR_TYPE_GRAY        O   O   O   O   O           16
+ * PNG_COLOR_TYPE_GRAY_ALPHA              O   O           16
+ * PNG_COLOR_TYPE_RGB                     O   O  possible 16 * 3
+ * PNG_COLOR_TYPE_RGB_ALPHA               O   O  possible 16 * 3
+ * 
+ * This code is based on jpeg.c and sample code from the libpng-1.0.5.
+ * 2000/01/10: YOSHIDA Hiroshi
+ *
+ * TODO:
+ * pngLoad(): Alpha channel, Transparency palette.
+ * pngDump(): Dump.
+ * 
+ */
+
+
+#include "image.h"	/* xloadimage declarations */
+#ifdef HAVE_LIBPNG
+#include "options.h"
+#include <png.h>
+#include <setjmp.h>
+
+#undef  DEBUG
+/* #define  DEBUG */
+#undef  debug
+
+#ifdef DEBUG
+# define debug(xx)	fprintf(stderr,xx)
+#else
+# define debug(xx)
+#endif
+
+#define PNG_BYTES_TO_CHECK 4
+
+static Image *image;    /* xloadimage image being returned */
+static ZFILE *zinput_file;
+static char *filename;
+
+int pngIdent(char *fullname, char *name);
+Image *pngLoad(char *fullname, char *name, unsigned int verbose);
+/* void pngDump(Image *image, char *options, char *file, int verbose); */
+
+
+/*
+ * png read handler
+ */
+static void png_read_data(png_structp png_ptr,
+			  png_bytep data, png_size_t length)
+{
+  if (zread(zinput_file, data, length) != length)
+    png_error(png_ptr, "Read Error");
+}
+
+
+/*
+ * png warn handler
+ */
+static void output_warn(png_structp png_ptr, png_const_charp str)
+{
+  debug(" #warn ");
+  fprintf(stderr, " PNG file: %s - %s\n", filename, str);
+  fflush(stderr);
+}
+
+
+/*
+ * png error handler
+ */
+static void output_error(png_structp png_ptr, png_const_charp str)
+{
+  debug(" #error ");
+  output_warn( png_ptr, str);
+  longjmp(png_ptr->jmpbuf, 1);	/* return control to outer routine */
+}
+
+
+static const char *pngColor(int color_type)
+{
+  const char *str;
+
+  switch (color_type) {
+  case PNG_COLOR_TYPE_GRAY:
+    str = "GRAY";
+    break;
+  case PNG_COLOR_TYPE_GRAY_ALPHA:
+    str = "GRAY_ALPHA";
+    break;
+  case PNG_COLOR_TYPE_PALETTE:
+    str = "PALETTE";
+    break;
+  case PNG_COLOR_TYPE_RGB:
+    str = "RGB";
+    break;
+  case PNG_COLOR_TYPE_RGB_ALPHA:
+    str = "RGB_ALPHA";
+    break;
+  default:
+    str = "UNKNOWN_COLOR_TYPE";
+  }
+  return str;
+}
+
+
+static const char *pngInterlace(int interlace_type)
+{
+  const char *str;
+
+  switch (interlace_type) {
+  case PNG_INTERLACE_NONE:
+    str = "NONE";
+    break;
+  case PNG_INTERLACE_ADAM7:
+    str = "ADAM7";
+    break;
+  default:
+    str = "UNKNOWN_TYPE";
+  }
+  return str;
+}
+
+
+/*
+ * Output PNG file infomation.
+ */
+static void pngInfo( png_uint_32 width, png_uint_32 height,
+		     int bit_depth, int color_type, int interlace_type,
+		     double file_gamma)
+{
+  printf("%s is %ldx%ld PNG image, color type %s, %d bit",
+	 filename, width, height, pngColor(color_type), bit_depth);
+  if( interlace_type != PNG_INTERLACE_NONE)
+    printf(", interlace %s", pngInterlace(interlace_type));
+  if( file_gamma >= 0.0)
+    printf(", file gamma %.4f", file_gamma);
+  putchar('\n');
+}
+
+
+/*
+ * pngIdent(), pngLoad()
+ * Read PNG header & allocate png's struct:
+ * return 1: success
+ */
+static int pngHeader(png_structpp png_pp,
+		     png_infopp info_pp, png_infopp end_pp)
+{
+  *info_pp = *end_pp = NULL;
+  *png_pp = png_create_read_struct(PNG_LIBPNG_VER_STRING,
+				   NULL, output_error, output_warn);
+  if (!*png_pp)
+    return 0;
+  *info_pp = png_create_info_struct(*png_pp);
+  if (!*info_pp) {
+    png_destroy_read_struct(png_pp, info_pp, end_pp);
+    return 0;
+  }
+  *end_pp = png_create_info_struct(*png_pp);
+  if (!*end_pp) {
+    png_destroy_read_struct(png_pp, info_pp, end_pp);
+    return 0;
+  }
+  if (setjmp((*png_pp)->jmpbuf)) {
+    /* On error */
+    png_destroy_read_struct(png_pp, info_pp, end_pp);
+    return 0;
+  }
+  png_set_sig_bytes(*png_pp, PNG_BYTES_TO_CHECK);
+  png_set_read_fn(*png_pp, NULL, png_read_data);
+  png_read_info(*png_pp, *info_pp);
+
+  return 1;
+}
+
+
+/*
+ * return !0: It is a PNG.
+ */
+static int is_png(ZFILE *zf)
+{
+  byte png_read_buff[PNG_BYTES_TO_CHECK];
+
+  /* Read in some of the signature bytes */
+  if (zread(zf, png_read_buff,PNG_BYTES_TO_CHECK) != PNG_BYTES_TO_CHECK)
+    return 0;
+  return !png_sig_cmp(png_read_buff, (png_size_t)0, PNG_BYTES_TO_CHECK);
+}
+
+
+/*
+ * Main control routine for identifying PNG without loading
+ * return 1: PNG file.
+ */
+int pngIdent(char *fullname, char *name)
+{
+  png_structp png_ptr;
+  png_infop info_ptr, end_info;
+  png_uint_32 width, height;
+  int color_type, bit_depth, interlace_type;
+  double file_gamma;
+
+  zinput_file = zopen(fullname);
+  if (zinput_file == NULL) {
+    zclose(zinput_file);
+    return 0;
+  }
+  /* check at early timing */
+  if (is_png(zinput_file) == 0) {
+    zclose(zinput_file);
+    return 0;
+  }
+  filename = name;
+
+  /* read infomation header */
+  if (!pngHeader(&png_ptr, &info_ptr, &end_info)) {
+    zclose(zinput_file);
+    return 0;
+  }
+  if (setjmp(png_ptr->jmpbuf)) {
+    /* On error */
+    freeImage(image);
+    png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+    zclose(zinput_file);
+    return 0;
+  }
+  png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
+	       &color_type, &interlace_type, NULL, NULL);
+  if(!png_get_gAMA( png_ptr, info_ptr, &file_gamma))
+    file_gamma = -1.0;
+  /* print out PNG infomation */
+  pngInfo( width, height, bit_depth, color_type, interlace_type, file_gamma);
+
+  znocache(zinput_file);
+  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+  zclose(zinput_file);
+  return 1;
+}
+
+
+/*
+ * Main control routine for loading
+ */
+Image *pngLoad(char *fullname, char *name, unsigned int verbose)
+{
+  png_structp png_ptr;
+  png_infop info_ptr, end_info;
+  png_colorp palette;
+  png_color_16p background;
+  png_bytep bufp, *row_pointers;
+  png_uint_32 width, height;
+  int i, row_stride, color_type, bit_depth, num_palette, interlace_type;
+  double file_gamma;
+
+  zinput_file = zopen(fullname);
+  if (zinput_file == NULL) {
+    zclose(zinput_file);
+    return NULL;
+  }
+  /* check at early timing */
+  if (is_png(zinput_file) == 0) {
+    zclose(zinput_file);
+    return NULL;
+  }
+  filename = name;
+
+  /* read infomation header */
+  if (!pngHeader(&png_ptr, &info_ptr, &end_info)) {
+    zclose(zinput_file);
+    return NULL;
+  }
+  png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
+	       &color_type, &interlace_type, NULL, NULL);
+  if(!png_get_gAMA( png_ptr, info_ptr, &file_gamma))
+    file_gamma = -1.0;
+  /* print out PNG infomation */
+  if (verbose)
+    pngInfo( width, height, bit_depth, color_type, interlace_type, file_gamma);
+  znocache(zinput_file);
+  image = NULL;
+
+  if (file_gamma <= 0.0)
+    file_gamma = 1.0;
+  png_set_gamma(png_ptr, 1.0, file_gamma);
+  if (bit_depth > 8)
+    png_set_strip_16(png_ptr);      /* 16 bit -> 8 bit */
+  /*  if (color_type & PNG_COLOR_MASK_ALPHA) */
+  png_set_strip_alpha(png_ptr);
+  if (png_get_bKGD(png_ptr, info_ptr, &background))
+    png_set_background(png_ptr, background, file_gamma, 1, 1.0);
+  switch (color_type) {
+  case PNG_COLOR_TYPE_PALETTE:
+    if (bit_depth < 8)
+      png_set_packing(png_ptr);     /* 1 pixlel 1 byte */
+    image = newRGBImage(width, height, 8);
+    png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
+    image->rgb.used = num_palette;
+    for (i = 0; i < num_palette; i++) {
+      *(image->rgb.red + i) = palette->red << 8;
+      *(image->rgb.green + i) = palette->green << 8;
+      *(image->rgb.blue + i) = palette->blue << 8;
+      palette++;
+    }
+    break;
+  case PNG_COLOR_TYPE_GRAY_ALPHA:
+  case PNG_COLOR_TYPE_GRAY:
+    if (bit_depth < 8)
+      png_set_gray_1_2_4_to_8(png_ptr);  /* 1 pixlel 1 byte */
+    image = newRGBImage(width, height, 8);
+    image->rgb.used = 256;
+    for (i = 0; i < 256; i++) {
+      *(image->rgb.red + i) = 
+	*(image->rgb.green + i) = 
+	*(image->rgb.blue + i) = i << 8;
+    }
+    break;
+  case PNG_COLOR_TYPE_RGB_ALPHA:
+  case PNG_COLOR_TYPE_RGB:
+    image = newTrueImage(width, height);
+    break;
+  default:
+    fprintf(stderr, "Unknown color type PNG.");
+    png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+    zclose(zinput_file);
+    return NULL;
+  }
+  image->title = dupString(filename);
+
+  bufp = image->data;
+  png_read_update_info(png_ptr, info_ptr);
+  row_stride = png_get_rowbytes(png_ptr, info_ptr);
+  row_pointers = (png_bytep *)lmalloc(sizeof(png_bytep) * height);
+  for (i = 0; i < height; i++) {
+    *(row_pointers + i) = bufp;
+    bufp += row_stride;
+  }
+  png_read_image(png_ptr, row_pointers);
+  lfree((byte *)row_pointers);
+  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+  zclose(zinput_file);
+
+  return image;
+}
+
+#else /* !HAVE_LIBPNG */
+static int unused;
+#endif /* !HAVE_LIBPNG */
diff -urNad xloadimage-4.1~/send.c xloadimage-4.1/send.c
--- xloadimage-4.1~/send.c	2005-12-06 02:59:04.000000000 +0000
+++ xloadimage-4.1/send.c	2005-12-06 02:59:07.000000000 +0000
@@ -255,7 +255,7 @@
 
   default:
   retry: /* this tag is used when retrying because we couldn't get a fit */
-    compress(image, verbose);
+    compress_cmap(image, verbose);
 
     index= (Pixel *)lmalloc(sizeof(Pixel) * image->rgb.used);
 
diff -urNad xloadimage-4.1~/vff.c xloadimage-4.1/vff.c
--- xloadimage-4.1~/vff.c	2005-12-06 02:59:07.000000000 +0000
+++ xloadimage-4.1/vff.c	2005-12-06 02:59:07.000000000 +0000
@@ -150,7 +150,7 @@
 	  op = image->data;
 	  skip = bands - 3;
 	  linewidth = bands * width;
-	  buf = (unsigned char *)malloc((unsigned)linewidth);
+	  buf = (unsigned char *)lmalloc((unsigned)linewidth);
 	  if (buf == NULL) {
 	       memoryExhausted();    
 	  }
@@ -337,7 +337,7 @@
 		    return(0);
 	       }
 
-	       if ((header[lines] = (char *)malloc((unsigned)count+1)) == NULL) {
+	       if ((header[lines] = (char *)lmalloc((unsigned)count+1)) == NULL) {
 		    memoryExhausted();    
 	       }
 	       bcopy(buf, header[lines], count);
diff -urNad xloadimage-4.1~/vicar.c xloadimage-4.1/vicar.c
--- xloadimage-4.1~/vicar.c	2005-12-06 02:59:04.000000000 +0000
+++ xloadimage-4.1/vicar.c	2005-12-06 02:59:07.000000000 +0000
@@ -12,7 +12,6 @@
 #define SAMPLES   label[6]
  
 #include <stdio.h>
-#include <malloc.h>
 #include "image.h"
 #include <sys/types.h>
 
diff -urNad xloadimage-4.1~/window.c xloadimage-4.1/window.c
--- xloadimage-4.1~/window.c	2005-12-06 02:59:07.000000000 +0000
+++ xloadimage-4.1/window.c	2005-12-06 02:59:07.000000000 +0000
@@ -15,23 +15,21 @@
 #include <X11/Xatom.h>
 #include <signal.h>
 #include <errno.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
+#endif
+#ifdef HAVE_SELECT
+#define ENABLE_TIMEOUT
+#include <sys/select.h>
+#else /* !HAVE_SELECT */
 #ifdef HAS_POLL
 #include <poll.h>
-#else /* !HAS_POLL */
-#ifdef HAS_SELECT_INCLUDE
-#include <sys/select.h>
-#endif /* HAS_SELECT_INCLUDE */
-#endif /* !HAS_POLL */
-
-/* we can use timeouts if either select() or poll() are available.
- */
-#if IS_BSD
 #define ENABLE_TIMEOUT
-#endif
-#if defined(HAS_SELECT_INCLUDE) || defined(HAS_POLL)
-#define ENABLE_TIMEOUT
-#endif
+#endif /* !HAS_POLL */
+#endif /* !HAVE_SELECT */
 
 /* SUPPRESS 560 */
 
diff -urNad xloadimage-4.1~/xloadimage.c xloadimage-4.1/xloadimage.c
--- xloadimage-4.1~/xloadimage.c	2005-12-06 02:59:07.000000000 +0000
+++ xloadimage-4.1/xloadimage.c	2005-12-06 02:59:07.000000000 +0000
@@ -16,6 +16,9 @@
 #else
 #include "patchlevel"
 #endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <signal.h>
 
 char *ProgramName= "xloadimage";
diff -urNad xloadimage-4.1~/xloadimagerc xloadimage-4.1/xloadimagerc
--- xloadimage-4.1~/xloadimagerc	2005-12-06 02:59:04.000000000 +0000
+++ xloadimage-4.1/xloadimagerc	2005-12-06 03:11:46.000000000 +0000
@@ -14,6 +14,7 @@
             .pbm .pgm .ppm    # PBMPLUS
             .img              # GEM IMG
             .pcx              # PCX image
+            .png              # PNG image
 
 # add uufilter for automatic uudecoding of files ending in .uu or .uue
 filter = "uufilter -s" .uu .uue