Index: kit/CHANGELOG
diff -u kit/CHANGELOG:1.9 kit/CHANGELOG:removed
--- kit/CHANGELOG:1.9	Sat Sep  5 00:11:21 1998
+++ kit/CHANGELOG	Mon Feb 21 05:10:03 2000
@@ -1,51 +0,0 @@
-CHANGELOG for magicpoint
-$Id: CHANGELOG,v 1.9 1998/09/04 15:11:21 onoe Exp $
-
-Fri Sep  5 1998  onoe@sm.sony.co.jp
-	* handle key inputs from invoked terminal as pressed on Xserver,
-	  even if the Xserver is running on a remote host.
-
-Mon Aug 26 1998  itojun@iijlab.net
-	* new copyright. (BSDish copyright without clause 3)
-
-Mon Aug 25 1998  itojun@iijlab.net
-	* print.c: better x11/freetype/vflib -> postscript font mapping.
-
-Mon Aug 23 1998  kato@wide.ad.jp
-	* embedded image support (added mgpembed.pl and embed.c)
-
-Mon Aug 22 1998  itojun@iijlab.net
-	* added contrib/xmindpath, MindPath PocketPoint user-level driver.
-
-Fri Jul 10 11:57:59 JST 1998  itojun@iijlab.net
-	* cache gs-generated image file.
-	  Suggested by: luigi@FreeBSD.org
-
-Mon Jul  6 11:38:32 JST 1998  itojun@iijlab.net
-	* capable of handling GB2312 and KSC5601 encoding.
-	  they must be encoded by using iso-2022 like escape sequences.
-	  EUC-cn or EUC-kr does not work.
-	* -x option is added.
-
-Thu Jul  2 18:04:16 JST 1998  itojun@iijlab.net
-	* eliminate gsview.
-	* revamp "xfont" directive. (see SYNTAX for detail)
-
-Thu Jun 25 13:10:28 JST 1998  itojun@iijlab.net
-	* print.c: color postscript support by "mgp2ps -c".
-
-changes between 1.02a and 1.03a:
-	* To allow color name that has space inbetween ("dark blue"), 
-	  color name after directives SHOULD come with doublequote.
-	  Therefore,
-		%fore blue
-	  should be
-		%fore "blue"
-	  At this moment, doublequote can be ommitted for backward
-	  compatibility.  We may require to have doublequote in the future.
-	  Font names and other string parameter obeys the same rule.
-	* %image is now capable of rendering encapsulated postscript files
-	  (*.eps).
-		%image foo.eps
-	  should work fine.
-	  By using -X option, you can specify device name for ghostscript.
Index: kit/configure
diff -u kit/configure:1.65 kit/configure:1.72
--- kit/configure:1.65	Sun Nov 28 23:34:59 1999
+++ kit/configure	Tue Feb 15 18:52:49 2000
@@ -14,8 +14,6 @@
 ac_help="$ac_help
   --enable-debug          compile debugging information in."
 ac_help="$ac_help
-  --enable-gif            compile gif support in."
-ac_help="$ac_help
   --enable-locale         perform setlocale() on invocation."
 ac_help="$ac_help
   --disable-freetype      DON'T use freetype routines."
@@ -26,6 +24,8 @@
 ac_help="$ac_help
   --enable-freetype-charset16         use freetype for chaset16."
 ac_help="$ac_help
+  --enable-gif            compile gif support in (need libungif)."
+ac_help="$ac_help
   --with-x                use the X Window System"
 
 # Initialize some variables set by options.
@@ -611,12 +611,92 @@
 host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$host" 1>&6
 
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:616: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+    # This must be in double quotes, not single quotes, because CPP may get
+  # substituted into the Makefile and "${CC-cc}" will confuse make.
+  CPP="${CC-cc} -E"
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp.
+  cat > conftest.$ac_ext <<EOF
+#line 631 "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:637: \"$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} -E -traditional-cpp"
+  cat > conftest.$ac_ext <<EOF
+#line 648 "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:654: \"$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 665 "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:671: \"$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=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+  ac_cv_prog_CPP="$CPP"
+fi
+  CPP="$ac_cv_prog_CPP"
+else
+  ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
 for ac_prog in mawk gawk nawk awk
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:620: checking for $ac_word" >&5
+echo "configure:700: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -650,7 +730,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:654: checking for $ac_word" >&5
+echo "configure:734: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -683,7 +763,7 @@
 # Extract the first word of "flex", so it can be a program name with args.
 set dummy flex; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:687: checking for $ac_word" >&5
+echo "configure:767: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -717,7 +797,7 @@
   *) ac_lib=l ;;
   esac
   echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6
-echo "configure:721: checking for yywrap in -l$ac_lib" >&5
+echo "configure:801: checking for yywrap in -l$ac_lib" >&5
 ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -725,7 +805,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-l$ac_lib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 729 "configure"
+#line 809 "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
@@ -736,7 +816,7 @@
 yywrap()
 ; return 0; }
 EOF
