[comp.sources.x] v09i064: xloadimage 2.01, Patch1, Part01/01

jimf@saber.com (10/01/90)

Submitted-by: saber.com!jimf@saber.com
Posting-number: Volume 9, Issue 64
Archive-name: xloadimage/patch1
Patch-To: xloadimage: Volume 9, Issues 48-56

Here's the patch I promised you.  It fixes all of the known serious
problems with version 2.00.  It appears that you sent out version 2.00
so please make this available ASAP.

Thanks!

jim frost
saber software
jimf@saber.com

-- cut here --
PATCH TO BRING XLOADIMAGE VERSION 2.00 UP TO VERSION 2.01

Following this message is a set of patches which will bring xloadimage
version 2.00 up to version 2.01.  Version 2.01 contains the following
fixes and enhancements:

* A fix to smooth.c was made to correct a bug which caused coredumps
  on some images.
* window.c was patched to work around a bug in twm/tvtwm where not
  setting the PMaxSize hint sometimes caused the window manager to
  crash the server.
* The resource class name was changed to Xloadimage to conform with
  naming standards and to work around a problem with twm/tvtwm where
  it would not assign a title bar to xloadimage windows.
* Several problems with System-V compilation were corrected.
* The gcc-1-37 make target was fixed.
* The GIF loader was patched to better identify GIF files and to
  respond better to short GIF files.
* The Utah RLE image loader was patched to work with the updated ZIO
  package.
* A new image format, McIDAS, was added.  This format is often used
  for weather images.

Enjoy,

jim frost
saber software
jimf@saber.com

-- cut here --
diff -c src.2.00/Imakefile src.2.01/Imakefile
*** src.2.00/Imakefile	Sun Sep 30 15:46:24 1990
--- src.2.01/Imakefile	Sun Sep 30 15:01:11 1990
***************
*** 5,18 ****
  SYS_LIBRARIES   = -lm
             SRCS = bright.c clip.c cmuwmraster.c compress.c dither.c \
  		  faces.c fbm.c fill.c g3.c gif.c halftone.c hash.c \
! 		  imagetypes.c mac.c merge.c misc.c new.c options.c \
! 		  path.c pbm.c reduce.c rle.c rlelib.c root.c \
                    rotate.c send.c smooth.c sunraster.c value.c window.c \
                    xbitmap.c xloadimage.c xpixmap.c xwd.c zio.c zoom.c
             OBJS = bright.o clip.o cmuwmraster.o compress.o dither.o \
  		  faces.o fbm.o fill.o g3.o gif.o halftone.o hash.o \
! 		  imagetypes.o mac.o merge.o misc.o new.o options.o \
! 		  path.o pbm.o reduce.o rle.o rlelib.o root.o \
                    rotate.o send.o smooth.o sunraster.o value.o window.o \
                    xbitmap.o xloadimage.o xpixmap.o xwd.o zio.o zoom.o
  
--- 5,18 ----
  SYS_LIBRARIES   = -lm
             SRCS = bright.c clip.c cmuwmraster.c compress.c dither.c \
  		  faces.c fbm.c fill.c g3.c gif.c halftone.c hash.c \
! 		  imagetypes.c mac.c mcidas.c mc_tables.c merge.c misc.c \
! 		  new.c options.c path.c pbm.c reduce.c rle.c rlelib.c root.c \
                    rotate.c send.c smooth.c sunraster.c value.c window.c \
                    xbitmap.c xloadimage.c xpixmap.c xwd.c zio.c zoom.c
             OBJS = bright.o clip.o cmuwmraster.o compress.o dither.o \
  		  faces.o fbm.o fill.o g3.o gif.o halftone.o hash.o \
! 		  imagetypes.o mac.o mcidas.o mc_tables.o merge.o misc.o \
! 		  new.o options.o path.o pbm.o reduce.o rle.o rlelib.o root.o \
                    rotate.o send.o smooth.o sunraster.o value.o window.o \
                    xbitmap.o xloadimage.o xpixmap.o xwd.o zio.o zoom.o
  
diff -c src.2.00/Makefile src.2.01/Makefile
*** src.2.00/Makefile	Sun Sep 30 15:46:25 1990
--- src.2.01/Makefile	Sun Sep 30 15:00:32 1990
***************
*** 1,8 ****
  # Makefile for xloadimage.  this replaces the multiple makefiles used in
! # versions prior to xloadimage 1.07.
  
  SYSPATHFILE=/usr/lib/X11/Xloadimage
  INSTALLDIR=/usr/bin/X11
  STD_CC= cc
  GCC= gcc
  CP= cp
--- 1,14 ----
  # Makefile for xloadimage.  this replaces the multiple makefiles used in
! # versions prior to xloadimage 2.00.
! #
! # WARNING: if you use gcc 1.37, there is an optimizer bug which causes GIF
! # images to come out black and colormap reduction to fail.  Use gcc-1-37 as
! # your make target if you have gcc 1.37.
  
  SYSPATHFILE=/usr/lib/X11/Xloadimage
  INSTALLDIR=/usr/bin/X11
+ SHELL= /bin/sh
+ MAKE= make
  STD_CC= cc
  GCC= gcc
  CP= cp
***************
*** 11,35 ****
  LIBS= -lX11 -lm
  CFLAGS= -O -DSYSPATHFILE=\"$(SYSPATHFILE)\" $(EXTRAFLAGS)
  GCCFLAGS= -fstrength-reduce -finline-functions
! GCC137FLAGS= -fforce-mem -fforce-addr -fstrength-reduce -finline-functions -DSYSPATHFILE=\"$(SYSPATHFILE)\"
  
! MISC= Imakefile Makefile README VMS-CHANGES buildshar.c xloadimage.man \
!       patchlevel pbm.h rle.h sunraster.h xloadimage.h xwd.h
  
  INCS= cmuwmraster.h copyright.h fbm.h g3.h gif.h hash.h image.h imagetypes.h \
        kljcpyrght.h mac.h mit.cpyrght mrmcpyrght.h options.h
  
  SRCS= bright.c clip.c cmuwmraster.c compress.c dither.c faces.c fbm.c \
!       fill.c g3.c gif.c halftone.c hash.c imagetypes.c mac.c merge.c misc.c \
!       new.c options.c path.c pbm.c reduce.c rle.c rlelib.c root.c \
!       rotate.c send.c smooth.c sunraster.c value.c window.c xbitmap.c \
!       xloadimage.c xpixmap.c xwd.c zio.c zoom.c 
  
  OBJS= bright.o clip.o cmuwmraster.o compress.o dither.o faces.o fbm.o \
!       fill.o g3.o gif.o halftone.o hash.o imagetypes.o mac.o merge.o misc.o \
!       new.o options.o path.o pbm.o reduce.o rle.o rlelib.o root.o \
!       rotate.o send.o smooth.o sunraster.o value.o window.o xbitmap.o \
!       xloadimage.o xpixmap.o xwd.o zio.o zoom.o
  
  ALL= $(MISC) $(INCS) $(SRCS)
  
--- 17,41 ----
  LIBS= -lX11 -lm
  CFLAGS= -O -DSYSPATHFILE=\"$(SYSPATHFILE)\" $(EXTRAFLAGS)
  GCCFLAGS= -fstrength-reduce -finline-functions
! GCC137FLAGS= -fforce-mem -fforce-addr -fstrength-reduce -finline-functions
  
! MISC= Imakefile Makefile Makefile.std README VMS-CHANGES buildshar.c \
!       xloadimage.man patchlevel pbm.h rle.h sunraster.h xloadimage.h xwd.h
  
  INCS= cmuwmraster.h copyright.h fbm.h g3.h gif.h hash.h image.h imagetypes.h \
        kljcpyrght.h mac.h mit.cpyrght mrmcpyrght.h options.h
  
  SRCS= bright.c clip.c cmuwmraster.c compress.c dither.c faces.c fbm.c \
!       fill.c g3.c gif.c halftone.c hash.c imagetypes.c mac.c mcidas.c \
!       mc_tables.c merge.c misc.c new.c options.c path.c pbm.c reduce.c \
!       rle.c rlelib.c root.c rotate.c send.c smooth.c sunraster.c value.c \
!       window.c xbitmap.c xloadimage.c xpixmap.c xwd.c zio.c zoom.c 
  
  OBJS= bright.o clip.o cmuwmraster.o compress.o dither.o faces.o fbm.o \
!       fill.o g3.o gif.o halftone.o hash.o imagetypes.o mac.o mcidas.o \
!       mc_tables.o merge.o misc.o new.o options.o path.o pbm.o reduce.o \
!       rle.o rlelib.o root.o rotate.o send.o smooth.o sunraster.o value.o \
!       window.o xbitmap.o xloadimage.o xpixmap.o xwd.o zio.o zoom.o
  
  ALL= $(MISC) $(INCS) $(SRCS)
  
***************
*** 39,51 ****
  std:
  	@echo "Building standard distribution.  If this fails, consider trying"
  	@echo "'make sysv'."
! 	make xloadimage CC=$(STD_CC)
  
  # system-v target.  use this if you have a system-v compliant system.
  	
  sysv:
  	@echo "Building standard distribution for System-V."
! 	make xloadimage CC=$(STD_CC) EXTRAFLAGS=-DSYSV
  
  # gcc target.  use this if you have a gcc that is not version 1.37.  you
  # should add -DSYSV between the quotes in EXTRAFLAGS if your system is
--- 45,57 ----
  std:
  	@echo "Building standard distribution.  If this fails, consider trying"
  	@echo "'make sysv'."
! 	$(MAKE) xloadimage CC=$(STD_CC)
  
  # system-v target.  use this if you have a system-v compliant system.
  	
  sysv:
  	@echo "Building standard distribution for System-V."
! 	$(MAKE) xloadimage CC=$(STD_CC) EXTRAFLAGS=-DSYSV
  
  # gcc target.  use this if you have a gcc that is not version 1.37.  you
  # should add -DSYSV between the quotes in EXTRAFLAGS if your system is
***************
*** 53,61 ****
  
  gcc:
  	@echo "Building distribution with GNU cc."
! 	@echo "If something doesn't work, try using 'make gcc-1-37' and then"
! 	@echo "'make std' before reporting a bug."
! 	make xloadimage CC=$(GCC) EXTRAFLAGS="$(GCCFLAGS)"
  
  # this target is for systems which use gcc 1.37.  there is a compiler bug
  # in gcc 1.37 which causes some xloadimage functions to fail with the
--- 59,73 ----
  
  gcc:
  	@echo "Building distribution with GNU cc."
! 	@echo "**************************************************************"
! 	@echo "If you use gcc 1.37, you should abort and type 'make gcc-1-37'"
! 	@echo "instead.  If GIF images always display solid black or if"
! 	@echo "color images reduce to only a single color, your version"
! 	@echo "of gcc has a bug and you should use the gcc-1-37 target."
! 	@echo "If something else doesn't work, try using 'make gcc-1-37' and"
! 	@echo "then 'make std' before reporting a bug."
! 	@echo "**************************************************************"
! 	$(MAKE) xloadimage CC=$(GCC) EXTRAFLAGS="$(GCCFLAGS)"
  
  # this target is for systems which use gcc 1.37.  there is a compiler bug
  # in gcc 1.37 which causes some xloadimage functions to fail with the
***************
*** 66,89 ****
  	@echo "Building distribution with GNU cc using flags for gcc 1.37."
  	@echo "If something doesn't work, try using std before reporting"
  	@echo "a bug."
! 	make xloadimage CC=$(GCC) EXTRAFLAGS="$(GCC137FLAGS)"
  
  sysv-gcc:
  	@echo "Building System-V distribution with GNU cc."
! 	@echo "If something doesn't work, try using 'make sysv-gcc-1-37' and"
! 	@echo "then 'make std' before reporting a bug."
! 	make xloadimage CC=$(GCC) EXTRAFLAGS="-DSYSV $(GCCFLAGS)"
  
! # this target is for systems which use gcc 1.37.  there is a compiler bug
! # in gcc 1.37 which causes some xloadimage functions to fail with the
! # standard optimizations.  use this if GIF loading and colormap reduction
! # product black pictures.
  
  sysv-gcc-1-37:
  	@echo "Building System-V distribution with GNU cc using flags for"
  	@echo "gcc 1.37.  If something doesn't work, try using std before"
  	@echo "reporting a bug."
! 	make xloadimage CC=$(GCC) EXTRAFLAGS="-DSYSV $(GCC137FLAGS)"
  
  install: $(SYSPATHFILE)
  	$(RM) $(INSTALLDIR)/xloadimage
--- 78,106 ----
  	@echo "Building distribution with GNU cc using flags for gcc 1.37."
  	@echo "If something doesn't work, try using std before reporting"
  	@echo "a bug."
! 	$(MAKE) xloadimage CC=$(GCC) EXTRAFLAGS="$(GCC137FLAGS)"
  
  sysv-gcc:
  	@echo "Building System-V distribution with GNU cc."
! 	@echo "Building distribution with GNU cc."
! 	@echo "***********************************************************"
! 	@echo "If you use gcc 1.37, you should abort and type"
! 	@echo "'make sysv-gcc-1-37' instead.  If GIF images always display"
! 	@echo "solid black or if color images reduce to only a single"
! 	@echo "color, your version of gcc has a bug and you should use"
! 	@echo "the gcc-1-37 target.  If something else doesn't work, try"
! 	@echo "using 'make sysv-gcc-1-37' and then 'make std' before"
! 	@echo "reporting a bug."
! 	@echo "***********************************************************"
! 	$(MAKE) xloadimage CC=$(GCC) EXTRAFLAGS="-DSYSV $(GCCFLAGS)"
  
! # see comment for gcc-1-37 target.
  
  sysv-gcc-1-37:
  	@echo "Building System-V distribution with GNU cc using flags for"
  	@echo "gcc 1.37.  If something doesn't work, try using std before"
  	@echo "reporting a bug."
! 	$(MAKE) xloadimage CC=$(GCC) EXTRAFLAGS="-DSYSV $(GCC137FLAGS)"
  
  install: $(SYSPATHFILE)
  	$(RM) $(INSTALLDIR)/xloadimage
***************
*** 121,129 ****
  
  shar: buildshar
  	rm -f shar.* doshar
  	./buildshar $(ALL) > doshar
  	sh doshar
! 	rm doshar
  
  # targets for building tar distributions
  
--- 138,147 ----
  
  shar: buildshar
  	rm -f shar.* doshar
+ 	cp Makefile Makefile.std # backup for imake users
  	./buildshar $(ALL) > doshar
  	sh doshar
! 	rm doshar Makefile.std
  
  # targets for building tar distributions
  