-if { (eval echo configure:740: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:820: \"$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
@@ -763,7 +843,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:767: checking for $ac_word" >&5
+echo "configure:847: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_mgp_cv_path_perl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -805,7 +885,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:809: checking for $ac_word" >&5
+echo "configure:889: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_mgp_cv_path_uuencode'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -847,7 +927,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:851: checking for $ac_word" >&5
+echo "configure:931: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_mgp_cv_path_gzip'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -889,7 +969,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:893: checking for $ac_word" >&5
+echo "configure:973: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_mgp_cv_path_uudecode'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -930,7 +1010,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:934: checking for $ac_word" >&5
+echo "configure:1014: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_mgp_cv_path_gunzip'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -981,7 +1061,7 @@
 OPTFLAGS="$OPTFLAGS -DGUNZIP=\\\"$mgp_cv_path_gunzip\\\""
 
 echo $ac_n "checking if --enable-debug option specified""... $ac_c" 1>&6
-echo "configure:985: checking if --enable-debug option specified" >&5
+echo "configure:1065: checking if --enable-debug option specified" >&5
 # Check whether --enable-debug or --disable-debug was given.
 if test "${enable_debug+set}" = set; then
   enableval="$enable_debug"
@@ -992,23 +1072,8 @@
 
 echo "$ac_t""$mgp_debug" 1>&6
 
-echo $ac_n "checking if --enable-gif option specified""... $ac_c" 1>&6
-echo "configure:997: checking if --enable-gif option specified" >&5
-# Check whether --enable-gif or --disable-gif was given.
-if test "${enable_gif+set}" = set; then
-  enableval="$enable_gif"
-  mgp_gif="yes"; cat >> confdefs.h <<\EOF
-#define USE_GIF 1
-EOF
-
-else
-  mgp_gif="no"
-fi
-
-echo "$ac_t""$mgp_gif" 1>&6
-
 echo $ac_n "checking if --enable-locale option specified""... $ac_c" 1>&6
-echo "configure:1012: checking if --enable-locale option specified" >&5
+echo "configure:1077: checking if --enable-locale option specified" >&5
 # Check whether --enable-locale or --disable-locale was given.
 if test "${enable_locale+set}" = set; then
   enableval="$enable_locale"
@@ -1022,7 +1087,7 @@
 LIBS="-lm $LIBS"
 
 echo $ac_n "checking if --disable-freetype option specified""... $ac_c" 1>&6
-echo "configure:1026: checking if --disable-freetype option specified" >&5
+echo "configure:1091: checking if --disable-freetype option specified" >&5
 # Check whether --enable-freetype or --disable-freetype was given.
 if test "${enable_freetype+set}" = set; then
   enableval="$enable_freetype"
@@ -1035,7 +1100,7 @@
  
 if test "$mgp_use_freetype" = "yes"; then
  	echo $ac_n "checking for freetype library/header""... $ac_c" 1>&6
-echo "configure:1039: checking for freetype library/header" >&5
+echo "configure:1104: checking for freetype library/header" >&5
  	for dir in /usr/local/freetype /usr/local /opt/freetype /usr/pkg /usr; do
  		ac_cv_ft_lib=no
  		ac_cv_ft_include=no
@@ -1073,7 +1138,7 @@
 	OPTFLAGS="-I$ac_cv_ft_include $OPTFLAGS"
 	DEPLIBS="$ac_cv_ft_lib/$ac_cv_ft_libpath $DEPLIBS"
  	echo $ac_n "checking for TT_Init_FreeType in -lttf""... $ac_c" 1>&6
-echo "configure:1077: checking for TT_Init_FreeType in -lttf" >&5
+echo "configure:1142: checking for TT_Init_FreeType in -lttf" >&5
 ac_lib_var=`echo ttf'_'TT_Init_FreeType | 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 +1146,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lttf  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1085 "configure"
+#line 1150 "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 +1157,7 @@
 TT_Init_FreeType()
 ; return 0; }
 EOF
-if { (eval echo configure:1096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1161: \"$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
@@ -1122,14 +1187,14 @@
 fi
 
  	cat > conftest.$ac_ext <<EOF
-#line 1126 "configure"
+#line 1191 "configure"
 #include "confdefs.h"
 #include <freetype.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1133: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1198: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -1144,16 +1209,16 @@
 EOF
 
 	echo $ac_n "checking for num_CharMaps field in TT_Face_Properties""... $ac_c" 1>&6
-echo "configure:1148: checking for num_CharMaps field in TT_Face_Properties" >&5
+echo "configure:1213: checking for num_CharMaps field in TT_Face_Properties" >&5
  	cat > conftest.$ac_ext <<EOF
-#line 1150 "configure"
+#line 1215 "configure"
 #include "confdefs.h"
 #include <freetype.h>
 int main() {
 TT_Face_Properties x; return x.num_CharMaps;
 ; return 0; }
 EOF
-if { (eval echo configure:1157: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1222: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   result=yes; cat >> confdefs.h <<\EOF
 #define HAVE_TT_FACE_PROPERTIES_CHARMAPS 1
@@ -1170,7 +1235,7 @@
 fi
 
 echo $ac_n "checking if --disable-vflib option specified""... $ac_c" 1>&6
-echo "configure:1174: checking if --disable-vflib option specified" >&5
+echo "configure:1239: checking if --disable-vflib option specified" >&5
 # Check whether --enable-vflib or --disable-vflib was given.
 if test "${enable_vflib+set}" = set; then
   enableval="$enable_vflib"
@@ -1183,7 +1248,7 @@
 
 if test "$mgp_use_vflib" = "yes"; then
 	echo $ac_n "checking for VFlib library/header""... $ac_c" 1>&6
-echo "configure:1187: checking for VFlib library/header" >&5
+echo "configure:1252: checking for VFlib library/header" >&5
 	for dir in /usr/local/VFlib /usr/local/vflib /usr/local /usr/pkg /usr; do
 		ac_cv_vf_libname=VFlib
 		ac_cv_vf_libdir=no
@@ -1232,7 +1297,7 @@
 	OPTFLAGS="-I$ac_cv_vf_hdrdir $OPTFLAGS"
 	DEPLIBS="$ac_cv_vf_libdir/$ac_cv_vf_libpath $DEPLIBS"
 	echo $ac_n "checking for VF_Init in -l$ac_cv_vf_libname""... $ac_c" 1>&6
-echo "configure:1236: checking for VF_Init in -l$ac_cv_vf_libname" >&5
+echo "configure:1301: checking for VF_Init in -l$ac_cv_vf_libname" >&5
 ac_lib_var=`echo $ac_cv_vf_libname'_'VF_Init | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1240,7 +1305,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-l$ac_cv_vf_libname  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1244 "configure"
+#line 1309 "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
@@ -1251,7 +1316,7 @@
 VF_Init()
 ; return 0; }
 EOF
-if { (eval echo configure:1255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1320: \"$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
@@ -1274,14 +1339,14 @@
 fi
 
 	cat > conftest.$ac_ext <<EOF
-#line 1278 "configure"
+#line 1343 "configure"
 #include "confdefs.h"
 #include <VF.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1285: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1350: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -1297,7 +1362,7 @@
 
 
 	echo $ac_n "checking for VFlib configuration file""... $ac_c" 1>&6
-echo "configure:1301: checking for VFlib configuration file" >&5
+echo "configure:1366: checking for VFlib configuration file" >&5
 	# Check whether --with-vfontcap or --without-vfontcap was given.
 if test "${with_vfontcap+set}" = set; then
   withval="$with_vfontcap"
@@ -1335,7 +1400,7 @@
 
 if test "$mgp_use_freetype" = "yes"; then
 	echo $ac_n "checking if --enable-freetype-charset16 option specified""... $ac_c" 1>&6
-echo "configure:1339: checking if --enable-freetype-charset16 option specified" >&5
+echo "configure:1404: checking if --enable-freetype-charset16 option specified" >&5
 	# Check whether --enable-freetype-charset16 or --disable-freetype-charset16 was given.
 if test "${enable_freetype_charset16+set}" = set; then
   enableval="$enable_freetype_charset16"
@@ -1354,32 +1419,39 @@
 	fi
 fi
 
-for i in /usr/pkg /usr/local; do
-	if test -f $i/include/png.h -a -f $i/lib/libpng.a; then
-		LIBS="$LIBS -L$i/lib"
-		OPTFLAGS="$OPTFLAGS -I$i/include"
-		DEPLIBS="$DEPLIBS $i/lib/libpng.a"
-		echo $ac_n "checking for png_write_init in -lpng""... $ac_c" 1>&6
-echo "configure:1364: checking for png_write_init in -lpng" >&5
-ac_lib_var=`echo png'_'png_write_init | sed 'y%./+-%__p_%'`
+echo $ac_n "checking if --enable-gif option specified""... $ac_c" 1>&6
+echo "configure:1424: checking if --enable-gif option specified" >&5
+# Check whether --enable-gif or --disable-gif was given.
+if test "${enable_gif+set}" = set; then
+  enableval="$enable_gif"
+  mgp_gif="yes"
+else
+  mgp_gif="no"
+fi
+
+echo "$ac_t""$mgp_gif" 1>&6
+if test $mgp_gif = "yes"; then
+	echo $ac_n "checking for DGifOpenFileName in -lungif""... $ac_c" 1>&6
+echo "configure:1436: checking for DGifOpenFileName in -lungif" >&5
+ac_lib_var=`echo ungif'_'DGifOpenFileName | 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"
+LIBS="-lungif  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1372 "configure"
+#line 1444 "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
     builtin and then its argument prototype would still apply.  */
-char png_write_init();
+char DGifOpenFileName();
 
 int main() {
-png_write_init()
+DGifOpenFileName()
 ; return 0; }
 EOF
-if { (eval echo configure:1383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1455: \"$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
@@ -1394,112 +1466,265 @@
 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
+  gif_ok=yes
+		LIBS="$LIBS -lungif"
+		cat >> confdefs.h <<\EOF
+#define USE_GIF 1
 EOF
 
-  LIBS="-lpng $LIBS"
-
 else
   echo "$ac_t""no" 1>&6
+echo $ac_n "checking for DGifOpenFileName in -lgif""... $ac_c" 1>&6
+echo "configure:1479: checking for DGifOpenFileName in -lgif" >&5
+ac_lib_var=`echo gif'_'DGifOpenFileName | 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="-lgif  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#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
+    builtin and then its argument prototype would still apply.  */
+char DGifOpenFileName();
+
+int main() {
+DGifOpenFileName()
+; return 0; }
+EOF
+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
+  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
+  gif_ok=yes
+		LIBS="$LIBS -lgif"
 		cat >> confdefs.h <<\EOF
-#define USE_PNG 1
+#define USE_GIF 1
 EOF
 
-		break
-	fi
-done
-
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1419: checking how to run the C preprocessor" >&5
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for DGifOpenFileName in -lungif""... $ac_c" 1>&6
+echo "configure:1522: checking for DGifOpenFileName in -lungif" >&5
+ac_lib_var=`echo ungif'_'DGifOpenFileName | 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
-    # This must be in double quotes, not single quotes, because CPP may get
-  # substituted into the Makefile and "${CC-cc}" will confuse make.
-  CPP="${CC-cc} -E"
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp.
-  cat > conftest.$ac_ext <<EOF
-#line 1434 "configure"
+  ac_save_LIBS="$LIBS"
+LIBS="-lungif -lX11 $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1530 "configure"
 #include "confdefs.h"
-#include <assert.h>
-Syntax Error
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char DGifOpenFileName();
+
+int main() {
+DGifOpenFileName()
+; return 0; }
 EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1440: \"$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
-  :
+if { (eval echo configure:1541: \"$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 "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  CPP="${CC-cc} -E -traditional-cpp"
-  cat > conftest.$ac_ext <<EOF
-#line 1451 "configure"
+  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
+  gif_ok=yes
+		LIBS="$LIBS -lungif"
+		cat >> confdefs.h <<\EOF
+#define USE_GIF 1
+EOF
+
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for DGifOpenFileName in -lgif""... $ac_c" 1>&6
+echo "configure:1565: checking for DGifOpenFileName in -lgif" >&5
+ac_lib_var=`echo gif'_'DGifOpenFileName | 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="-lgif -lX11 $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1573 "configure"
 #include "confdefs.h"
-#include <assert.h>
-Syntax Error
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char DGifOpenFileName();
+
+int main() {
+DGifOpenFileName()
+; return 0; }
 EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1457: \"$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
-  :
+if { (eval echo configure:1584: \"$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 "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  CPP="${CC-cc} -nologo -E"
+  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
+  gif_ok=yes
+		LIBS="$LIBS -lgif"
+		cat >> confdefs.h <<\EOF
+#define USE_GIF 1
+EOF
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+fi
+
+fi
+
+fi
+
+	if test "x$gif_ok" != "xyes"; then
+		echo 'FATAL: You need libungif to use gif images.  pass proper LIBS to configure.'
+		exit 1
+	fi
+	for ac_hdr in gif_lib.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1623: 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 1468 "configure"
+#line 1628 "configure"
 #include "confdefs.h"
-#include <assert.h>
-Syntax Error
+#include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1474: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1633: \"$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"
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  CPP=/lib/cpp
+  eval "ac_cv_header_$ac_safe=no"
 fi
 rm -f conftest*
 fi
-rm -f conftest*
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+ 
+else
+  echo "$ac_t""no" 1>&6
+echo 'FATAL: You need libungif to use gif images.  pass proper CPPFLAGS to configure.'
+		exit 1
+fi
+done
+
+fi
+
+for i in /usr/pkg /usr/local; do
+	if test -f $i/include/png.h -a -f $i/lib/libpng.a; then
+		LIBS="$LIBS -L$i/lib"
+		OPTFLAGS="$OPTFLAGS -I$i/include"
+		DEPLIBS="$DEPLIBS $i/lib/libpng.a"
+		echo $ac_n "checking for png_write_init in -lpng""... $ac_c" 1>&6
+echo "configure:1669: checking for png_write_init in -lpng" >&5
+ac_lib_var=`echo png'_'png_write_init | 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 1677 "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
+    builtin and then its argument prototype would still apply.  */
+char png_write_init();
+
+int main() {
+png_write_init()
+; return 0; }
+EOF
+if { (eval echo configure:1688: \"$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*
-  ac_cv_prog_CPP="$CPP"
+LIBS="$ac_save_LIBS"
+
 fi
-  CPP="$ac_cv_prog_CPP"
+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
-  ac_cv_prog_CPP="$CPP"
+  echo "$ac_t""no" 1>&6
 fi
-echo "$ac_t""$CPP" 1>&6
 
+		cat >> confdefs.h <<\EOF
+#define USE_PNG 1
+EOF
+
+		break
+	fi
+done
+
 # If we find X, set shell vars x_includes and x_libraries to the
 # paths, otherwise set no_x=yes.
 # 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:1503: checking for X" >&5
+echo "configure:1728: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -1561,12 +1786,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 1565 "configure"
+#line 1790 "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:1570: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1795: \"$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*
@@ -1635,14 +1860,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1639 "configure"
+#line 1864 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:1646: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1871: \"$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.
@@ -1729,12 +1954,12 @@
 fi
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1733: checking for ANSI C header files" >&5
+echo "configure:1958: 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 1738 "configure"
+#line 1963 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1742,7 +1967,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1746: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1971: \"$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*
@@ -1759,7 +1984,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 1763 "configure"
+#line 1988 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1777,7 +2002,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 1781 "configure"
+#line 2006 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1798,7 +2023,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1802 "configure"
+#line 2027 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1809,7 +2034,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:1813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2038: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1833,12 +2058,12 @@
 fi
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:1837: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:2062: checking for sys/wait.h that is POSIX.1 compatible" >&5
 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1842 "configure"
+#line 2067 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -1854,7 +2079,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:1858: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2083: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -1878,17 +2103,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1882: checking for $ac_hdr" >&5
+echo "configure:2107: 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 1887 "configure"
+#line 2112 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1892: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2117: \"$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*
@@ -1916,12 +2141,12 @@
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1920: checking for working const" >&5
+echo "configure:2145: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1925 "configure"
+#line 2150 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1970,7 +2195,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1974: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2199: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -1991,21 +2216,21 @@
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:1995: checking for inline" >&5
+echo "configure:2220: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 2002 "configure"
+#line 2227 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:2009: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2234: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -2031,12 +2256,12 @@
 esac
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2035: checking for pid_t" >&5
+echo "configure:2260: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2040 "configure"
+#line 2265 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2064,12 +2289,12 @@
 fi
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:2068: checking for size_t" >&5
+echo "configure:2293: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2073 "configure"
+#line 2298 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2097,12 +2322,12 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2101: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:2326: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2106 "configure"
+#line 2331 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -2111,7 +2336,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:2115: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2340: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -2132,12 +2357,12 @@
 fi
 
 echo $ac_n "checking for u_int""... $ac_c" 1>&6
-echo "configure:2136: checking for u_int" >&5
+echo "configure:2361: checking for u_int" >&5
 if eval "test \"`echo '$''{'ac_cv_type_u_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2141 "configure"
+#line 2366 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2165,12 +2390,12 @@
 fi
 
 echo $ac_n "checking for u_char""... $ac_c" 1>&6
-echo "configure:2169: checking for u_char" >&5
+echo "configure:2394: checking for u_char" >&5
 if eval "test \"`echo '$''{'ac_cv_type_u_char'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2174 "configure"
+#line 2399 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -2199,7 +2424,7 @@
 
 
 echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:2203: checking for 8-bit clean memcmp" >&5
+echo "configure:2428: checking for 8-bit clean memcmp" >&5
 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2207,7 +2432,7 @@
   ac_cv_func_memcmp_clean=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 2211 "configure"
+#line 2436 "configure"
 #include "confdefs.h"
 
 main()
@@ -2217,7 +2442,7 @@
 }
 
 EOF
-if { (eval echo configure:2221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2446: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_memcmp_clean=yes
 else
@@ -2235,12 +2460,12 @@
 test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:2239: checking return type of signal handlers" >&5
+echo "configure:2464: 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 2244 "configure"
+#line 2469 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -2257,7 +2482,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:2261: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -2278,12 +2503,12 @@
 for ac_func in poll strstr _setbufend
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2282: checking for $ac_func" >&5
+echo "configure:2507: 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 2287 "configure"
+#line 2512 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2306,7 +2531,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2535: \"$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
@@ -2333,12 +2558,12 @@
 for ac_func in usleep strsep strdup mkstemp snprintf memcmp
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2337: checking for $ac_func" >&5
+echo "configure:2562: 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 2342 "configure"
+#line 2567 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2361,7 +2586,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2590: \"$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
@@ -2542,6 +2767,7 @@
 s%@host_cpu@%$host_cpu%g
 s%@host_vendor@%$host_vendor%g
 s%@host_os@%$host_os%g
+s%@CPP@%$CPP%g
 s%@AWK@%$AWK%g
 s%@YACC@%$YACC%g
 s%@LEX@%$LEX%g
@@ -2554,7 +2780,6 @@
 s%@OPTFLAGS@%$OPTFLAGS%g
 s%@DEPLIBS@%$DEPLIBS%g
 s%@mgp_cv_vflib_a@%$mgp_cv_vflib_a%g
-s%@CPP@%$CPP%g
 s%@LIBOBJS@%$LIBOBJS%g
 s%@mgp_keywords@%$mgp_keywords%g
 
Index: kit/configure.in
diff -u kit/configure.in:1.62 kit/configure.in:1.69
--- kit/configure.in:1.62	Sun Nov 28 23:35:01 1999
+++ kit/configure.in	Tue Feb 15 18:52:51 2000
@@ -3,7 +3,7 @@
 dnl independent (using srcdir), however, xmkmf and Imake.tmpl do not
 dnl allow us to switch compilation directory.
 dnl
-dnl $Id: configure.in,v 1.62 1999/11/28 14:35:01 nishida Exp $
+dnl $Id: configure.in,v 1.69 2000/02/15 09:52:51 itojun Exp $
 AC_INIT(image/imagetypes.c)
 
 dnl Checks for programs.
@@ -12,6 +12,7 @@
 dnl  AC_PROG_CC cannot be specified here, since imake may not like the
 dnl  compiler probed by AC_PROG_CC (i.e. gcc).
 dnl AC_PROG_CC
+AC_PROG_CPP
 AC_PROG_AWK
 AC_PROG_YACC
 AC_PROG_LEX
@@ -45,14 +46,6 @@
 	[mgp_debug="no"])
 AC_MSG_RESULT($mgp_debug)
 
-dnl Checks for gif support.
-AC_MSG_CHECKING(if --enable-gif option specified)
-AC_ARG_ENABLE(gif,
-	[  --enable-gif            compile gif support in.],
-	[mgp_gif="yes"; AC_DEFINE(USE_GIF)],
-	[mgp_gif="no"])
-AC_MSG_RESULT($mgp_gif)
-
 dnl Checks for locale option.
 AC_MSG_CHECKING(if --enable-locale option specified)
 AC_ARG_ENABLE(locale,
@@ -228,6 +221,39 @@
 	if test "$mgp_use_freetype_c16" = "yes"; then
 		AC_DEFINE(FREETYPE_CHARSET16)
 	fi
+fi
+
+dnl Checks for gif support.
+AC_MSG_CHECKING(if --enable-gif option specified)
+AC_ARG_ENABLE(gif,
+	[  --enable-gif            compile gif support in (need libungif).],
+	[mgp_gif="yes"],
+	[mgp_gif="no"])
+AC_MSG_RESULT($mgp_gif)
+if test $mgp_gif = "yes"; then
+	AC_CHECK_LIB(ungif, DGifOpenFileName,
+		[gif_ok=yes
+		LIBS="$LIBS -lungif"
+		AC_DEFINE(USE_GIF)],
+	[AC_CHECK_LIB(gif, DGifOpenFileName,
+		[gif_ok=yes
+		LIBS="$LIBS -lgif"
+		AC_DEFINE(USE_GIF)],
+	[AC_CHECK_LIB(ungif, DGifOpenFileName,
+		[gif_ok=yes
+		LIBS="$LIBS -lungif"
+		AC_DEFINE(USE_GIF)],
+	[AC_CHECK_LIB(gif, DGifOpenFileName,
+		[gif_ok=yes
+		LIBS="$LIBS -lgif"
+		AC_DEFINE(USE_GIF)], [], [-lX11])], [-lX11])])])
+	if test "x$gif_ok" != "xyes"; then
+		echo 'FATAL: You need libungif to use gif images.  pass proper LIBS to configure.'
+		exit 1
+	fi
+	AC_CHECK_HEADERS(gif_lib.h, [], 
+		[echo 'FATAL: You need libungif to use gif images.  pass proper CPPFLAGS to configure.'
+		exit 1])
 fi
 
 for i in /usr/pkg /usr/local; do
Index: kit/ctlwords.pl
diff -u kit/ctlwords.pl:1.2 kit/ctlwords.pl:removed
--- kit/ctlwords.pl:1.2	Sat Sep  5 06:05:08 1998
+++ kit/ctlwords.pl	Mon Feb 21 05:10:08 2000
@@ -1,12 +0,0 @@
-#! /usr/bin/perl
-$counter = 0;	# 0 origin
-print "/* generated by ctlwords.awk. do not edit by hand. */\n";
-
-while (<>) {
-	next if (!/^\/\*CTL\*\//);
-	next if ($_ !~ /(CTL_[A-Z0-9]+)/);
-
-	$word = $1;
-	print "#define $word\t$counter\n";
-	$counter++;
-}
Index: kit/image/Imakefile.in
diff -u kit/image/Imakefile.in:1.8 kit/image/Imakefile.in:1.9
--- kit/image/Imakefile.in:1.8	Fri Sep 10 16:12:02 1999
+++ kit/image/Imakefile.in	Tue Feb 15 03:45:36 2000
@@ -18,7 +18,7 @@
 AllTarget($(TARGET))
 DependTarget()
 SpecialObjectRule(window.o,window.c,$(DEFS))
-SpecialObjectRule(gif.o,gif.c,$(DEFS))
+SpecialObjectRule(gif.o,gif.c,$(DEFS) $(OPTFLAGS))
 SpecialObjectRule(imagetypes.o,imagetypes.c,$(DEFS))
 #SpecialObjectRule(png.o,png.c,$(DEFS) $(OPTFLAGS))
 
Index: kit/image/gif.c
diff -u kit/image/gif.c:1.5 kit/image/gif.c:1.8
--- kit/image/gif.c:1.5	Sat Aug 28 04:02:55 1999
+++ kit/image/gif.c	Wed Feb 16 13:18:42 2000
@@ -13,623 +13,189 @@
  * "kljcpyrght.h" for complete copyright information)
  */
 
-#include "image.h"
-#include "gif.h"
-#include "kljcpyrght.h"
-
 #ifdef USE_GIF
-
-/****
- **
- ** local #defines
- **
- ****/
-
-#define PUSH_PIXEL(p)                                       \
-{                                                           \
-  if (pstk_idx == PSTK_SIZE)                                \
-    gifin_fatal("pixel stack overflow in PUSH_PIXEL()");    \
-  else                                                      \
-    pstk[pstk_idx++] = (p);                                 \
-}
-
-
-/****
- **
- ** local variables
- **
- ****/
-
-static int interlace_start[4]= { /* start line for interlacing */
-  0, 4, 2, 1
-};
-
-static int interlace_rate[4]= { /* rate at which we accelerate vertically */
-  8, 8, 4, 2
-};
-
-static BYTE file_open  = 0;     /* status flags */
-static BYTE image_open = 0;
-
-static ZFILE *ins;              /* input stream */
-
-static int  root_size;          /* root code size */
-static int  clr_code;           /* clear code */
-static int  eoi_code;           /* end of information code */
-static int  code_size;          /* current code size */
-static int  code_mask;          /* current code mask */
-static int  prev_code;          /* previous code */
-
-/*
- * NOTE: a long is assumed to be at least 32 bits wide
- */
-static long work_data;          /* working bit buffer */
-static int  work_bits;          /* working bit count */
-
-static BYTE buf[256];           /* byte buffer */
-static int  buf_cnt;            /* byte count */
-static int  buf_idx;            /* buffer index */
-
-static int table_size;          /* string table size */
-static int prefix[STAB_SIZE];   /* string table : prefixes */
-static int extnsn[STAB_SIZE];   /* string table : extensions */
-
-static BYTE pstk[PSTK_SIZE];    /* pixel stack */
-static int  pstk_idx;           /* pixel stack pointer */
-
-
-/****
- **
- ** global variables
- **
- ****/
-
-static int  gifin_rast_width;          /* raster width */
-static int  gifin_rast_height;         /* raster height */
-static BYTE gifin_g_cmap_flag;         /* global colormap flag */
-static int  gifin_g_pixel_bits;        /* bits per pixel, global colormap */
-static int  gifin_g_ncolors;           /* number of colors, global colormap */
-static BYTE gifin_g_cmap[3][256];      /* global colormap */
-static int  gifin_bg_color;            /* background color index */
-static int  gifin_color_bits;          /* bits of color resolution */
-
-static int  gifin_img_left;            /* image position on raster */
-static int  gifin_img_top;             /* image position on raster */
-static int  gifin_img_width;           /* image width */
-static int  gifin_img_height;          /* image height */
-static BYTE gifin_l_cmap_flag;         /* local colormap flag */
-static int  gifin_l_pixel_bits;        /* bits per pixel, local colormap */
-static int  gifin_l_ncolors;           /* number of colors, local colormap */
-static BYTE gifin_l_cmap[3][256];      /* local colormap */
-static BYTE gifin_interlace_flag;      /* interlace image format flag */
-static int  gifin_trans_index;         /* transparent color index */
-
-/*
- * open a GIF file, using s as the input stream
- */
-
-static int gifin_open_file(s)
-     ZFILE *s;
-{
-  /* make sure there isn't already a file open */
-  if (file_open)
-    return GIFIN_ERR_FAO;
-
-  /* remember that we've got this file open */
-  file_open = 1;
-  ins       = s;
-
-  /* check GIF signature */
-  if (zread(ins, buf, GIF_SIG_LEN) != GIF_SIG_LEN)
-    return GIFIN_ERR_EOF;
-
-  buf[GIF_SIG_LEN] = '\0';
-  if ((strcmp((char *) buf, GIF_SIG) != 0) &&
-      (strcmp((char *) buf, GIF_SIG_89) != 0))
-    return GIFIN_ERR_BAD_SIG;
-
-  /* read screen descriptor */
-  if (zread(ins, buf, GIF_SD_SIZE) != GIF_SD_SIZE)
-    return GIFIN_ERR_EOF;
-
-  /* decode screen descriptor */
-  gifin_rast_width   = (buf[1] << 8) + buf[0];
-  gifin_rast_height  = (buf[3] << 8) + buf[2];
-  gifin_g_cmap_flag  = (buf[4] & 0x80) ? 1 : 0;
-  gifin_color_bits   = ((buf[4] & 0x70) >> 4) + 1;
-  gifin_g_pixel_bits = (buf[4] & 0x07) + 1;
-  gifin_bg_color     = buf[5];
-
-  if (buf[6] != 0)
-    return GIFIN_ERR_BAD_SD;
-
-  /* load global colormap */
-  if (gifin_g_cmap_flag)
-  {
-    gifin_g_ncolors = (1 << gifin_g_pixel_bits);
-
-    if (gifin_load_cmap(gifin_g_cmap, gifin_g_ncolors) != GIFIN_SUCCESS)
-      return GIFIN_ERR_EOF;
-  }
-  else
-  {
-    gifin_g_ncolors = 0;
-  }
-  gifin_trans_index = -1;
-
-  /* done! */
-  return GIFIN_SUCCESS;
-}
-
-
-/*
- * open next GIF image in the input stream; returns GIFIN_SUCCESS if
- * successful. if there are no more images, returns GIFIN_DONE. (might
- * also return various GIFIN_ERR codes.)
- */
-
-static int gifin_open_image()
-{
-  int i;
-  int separator;
-
-  /* make sure there's a file open */
-  if (!file_open)
-    return GIFIN_ERR_NFO;
-
-  /* make sure there isn't already an image open */
-  if (image_open)
-    return GIFIN_ERR_IAO;
-
-  /* remember that we've got this image open */
-  image_open = 1;
-
-  /* skip over any extension blocks */
-  do
-  {
-    separator = zgetc(ins);
-    if (separator == GIF_EXTENSION)
-    {
-      if (gifin_skip_extension() != GIFIN_SUCCESS)
-        return GIFIN_ERR_EOF;
-    }
-  }
-  while (separator == GIF_EXTENSION);
-
-  /* check for end of file marker */
-  if (separator == GIF_TERMINATOR)
-    return GIFIN_DONE;
-
-  /* make sure we've got an image separator */
-  if (separator != GIF_SEPARATOR)
-    return GIFIN_ERR_BAD_SEP;
-
-  /* read image descriptor */
-  if (zread(ins, buf, GIF_ID_SIZE) != GIF_ID_SIZE)
-    return GIFIN_ERR_EOF;
-
-  /* decode image descriptor */
-  gifin_img_left       = (buf[1] << 8) + buf[0];
-  gifin_img_top        = (buf[3] << 8) + buf[2];
-  gifin_img_width      = (buf[5] << 8) + buf[4];
-  gifin_img_height     = (buf[7] << 8) + buf[6];
-  gifin_l_cmap_flag    = (buf[8] & 0x80) ? 1 : 0;
-  gifin_interlace_flag = (buf[8] & 0x40) ? 1 : 0;
-  gifin_l_pixel_bits   = (buf[8] & 0x07) + 1;
-
-  /* load local colormap */
-  if (gifin_l_cmap_flag)
-  {
-    gifin_l_ncolors = (1 << gifin_l_pixel_bits);
-
-    if (gifin_load_cmap(gifin_l_cmap, gifin_l_ncolors) != GIFIN_SUCCESS)
-      return GIFIN_ERR_EOF;
-  }
-  else
-  {
-    gifin_l_ncolors = 0;
-  }
-
-  /* initialize raster data stream decoder */
-  root_size = zgetc(ins);
-  clr_code  = 1 << root_size;
-  eoi_code  = clr_code + 1;
-  code_size = root_size + 1;
-  code_mask = (1 << code_size) - 1;
-  work_bits = 0;
-  work_data = 0;
-  buf_cnt   = 0;
-  buf_idx   = 0;
-
-  /* initialize string table */
-  for (i=0; i<STAB_SIZE; i++)
-  {
-    prefix[i] = NULL_CODE;
-    extnsn[i] = i;
-  }
-
-  /* initialize pixel stack */
-  pstk_idx = 0;
-
-  /* done! */
-  return GIFIN_SUCCESS;
-}
-
-/*
- * try to read next pixel from the raster, return result in *pel
- */
-
-static int gifin_get_pixel(pel)
-     int *pel;
-{
-  int  code;
-  int  first;
-  int  place;
-
-  /* decode until there are some pixels on the pixel stack */
-  while (pstk_idx == 0)
-  {
-    /* load bytes until we have enough bits for another code */
-    while (work_bits < code_size)
-    {
-      if (buf_idx == buf_cnt)
-      {
-        /* read a new data block */
-        if (gifin_read_data_block() != GIFIN_SUCCESS)
-          return GIFIN_ERR_EOF;
-
-        if (buf_cnt == 0)
-          return GIFIN_ERR_EOD;
-      }
-
-      work_data |= ((long) buf[buf_idx++]) << work_bits;
-      work_bits += 8;
-    }
-
-    /* get the next code */
-    code        = work_data & code_mask;
-    work_data >>= code_size;
-    work_bits  -= code_size;
-
-    /* interpret the code */
-    if (code == clr_code)
-    {
-      /* reset decoder stream */
-      code_size  = root_size + 1;
-      code_mask  = (1 << code_size) - 1;
-      prev_code  = NULL_CODE;
-      table_size = eoi_code + 1;
-    }
-    else if (code == eoi_code)
-    {
-      /* Ooops! no more pixels */
-      return GIFIN_ERR_EOF;
-    }
-    else if (prev_code == NULL_CODE)
-    {
-      gifin_push_string(code);
-      prev_code = code;
-    }
-    else
-    {
-      if (code < table_size)
-      {
-        first = gifin_push_string(code);
-      }
-      else
-      {
-        place = pstk_idx;
-        PUSH_PIXEL(NULL_CODE);
-        first = gifin_push_string(prev_code);
-        pstk[place] = first;
-      }
-
-      gifin_add_string(prev_code, first);
-      prev_code = code;
-    }
-  }
-
-  /* pop a pixel off the pixel stack */
-  *pel = (int) pstk[--pstk_idx];
-
-  /* done! */
-  return GIFIN_SUCCESS;
-}
-
-#if 0
-/*
- * close an open GIF image
- */
-
-static int gifin_close_image()
-{
-  /* make sure there's an image open */
-  if (!image_open)
-    return GIFIN_ERR_NIO;
-
-  /* skip any remaining raster data */
-  do
-  {
-    if (gifin_read_data_block() != GIFIN_SUCCESS)
-      return GIFIN_ERR_EOF;
-  }
-  while (buf_cnt > 0);
-
-  /* mark image as closed */
-  image_open = 0;
-
-  /* done! */
-  return GIFIN_SUCCESS;
-}
-#endif
-
-/*
- * close an open GIF file
- */
-
-static int gifin_close_file()
-{
-  /* make sure there's a file open */
-  if (!file_open)
-    return GIFIN_ERR_NFO;
-
-  /* mark file (and image) as closed */
-  file_open  = 0;
-  image_open = 0;
-
-  /* done! */
-  return GIFIN_SUCCESS;
-}
-
-/*
- * load a colormap from the input stream
- */
-
-static int gifin_load_cmap(cmap, ncolors)
-     BYTE cmap[3][256];
-     int  ncolors;
-{
-  int i;
-
-  for (i=0; i<ncolors; i++)
-  {
-    if (zread(ins, buf, 3) != 3)
-      return GIFIN_ERR_EOF;
-    
-    cmap[GIF_RED][i] = buf[GIF_RED];
-    cmap[GIF_GRN][i] = buf[GIF_GRN];
-    cmap[GIF_BLU][i] = buf[GIF_BLU];
-  }
-
-  /* done! */
-  return GIFIN_SUCCESS;
-}
- 
-/*
- * skip an extension block in the input stream
- */
-
-static int gifin_skip_extension()
-{
-  int func;
-
-  /* get the extension function byte */
-  func = zgetc(ins);
-
-  /* skip any remaining raster data */
-  do
-  {
-    if (gifin_read_data_block() != GIFIN_SUCCESS)
-      return GIFIN_ERR_EOF;
-    if (func == 0xf9 && buf_cnt == 4)
-      gifin_trans_index = buf[3];
-  }
-  while (buf_cnt > 0);
-
-  /* done! */
-  return GIFIN_SUCCESS;
-}
-
-/*
- * read a new data block from the input stream
- */
-
-static int gifin_read_data_block()
-{
-  /* read the data block header */
-  buf_cnt = zgetc(ins);
-
-  /* read the data block body */
-  if (zread(ins, buf, buf_cnt) != buf_cnt)
-    return GIFIN_ERR_EOF;
 
-  buf_idx = 0;
-
-  /* done! */
-  return GIFIN_SUCCESS;
-}
-
-/*
- * push a string (denoted by a code) onto the pixel stack
- * (returns the code of the first pixel in the string)
- */
+#include "image.h"
+#include <gif_lib.h>
 
-static int gifin_push_string(code)
-     int code;
-{
-  int rslt;
+static void
+tellAboutImage(name, gifp)
+	char *name;
+	GifFileType *gifp;
+{
+	fprintf(stderr, "%s is a %dx%d GIF image\n",
+	    name, gifp->SWidth, gifp->SHeight);
+}
+
+/* The way Interlaced image should. */
+static int InterlacedOffset[] = { 0, 4, 2, 1 };
+/* be read - offsets and jumps... */
+static int InterlacedJumps[] = { 8, 8, 4, 2 };
+
+Image *
+gifLoad(fullname, name, verbose)
+	char *fullname, *name;
+	unsigned int verbose;
+{
+	byte *pixline;
+	unsigned char *Buffer, *BufferP;
+	Image *image;
+	int Size, Row, Col, Width, Height, Count, ExtCode;
+	int i, j, x, y;
+	GifRecordType RecordType;
+	GifByteType *Extension;
+	GifRowType *ScreenBuffer;
+	GifRowType GifRow;
+	GifFileType *GifFile;
+	ColorMapObject *ColorMap;
+	GifColorType *ColorMapEntry;
+
+	GifFile = DGifOpenFileName(fullname);
+	if (GifFile == NULL)
+		return NULL;
+
+	if ((ScreenBuffer = (GifRowType *)
+	    malloc(GifFile->SHeight * sizeof(GifRowType *))) == NULL) {
+		fprintf(stderr, "malloc failed\n");
+		exit(1);
+	}
 
-  while (prefix[code] != NULL_CODE)
-  {
-    PUSH_PIXEL(extnsn[code]);
-    code = prefix[code];
-  }
+	/* Size in bytes one row.*/
+	Size = GifFile->SWidth * sizeof(GifPixelType);
+	/* First row. */
+	if ((ScreenBuffer[0] = (GifRowType) malloc(Size)) == NULL) {
+		fprintf(stderr, "malloc failed\n");
+		exit(1);
+	}
 
-  PUSH_PIXEL(extnsn[code]);
-  rslt = extnsn[code];
+	/* Set its color to BackGround. */
+	for (i = 0; i < GifFile->SWidth; i++)
+		ScreenBuffer[0][i] = GifFile->SBackGroundColor;
+	for (i = 1; i < GifFile->SHeight; i++) {
+		/*
+		 * Allocate the other rows, and set their color to background
+		 * too:
+		 */
+		if ((ScreenBuffer[i] = (GifRowType) malloc(Size)) == NULL) {
+			fprintf(stderr, "malloc failed\n");
+			exit(1);
+		}
 
-  return rslt;
-}
+		memcpy(ScreenBuffer[i], ScreenBuffer[0], Size);
+	}
 
-/*
- * add a new string to the string table
- */
-
-static void gifin_add_string(p, e)
-     int p;
-     int e;
-{
-  prefix[table_size] = p;
-  extnsn[table_size] = e;
+	/* Scan the content of the GIF file and load the image(s) in: */
+	do {
+		if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) {
+			PrintGifError();
+			exit(-1);
+		}
+		switch (RecordType) {
+		case IMAGE_DESC_RECORD_TYPE:
+			if (DGifGetImageDesc(GifFile) == GIF_ERROR) {
+				PrintGifError();
+				exit(-1);
+			}
+			Row = GifFile->Image.Top; /* Image Position relative to Screen. */
+			Col = GifFile->Image.Left;
+			Width = GifFile->Image.Width;
+			Height = GifFile->Image.Height;
+			if (GifFile->Image.Left + GifFile->Image.Width > GifFile->SWidth ||
+			   GifFile->Image.Top + GifFile->Image.Height > GifFile->SHeight) {
+				fprintf(stderr,
+"Image %d is not confined to screen dimension, aborted.\n");
+				exit(-2);
+			}
+			if (GifFile->Image.Interlace) {
+				/* Need to perform 4 passes on the images: */
+				for (Count = i = 0; i < 4; i++)
+					for (j = Row + InterlacedOffset[i]; j < Row + Height;
+							     j += InterlacedJumps[i]) {
+					if (DGifGetLine(GifFile, &ScreenBuffer[j][Col],
+					    Width) == GIF_ERROR) {
+					    PrintGifError();
+					    exit(-1);
+					}
+				}
+			}
+			else {
+				for (i = 0; i < Height; i++) {
+					if (DGifGetLine(GifFile, &ScreenBuffer[Row++][Col],
+					    Width) == GIF_ERROR) {
+						PrintGifError();
+						exit(-1);
+					}
+				}
+			}
+			break;
+		case EXTENSION_RECORD_TYPE:
+			/* Skip any extension blocks in file: */
+			if (DGifGetExtension(GifFile, &ExtCode, &Extension) == GIF_ERROR) {
+				PrintGifError();
+				exit(-1);
+			}
+			while (Extension != NULL) {
+				if (DGifGetExtensionNext(GifFile, &Extension) == GIF_ERROR) {
+					PrintGifError();
+					exit(-1);
+				}
+			}
+			break;
+		case TERMINATE_RECORD_TYPE:
+			break;
+		default: /* Should be traps by DGifGetRecordType. */
+			break;
+		}
+	} while (RecordType != TERMINATE_RECORD_TYPE);
+
+	/* Lets dump it - set the global variables required and do it: */
+	ColorMap = (GifFile->Image.ColorMap
+		? GifFile->Image.ColorMap
+		: GifFile->SColorMap);
+
+	image = newRGBImage(GifFile->SWidth, GifFile->SHeight, 8);
+
+	image->trans = GifFile->SBackGroundColor;
+	image->rgb.used = ColorMap->ColorCount;
+	for (i = 0; i < ColorMap->ColorCount; i++) {
+		ColorMapEntry = &ColorMap->Colors[i];
+		image->rgb.red[i]= ColorMapEntry->Red << 8;
+		image->rgb.green[i]= ColorMapEntry->Green << 8;
+		image->rgb.blue[i]= ColorMapEntry->Blue << 8;
+	}
 
-  if ((table_size == code_mask) && (code_size < 12))
-  {
-    code_size += 1;
-    code_mask  = (1 << code_size) - 1;
-  }
+	for (y = 0; y < GifFile->SHeight; y++) {
+		GifRow = ScreenBuffer[y];
+		pixline = image->data + (y * image->width * image->pixlen);
+		for (x = 0; x < GifFile->SWidth; x++)
+			pixline[x] = GifRow[x];
+	}
 
-  table_size += 1;
-}
+	if (DGifCloseFile(GifFile) == GIF_ERROR) {
+		PrintGifError();
+		exit(-1);
+	}
 
-/*
- * semi-graceful fatal error mechanism
- */
+	image->title = dupString(name);
 
-static void gifin_fatal(msg)
-     char *msg;
-{
-  fprintf(stderr, "Error reading GIF file: %s\n", msg);
-  cleanup(-1);
+	return image;
 }
-
-/* these are the routines added for interfacing to xloadimage
- */
 
-/* tell someone what the image we're loading is.  this could be a little more
- * descriptive but I don't care
- */
-
-static void tellAboutImage(name)
-     char *name;
+int
+gifIdent(fullname, name)
+	char *fullname, *name;
 {
-  fprintf(stderr, "%s is a %dx%d %sGIF image with %d colors\n", name,
-	 gifin_img_width, gifin_img_height,
-	 (gifin_interlace_flag ? "interlaced " : ""),
-	 (gifin_l_cmap_flag ? gifin_l_ncolors : gifin_g_ncolors));
-}
+	GifFileType *gifp;
+	int ret;
 
-Image *gifLoad(fullname, name, verbose)
-     char         *fullname, *name;
-     unsigned int  verbose;
-{ ZFILE *zf;
-  Image *image;
-  int    x, y, pixel, pass, scanlen;
-  byte  *pixptr, *pixline;
-
-  if (! (zf= zopen(fullname)))
-    return(NULL);
-  if ((gifin_open_file(zf) != GIFIN_SUCCESS) || /* read GIF header */
-      (gifin_open_image() != GIFIN_SUCCESS)) {  /* read image header */
-    gifin_close_file();
-    zclose(zf);
-    return(NULL);
-  }
-  if (verbose)
-    tellAboutImage(name);
-  znocache(zf);
-  image= newRGBImage(gifin_img_width, gifin_img_height, (gifin_l_cmap_flag ?
-							 gifin_l_pixel_bits :
-							 gifin_g_pixel_bits));
-  for (x= 0; x < gifin_g_ncolors; x++) {
-    image->rgb.red[x]= gifin_g_cmap[GIF_RED][x] << 8;
-    image->rgb.green[x]= gifin_g_cmap[GIF_GRN][x] << 8;
-    image->rgb.blue[x]= gifin_g_cmap[GIF_BLU][x] << 8;
-  }
-  image->rgb.used= gifin_g_ncolors;
-
-  /* if image has a local colormap, override global colormap
-   */
-
-  if (gifin_l_cmap_flag) {
-    for (x= 0; x < image->rgb.size; x++) {
-      image->rgb.red[x]= gifin_g_cmap[GIF_RED][x] << 8;
-      image->rgb.green[x]= gifin_g_cmap[GIF_GRN][x] << 8;
-      image->rgb.blue[x]= gifin_g_cmap[GIF_BLU][x] << 8;
-    }
-    image->rgb.used= gifin_l_ncolors;
-  }
-  image->trans = gifin_trans_index;
-
-  /* interlaced image -- futz with the vertical trace.  i wish i knew what
-   * kind of drugs the GIF people were on when they decided that they
-   * needed to support interlacing.
-   */
-
-  if (gifin_interlace_flag) {
-    scanlen= image->height * image->pixlen;
-
-    /* interlacing takes four passes to read, each starting at a different
-     * vertical point.
-     */
-
-    for (pass= 0; pass < 4; pass++) {
-      y= interlace_start[pass];
-      scanlen= image->width * image->pixlen * interlace_rate[pass];
-      pixline= image->data + (y * image->width * image->pixlen);
-      while (y < gifin_img_height) {
-	pixptr= pixline;
-	for (x= 0; x < gifin_img_width; x++) {
-	  if (gifin_get_pixel(&pixel) != GIFIN_SUCCESS) {
-	    fprintf(stderr, "%s: Short read within image data\n", fullname);
-	    y = gifin_img_height; x = gifin_img_width;
-	  }
-	  valToMem(pixel, pixptr, image->pixlen);
-	  pixptr += image->pixlen;
+	gifp = DGifOpenFileName(fullname);
+	if (gifp == NULL)
+		ret = 0;
+	else {
+		DGifCloseFile(gifp);
+		tellAboutImage(name);
+		ret = 1;
 	}
-	y += interlace_rate[pass];
-	pixline += scanlen;
-      }
-    }
-  }
-
-  /* not an interlaced image, just read in sequentially
-   */
-
-  else {
-    pixptr= image->data;
-    for (y= 0; y < gifin_img_height; y++)
-      for (x= 0; x < gifin_img_width; x++) {
-	if (gifin_get_pixel(&pixel) != GIFIN_SUCCESS) {
-	  fprintf(stderr, "%s: Short read within image data\n", fullname);
-	  y = gifin_img_height; x = gifin_img_width;
-	}
-	valToMem(pixel, pixptr, image->pixlen);
-	pixptr += image->pixlen;
-      }
-  }
-  gifin_close_file();
-  zclose(zf);
-  image->title= dupString(name);
-  return(image);
-}
-
-int gifIdent(fullname, name)
-     char *fullname, *name;
-{ ZFILE        *zf;
-  unsigned int  ret;
-
-  if (! (zf= zopen(fullname)))
-    return(0);
-  if ((gifin_open_file(zf) == GIFIN_SUCCESS) &&
-      (gifin_open_image() == GIFIN_SUCCESS)) {
-    tellAboutImage(name);
-    ret= 1;
-  }
-  else
-    ret= 0;
-  gifin_close_file();
-  zclose(zf);
-  return(ret);
+	return ret;
 }
-
 #endif /*USE_GIF*/
Index: kit/image/gif.h
diff -u kit/image/gif.h:1.2 kit/image/gif.h:removed
--- kit/image/gif.h:1.2	Mon Dec 28 17:23:03 1998
+++ kit/image/gif.h	Mon Feb 21 05:10:14 2000
@@ -1,72 +0,0 @@
-/* gif.h:
- *
- * gifin.h
- * kirk johnson
- * november 1989
- * external interface to gifin.c
- *
- * Copyright 1989 Kirk L. Johnson (see the included file
- * "kljcpyrght.h" for complete copyright information)
- */
-
-/*
- * gifin return codes
- */
-#define GIFIN_SUCCESS       0   /* success */
-#define GIFIN_DONE          1   /* no more images */
-
-#define GIFIN_ERR_BAD_SD   -1   /* bad screen descriptor */
-#define GIFIN_ERR_BAD_SEP  -2   /* bad image separator */
-#define GIFIN_ERR_BAD_SIG  -3   /* bad signature */
-#define GIFIN_ERR_EOD      -4   /* unexpected end of raster data */
-#define GIFIN_ERR_EOF      -5   /* unexpected end of input stream */
-#define GIFIN_ERR_FAO      -6   /* file already open */
-#define GIFIN_ERR_IAO      -7   /* image already open */
-#define GIFIN_ERR_NFO      -8   /* no file open */
-#define GIFIN_ERR_NIO      -9   /* no image open */
-
-/*
- * colormap indices 
- */
-
-#define GIF_RED  0
-#define GIF_GRN  1
-#define GIF_BLU  2
-
-/*
- * typedef BYTE for convenience
- */
-
-typedef unsigned char BYTE;
-
-static int gifin_open_file();
-static int gifin_open_image();
-static int gifin_get_pixel();
-#if 0
-static int gifin_close_image();
-#endif
-static int gifin_close_file();
-static int gifin_load_cmap();
-static int gifin_skip_extension();
-static int gifin_read_data_block();
-static int gifin_push_string();
-static void gifin_add_string();
-static void gifin_fatal();
-
-/* #defines, typedefs, and such
- */
-
-#define GIF_SIG      "GIF87a"
-#define GIF_SIG_89   "GIF89a"
-#define GIF_SIG_LEN  6          /* GIF signature length */
-#define GIF_SD_SIZE  7          /* GIF screen descriptor size */
-#define GIF_ID_SIZE  9          /* GIF image descriptor size */
-
-#define GIF_SEPARATOR   ','     /* GIF image separator */
-#define GIF_EXTENSION   '!'     /* GIF extension block marker */
-#define GIF_TERMINATOR  ';'     /* GIF terminator */
-
-#define STAB_SIZE  4096         /* string table size */
-#define PSTK_SIZE  4096         /* pixel stack size */
-
-#define NULL_CODE  -1           /* string table null code */
Index: kit/sample/cloud.gif
Index: kit/sample/dad.gif
Index: kit/sample/mgp-old1.gif
Index: kit/sample/mgp-old2.gif
Index: kit/sample/mgp-old3.gif
Index: kit/sample/mgp1.gif
Index: kit/sample/mgp2.gif
Index: kit/sample/mgp3.gif
Index: kit/sample/v6header.gif