***************
*** 133,139 ****
--- 151,159 ----
  	compress xloadimage.tar
  
  xloadimage.tar:
+ 	cp Makefile Makefile.std # backup for imake users
  	tar cf xloadimage.tar $(ALL)
+ 	rm Makefile.std
  
  # these targets are for those of us who have Saber-C
  
diff -c src.2.00/README src.2.01/README
*** src.2.00/README	Sun Sep 30 15:46:26 1990
--- src.2.01/README	Sun Sep 30 15:17:59 1990
***************
*** 10,15 ****
--- 10,16 ----
  	Fuzzy Bitmap (FBM) images
  	GIF images
  	G3 FAX images
+ 	McIDAS areafiles
  	MacPaint images
  	Portable Bitmap (PBM) images
  	Sun monochrome rasterfiles
***************
*** 35,41 ****
  If you are compiling under the X11R4 distribution, the apropriate
  Imakefile is included and you should compile as with any other client.
  I haven't personally tested this, but if it's broken it'll be easy to
! fix.
  
  If you're compiling on a BSD system or a system that's mostly BSDish,
  use "make std" or just "make".  If you have gcc you should keep
--- 36,43 ----
  If you are compiling under the X11R4 distribution, the apropriate
  Imakefile is included and you should compile as with any other client.
  I haven't personally tested this, but if it's broken it'll be easy to
! fix.  Since imake trashes the standard Makefile, a backup copy is kept
! in Makefile.std.
  
  If you're compiling on a BSD system or a system that's mostly BSDish,
  use "make std" or just "make".  If you have gcc you should keep
***************
*** 121,132 ****
  reporting a bug.
  
  Functions implementing new image types are welcomed; mail them to the
! same address and I'll do my best to distribute them.  Try do send them
! as public domain so I can keep the number of differing copyright
! messages to a minimum -- I'll use my standard message and leave the
! implementor's name and information in the file for credit.  I wouldn't
! copyright this stuff at all except that it's a requirement for X11
! distribution.
  
  THANKS
  
--- 123,134 ----
  reporting a bug.
  
  Functions implementing new image types are welcomed; mail them to the
! same address and I'll do my best to distribute them.  Please include a
! small sample image.  Try to send them as public domain so I can keep
! the number of differing copyright messages to a minimum -- I'll use my
! standard message and leave the implementor's name and information in
! the file for credit.  I wouldn't copyright this stuff at all except
! that it's a requirement for X11 distribution.
  
  THANKS
  
***************
*** 139,156 ****
  for miscellaneous bug fixes, to Anthony A. Datri (datri@convex.com)
  for adding the class hint, to Mark Moraes (moraes@cs.toronto.edu) for
  the slideshow colormap fix, to Gregg Townsend (gmt@cs.arizona.edu) for
! a suggested dithering routine, to Brian Frost (B1F5814@RIGEL.TAMU.EDU)
! for changes for VMS, to Chip Horstman for G3 FAX support, to Deron
! Dann Johnson (dj@eng.sun.com) for fixing the RetainTemporary bug, to
! Tom Tatlow (tatlow@dash.enet.dec.com) for image rotation code, to Mark
! A. Horstman (mhorstm@sarek.sbc.com) for tilde expansion in
! .xloadimagerc files and virtual-root support in root.c, to Tim Roper
! (timr@labtam.labtam.oz.au), Graeme Gill (graeme@labtam.oz.au) for
! gamma correction and Utah RLE image support, Mark Majhor
! (uunet!sequent!markm) for FBM and MacPaint support, Ian MacPhedran
! (macphed@dvinci.usask.ca) for PGM and PPM support, Per Fogelstrom
! (pf@diab.se) for a fix to send.c, and any others whose names I've
! missed.
  
  HISTORY
  
--- 141,162 ----
  for miscellaneous bug fixes, to Anthony A. Datri (datri@convex.com)
  for adding the class hint, to Mark Moraes (moraes@cs.toronto.edu) for
  the slideshow colormap fix, to Gregg Townsend (gmt@cs.arizona.edu) for
! a suggested dithering routine and other fixes, to Brian Frost
! (B1F5814@RIGEL.TAMU.EDU) for changes for VMS, to Chip Horstman for G3
! FAX support, to Deron Dann Johnson (dj@eng.sun.com) for fixing the
! RetainTemporary bug, to Tom Tatlow (tatlow@dash.enet.dec.com) for
! image rotation code, to Mark A. Horstman (mhorstm@sarek.sbc.com) for
! tilde expansion in .xloadimagerc files and virtual-root support in
! root.c, to Tim Roper (timr@labtam.labtam.oz.au), Graeme Gill
! (graeme@labtam.oz.au) for gamma correction and Utah RLE image support,
! Mark Majhor (uunet!sequent!markm) for FBM and MacPaint support, Ian
! MacPhedran (macphed@dvinci.usask.ca) for PGM and PPM support, Per
! Fogelstrom (pf@diab.se) for a fix to send.c, Hans J. Albertsson
! (hans@Sweden.Sun.COM) for cleaning up GIF aborting, Graham Hudspith
! (gwh@inmos.com) for a geometry patch, Glenn P. Davis
! (davis@unidata.ucar.edu) for McIDAS areafile support, Keith S. Pickens
! (maxwell.nde.swri.edu!ksp) for fixing the RLE loader to work with the
! updated zio package, and any others whose names I've missed.
  
  HISTORY
  
***************
*** 199,212 ****
  changes to root.c to make previously allocated resources be freed
  properly, and a completely new dithering routine.
  
! Patchlevel 07 contained support for MacPaint, FBM, PGM, PPM, CMU, Utah
! RLE and XWD image formats, gamma equalization, image smoothing, and
! image rotation.  G3 FAX support was modified to cut down on false
! positive identifications.  The zio subsystem was modified to cache
! reads for performance improvements and to allow stdin to be used as an
! input source.  Several loader functions which did not properly close
! their files were fixed.  Color slideshows now work.  Icon titles use
! an abbreviated titlebar title to enhance readability.  The resource
! class name was changed from XLoadImage to xloadimage to be more
! predictable.  Several options now propagate to all images following
! them if the -slideshow option is specified.
--- 205,226 ----
  changes to root.c to make previously allocated resources be freed
  properly, and a completely new dithering routine.
  
! Version 2, patchlevel 00 contained support for MacPaint, FBM, PGM,
! PPM, CMU, Utah RLE and XWD image formats, gamma equalization, image
! smoothing, and image rotation.  G3 FAX support was modified to cut
! down on false positive identifications.  The zio subsystem was
! modified to cache reads for performance improvements and to allow
! stdin to be used as an input source.  Several loader functions which
! did not properly close their files were fixed.  Color slideshows now
! work.  Icon titles use an abbreviated titlebar title to enhance
! readability.  The resource class name was changed from XLoadImage to
! xloadimage to be more predictable.  Several options now propagate to
! all images following them if the -slideshow option is specified.
! 
! Version 2.01 contained several fixes to window.c to work around a bug
! in twm/tvtwm which could crash servers.  The resource class name was
! changed (again) to Xloadimage to conform with standard class naming
! practices.  Several problems with System-V compilation were corrected.
! The gcc-1-37 make target was fixed to prevent a double-define.  The
! GIF loader was patched to respond better to short GIF files.  The Utah
! RLE image loader was patched to work with the updated ZIO package.
diff -c src.2.00/cmuwmraster.c src.2.01/cmuwmraster.c
*** src.2.00/cmuwmraster.c	Sun Sep 30 15:46:41 1990
--- src.2.01/cmuwmraster.c	Sun Sep 30 13:20:25 1990
***************
*** 72,78 ****
      ZFILE *zf;
      struct cmuwm_header header;
      Image *image;
!     int depth, height, width, row, col, linelen, r;
      byte *lineptr;
  
      if (!(zf= zopen(fullname))) 
--- 72,78 ----
      ZFILE *zf;
      struct cmuwm_header header;
      Image *image;
!     int height, width, row, col, linelen, r;
      byte *lineptr;
  
      if (!(zf= zopen(fullname))) 
***************
*** 106,112 ****
        {
  	  fprintf(stderr,"CMU WM raster %s is of depth %d, must be 1",
  		  name,
! 		  depth);
  	  return(NULL);
        }
  
--- 106,112 ----
        {
  	  fprintf(stderr,"CMU WM raster %s is of depth %d, must be 1",
  		  name,
! 		  header.depth);
  	  return(NULL);
        }
  
diff -c src.2.00/copyright.h src.2.01/copyright.h
*** src.2.00/copyright.h	Sun Sep 30 15:46:34 1990
--- src.2.01/copyright.h	Wed Sep 26 17:17:55 1990
***************
*** 19,24 ****
   * USE OR PERFORMANCE OF THIS SOFTWARE.
   */
  
! static char *Copyright= "Copyright 1989 Jim Frost";
  #define _JIM_COPYRIGHT_
  #endif
--- 19,24 ----
   * USE OR PERFORMANCE OF THIS SOFTWARE.
   */
  
! static char *Copyright= "Copyright 1989, 1990 Jim Frost";
  #define _JIM_COPYRIGHT_
  #endif
diff -c src.2.00/g3.c src.2.01/g3.c
*** src.2.00/g3.c	Sun Sep 30 15:46:45 1990
--- src.2.01/g3.c	Sun Sep 30 15:06:33 1990
***************
*** 280,286 ****
  	int	ret = 0;
  
  	for (g3_rawzeros = 0; !g3_rawgetbit(fd) && !g3_eof;);
! 	if(g3_rawzeros >=11 || g3_rawzeros <= 15)
  		ret = 1;
  
  	return(ret);
--- 280,286 ----
  	int	ret = 0;
  
  	for (g3_rawzeros = 0; !g3_rawgetbit(fd) && !g3_eof;);
! 	if(g3_rawzeros >=11 && g3_rawzeros <= 15)
  		ret = 1;
  
  	return(ret);
diff -c src.2.00/gif.c src.2.01/gif.c
*** src.2.00/gif.c	Sun Sep 30 15:46:47 1990
--- src.2.01/gif.c	Sun Sep 30 14:26:27 1990
***************
*** 573,579 ****
  	for (x= 0; x < gifin_img_width; x++) {
  	  if (gifin_get_pixel(&pixel) != GIFIN_SUCCESS) {
  	    printf("%s: Short read within image data\n", fullname);
! 	    exit(0);
  	  }
  	  valToMem(pixel, pixptr, image->pixlen);
  	  pixptr += image->pixlen;
--- 573,579 ----
  	for (x= 0; x < gifin_img_width; x++) {
  	  if (gifin_get_pixel(&pixel) != GIFIN_SUCCESS) {
  	    printf("%s: Short read within image data\n", fullname);
! 	    y = gifin_img_height; x = gifin_img_width;
  	  }
  	  valToMem(pixel, pixptr, image->pixlen);
  	  pixptr += image->pixlen;
***************
*** 593,599 ****
        for (x= 0; x < gifin_img_width; x++) {
  	if (gifin_get_pixel(&pixel) != GIFIN_SUCCESS) {
  	  printf("%s: Short read within image data\n", fullname);
! 	  exit(0);
  	}
  	valToMem(pixel, pixptr, image->pixlen);
  	pixptr += image->pixlen;
--- 593,599 ----
        for (x= 0; x < gifin_img_width; x++) {
  	if (gifin_get_pixel(&pixel) != GIFIN_SUCCESS) {
  	  printf("%s: Short read within image data\n", fullname);
! 	  y = gifin_img_height; x = gifin_img_width;
  	}
  	valToMem(pixel, pixptr, image->pixlen);
  	pixptr += image->pixlen;
diff -c src.2.00/image.h src.2.01/image.h
*** src.2.00/image.h	Sun Sep 30 15:46:36 1990
--- src.2.01/image.h	Sun Sep 30 15:45:16 1990
***************
*** 16,22 ****
  typedef unsigned char  byte;      /* byte type */
  
  struct cache {
!   unsigned int  len;
    char          buf[BUFSIZ];
    struct cache *next;
  };
--- 16,22 ----
  typedef unsigned char  byte;      /* byte type */
  
  struct cache {
!   int           len;
    char          buf[BUFSIZ];
    struct cache *next;
  };
diff -c src.2.00/imagetypes.h src.2.01/imagetypes.h
*** src.2.00/imagetypes.h	Sun Sep 30 15:46:37 1990
--- src.2.01/imagetypes.h	Sun Sep 30 15:50:20 1990
***************
*** 19,24 ****
--- 19,25 ----
  Image *fbmLoad();
  Image *macLoad();
  Image *cmuwmLoad();
+ Image *mcidasLoad();
  
  int facesIdent();
  int pbmIdent();
***************
*** 32,37 ****
--- 33,39 ----
  int fbmIdent();
  int macIdent();
  int cmuwmIdent();
+ int mcidasIdent();
  
  /* some of these are order-dependent
   */
***************
*** 44,54 ****
    fbmIdent,       fbmLoad,       "FBM Image",
    sunRasterIdent, sunRasterLoad, "Sun Rasterfile",
    cmuwmIdent,     cmuwmLoad,     "CMU WM Raster",
!   pbmIdent,       pbmLoad,       "Portable Bit Map (PBM)",
    facesIdent,     facesLoad,     "Faces Project",
    gifIdent,       gifLoad,       "GIF Image",
    rleIdent,       rleLoad,       "Utah RLE Image",
    xwdIdent,       xwdLoad,       "X Window Dump",
    macIdent,       macLoad,       "MacPaint Image",
    xpixmapIdent,   xpixmapLoad,   "X Pixmap",
    xbitmapIdent,   xbitmapLoad,   "X Bitmap",
--- 46,57 ----
    fbmIdent,       fbmLoad,       "FBM Image",
    sunRasterIdent, sunRasterLoad, "Sun Rasterfile",
    cmuwmIdent,     cmuwmLoad,     "CMU WM Raster",
!   pbmIdent,       pbmLoad,       "Portable Bit Map (PBM, PGM, PPM)",
    facesIdent,     facesLoad,     "Faces Project",
    gifIdent,       gifLoad,       "GIF Image",
    rleIdent,       rleLoad,       "Utah RLE Image",
    xwdIdent,       xwdLoad,       "X Window Dump",
+   mcidasIdent,    mcidasLoad,    "McIDAS areafile",
    macIdent,       macLoad,       "MacPaint Image",
    xpixmapIdent,   xpixmapLoad,   "X Pixmap",
    xbitmapIdent,   xbitmapLoad,   "X Bitmap",
diff -c src.2.00/merge.c src.2.01/merge.c
*** src.2.00/merge.c	Sun Sep 30 15:46:50 1990
--- src.2.01/merge.c	Sun Sep 30 15:43:43 1990
***************
*** 271,277 ****
       Image        *src;
       int           atx, aty;
       unsigned int  verbose;
! { unsigned int clipw, cliph;
    int clipped = 0;
  
    goodImage(dest, "merge");
--- 271,277 ----
       Image        *src;
       int           atx, aty;
       unsigned int  verbose;
! { int clipw, cliph;
    int clipped = 0;
  
    goodImage(dest, "merge");
diff -c src.2.00/patchlevel src.2.01/patchlevel
*** src.2.00/patchlevel	Sun Sep 30 15:46:28 1990
--- src.2.01/patchlevel	Wed Sep 26 12:19:32 1990
***************
*** 2,5 ****
   */
  
  #define VERSION    "2"
! #define PATCHLEVEL "00"
--- 2,5 ----
   */
  
  #define VERSION    "2"
! #define PATCHLEVEL "01"
diff -c src.2.00/rlelib.c src.2.01/rlelib.c
*** src.2.00/rlelib.c	Sun Sep 30 15:47:03 1990
--- src.2.01/rlelib.c	Sun Sep 30 15:09:24 1990
***************
*** 19,24 ****
--- 19,25 ----
  #include "rle.h"
  
  #define zeof(zfp) feof((zfp)->stream)
+ #define zclearerr(zfp) clearerr((zfp)->stream)
  
  /*
   * This software is copyrighted as noted below.  It may be freely copied,
***************
*** 897,902 ****
--- 898,904 ----
      register int i;
      char * comment_buf;
  
+     zclearerr(infile);
      BREAD( short, magic, sizeof magic );
      SWAB(magic);
      if ( zeof( infile ) )
diff -c src.2.00/smooth.c src.2.01/smooth.c
*** src.2.00/smooth.c	Sun Sep 30 15:46:59 1990
--- src.2.01/smooth.c	Wed Sep 26 17:18:27 1990
***************
*** 4,10 ****
   *
   * jim frost 09.20.90
   *
!  * Copyright 1989 Jim Frost.  See included file "copyright.h" for complete
   * copyright information.
   */
  
--- 4,10 ----
   *
   * jim frost 09.20.90
   *
!  * Copyright 1990 Jim Frost.  See included file "copyright.h" for complete
   * copyright information.
   */
  
***************
*** 65,74 ****
  
    pick= areasize= rgb->used / 2;
    while ((pick > 0) && (pick < rgb->used - 1)) {
-     areasize= (areasize + 1) >> 1;
-     pick += (carray[pick].sum > sum ? -areasize : areasize);
      if ((carray[pick].sum <= sum) && (sum < carray[pick + 1].sum))
        break;
    }
  
    /* look at colors that are a little darker than we are
--- 65,84 ----
  
    pick= areasize= rgb->used / 2;
    while ((pick > 0) && (pick < rgb->used - 1)) {
      if ((carray[pick].sum <= sum) && (sum < carray[pick + 1].sum))
        break;
+     areasize= (areasize + 1) >> 1;
+     if (carray[pick].sum > sum) {
+       if (pick > areasize)
+ 	pick -= areasize;
+       else
+ 	pick= 0;
+     }
+     else {
+       pick += areasize;
+       if (pick >= rgb->used)
+ 	pick= rgb->used - 1;
+     }
    }
  
    /* look at colors that are a little darker than we are
diff -c src.2.00/window.c src.2.01/window.c
*** src.2.00/window.c	Sun Sep 30 15:47:04 1990
--- src.2.01/window.c	Sun Sep 30 14:36:23 1990
***************
*** 14,22 ****
  #include <X11/cursorfont.h>
  
  #ifdef SYSV
! #include <strings.h>
  #define index strchr
! y#define rindex strrchr
  #else
  char *index();
  char *rindex();
--- 14,22 ----
  #include <X11/cursorfont.h>
  
  #ifdef SYSV
! #include <string.h>
  #define index strchr
! #define rindex strrchr
  #else
  char *index();
  char *rindex();
***************
*** 167,173 ****
       unsigned int  verbose;
  { Pixmap               pixmap;
    Colormap             xcmap;
-   static Colormap      tmpxcmap= 0; /* used when in slideshow mode */
    XSetWindowAttributes swa;
    XSizeHints           sh;
    XWMHints             wmh;
--- 167,172 ----
***************
*** 187,202 ****
      XResizeRequestEvent resize;
    } event;
    unsigned int          winx, winy, winwidth, winheight;
-   char                  def_geom[30];
  
    /* figure out the window size.  unless specifically requested to do so,
     * we will not exceed 90% of display real estate.
     */
  
!   sprintf(def_geom, "%ux%u+0+0", image->width, image->height);
!   XGeometry(disp, scrn, user_geometry, def_geom, 0, 1, 1, 0, 0,
! 	    &winx, &winy, &winwidth, &winheight);
  
    if (fullscreen) {
      winwidth= DisplayWidth(disp, scrn);
      winheight= DisplayHeight(disp, scrn);
--- 186,207 ----
      XResizeRequestEvent resize;
    } event;
    unsigned int          winx, winy, winwidth, winheight;
  
    /* figure out the window size.  unless specifically requested to do so,
     * we will not exceed 90% of display real estate.
     */
  
!   if (user_geometry == NULL) {
!     winx= winy= winwidth= winheight= 0;
!   }
!   else {
!     char                def_geom[30];
  
+     sprintf(def_geom, "%ux%u+0+0", image->width, image->height);
+     XGeometry(disp, scrn, user_geometry, def_geom, 0, 1, 1, 0, 0,
+ 	      &winx, &winy, &winwidth, &winheight);
+   }
+ 
    if (fullscreen) {
      winwidth= DisplayWidth(disp, scrn);
      winheight= DisplayHeight(disp, scrn);
***************
*** 238,253 ****
  			       CWBitGravity | CWCursor | CWColormap |
  			       CWEventMask | CWSaveUnder, &swa);
      XSetCommand(disp, ImageWindow, argv, argc);
!     classHint.res_class = "xloadimage";
      classHint.res_name=NULL;
      (void) XSetClassHint(disp,ImageWindow,&classHint);
      paint= 0;
    }
!   else {
!     XResizeWindow(disp, ImageWindow, winwidth, winheight);
!     XChangeWindowAttributes(disp, ImageWindow, CWColormap, &swa);
      paint= 1;
!   }
    XStoreName(disp, ImageWindow, image->title);
    XSetIconName(disp, ImageWindow, iconName(image->title));
  
--- 243,256 ----
  			       CWBitGravity | CWCursor | CWColormap |
  			       CWEventMask | CWSaveUnder, &swa);
      XSetCommand(disp, ImageWindow, argv, argc);
!     classHint.res_class = "Xloadimage";
      classHint.res_name=NULL;
      (void) XSetClassHint(disp,ImageWindow,&classHint);
      paint= 0;
    }
!   else
      paint= 1;
! 
    XStoreName(disp, ImageWindow, image->title);
    XSetIconName(disp, ImageWindow, iconName(image->title));
  
***************
*** 265,275 ****
    }
    sh.width_inc= 1;
    sh.height_inc= 1;
!   if (slideshow) {
!       sh.flags= PMinSize | PResizeInc;
!   } else {
!       sh.flags= PMinSize | PMaxSize | PResizeInc;
!   }
    if (lastx || fullscreen)
      sh.flags |= USSize;
    else
--- 268,274 ----
    }
    sh.width_inc= 1;
    sh.height_inc= 1;
!   sh.flags= PMinSize | PMaxSize | PResizeInc;
    if (lastx || fullscreen)
      sh.flags |= USSize;
    else
***************
*** 294,315 ****
    gc= XCreateGC(disp, ImageWindow, GCFunction | GCForeground, &gcv);
    XMapWindow(disp, ImageWindow);
    placeImage(image->width, image->height, winwidth, winheight, &pixx, &pixy);
!   if (paint)
      blitImage(disp, pixmap, ImageWindow, gc,
  	      pixx, pixy, image->width, image->height, winwidth, winheight,
  	      0, 0, winwidth, winheight);
    setCursor(disp, ImageWindow, image->width, image->height,
  	    winwidth, winheight, &(swa.cursor));
  
-  /* free old image's colormap if necessary.  this is done here to minimize
-   * technicolor when swapping images.
-   */
- 
-   if (slideshow && tmpxcmap) {
-     XFreeColormap(disp, tmpxcmap);
-     tmpxcmap= 0;
-   }
- 
    lastx= lasty= -1;
    for (;;) {
      XNextEvent(disp, &event);
--- 293,309 ----
    gc= XCreateGC(disp, ImageWindow, GCFunction | GCForeground, &gcv);
    XMapWindow(disp, ImageWindow);
    placeImage(image->width, image->height, winwidth, winheight, &pixx, &pixy);
!   if (paint) {
      blitImage(disp, pixmap, ImageWindow, gc,
  	      pixx, pixy, image->width, image->height, winwidth, winheight,
  	      0, 0, winwidth, winheight);
+     XResizeWindow(disp, ImageWindow, winwidth, winheight);
+     XChangeWindowAttributes(disp, ImageWindow, CWColormap, &swa);
+   }
+ 
    setCursor(disp, ImageWindow, image->width, image->height,
  	    winwidth, winheight, &(swa.cursor));
  
    lastx= lasty= -1;
    for (;;) {
      XNextEvent(disp, &event);
***************
*** 329,339 ****
        char ret;
        Cursor cursor;
  
!       XLookupString(&event.key,buf,128,&ks,&status);
        ret= buf[0];
        if (isupper(ret))
  	ret= tolower(ret);
        switch (ret) {
        case 'n':
        case 'p':
  	cursor= swa.cursor;
--- 323,335 ----
        char ret;
        Cursor cursor;
  
!       if (XLookupString(&event.key,buf,128,&ks,&status) != 1)
! 	break;
        ret= buf[0];
        if (isupper(ret))
  	ret= tolower(ret);
        switch (ret) {
+       case ' ':
        case 'n':
        case 'p':
  	cursor= swa.cursor;
***************
*** 354,363 ****
  	 * trying XQueryColor on an unallocated colormap entry so I gave up.
  	 */
  
- 	if (slideshow && xcmap == DefaultColormap(disp, scrn) && (ret != 'q'))
- 	  tmpxcmap= XCopyColormapAndFree(disp, xcmap);
  	if (xcmap != DefaultColormap(disp, scrn))
!           XFreeColormap(disp, xcmap);
  	return(ret);
        }
        break;
--- 350,360 ----
  	 * trying XQueryColor on an unallocated colormap entry so I gave up.
  	 */
  
  	if (xcmap != DefaultColormap(disp, scrn))
! 	    XFreeColormap(disp, xcmap);
! 	else if (slideshow)
! 	  XFreeColormap(disp, XCopyColormapAndFree(disp, xcmap));
! 
  	return(ret);
        }
        break;
diff -c src.2.00/xloadimage.c src.2.01/xloadimage.c
*** src.2.00/xloadimage.c	Sun Sep 30 15:47:05 1990
--- src.2.01/xloadimage.c	Sun Sep 30 14:00:13 1990
***************
*** 366,371 ****
--- 366,375 ----
  
      case XZOOM:
        if (argv[++a]) {
+ 	if (atoi(argv[a]) < 0) {
+ 	  printf("Zoom argument must be positive (ignored).\n");
+ 	  continue;
+ 	}
  	images[imagecount].xzoom= atoi(argv[a]);
  	if (slideshow)
  	  slide_xzoom= images[imagecount].xzoom;
***************
*** 374,379 ****
--- 378,387 ----
  
      case YZOOM:
        if (argv[++a]) {
+ 	if (atoi(argv[a]) < 0) {
+ 	  printf("Zoom argument must be positive (ignored).\n");
+ 	  continue;
+ 	}
  	images[imagecount].yzoom= atoi(argv[a]);
  	if (slideshow)
  	  slide_yzoom= images[imagecount].yzoom;
***************
*** 382,387 ****
--- 390,399 ----
  
      case ZOOM:
        if (argv[++a]) {
+ 	if (atoi(argv[a]) < 0) {
+ 	  printf("Zoom argument must be positive (ignored).\n");
+ 	  continue;
+ 	}
  	images[imagecount].xzoom= images[imagecount].yzoom= atoi(argv[a]);
  	if (slideshow)
  	  slide_xzoom= slide_yzoom= images[imagecount].xzoom;
***************
*** 425,435 ****
      exit(1);
    }
    Scrn= scrn= DefaultScreen(disp);
- #if defined(mips) || defined(_IBMR2)
    XSetIOErrorHandler(ioErrorHandler);
- #else
-   XSetIOErrorHandler((XIOErrorHandler)ioErrorHandler);
- #endif
  
    dispimage= NULL;
  
--- 437,443 ----
***************
*** 506,512 ****
        case 'q':  /* user quit */
  	XCloseDisplay(disp);
  	exit(0);
! 	
        case 'n':  /* next image */
  	break;
        case 'p':  /* previous image */
--- 514,520 ----
        case 'q':  /* user quit */
  	XCloseDisplay(disp);
  	exit(0);
!       case ' ':
        case 'n':  /* next image */
  	break;
        case 'p':  /* previous image */
diff -c src.2.00/xloadimage.man src.2.01/xloadimage.man
*** src.2.00/xloadimage.man	Sun Sep 30 15:46:33 1990
--- src.2.01/xloadimage.man	Sun Sep 30 15:02:32 1990
***************
*** 46,55 ****
  \fIXsetbg\fR is equivalent to \fIxloadimage -onroot -quiet\fR and
  \fIxview\fR is equivalent to \fIxloadimage -view -verbose\fR.
  .SH RESOURCE CLASS
! \fIXloadimage\fR uses the resource class name \fIxloadimage\fR for
  window managers which need this resource set.  This name changed
! in version 2.00; some previous versions used the name \fIXLoadImage\fR
! which was difficult to predict.
  .SH GLOBAL OPTIONS
  The following options affect the global operation of \fIxloadimage\fR.
  They may be specified anywhere on the command line.
--- 46,56 ----
  \fIXsetbg\fR is equivalent to \fIxloadimage -onroot -quiet\fR and
  \fIxview\fR is equivalent to \fIxloadimage -view -verbose\fR.
  .SH RESOURCE CLASS
! \fIXloadimage\fR uses the resource class name \fIXloadimage\fR for
  window managers which need this resource set.  This name changed
! in version 2.00 and 2.01; some previous versions used the name
! \fIXLoadImage\fR (which was difficult to predict) or \fIxloadimage\fR
! (which conflicted with class naming conventions).
  .SH GLOBAL OPTIONS
  The following options affect the global operation of \fIxloadimage\fR.
  They may be specified anywhere on the command line.
***************
*** 125,131 ****
  .TP
  -view
  View image(s) in a window.  This is the opposite of \fI-onroot\fR and
! the default for \fIxsetbg\fR. 
  .SH IMAGE OPTIONS
  The following options may preceed each image.  These options are
  local to the image they preceed. 
--- 126,132 ----
  .TP
  -view
  View image(s) in a window.  This is the opposite of \fI-onroot\fR and
! the default for \fIxview\fR and \fIxloadimage\fR. 
  .SH IMAGE OPTIONS
  The following options may preceed each image.  These options are
  local to the image they preceed. 
***************
*** 347,352 ****
--- 348,354 ----
    Fuzzy Bitmap (FBM) images
    GIF images
    G3 FAX images
+   McIDAS areafiles
    MacPaint images
    Portable Bitmap (PBM) images
    Sun monochrome rasterfiles
diff -c src.2.00/xwd.c src.2.01/xwd.c
*** src.2.00/xwd.c	Sun Sep 30 15:47:07 1990
--- src.2.01/xwd.c	Sun Sep 30 13:17:36 1990
***************
*** 8,14 ****
   *
   * jim frost 07.24.90
   *
!  * Copyright 1989 Jim Frost.  See included file "copyright.h" for complete
   * copyright information.
   */
  
--- 8,14 ----
   *
   * jim frost 07.24.90
   *
!  * Copyright 1990 Jim Frost.  See included file "copyright.h" for complete
   * copyright information.
   */
  
***************
*** 335,340 ****
--- 335,341 ----
      depth= header.pixmap_depth;
  
    pixmask= 0xffffffff >> (32 - header.pixmap_depth);
+   pixlen= image->pixlen;
    if (header.bytes_per_line)
      dlinelen= header.bytes_per_line;
    else
diff -c src.2.00/zio.c src.2.01/zio.c
*** src.2.00/zio.c	Sun Sep 30 15:47:01 1990
--- src.2.01/zio.c	Wed Sep 26 17:19:05 1990
***************
*** 6,13 ****
   *
   * this was hacked on 09.12.90 to cache reads and to use stdin.
   *
!  * Copyright 1989 Jim Frost.  See included file "copyright.h" for complete
!  * copyright information.
   */
  
  #include "copyright.h"
--- 6,13 ----
   *
   * this was hacked on 09.12.90 to cache reads and to use stdin.
   *
!  * Copyright 1989, 1990 Jim Frost.  See included file "copyright.h" for
!  * complete copyright information.
   */
  
  #include "copyright.h"
*** /dev/null	Sun Sep 30 15:20:06 1990
--- src.2.01/mc_tables.c	Sun Sep 30 14:45:35 1990
***************
*** 0 ****
--- 1,79 ----
+ /* $Id: mc_tables.c,v 1.1 89/10/16 16:27:48 davis Exp $ */
+ 
+ /*
+  *  From McIDAS Reference Manual
+  *     Introduction - pg 21
+  *     Table 1, UD-14 9/88,
+  *
+  * Given the "SS Code" (word three of the area directory)
+  *   return a string describing the sensor source.
+  *
+  */
+ char *
+ mc_sensor(sscode)
+ int sscode ;
+ {
+ 	switch (sscode) {
+ 	case 0 : return("Non-Image Derived Data") ;
+ 	case 1 : return("Test patterns") ;
+ 	case 2 : return("Graphics") ;
+ 	case 3 : return("Miscellaneous") ;
+ 	case 4 : return("PDUS Meteosat Visible") ;
+ 	case 5 : return("PDUS Meteosat Infrared") ;
+ 	case 6 : return("PDUS Meteosat Water Vapor") ;
+ 	case 7 : return("Radar") ;
+ 	case 8 : return("Miscellaneous Aircraft Data (MAMS)") ;
+ 	case 12 : return("GMS Visible") ;
+ 	case 13 : return("GMS Infrared") ;
+ 	case 14 : return("ATS 6 Visible") ;
+ 	case 15 : return("ATS 6 Infrared") ;
+ 	case 16 : return("SMS-1 Visible") ;
+ 	case 17 : return("SMS-1 Infrared") ;
+ 	case 18 : return("SMS-2 Visible") ;
+ 	case 19 : return("SMS-2 Infrared") ;
+ 	case 20 : return("GOES-1 Visible") ;
+ 	case 21 : return("GOES-1 Infrared") ;
+ 	case 22 : return("GOES-2 Visible") ;
+ 	case 23 : return("GOES-2 Infrared") ;
+ 	case 24 : return("GOES-3 Visible") ;
+ 	case 25 : return("GOES-3 Infrared") ;
+ 	case 26 : return("GOES-4 Visible (VAS)") ;
+ 	case 27 : return("GOES-4 Infrared and Water Vapor (VAS)") ;
+ 	case 28 : return("GOES-5 Visible (VAS)") ;
+ 	case 29 : return("GOES-5 Infrared and Water Vapor (VAS)") ;
+ 	case 30 : return("GOES-6 Visible") ;
+ 	case 31 : return("GOES-6 Infrared") ;
+ 	case 32 : return("GOES-Visible, Block 1 Auxiliary Data") ;
+ 	case 33 : return("GOES-7 Infrared") ;
+ 	case 34 :
+ 	case 36 :
+ 	case 37 :
+ 	case 38 :
+ 	case 39 :
+ 	case 40 : return("NOAA Series Satellites") ;
+ 	case 41 : return("TIROS-N") ;
+ 	case 42 : return("NOAA-6") ;
+ 	case 43 : return("NOAA-7") ;
+ 	case 44 : return("NOAA-8") ;
+ 	case 45 : return("NOAA-9") ;
+ 	case 46 : return("Venus") ;
+ 	case 47 : return("Voyager 1") ;
+ 	case 48 : return("Voyager 2") ;
+ 	case 50 : return("Hubble St.") ;
+ 	case 60 : return("NOAA-10") ;
+ 	case 61 : return("NOAA-11") ;
+ 	case 70 : return("GOES-I (IMAGER)") ;
+ 	case 71 : return("GOES-I (SOUNDER)") ;
+ 	case 72 : return("GOES-J (IMAGER)") ;
+ 	case 73 : return("GOES-J (SOUNDER)") ;
+ 	case 74 : return("GOES-K (IMAGER)") ;
+ 	case 75 : return("GOES-K (SOUNDER)") ;
+ 	case 76 : return("GOES-L (IMAGER)") ;
+ 	case 77 : return("GOES-L (SOUNDER)") ;
+ 	case 78 : return("GOES-M (IMAGER)") ;
+ 	case 79 : return("GOES-M (SOUNDER)") ;
+ 	case 80 : return("ERBE") ;
+ 	case 90 : return("RAW METEOSAT") ;
+ 	}
+ 	return("Unknown") ;
+ }
*** /dev/null	Sun Sep 30 15:20:06 1990
--- src.2.01/mcidas.c	Sun Sep 30 14:59:12 1990
***************
*** 0 ****
--- 1,148 ----
+ /* mcidas.c:
+  *
+  * McIDAS areafile support.  contributed by Glenn P. Davis
+  * (davis@unidata.ucar.edu).
+  */
+ 
+ #include "xloadimage.h"
+ #include "mcidas.h"
+ 
+ /*
+  * convert from little endian to big endian four byte object
+  */
+ static unsigned long
+ vhtonl(lend)
+ unsigned long lend ;
+ {
+ 	unsigned long bend ;
+ 	unsigned char *lp, *bp ;
+ 
+ 	lp = ((unsigned char *)&lend) + 3 ;
+ 	bp = (unsigned char *) &bend ;
+ 
+ 	*bp++ = *lp-- ;
+ 	*bp++ = *lp-- ;
+ 	*bp++ = *lp-- ;
+ 	*bp = *lp ;
+ 
+ 	return(bend) ;
+ }
+ 
+ 
+ int mcidasIdent(fullname, name)
+      char *fullname, *name;
+ { ZFILE          *zf;
+   struct area_dir dir ;
+   int             r;
+ 
+   if (! (zf= zopen(fullname))) {
+     perror("mcidasIdent");
+     return(0);
+   }
+   switch (zread(zf, &dir, sizeof(struct area_dir))) {
+   case -1:
+     perror("mcidasIdent");
+     r= 0;
+     break;
+ 
+   case sizeof(struct area_dir):
+     if (dir.type != 4 && dir.type != 67108864) {
+       r= 0;
+       break;
+     }
+     r= 1;
+     break;
+ 
+   default:
+     r= 0;
+     break;
+   }
+   zclose(zf);
+   return(r);
+ }
+ 
+ 
+ Image *mcidasLoad(fullname, name, verbose)
+      char         *fullname, *name;
+      unsigned int  verbose;
+ { ZFILE          *zf;
+   struct area_dir  dir;
+   struct navigation  nav;
+   Image          *image;
+   unsigned int    y;
+   int doswap = 0 ;
+ 
+   if (! (zf= zopen(fullname))) {
+     perror("mcidasLoad");
+     return(NULL);
+   }
+   switch (zread(zf, &dir, sizeof(struct area_dir))) {
+   case -1:
+     perror("mcidasLoad");
+     zclose(zf);
+     exit(1);
+ 
+   case sizeof(struct area_dir):
+     if (dir.type != 4) {
+       if(dir.type != 67108864) {
+         zclose(zf);
+         return(NULL) ;
+       } else {
+ 	doswap = 1 ;
+       }
+     }
+     break;
+ 
+   default:
+     zclose(zf);
+     return(NULL);
+   }
+ 
+   if(doswap) {
+     unsigned long *begin ; 
+     unsigned long *ulp ;
+     begin = (unsigned long *)&dir ;
+     for(ulp = begin ; ulp < &begin[AREA_COMMENTS] ; ulp++)
+        *ulp = vhtonl(*ulp) ;
+      for(ulp = &begin[AREA_CALKEY] ; ulp < &begin[AREA_STYPE] ; ulp++)
+         *ulp = vhtonl(*ulp) ;
+    }
+ 
+     if (verbose)
+ 	(void)printf("%s %d %d (%d, %d) (%d, %d)\n",
+ 		mc_sensor(dir.satid),
+ 		dir.idate,
+ 		dir.itime,
+ 		dir.lcor,
+ 		dir.ecor,
+ 		dir.lres,
+ 		dir.eres) ;
+   /* skip the nav */
+   if( zread(zf,&nav, sizeof(struct navigation)) != sizeof(struct navigation)) {
+       zclose(zf);
+       return(NULL) ;
+   }
+ 
+   /* get an image to put the data in
+    */
+ 
+    image= newRGBImage(dir.esiz,
+ 		       dir.lsiz,
+ 		       8 * dir.bands);
+ 
+   /* set up the colormap, linear grey scale
+    */
+ 
+     for (y= 0; y < 255; y++) {
+       *(image->rgb.red + y)= 
+        *(image->rgb.green + y)=
+         *(image->rgb.blue + y)= y * 257 ;
+     }
+     image->rgb.used= 255 ;
+ 
+   zread(zf, image->data, dir.esiz * dir.lsiz) ;
+ 
+   zclose(zf);
+   image->title= dupString(name);
+   return(image);
+ }
*** /dev/null	Sun Sep 30 15:20:06 1990
--- src.2.01/mcidas.h	Sun Sep 30 15:38:23 1990
***************
*** 0 ****
--- 1,73 ----
+ /*	$Id: mcidas.h,v 1.1 90/09/28 20:26:36 davis Exp $ */
+ 
+ /* Argh, looks like the numbers are in vax byte order */
+ 
+ #define TYPELEN		4 /* Short strings used as identifiers */
+ #define COMMENTLEN	32	/* longer strings */
+ /*
+  * McIdas AREA DIRECTORY, based on documentation dated 5/87 by R. Dengal
+  */
+ struct area_dir {
+ /*  1 */ unsigned long	status ;
+ /*  2 */ unsigned long	type ;
+ /*  3 */ unsigned long	satid ;
+ /*  4 */ unsigned long	ndate ; /* YYDDD */
+ /*  5 */ unsigned long	ntime ; /* HHMMSS */
+ /*  6 */ unsigned long	lcor ;
+ /*  7 */ unsigned long	ecor ;
+ /*  8 */ unsigned long	zcor ;
+ /*  9 */ unsigned long	lsiz ;
+ /* 10 */ unsigned long	esiz ;
+ /* 11 */ unsigned long	zsiz ;
+ /* 12 */ unsigned long	lres ;
+ /* 13 */ unsigned long	eres ;
+ /* 14 */ unsigned long	bands ;
+ /* 15 */ unsigned long	yzprefix ;
+ /* 16 */ unsigned long	projnum ;
+ /* 17 */ unsigned long	cdate ;
+ /* 18 */ unsigned long	ctime ;
+ /* 19 */ unsigned long	filtmap ;
+ /* 20 */ unsigned long	imageid ;
+ /* 21 */ unsigned long	resvid[4] ;
+ #define AREA_COMMENTS 24
+ /* 25 */ char	comments[COMMENTLEN] ;
+ #define AREA_CALKEY 32
+ /* 33 */ unsigned long	calkey ;
+ /* 34 */ unsigned long	navkey ;
+ /* 35 */ unsigned long	navkey2 ;
+ /* 36 */ unsigned long	lprefix ;
+ /* 37 */ unsigned long	pdl[8] ;
+ /* 45 */ unsigned long	band8 ;
+ /* 46 */ unsigned long idate ;
+ /* 47 */ unsigned long itime ;
+ /* 48 */ unsigned long	startscan ;
+ /* 49 */ unsigned long	doclen ;
+ /* 50 */ unsigned long	callen ;
+ /* 51 */ unsigned long	levlen ;
+ #define AREA_STYPE 51
+ /* 52 */ char	stype[TYPELEN] ;
+ /* 53 */ char	ctype[TYPELEN] ;
+ /* 54 */ unsigned long	reserved[11] ;
+ } ;
+ 
+ /*
+  * McIdas NAVIGATION CODICIL, based on documentation dated 5/87 by D. Santek
+  *  Only type 'GOES' used here currently
+  */
+ struct navigation {
+ /*   1 */ char	type[TYPELEN] ;
+ #define NAV_DATA 1
+ /*   2 */ unsigned long iddate ;
+ /*   3 */ unsigned long itime ;
+ /*   4 */ unsigned long fill[37] ; /* expand this later, if needed */
+ #define NAV_RESERVED 40
+ /*  41 */ unsigned long	reserved[80] ;
+ /* 121 */ char	memo[COMMENTLEN] ;
+ } ;
+ 
+ struct mc_area {
+ 	struct area_dir *dir ;
+ 	struct navigation *nav ;
+ 	unsigned char *image ;
+ 	unsigned char *private ; /* conveninence pointer */
+ } ;

dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.