Imported Debian patch 1.3.11-1 debian/1.3.11-1
authorBdale Garbee <bdale@gag.com>
Tue, 15 Apr 2008 20:34:32 +0000 (14:34 -0600)
committerBdale Garbee <bdale@gag.com>
Thu, 5 Jun 2008 23:27:01 +0000 (17:27 -0600)
63 files changed:
CHANGES
COMPATABILITY
FAQ
Makefile.in
README
README.win32 [new file with mode: 0644]
TODO
build.win32 [new file with mode: 0755]
config.guess
config.h [deleted file]
config.h.in
config.sub
configure
configure.in
contrib/config_sgen_solaris.sh
contrib/mtx-changer [changed mode: 0644->0755]
contrib/mtx.py
contrib/qdback.tar.gz [new file with mode: 0644]
debian/changelog
debian/control
debian/rules
du/scsi.c
install-sh
loaderinfo.1
loaderinfo.c
makedist
mam2debug.c
mam2debug2.c
msvc/config.h [new file with mode: 0644]
msvc/loaderinfo/loaderinfo.vcproj [new file with mode: 0644]
msvc/mtx.sln [new file with mode: 0644]
msvc/mtx/Distributions.txt [new file with mode: 0644]
msvc/mtx/mtx.vcproj [new file with mode: 0644]
msvc/nsmhack/nsmhack.vcproj [new file with mode: 0644]
msvc/scsieject/scsieject.vcproj [new file with mode: 0644]
msvc/scsitape/scsitape.vcproj [new file with mode: 0644]
msvc/tapeinfo/tapeinfo.vcproj [new file with mode: 0644]
mtx.1
mtx.c
mtx.h
mtx.spec
mtx.spec.in
mtxl.README.html
mtxl.c
mtxl.h
nsmhack.c [new file with mode: 0644]
scsi_aix.c
scsi_freebsd.c
scsi_hpux.c
scsi_linux.c
scsi_sgi.c
scsi_sun.c
scsi_win32.c [new file with mode: 0644]
scsieject.1 [new file with mode: 0644]
scsieject.c [new file with mode: 0644]
scsitape.1
scsitape.c
sg_err.c [new file with mode: 0644]
sg_err.h [new file with mode: 0644]
sparc-patch1 [deleted file]
tapeinfo.1
tapeinfo.c
vms/scsi.c

diff --git a/CHANGES b/CHANGES
index 145ca0c4a9fa4a4d531f8ad19f5429e85cad7a93..a04245beef2555aa051f9e3128f2b608eedfe732 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,21 +1,94 @@
-CHANGES, mtx 1.2.17:
-- copy_barcode was off by one.
-- Replace garbled chars with \0 in case barcodes full of BS. Barcode
-  changes courtesy of dirkx at covalent dot net. Set __WEIRD_CHAR_SUPPRESS
-  to activate this code (it is not activated by default in -current.)
-
-CHANGES, mtx 1.2.16:
-- Fix a very special case that ADIC loaders presented to element status
-  parser
-- Fix a buffer overflow w/some weird hardware, courtesy of Lars
-  Fredricksen
-- Make version number include a "rel" so that the rpm will overrride  
-  a "pre" version's rpm, i.e., --version will  say "mtx 1.2.16rel". 
-- Added TapeChanger Perl package for use with Amanda to the contrib
-  directory (see http://www.killfile.org/~tskirvin/software/tapechanger.html )
-  courtesy of Tim Skirvin. 
-- Fixed spec file that was broken by 1.2.15 :-(, courtesy of Kenneth
-  Porter
+CHANGES, mtx 1.3.11
+- loaderinfo: Print RequestSense information if an operation fails.
+- loaderinfo: Print all information from the Device Configuration Page.
+- mtx: Fix problems with a lot of loaders determining the number of elements.
+- mtx: Implement Previous command.
+- mtx: Fix bugs in Last command.
+- scsieject: New tool that handles start/stop, load/unload.
+- tapeinfo: Fix inconsistencies in output.
+- Fix timeout handling on Linux.
+- Merge in fixes from the Debian and FreeBSD distributions.
+
+CHANGES, mtx 1.3.10
+- Add support for Microsoft Windows.
+- Add support for Sony VGP-XL1B(2) Media Changer.
+  Thanks to Will (nodenet at hotmail dot com)
+- Add build support for Microsoft Windows using MinGW native and Linux
+  cross-compile.
+- Add build support for Microsoft Windows using Microsoft Visual Studio 2005.
+- Add support for building on x86_64.
+- Add more debugging information.
+- Eliminate compiler warnings.
+
+CHANGES, mtx 1.3.9
+- Cleaned up scsi_linux.c a little to eliminate around 40 lines of code. 
+- Change to using SG_IO ioctl rather than write-read interface. This
+  should make us a little safer, as well as (on 2.6.x) letting us issue SCSI 
+  commands to regular block devices as well as to /dev/sgXX devices. 
+  WARNING: Can cause the system to *CRASH* if the SCSI device is in use, due 
+  to brokenness inside the Linux kernel! It's always preferable to use the 
+  /dev/sgXX device, which has specialness in its buffer handling that bypasses
+  some of the brokenness elsewhere in the SCSI subsystem.
+- Check SG version before using SG_IO interface, so that if we're run on a
+  Linux 2.2 system and we were compiled on Linux 2.4 or above, 
+- If a tape is in the drive, make tapeinfo print out its partition info. Seems
+  to work on my DAT drive, anyhow (shrug). 
+- Minor cleanups in mtxl.c (other cleanups necessary in tapeinfo and etc.). 
+
+CHANGES, mtx 1.3.8
+- Forgot about 8 bytes for header
+- Handle pedantic loader whose firmware writer spends too much time
+  parsing phrases in the SCSI spec and not enough time in the
+  real world. 
+
+CHANGES, mtx 1.3.6
+- The You Gotta Be F'ing Kidding Release (see rant on mailing list)
+- Added AIX support with http://fz.eryx.net/aix/ GSC driver, courtesy
+  of Steve Heck. 
+- Make __WEIRD_CHAR_SUPPRESS the default to stop barcode garbling
+- Fix core dump on invalid inputs in mtx.c
+- Add retry with bigger ALLOCATION_LENGTH if 
+  BYTE_COUNT_OF_REPORT_AVAILABLE is > than our original estimate. (see rant
+  on mailing list). 
+- Shut up the low-level SCSI sg_read and sg_write routines, which were poofting
+  all over the place on innocuous things like no EAAP. 
+
+CHANGES, mtx 1.3.5
+- The I-Need-A-Job Release (see http://badtux.org) :-}
+- Change Makefile so that it works w/systems whose 'install' program
+  accepts only one argument. That's it. 
+- Uncomment the Exabyte hack in the drive parsing code so that it works
+  with ATL loaders again. 
+- Add hack for ATL stacked loaders to keep them from reporting ghost slots
+
+CHANGES, mtx 1.3.4
+- Forward-ported the ATL/Exabyte patches from mtx 1.2
+- Added progress indicator to 'tapeinfo' for DAT drives. (PLEASE TEST)
+- Purged a few more estinc.com out of the documentation, point to bru.com.
+
+CHANGES, mtx 1.3.3
+- Reversed James' long descriptor patch until can figure out what's wrong with
+  it.
+- Fixed some debug declarations, courtesy of Kevin Wang. 
+- Point COMPATIBILITY file at mtx.sourceforge.net.
+
+CHANGES, mtx 1.3.2
+- Merged Makefile changes from mtx-1.2 code
+- Changes from James Dugal to get all info for newer loaders, fix debugging
+
+CHANGES, mtx 1.3.1
+- add an Exchange command
+
+CHANGES, mtx 1.3.0
+- New Linux SCSI subsystem interface for 2.4 kernels, ripped boldly 
+  from sgtools by Doug Gilbert
+- mtx 'next' now skips blank slots, courtesy of Christopher McCrory
+- mtx 'unload' now prints an error message telling you that you need to
+  eject the tape in the drive prior to unloading it, under certain
+  conditions. 
+- Started work on 'nsmhack' for controlling NSM jukeboxes. 
+- copy_barcode was off by one. 
+- 'position to element' command now added, courtesy of Mahlon Stacy
 
 CHANGES, mtx 1.2.15:
 - Some Solaris fixes, courtesy of Matt Ward
index 3bc9d40f3aff61f108c61b2c32b928d07ce22599..e8cde0d1a8b3c7a020e9dd564125ce766ae830fc 100644 (file)
@@ -1,20 +1,5 @@
-PLEASE CONTRIBUTE YOUR HARDWARE!
---------------------------------
-If you are currently using mtx on hardware not listed below, please
-forward me the result of 'mtx inquiry' on your hardware, plus the first
-few lines of 'mtx status', so that I can add it to the list. 
-That EMAIL address is:
-
-    eric@badtux.org
-
-Compilers:
-----------
-mtx requires the GNU 'make' command in order to build. On FreeBSD or other
-Unixes you must thus install 'gmake' and use that command for building.
-In addition, it has only been verified to compile correctly using the
-GNU "C" compiler. It may not compile with vendor "C" compilers, which
-typically tend to implement an earlier version of "C" than the version
-implemented by "gcc". 
+WARNING: THIS FILE IS OBSOLETE AND FOR HISTORICAL USE ONLY. Please
+see http://mtx.sourceforge.net for a more up-to-date compatibility list. 
 
 Operating Systems:
 -----------------
@@ -43,24 +28,6 @@ From Dan Wright (dtwright at uiuc dot uiuc.edu):
   IRIX 6.5 has a generic scsi interface installed by default, so to
   access the autoloader I use "mtx -f /dev/scsi/sc1d1l0" (bus 1 id 1
   lun 0).
-  
-Vendors:
---------
-
-'mtx' tries to stay with generic SCSI media changer commands, thus
-works with most vendors' products (see list of tested media changers
-that follows). The following vendors have been singled out for special
-mention because they provide easily-accessible SCSI documentation via
-their web site, thus making it easier for people world-wide to
-contribute to 'mtx' development:
-
-  Tandberg Data  http://www.tandberg.com
-  Exabyte/Ecrix  http://www.exabyte.com
-  SpectraLogic   http://www.spectralogic.com
-
-If contacting other companies asking them to provide easily-accessible
-SCSI documentation for their loaders, please be polite. Remember, several
-'mtx' contributors work for those "other" companies.
 
 ----------------
 Changer Devices
@@ -86,14 +53,7 @@ The following has been directly tested:
    Vendor ID: 'Maxoptix'
    Product ID: 'MAXLYB          '
    Revision: '3.04'
-
-* DISC/NSM 3000-series DVD optical library (4 drives, 240 slot,  1 mail slot)
-  Limitations: Will export to mail slot, but won't import from it (yet). 
-    'transfer' command does not work because of mechanical limitations of
-    the hardware. Initial mtx status takes a while.  
-   Vendor ID: 'NSM     '
-   Product ID: 'NSM3000         '
-   Revision: '1140'
+   Attached Changer: No
 
 The following have been tested by others, and information may be
 incomplete or in error even.
diff --git a/FAQ b/FAQ
index 3f22e08115d023e641354ec2c61046232e4098ec..186242f95bcd1557ee695d5069219a85613c3774 100644 (file)
--- a/FAQ
+++ b/FAQ
@@ -37,8 +37,7 @@ Q: Why does this command not work??
    In /var/log/messages I see:
       st0: Write not multiple of tape block size. 
 A: Note that mtx 1.2 and above use the SCSI GENERIC interface on Linux,
-  FreeBSD, and Solaris (at least). They do NOT use the tape device node. Please
-  read the man page for directions.
+  FreeBSD, and Solaris (at least). They do NOT use the tape device node.
 
 Q: When I do 'mtx -f /dev/sga inquiry' it shows 
       Product Type: Tape Drive
index 8012cbdc8287a12bd3da999ebd701c9933d34825..adde51efc4d2fc9ae1088beafece3cbc1a8e133b 100644 (file)
@@ -9,8 +9,14 @@
 # GNU Autoconf. 
 
 # Version # for 'make dist'...
-VERSION=1.2.17rel
-BINS = mtx tapeinfo loaderinfo scsitape
+VERSION=1.3.11
+
+BINS = mtx@EXEEXT@ tapeinfo@EXEEXT@ loaderinfo@EXEEXT@ scsitape@EXEEXT@ scsieject@EXEEXT@ \
+       nsmhack@EXEEXT@
+DBGS := $(BINS:%@EXEEXT@=%.dbg)
+MAN = mtx.1 tapeinfo.1 loaderinfo.1 scsitape.1 scsieject.1
+MAN_HTML := $(MAN:%.1=%.html)
+MAN_TXT := $(MAN:%.1=%.txt)
 
 TARGET = @TARGET@
 CPU    = @CPU@
@@ -21,6 +27,7 @@ CFLAGS                = @CFLAGS@
 CPPFLAGS       = @CPPFLAGS@ -DVERSION="\"$(VERSION)\""
 LDFLAGS                = @LDFLAGS@
 LIBS           = @LIBS@
+USE_OBJCOPY    = @USE_OBJCOPY@
 
 INSTALL_DOC = $(INSTALL) -m 644
 INSTALL_BIN = $(INSTALL) -m 755
@@ -36,15 +43,19 @@ mandir              = @mandir@
 #
 ifeq ($(TARGET),linux)
 CFLAGS += -Wall
-CPPFLAGS       += -I/usr/src/linux/include -DLONG_PRINT_REQUEST_SENSE=1
+CPPFLAGS       += -DLONG_PRINT_REQUEST_SENSE=1
+endif
+
+ifeq ($(TARGET),mingw)
+CFLAGS += -Wall
+CPPFLAGS       += -DLONG_PRINT_REQUEST_SENSE=1
 endif
 
 #
-# FreeBSD on x86...
+# FreeBSD
 #
 ifeq ($(TARGET),freebsd86)
-CFLAGS         += -m486
-CPPFLAGS       += -I/usr/src/linux/include -DLONG_PRINT_REQUEST_SENSE=1
+CPPFLAGS       += -DLONG_PRINT_REQUEST_SENSE=1
 LIBS           += -lcam
 endif
 
@@ -81,49 +92,72 @@ ifeq ($(TARGET),vms)
 See vms/000readme for information.
 endif
 
+%.dbg : %@EXEEXT@
+ifeq ($(USE_OBJCOPY),yes)
+       objcopy --only-keep-debug $< $@
+       objcopy --strip-debug $<
+       objcopy --add-gnu-debuglink=$@ $<
+else
+       strip $< -o $@
+endif
+
 all:   $(BINS)
 
-install: $(BINS)
+dbgs: $(DBGS)
+
+install: $(BINS) $(DBGS)
+       $(INSTALL_DIR) $(sbindir)
        for file in $(BINS); do \
-       strip $$file;   \
+       $(INSTALL_BIN) "$$file" $(sbindir) ; \
        done    
-       $(INSTALL_DIR) $(sbindir)
-       $(INSTALL_BIN) $(BINS) $(sbindir)
        $(INSTALL_DIR) $(mandir) $(mandir)/man1
-       $(INSTALL_DOC) mtx.1 tapeinfo.1 scsitape.1 loaderinfo.1 $(mandir)/man1
+       for file in mtx.1 tapeinfo.1 scsitape.1 scsieject.1 loaderinfo.1 ; do \
+       $(INSTALL_DOC) "$$file"  $(mandir)/man1 ; \
+       done
 
 clean:
-       rm -f *.o *~
+       rm -f *.o *~ mtx-*.zip
        rm -f $(BINS)
-       rm -f mam2debug mam2debug2
+       rm -f $(DBGS)
+       rm -f $(MAN_HTML)
+       rm -f $(MAN_TXT)
+       rm -f mam2debug@EXEEXT@ mam2debug2@EXEEXT@
+       rm -rf autom4te.cache
 
 distclean: clean
-       rm -f Makefile config.log config.cache config.status
+       rm -f Makefile config.h config.log config.cache config.status
 
 dist: distclean
        ./makedist $(VERSION)   
 
-loaderinfo: loaderinfo.o mtxl.o mtxl.h mtx.h $(EXTRA)
-       $(CC) $(LDFLAGS) -o loaderinfo loaderinfo.o mtxl.o $(EXTRA) $(LIBS)
+loaderinfo@EXEEXT@: loaderinfo.o mtxl.o mtxl.h mtx.h $(EXTRA)
+       $(CC) $(LDFLAGS) -o loaderinfo@EXEEXT@ loaderinfo.o mtxl.o $(EXTRA) $(LIBS)
 
+nsmhack@EXEEXT@: nsmhack.o mtxl.o $(EXTRA)
+       $(CC) $(LDFLAGS) -o nsmhack@EXEEXT@ nsmhack.o mtxl.o $(EXTRA) $(LIBS)
 
-mtx: mtx.o mtxl.o mtxl.h mtx.h $(EXTRA)
-       $(CC) $(LDFLAGS) -o mtx mtx.o mtxl.o $(EXTRA) $(LIBS)
+mtx@EXEEXT@: mtx.o mtxl.o mtxl.h mtx.h $(EXTRA)
+       $(CC) $(LDFLAGS) -o mtx@EXEEXT@ mtx.o mtxl.o $(EXTRA) $(LIBS)
 
-mam2debug: mtxl.o mam2debug.o mtx.h $(EXTRA)   
-       $(CC) $(LDFLAGS) -o mam2debug mtxl.o mam2debug.o $(EXTRA) $(LIBS)
+mam2debug@EXEEXT@: mtxl.o mam2debug.o mtx.h $(EXTRA)   
+       $(CC) $(LDFLAGS) -o mam2debug@EXEEXT@ mtxl.o mam2debug.o $(EXTRA) $(LIBS)
 
-tapeinfo: tapeinfo.o mtxl.o mtx.h mtxl.h $(EXTRA)
-       $(CC) $(LDFLAGS) -o tapeinfo tapeinfo.o mtxl.o $(EXTRA) $(LIBS)
+tapeinfo@EXEEXT@: tapeinfo.o mtxl.o mtx.h mtxl.h $(EXTRA)
+       $(CC) $(LDFLAGS) -o tapeinfo@EXEEXT@ tapeinfo.o mtxl.o $(EXTRA) $(LIBS)
 
-mam2debug2: mtxl.o mam2debug2.o mtx.h $(EXTRA)
-       $(CC) $(LDFLAGS) -o mam2debug2 mtxl.o mam2debug2.o $(EXTRA) $(LIBS)
+mam2debug2@EXEEXT@: mtxl.o mam2debug2.o mtx.h $(EXTRA)
+       $(CC) $(LDFLAGS) -o mam2debug2@EXEEXT@ mtxl.o mam2debug2.o $(EXTRA) $(LIBS)
 
-scsitape: scsitape.o mtxl.o mtxl.h mtx.h $(EXTRA)
-       $(CC) $(LDFLAGS) -o scsitape scsitape.o mtxl.o $(EXTRA) $(LIBS)
+scsitape@EXEEXT@: scsitape.o mtxl.o mtxl.h mtx.h $(EXTRA)
+       $(CC) $(LDFLAGS) -o scsitape@EXEEXT@ scsitape.o mtxl.o $(EXTRA) $(LIBS)
 
 scsitape.o: scsitape.c mtx.h mtxl.h
 
+scsieject@EXEEXT@: scsieject.o mtxl.o mtxl.h mtx.h $(EXTRA)
+       $(CC) $(LDFLAGS) -o scsieject@EXEEXT@ scsieject.o mtxl.o $(EXTRA) $(LIBS)
+
+scsieject.o: scsieject.c mtx.h mtxl.h
+
 loaderinfo.o: loaderinfo.c mtx.h mtxl.h
 
 tapeinfo.o: tapeinfo.c mtx.h mtxl.h
@@ -134,4 +168,6 @@ mam2debug2.o: mam2debug2.c mtx.h mtxl.h
 
 mtx.o: mtx.c mtx.h mtxl.h
 
-mtxl.o: mtxl.c mtxl.h scsi_linux.c 
+mtxl.o: mtxl.c mtx.h mtxl.h scsi_linux.c scsi_win32.c
+
+nsmhack.o: nsmhack.c mtxl.h mtx.h
diff --git a/README b/README
index e906899867f8b1e6fb951f8c8a14a57dabe9df55..f81f6ca4be87d841fed2d6736491694c3ed76fac 100644 (file)
--- a/README
+++ b/README
@@ -24,7 +24,7 @@ Credits:
 The original 'mtx' program is copyright 1996-1997 by Leonard Zubkoff
 <lnz@dandelion.com>. This version was modified for multi-drive,
 optical changer, and tape library support by Eric Lee Green
-<eric@estinc.com>. Also added FreeBSD support. Please see the man page
+<eric@badtux.org>. Also added FreeBSD support. Please see the man page
 for current info, and the file 'mtx.doc' for historical info.
 
 My thanks to Doug Bonnell of Breece Hill for suggestions on
@@ -35,4 +35,4 @@ for the barcode backoff fix, and to all the other people out there who
 have used it, found problems with it, and let me know about it (you
 know who you are).
   
-   -- Eric Lee Green <eric@estinc.com>
+   -- Eric Lee Green <eric@badtux.org>
diff --git a/README.win32 b/README.win32
new file mode 100644 (file)
index 0000000..b3a92fe
--- /dev/null
@@ -0,0 +1,45 @@
+BUILDING FOR MICROSOFT WINDOWS
+==============================
+
+You can perform the build using either MinGW or Microsoft Visual Studio 2005.
+
+       Microsoft Visual Studio 2005
+       ----------------------------
+       
+       Open the solution in msvc/mtx.sln.
+       
+       Select the Build / Build Solution menu item.
+       
+       
+       MinGW with GCC
+       --------------
+       
+       You must be using at least version 2.16.91 of binutils.
+       
+       To generate the intitial configure script, this only needs to be 
+       done once.
+       
+       ./configure --host=mingw32
+       make
+       
+CHANGES FROM UNIX
+=================
+
+The only difference is in the naming of devices.  On Linux the changer is 
+accessed using /dev/sg<N>, on Windows you use Changer<N>.
+
+On Linux the tape drive is referenced using /dev/nst<N>, on Windows you use Tape<N>.
+
+There is one exception in the case where there isn't a driver loaded for the device.  
+This is usually only the case on Windows 2000 or if the Windows XP or Windows Server 
+2003 system supplied driver has been disabled.
+
+In the case where there is no driver loaded you can access the device directly 
+through the SCSI driver using the following notation:
+
+       <port>:<bus>:<target>:<lun>
+       
+               Port is the adapter number
+               Bus is the SCSI bus number relative to the adapter
+               Target is the SCSI device's target ID
+               LUN is the SCSI device's logical unit number
diff --git a/TODO b/TODO
index 77cabe0e5f83706e2f114c7d81ac6f4ae9328c08..4a7c757a5f72f99a9c08d9ccd3067b5dd873412a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,14 +1,15 @@
+1 Fix the big element descriptor overflow problem by adding a retry/reallocate
+  if things overflow.
 1 Add a 'timeout' command to adjust the timeout (timeout will be in seconds!).
-1 Adjust timeout lenghts for various operations now that the low level
- SCSI routines now support timeouts. 
 1 Add IES command (sets CDB[5] to something in routine Inventory() ).
-1 Increase the timeout for Inventory() commands to something *BIG*.
 1 Fix 'scsitape' READ and WRITE so that block counts work.
+1 Add EXCHANGE command so that we can exchange media between slots in
+  NSM/DISC optical jukeboxes.
+1 If moving media to/from import/export slot, try to do it even if the slot
+  reports that it's empty or full, this will let us stick our tongue out
+  on NSM/DISC optical jukeboxes for importing media. 
 2 Fix ports to other Unixes/VMS.
-2 Port to AIX (no longer care about SCO Unix).
 2 Add a range to 'mtx status' so that we request status only of 
   the elements we're interested in, rather than of all of them.
   (nice for the very big loaders!). 
 3 Better Import/Export port support?
-3 Create a TCL/TK GUI front end (otherwise managing big libraries is HARD!).
-
diff --git a/build.win32 b/build.win32
new file mode 100755 (executable)
index 0000000..5c2c00a
--- /dev/null
@@ -0,0 +1,15 @@
+manpages="mtx.1 tapeinfo.1 loaderinfo.1 scsitape.1 scsieject.1"
+txtpages="mtx.txt tapeinfo.txt loaderinfo.txt scsitape.txt scsieject.txt"
+htmlpages="mtx.html tapeinfo.html loaderinfo.html scsitape.html scsieject.html"
+
+./configure --host=mingw32
+make
+make dbgs
+
+for i in $manpages
+do
+       groff -et -Thtml -mandoc $i | col -b > `basename $i .1`.html
+       groff -et -Tascii -mandoc $i | col -b > `basename $i .1`.txt
+done
+
+zip mtx-$1.zip README.win32 *.exe $htmlpages $txtpages
index 396482d6cb50b24a598700992f65d340165591d6..f32079abda668e5fc8f8de6f226e7b26384e8a03 100755 (executable)
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
-#   Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 
-timestamp='2006-07-02'
+timestamp='2008-01-23'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -56,8 +56,8 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -161,6 +161,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
            arm*) machine=arm-unknown ;;
            sh3el) machine=shl-unknown ;;
            sh3eb) machine=sh-unknown ;;
+           sh5el) machine=sh5le-unknown ;;
            *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
        esac
        # The Operating System including object format, if it has switched
@@ -329,7 +330,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
        echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
        exit ;;
-    i86pc:SunOS:5.*:*)
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
        echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
        exit ;;
     sun4*:SunOS:6*:*)
@@ -531,7 +532,7 @@ EOF
                echo rs6000-ibm-aix3.2
        fi
        exit ;;
-    *:AIX:*:[45])
+    *:AIX:*:[456])
        IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
        if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
                IBM_ARCH=rs6000
@@ -780,7 +781,7 @@ EOF
     i*:CYGWIN*:*)
        echo ${UNAME_MACHINE}-pc-cygwin
        exit ;;
-    i*:MINGW*:*)
+    *:MINGW*:*)
        echo ${UNAME_MACHINE}-pc-mingw32
        exit ;;
     i*:windows32*:*)
@@ -790,12 +791,18 @@ EOF
     i*:PW*:*)
        echo ${UNAME_MACHINE}-pc-pw32
        exit ;;
-    x86:Interix*:[3456]*)
-       echo i586-pc-interix${UNAME_RELEASE}
-       exit ;;
-    EM64T:Interix*:[3456]*)
-       echo x86_64-unknown-interix${UNAME_RELEASE}
-       exit ;;
+    *:Interix*:[3456]*)
+       case ${UNAME_MACHINE} in
+           x86)
+               echo i586-pc-interix${UNAME_RELEASE}
+               exit ;;
+           EM64T | authenticamd)
+               echo x86_64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+           IA64)
+               echo ia64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+       esac ;;
     [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
        echo i${UNAME_MACHINE}-pc-mks
        exit ;;
@@ -829,7 +836,14 @@ EOF
        echo ${UNAME_MACHINE}-pc-minix
        exit ;;
     arm*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       eval $set_cc_for_build
+       if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+           | grep -q __ARM_EABI__
+       then
+           echo ${UNAME_MACHINE}-unknown-linux-gnu
+       else
+           echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+       fi
        exit ;;
     avr32*:Linux:*:*)
        echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -950,6 +964,9 @@ EOF
     x86_64:Linux:*:*)
        echo x86_64-unknown-linux-gnu
        exit ;;
+    xtensa*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
     i*86:Linux:*:*)
        # The BFD linker knows what the default object file format is, so
        # first see if it will tell us. cd to the root directory to prevent
@@ -1208,6 +1225,15 @@ EOF
     SX-6:SUPER-UX:*:*)
        echo sx6-nec-superux${UNAME_RELEASE}
        exit ;;
+    SX-7:SUPER-UX:*:*)
+       echo sx7-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8:SUPER-UX:*:*)
+       echo sx8-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8R:SUPER-UX:*:*)
+       echo sx8r-nec-superux${UNAME_RELEASE}
+       exit ;;
     Power*:Rhapsody:*:*)
        echo powerpc-apple-rhapsody${UNAME_RELEASE}
        exit ;;
@@ -1458,9 +1484,9 @@ This script, last modified $timestamp, has failed to recognize
 the operating system you are using. It is advised that you
 download the most up to date version of the config scripts from
 
-  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 and
-  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
 
 If the version you run ($0) is already up to date, please
 send the following data and any information you think might be
diff --git a/config.h b/config.h
deleted file mode 100644 (file)
index 3a39632..0000000
--- a/config.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* config.h.  Generated automatically by configure.  */
-/* Copyright 2001 Enhanced Software Technologies Inc.
- * Released under GNU General Public License V2 or Above
- * See http://www.gnu.org for more information about the terms of
- * the GNU General Public License.
- * $Date: 2001/06/05 17:10:18 $
- * $Revision: 1.1.1.1 $
- */
-
-#ifndef CONFIG_H
-#define CONFIG_H 1
-
-/* autoconf changes these. */
-#define HAVE_STRING_H 1
-#define HAVE_UNISTD_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STDARG_H 1
-#define HAVE_SCSI_SCSI_H 1
-#define HAVE_SCSI_SCSI_IOCTL_H 1
-#define HAVE_SCSI_SG_H 1
-#define HAVE_CAMLIB_H 0
-#define HAVE_SYS_SCSI_IMPL_USCSI_H 0
-#define HAVE_SYS_SCSI_CTL_H 0
-#define HAVE_DSLIB_H 0
-#define HAVE_DU_DEFS_H 0
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_FCNTL_H 1
-#define HAVE_SYS_IOCTL_H 1
-
-#define WORDS_BIGENDIAN 0
-
-#endif
-
index 38802d21dcb4ee596ea41e8c63ee72ca32a0ff34..7282e460476adf9647e0c76807844b8fca2de0df 100644 (file)
@@ -2,8 +2,8 @@
  * Released under GNU General Public License V2 or Above
  * See http://www.gnu.org for more information about the terms of
  * the GNU General Public License.
- * $Date: 2001/06/05 17:10:18 $
- * $Revision: 1.1.1.1 $
+ * $Date: 2007-02-13 08:45:31 -0800 (Tue, 13 Feb 2007) $
+ * $Revision: 144 $
  */
 
 #ifndef CONFIG_H
 #define HAVE_UNISTD_H 0
 #define HAVE_STDLIB_H 0
 #define HAVE_STDARG_H 0
+#define HAVE_SYS_PARAM_H 0
 #define HAVE_SCSI_SCSI_H 0
 #define HAVE_SCSI_SCSI_IOCTL_H 0
 #define HAVE_SCSI_SG_H 0
+#define HAVE_SYS_GSCDDS_H 0
 #define HAVE_CAMLIB_H 0
 #define HAVE_SYS_SCSI_IMPL_USCSI_H 0
 #define HAVE_SYS_SCSI_CTL_H 0
@@ -26,6 +28,8 @@
 #define HAVE_SYS_TYPES_H 0
 #define HAVE_FCNTL_H 0
 #define HAVE_SYS_IOCTL_H 0
+#define HAVE_SYS_MTIO_H 0
+#define HAVE_DDK_NTDDSCSI_H 0
 
 #define WORDS_BIGENDIAN 0
 
index 387c18d1a135c2e33cb9f911c198efdf7b12b96c..6759825a5b7fcf64476b4398dc0e30b3090b925c 100755 (executable)
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
-#   Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 
-timestamp='2006-07-02'
+timestamp='2008-01-16'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -72,8 +72,8 @@ Report bugs and patches to <config-patches@gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -245,12 +245,12 @@ case $basic_machine in
        | bfin \
        | c4x | clipper \
        | d10v | d30v | dlx | dsp16xx \
-       | fr30 | frv \
+       | fido | fr30 | frv \
        | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
        | i370 | i860 | i960 | ia64 \
        | ip2k | iq2000 \
        | m32c | m32r | m32rle | m68000 | m68k | m88k \
-       | maxq | mb | microblaze | mcore \
+       | maxq | mb | microblaze | mcore | mep \
        | mips | mipsbe | mipseb | mipsel | mipsle \
        | mips16 \
        | mips64 | mips64el \
@@ -276,6 +276,7 @@ case $basic_machine in
        | pdp10 | pdp11 | pj | pjl \
        | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
        | pyramid \
+       | score \
        | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
        | sh64 | sh64le \
        | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
@@ -284,7 +285,7 @@ case $basic_machine in
        | tahoe | thumb | tic4x | tic80 | tron \
        | v850 | v850e \
        | we32k \
-       | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
+       | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
        | z8k)
                basic_machine=$basic_machine-unknown
                ;;
@@ -323,7 +324,7 @@ case $basic_machine in
        | clipper-* | craynv-* | cydra-* \
        | d10v-* | d30v-* | dlx-* \
        | elxsi-* \
-       | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
        | h8300-* | h8500-* \
        | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
        | i*86-* | i860-* | i960-* | ia64-* \
@@ -367,11 +368,15 @@ case $basic_machine in
        | tron-* \
        | v850-* | v850e-* | vax-* \
        | we32k-* \
-       | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
-       | xstormy16-* | xtensa-* \
+       | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+       | xstormy16-* | xtensa*-* \
        | ymp-* \
        | z8k-*)
                ;;
+       # Recognize the basic CPU types without company name, with glob match.
+       xtensa*)
+               basic_machine=$basic_machine-unknown
+               ;;
        # Recognize the various machine names and aliases which stand
        # for a CPU type and a company and sometimes even an OS.
        386bsd)
@@ -442,6 +447,14 @@ case $basic_machine in
                basic_machine=ns32k-sequent
                os=-dynix
                ;;
+       blackfin)
+               basic_machine=bfin-unknown
+               os=-linux
+               ;;
+       blackfin-*)
+               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
        c90)
                basic_machine=c90-cray
                os=-unicos
@@ -474,8 +487,8 @@ case $basic_machine in
                basic_machine=craynv-cray
                os=-unicosmp
                ;;
-       cr16c)
-               basic_machine=cr16c-unknown
+       cr16)
+               basic_machine=cr16-unknown
                os=-elf
                ;;
        crds | unos)
@@ -667,6 +680,14 @@ case $basic_machine in
                basic_machine=m68k-isi
                os=-sysv
                ;;
+       m68knommu)
+               basic_machine=m68k-unknown
+               os=-linux
+               ;;
+       m68knommu-*)
+               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
        m88k-omron*)
                basic_machine=m88k-omron
                ;;
@@ -682,6 +703,10 @@ case $basic_machine in
                basic_machine=i386-pc
                os=-mingw32
                ;;
+       mingw32ce)
+               basic_machine=arm-unknown
+               os=-mingw32ce
+               ;;
        miniframe)
                basic_machine=m68000-convergent
                ;;
@@ -808,6 +833,14 @@ case $basic_machine in
                basic_machine=i860-intel
                os=-osf
                ;;
+       parisc)
+               basic_machine=hppa-unknown
+               os=-linux
+               ;;
+       parisc-*)
+               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
        pbd)
                basic_machine=sparc-tti
                ;;
@@ -909,6 +942,10 @@ case $basic_machine in
        sb1el)
                basic_machine=mipsisa64sb1el-unknown
                ;;
+       sde)
+               basic_machine=mipsisa32-sde
+               os=-elf
+               ;;
        sei)
                basic_machine=mips-sei
                os=-seiux
@@ -920,6 +957,9 @@ case $basic_machine in
                basic_machine=sh-hitachi
                os=-hms
                ;;
+       sh5el)
+               basic_machine=sh5le-unknown
+               ;;
        sh64)
                basic_machine=sh64-unknown
                ;;
@@ -1009,6 +1049,10 @@ case $basic_machine in
                basic_machine=tic6x-unknown
                os=-coff
                ;;
+       tile*)
+               basic_machine=tile-unknown
+               os=-linux-gnu
+               ;;
        tx39)
                basic_machine=mipstx39-unknown
                ;;
@@ -1214,7 +1258,7 @@ case $os in
              | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
              | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
              | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-             | -skyos* | -haiku* | -rdos* | -toppers*)
+             | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
        # Remember, each alternative MUST END IN *, to match a version number.
                ;;
        -qnx*)
@@ -1366,6 +1410,9 @@ else
 # system, and we'll never get to this point.
 
 case $basic_machine in
+        score-*)
+               os=-elf
+               ;;
         spu-*)
                os=-elf
                ;;
@@ -1406,6 +1453,9 @@ case $basic_machine in
        m68*-cisco)
                os=-aout
                ;;
+        mep-*)
+               os=-elf
+               ;;
        mips*-cisco)
                os=-elf
                ;;
index bb5848191f2b6dc4923ae398396ea3d2043464be..f707b21301ea22501213c0e325435ed84dc565c6 100755 (executable)
--- a/configure
+++ b/configure
 #! /bin/sh
-
 # Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13 
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+# Generated by GNU Autoconf 2.59.
 #
+# Copyright (C) 2003 Free Software Foundation, Inc.
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
+do
+  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    $as_unset $as_var
+  fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)$' \| \
+        .     : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+         /^X\/\(\/\/\)$/{ s//\1/; q; }
+         /^X\/\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
+  # Find who we are.  Look in the path if we contain no path at all
+  # relative or not.
+  case $0 in
+    *[\\/]* ) as_myself=$0 ;;
+    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+       ;;
+  esac
+  # We did not find ourselves, most probably we were run as `sh COMMAND'
+  # in which case we are not to be found in the path.
+  if test "x$as_myself" = x; then
+    as_myself=$0
+  fi
+  if test ! -f "$as_myself"; then
+    { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+   { (exit 1); exit 1; }; }
+  fi
+  case $CONFIG_SHELL in
+  '')
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for as_base in sh bash ksh sh5; do
+        case $as_dir in
+        /*)
+          if ("$as_dir/$as_base" -c '
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
+            $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+            $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+            CONFIG_SHELL=$as_dir/$as_base
+            export CONFIG_SHELL
+            exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+          fi;;
+        esac
+       done
+done
+;;
+  esac
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line before each line; the second 'sed' does the real
+  # work.  The second script uses 'N' to pair each line-number line
+  # with the numbered line, and appends trailing '-' during
+  # substitution so that $LINENO is not a special case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
+  sed '=' <$as_myself |
+    sed '
+      N
+      s,$,-,
+      : loop
+      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      t loop
+      s,-$,,
+      s,^['$as_cr_digits']*\n,,
+    ' >$as_me.lineno &&
+  chmod +x $as_me.lineno ||
+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensible to this).
+  . ./$as_me.lineno
+  # Exit status is that of the last command.
+  exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T='     ' ;;
+  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  # We could just check for DJGPP; but this test a) works b) is more generic
+  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+  if test -f conf$$.exe; then
+    # Don't use ln at all; we don't have any links
+    as_ln_s='cp -p'
+  else
+    as_ln_s='ln -s'
+  fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
 
-# Defaults:
-ac_help=
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS="  $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
 ac_default_prefix=/usr/local
-# Any additions from configure.in:
+ac_config_libobj_dir=.
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete.  It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+
+ac_unique_file="mtx.c"
 ac_default_prefix=/usr/local
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os TARGET CPU CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA USE_OBJCOPY CPP EGREP LIBOBJS LTLIBOBJS'
+ac_subst_files=''
 
 # Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
 # The variables have the same names as the options, with
 # dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
+cache_file=/dev/null
 exec_prefix=NONE
-host=NONE
 no_create=
-nonopt=NONE
 no_recursion=
 prefix=NONE
 program_prefix=NONE
@@ -30,10 +329,15 @@ program_transform_name=s,x,x,
 silent=
 site=
 srcdir=
-target=NONE
 verbose=
 x_includes=NONE
 x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
 bindir='${exec_prefix}/bin'
 sbindir='${exec_prefix}/sbin'
 libexecdir='${exec_prefix}/libexec'
@@ -47,17 +351,9 @@ oldincludedir='/usr/include'
 infodir='${prefix}/info'
 mandir='${prefix}/man'
 
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-# Maximum number of lines to put in a shell here document.
-ac_max_here_lines=12
-
 ac_prev=
 for ac_option
 do
-
   # If the previous option needs an argument, assign it.
   if test -n "$ac_prev"; then
     eval "$ac_prev=\$ac_option"
@@ -65,59 +361,59 @@ do
     continue
   fi
 
-  case "$ac_option" in
-  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-  *) ac_optarg= ;;
-  esac
+  ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
 
-  case "$ac_option" in
+  case $ac_option in
 
   -bindir | --bindir | --bindi | --bind | --bin | --bi)
     ac_prev=bindir ;;
   -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
-    bindir="$ac_optarg" ;;
+    bindir=$ac_optarg ;;
 
   -build | --build | --buil | --bui | --bu)
-    ac_prev=build ;;
+    ac_prev=build_alias ;;
   -build=* | --build=* | --buil=* | --bui=* | --bu=*)
-    build="$ac_optarg" ;;
+    build_alias=$ac_optarg ;;
 
   -cache-file | --cache-file | --cache-fil | --cache-fi \
   | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
     ac_prev=cache_file ;;
   -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
   | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
-    cache_file="$ac_optarg" ;;
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
 
   -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
     ac_prev=datadir ;;
   -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
   | --da=*)
-    datadir="$ac_optarg" ;;
+    datadir=$ac_optarg ;;
 
   -disable-* | --disable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
-      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
-    fi
-    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
-    eval "enable_${ac_feature}=no" ;;
+    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    eval "enable_$ac_feature=no" ;;
 
   -enable-* | --enable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
-      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
-    fi
-    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
-    case "$ac_option" in
-      *=*) ;;
+    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    case $ac_option in
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
-    eval "enable_${ac_feature}='$ac_optarg'" ;;
+    eval "enable_$ac_feature='$ac_optarg'" ;;
 
   -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
   | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
@@ -126,95 +422,47 @@ do
   -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
   | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
   | --exec=* | --exe=* | --ex=*)
-    exec_prefix="$ac_optarg" ;;
+    exec_prefix=$ac_optarg ;;
 
   -gas | --gas | --ga | --g)
     # Obsolete; use --with-gas.
     with_gas=yes ;;
 
-  -help | --help | --hel | --he)
-    # Omit some internal or obsolete options to make the list less imposing.
-    # This message is too long to be a string in the A/UX 3.1 sh.
-    cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
-  --cache-file=FILE       cache test results in FILE
-  --help                  print this message
-  --no-create             do not create output files
-  --quiet, --silent       do not print \`checking...' messages
-  --version               print the version of autoconf that created configure
-Directory and file names:
-  --prefix=PREFIX         install architecture-independent files in PREFIX
-                          [$ac_default_prefix]
-  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-                          [same as prefix]
-  --bindir=DIR            user executables in DIR [EPREFIX/bin]
-  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
-  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
-  --datadir=DIR           read-only architecture-independent data in DIR
-                          [PREFIX/share]
-  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
-  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
-                          [PREFIX/com]
-  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
-  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
-  --includedir=DIR        C header files in DIR [PREFIX/include]
-  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
-  --infodir=DIR           info documentation in DIR [PREFIX/info]
-  --mandir=DIR            man documentation in DIR [PREFIX/man]
-  --srcdir=DIR            find the sources in DIR [configure dir or ..]
-  --program-prefix=PREFIX prepend PREFIX to installed program names
-  --program-suffix=SUFFIX append SUFFIX to installed program names
-  --program-transform-name=PROGRAM
-                          run sed PROGRAM on installed program names
-EOF
-    cat << EOF
-Host type:
-  --build=BUILD           configure for building on BUILD [BUILD=HOST]
-  --host=HOST             configure for HOST [guessed]
-  --target=TARGET         configure for TARGET [TARGET=HOST]
-Features and packages:
-  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --x-includes=DIR        X include files are in DIR
-  --x-libraries=DIR       X library files are in DIR
-EOF
-    if test -n "$ac_help"; then
-      echo "--enable and --with options recognized:$ac_help"
-    fi
-    exit 0 ;;
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
 
   -host | --host | --hos | --ho)
-    ac_prev=host ;;
+    ac_prev=host_alias ;;
   -host=* | --host=* | --hos=* | --ho=*)
-    host="$ac_optarg" ;;
+    host_alias=$ac_optarg ;;
 
   -includedir | --includedir | --includedi | --included | --include \
   | --includ | --inclu | --incl | --inc)
     ac_prev=includedir ;;
   -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
   | --includ=* | --inclu=* | --incl=* | --inc=*)
-    includedir="$ac_optarg" ;;
+    includedir=$ac_optarg ;;
 
   -infodir | --infodir | --infodi | --infod | --info | --inf)
     ac_prev=infodir ;;
   -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
-    infodir="$ac_optarg" ;;
+    infodir=$ac_optarg ;;
 
   -libdir | --libdir | --libdi | --libd)
     ac_prev=libdir ;;
   -libdir=* | --libdir=* | --libdi=* | --libd=*)
-    libdir="$ac_optarg" ;;
+    libdir=$ac_optarg ;;
 
   -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
   | --libexe | --libex | --libe)
     ac_prev=libexecdir ;;
   -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
   | --libexe=* | --libex=* | --libe=*)
-    libexecdir="$ac_optarg" ;;
+    libexecdir=$ac_optarg ;;
 
   -localstatedir | --localstatedir | --localstatedi | --localstated \
   | --localstate | --localstat | --localsta | --localst \
@@ -223,19 +471,19 @@ EOF
   -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
   | --localstate=* | --localstat=* | --localsta=* | --localst=* \
   | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
-    localstatedir="$ac_optarg" ;;
+    localstatedir=$ac_optarg ;;
 
   -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
     ac_prev=mandir ;;
   -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
-    mandir="$ac_optarg" ;;
+    mandir=$ac_optarg ;;
 
   -nfp | --nfp | --nf)
     # Obsolete; use --without-fp.
     with_fp=no ;;
 
   -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c)
+  | --no-cr | --no-c | -n)
     no_create=yes ;;
 
   -no-recursion | --no-recursion | --no-recursio | --no-recursi \
@@ -249,26 +497,26 @@ EOF
   -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
   | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
   | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
-    oldincludedir="$ac_optarg" ;;
+    oldincludedir=$ac_optarg ;;
 
   -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
     ac_prev=prefix ;;
   -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
-    prefix="$ac_optarg" ;;
+    prefix=$ac_optarg ;;
 
   -program-prefix | --program-prefix | --program-prefi | --program-pref \
   | --program-pre | --program-pr | --program-p)
     ac_prev=program_prefix ;;
   -program-prefix=* | --program-prefix=* | --program-prefi=* \
   | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
-    program_prefix="$ac_optarg" ;;
+    program_prefix=$ac_optarg ;;
 
   -program-suffix | --program-suffix | --program-suffi | --program-suff \
   | --program-suf | --program-su | --program-s)
     ac_prev=program_suffix ;;
   -program-suffix=* | --program-suffix=* | --program-suffi=* \
   | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
-    program_suffix="$ac_optarg" ;;
+    program_suffix=$ac_optarg ;;
 
   -program-transform-name | --program-transform-name \
   | --program-transform-nam | --program-transform-na \
@@ -285,7 +533,7 @@ EOF
   | --program-transfo=* | --program-transf=* \
   | --program-trans=* | --program-tran=* \
   | --progr-tra=* | --program-tr=* | --program-t=*)
-    program_transform_name="$ac_optarg" ;;
+    program_transform_name=$ac_optarg ;;
 
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil)
@@ -295,7 +543,7 @@ EOF
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
   | --sbi=* | --sb=*)
-    sbindir="$ac_optarg" ;;
+    sbindir=$ac_optarg ;;
 
   -sharedstatedir | --sharedstatedir | --sharedstatedi \
   | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
@@ -306,58 +554,57 @@ EOF
   | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
   | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
   | --sha=* | --sh=*)
-    sharedstatedir="$ac_optarg" ;;
+    sharedstatedir=$ac_optarg ;;
 
   -site | --site | --sit)
     ac_prev=site ;;
   -site=* | --site=* | --sit=*)
-    site="$ac_optarg" ;;
+    site=$ac_optarg ;;
 
   -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
     ac_prev=srcdir ;;
   -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
-    srcdir="$ac_optarg" ;;
+    srcdir=$ac_optarg ;;
 
   -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
   | --syscon | --sysco | --sysc | --sys | --sy)
     ac_prev=sysconfdir ;;
   -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
   | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
-    sysconfdir="$ac_optarg" ;;
+    sysconfdir=$ac_optarg ;;
 
   -target | --target | --targe | --targ | --tar | --ta | --t)
-    ac_prev=target ;;
+    ac_prev=target_alias ;;
   -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
-    target="$ac_optarg" ;;
+    target_alias=$ac_optarg ;;
 
   -v | -verbose | --verbose | --verbos | --verbo | --verb)
     verbose=yes ;;
 
-  -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.13"
-    exit 0 ;;
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
 
   -with-* | --with-*)
-    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
-      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
-    fi
+    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
     ac_package=`echo $ac_package| sed 's/-/_/g'`
-    case "$ac_option" in
-      *=*) ;;
+    case $ac_option in
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
-    eval "with_${ac_package}='$ac_optarg'" ;;
+    eval "with_$ac_package='$ac_optarg'" ;;
 
   -without-* | --without-*)
-    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
-      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
-    fi
-    ac_package=`echo $ac_package| sed 's/-/_/g'`
-    eval "with_${ac_package}=no" ;;
+    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package | sed 's/-/_/g'`
+    eval "with_$ac_package=no" ;;
 
   --x)
     # Obsolete; use --with-x.
@@ -368,99 +615,110 @@ EOF
     ac_prev=x_includes ;;
   -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
   | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
-    x_includes="$ac_optarg" ;;
+    x_includes=$ac_optarg ;;
 
   -x-libraries | --x-libraries | --x-librarie | --x-librari \
   | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
     ac_prev=x_libraries ;;
   -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
-    x_libraries="$ac_optarg" ;;
+    x_libraries=$ac_optarg ;;
 
-  -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+  -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; }
     ;;
 
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+   { (exit 1); exit 1; }; }
+    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+    eval "$ac_envvar='$ac_optarg'"
+    export $ac_envvar ;;
+
   *)
-    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
-      echo "configure: warning: $ac_option: invalid host type" 1>&2
-    fi
-    if test "x$nonopt" != xNONE; then
-      { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
-    fi
-    nonopt="$ac_option"
+    # FIXME: should be removed in autoconf 3.0.
+    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
     ;;
 
   esac
 done
 
 if test -n "$ac_prev"; then
-  { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
-  exec 6>/dev/null
-else
-  exec 6>&1
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  { echo "$as_me: error: missing argument to $ac_option" >&2
+   { (exit 1); exit 1; }; }
 fi
-exec 5>./config.log
 
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+  eval ac_val=$`echo $ac_var`
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; };;
+  esac
+done
 
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+             localstatedir libdir includedir oldincludedir infodir mandir
 do
-  case "$ac_arg" in
-  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c) ;;
-  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
-  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
-  *" "*|*"     "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
-  ac_configure_args="$ac_configure_args '$ac_arg'" ;;
-  *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+  eval ac_val=$`echo $ac_var`
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* ) ;;
+    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; };;
   esac
 done
 
-# NLS nuisances.
-# Only set these to C if already set.  These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
 
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
 
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=mtx.c
 
 # Find the source files, if location was not specified.
 if test -z "$srcdir"; then
   ac_srcdir_defaulted=yes
   # Try the directory containing this script, then its parent.
-  ac_prog=$0
-  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
-  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+  ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$0" : 'X\(//\)[^/]' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| \
+        .     : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+         /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+         /^X\(\/\/\)$/{ s//\1/; q; }
+         /^X\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
   srcdir=$ac_confdir
   if test ! -r $srcdir/$ac_unique_file; then
     srcdir=..
@@ -470,13 +728,459 @@ else
 fi
 if test ! -r $srcdir/$ac_unique_file; then
   if test "$ac_srcdir_defaulted" = yes; then
-    { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+   { (exit 1); exit 1; }; }
   else
-    { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+   { (exit 1); exit 1; }; }
   fi
 fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+  { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+   { (exit 1); exit 1; }; }
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+_ACEOF
+
+  cat <<_ACEOF
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                         [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                         [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR           user executables [EPREFIX/bin]
+  --sbindir=DIR          system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR       program executables [EPREFIX/libexec]
+  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
+  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
+  --libdir=DIR           object code libraries [EPREFIX/lib]
+  --includedir=DIR       C header files [PREFIX/include]
+  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
+  --infodir=DIR          info documentation [PREFIX/info]
+  --mandir=DIR           man documentation [PREFIX/man]
+_ACEOF
+
+  cat <<\_ACEOF
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
+  --target=TARGET   configure for building compilers for TARGET [HOST]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+  cat <<\_ACEOF
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
+              headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+_ACEOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  ac_popdir=`pwd`
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d $ac_dir || continue
+    ac_builddir=.
+
+if test "$ac_dir" != .; then
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A "../" for each directory in $ac_dir_suffix.
+  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+  ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+  .)  # No --srcdir option.  We are building in place.
+    ac_srcdir=.
+    if test -z "$ac_top_builddir"; then
+       ac_top_srcdir=.
+    else
+       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+    fi ;;
+  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir ;;
+  *) # Relative path.
+    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+  case "$ac_dir" in
+  .) ac_abs_builddir=`pwd`;;
+  [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+  *) ac_abs_builddir=`pwd`/"$ac_dir";;
+  esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+  case ${ac_top_builddir}. in
+  .) ac_abs_top_builddir=$ac_abs_builddir;;
+  [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+  *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+  esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+  case $ac_srcdir in
+  .) ac_abs_srcdir=$ac_abs_builddir;;
+  [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+  *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+  esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+  case $ac_top_srcdir in
+  .) ac_abs_top_srcdir=$ac_abs_builddir;;
+  [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+  *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+  esac;;
+esac
+
+    cd $ac_dir
+    # Check for guested configure; otherwise get Cygnus style configure.
+    if test -f $ac_srcdir/configure.gnu; then
+      echo
+      $SHELL $ac_srcdir/configure.gnu  --help=recursive
+    elif test -f $ac_srcdir/configure; then
+      echo
+      $SHELL $ac_srcdir/configure  --help=recursive
+    elif test -f $ac_srcdir/configure.ac ||
+          test -f $ac_srcdir/configure.in; then
+      echo
+      $ac_configure --help
+    else
+      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi
+    cd $ac_popdir
+  done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+  cat <<\_ACEOF
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit 0
+fi
+exec 5>config.log
+cat >&5 <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.59.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  echo "PATH: $as_dir"
+done
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_sep=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *" "*|*"   "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+      ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+    2)
+      ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+       ac_must_keep_next=false # Got value, back to normal.
+      else
+       case $ac_arg in
+         *=* | --config-cache | -C | -disable-* | --disable-* \
+         | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+         | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+         | -with-* | --with-* | -without-* | --without-* | --x)
+           case "$ac_configure_args0 " in
+             "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+           esac
+           ;;
+         -* ) ac_must_keep_next=true ;;
+       esac
+      fi
+      ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+      # Get rid of the leading space.
+      ac_sep=" "
+      ;;
+    esac
+  done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+{
+  (set) 2>&1 |
+    case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+    *ac_space=\ *)
+      sed -n \
+       "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+      ;;
+    *)
+      sed -n \
+       "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+}
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=$`echo $ac_var`
+      echo "$ac_var='"'"'$ac_val'"'"'"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+       eval ac_val=$`echo $ac_var`
+       echo "$ac_var='"'"'$ac_val'"'"'"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      sed "/^$/d" confdefs.h | sort
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      echo "$as_me: caught signal $ac_signal"
+    echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core &&
+  rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+     ' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
 
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
 # Prefer explicitly selected file to automatically selected ones.
 if test -z "$CONFIG_SITE"; then
   if test "x$prefix" != xNONE; then
@@ -487,43 +1191,108 @@ if test -z "$CONFIG_SITE"; then
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
-    echo "loading site script $ac_site_file"
+    { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
     . "$ac_site_file"
   fi
 done
 
 if test -r "$cache_file"; then
-  echo "loading cache $cache_file"
-  . $cache_file
+  # Some versions of bash will fail to source /dev/null (special
+  # files actually), so we avoid doing that.
+  if test -f "$cache_file"; then
+    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . $cache_file;;
+      *)                      . ./$cache_file;;
+    esac
+  fi
 else
-  echo "creating cache $cache_file"
-  > $cache_file
+  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
 fi
 
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-ac_exeext=
-ac_objext=o
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
-  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
-  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
-    ac_n= ac_c='
-' ac_t='       '
-  else
-    ac_n=-n ac_c= ac_t=
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+              sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+  eval ac_new_val="\$ac_env_${ac_var}_value"
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+       { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+       { echo "$as_me:$LINENO:   former value:  $ac_old_val" >&5
+echo "$as_me:   former value:  $ac_old_val" >&2;}
+       { echo "$as_me:$LINENO:   current value: $ac_new_val" >&5
+echo "$as_me:   current value: $ac_new_val" >&2;}
+       ac_cache_corrupted=:
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *" "*|*"   "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+      ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+    esac
   fi
-else
-  ac_n= ac_c='\c' ac_t=
+done
+if $ac_cache_corrupted; then
+  { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+   { (exit 1); exit 1; }; }
 fi
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+          ac_config_headers="$ac_config_headers config.h"
+
+
 ac_aux_dir=
 for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
   if test -f $ac_dir/install-sh; then
@@ -534,116 +1303,115 @@ for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/install.sh -c"
     break
+  elif test -f $ac_dir/shtool; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
   fi
 done
 if test -z "$ac_aux_dir"; then
-  { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+   { (exit 1); exit 1; }; }
 fi
-ac_config_guess=$ac_aux_dir/config.guess
-ac_config_sub=$ac_aux_dir/config.sub
-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
 
+# Make sure we can run config.sub.
+$ac_config_sub sun4 >/dev/null 2>&1 ||
+  { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
+echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+   { (exit 1); exit 1; }; }
+
+echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6
+if test "${ac_cv_build+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+  ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+  { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+   { (exit 1); exit 1; }; }
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
 
-# Do some error checking and defaulting for the host and target type.
-# The inputs are:
-#    configure --host=HOST --target=TARGET --build=BUILD NONOPT
-#
-# The rules are:
-# 1. You are not allowed to specify --host, --target, and nonopt at the
-#    same time.
-# 2. Host defaults to nonopt.
-# 3. If nonopt is not specified, then host defaults to the current host,
-#    as determined by config.guess.
-# 4. Target and build default to nonopt.
-# 5. If nonopt is not specified, then target and build default to host.
-
-# The aliases save the names the user supplied, while $host etc.
-# will get canonicalized.
-case $host---$target---$nonopt in
-NONE---*---* | *---NONE---* | *---*---NONE) ;;
-*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
-esac
-
+fi
+echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6
+build=$ac_cv_build
+build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6
+if test "${ac_cv_host+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+  ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
 
-# Make sure we can run config.sub.
-if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
-else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
+echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6
+host=$ac_cv_host
+host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking target system type" >&5
+echo $ECHO_N "checking target system type... $ECHO_C" >&6
+if test "${ac_cv_target+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_target_alias=$target_alias
+test "x$ac_cv_target_alias" = "x" &&
+  ac_cv_target_alias=$ac_cv_host_alias
+ac_cv_target=`$ac_config_sub $ac_cv_target_alias` ||
+  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
 
-echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:575: checking host system type" >&5
+fi
+echo "$as_me:$LINENO: result: $ac_cv_target" >&5
+echo "${ECHO_T}$ac_cv_target" >&6
+target=$ac_cv_target
+target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 
-host_alias=$host
-case "$host_alias" in
-NONE)
-  case $nonopt in
-  NONE)
-    if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
-    else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
-    fi ;;
-  *) host_alias=$nonopt ;;
-  esac ;;
-esac
 
-host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
-host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$host" 1>&6
-
-echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:596: checking target system type" >&5
-
-target_alias=$target
-case "$target_alias" in
-NONE)
-  case $nonopt in
-  NONE) target_alias=$host_alias ;;
-  *) target_alias=$nonopt ;;
-  esac ;;
-esac
-
-target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
-target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$target" 1>&6
-
-echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:614: checking build system type" >&5
-
-build_alias=$build
-case "$build_alias" in
-NONE)
-  case $nonopt in
-  NONE) build_alias=$host_alias ;;
-  *) build_alias=$nonopt ;;
-  esac ;;
-esac
-
-build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
-build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$build" 1>&6
-
-test "$host_alias" != "$target_alias" &&
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+test -n "$target_alias" &&
   test "$program_prefix$program_suffix$program_transform_name" = \
     NONENONEs,x,x, &&
   program_prefix=${target_alias}-
 
 
-
 case "$host_os" in
-  *linux*) cat >> confdefs.h <<\EOF
+  *linux*) cat >>confdefs.h <<\_ACEOF
 #define LINUX 1
-EOF
+_ACEOF
 
        TARGET=linux
     ;;
-  *solaris*) cat >> confdefs.h <<\EOF
+  *solaris*) cat >>confdefs.h <<\_ACEOF
 #define SOLARIS 1
-EOF
+_ACEOF
 
        TARGET=solarissparc
        ;;
@@ -651,23 +1419,31 @@ EOF
         ;;
   *freebsd*) TARGET=freebsd86
        ;;
+  *aix*) TARGET=aix
+       ;;
   *irix*) TARGET=sgi
       ;;
   *hp*) TARGET=hpux
      ;;
   *HP*) TARGET=hpux
      ;;
-  *sequent*) cat >> confdefs.h <<\EOF
+  *sequent*) cat >>confdefs.h <<\_ACEOF
 #define SEQUENT 1
-EOF
+_ACEOF
+
        ;;
+  *MINGW*) TARGET=mingw
+     ;;
+  *MinGW*) TARGET=mingw
+     ;;
+  *mingw*) TARGET=mingw
+     ;;
   *) TARGET=$host_os
      ;;
 esac
 
 case "$host_cpu" in
-  # force us down to '386 if we're on some other machine. 
+  # force us down to '386 if we're on some other machine.
  *?86*) host_cpu='i386'
        CPU=386
        ;;
@@ -678,214 +1454,659 @@ esac
 
 
 
-# Extract the first word of "gcc", so it can be a program name with args.
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:685: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CC="gcc"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
 fi
 fi
-CC="$ac_cv_prog_CC"
+CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$ac_t""$CC" 1>&6
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$ac_t""no" 1>&6
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+fi
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:715: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
-        ac_prog_rejected=yes
-       continue
-      fi
-      ac_cv_prog_CC="cc"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
 if test $ac_prog_rejected = yes; then
   # We found a bogon in the path, so make sure we never use it.
   set dummy $ac_cv_prog_CC
   shift
-  if test $# -gt 0; then
+  if test $# != 0; then
     # We chose a different compiler from the bogus one.
     # However, it has the same basename, so the bogon will be chosen
     # first if we set CC to just the basename; use the full file name.
     shift
-    set dummy "$ac_dir/$ac_word" "$@"
-    shift
-    ac_cv_prog_CC="$@"
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
   fi
 fi
 fi
 fi
-CC="$ac_cv_prog_CC"
+CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$ac_t""$CC" 1>&6
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
 else
-  echo "$ac_t""no" 1>&6
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
-  if test -z "$CC"; then
-    case "`uname -s`" in
-    *win32* | *WIN32*)
-      # Extract the first word of "cl", so it can be a program name with args.
-set dummy cl; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:766: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CC="cl"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
 fi
 fi
-CC="$ac_cv_prog_CC"
+CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$ac_t""$CC" 1>&6
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
 else
-  echo "$ac_t""no" 1>&6
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
- ;;
-    esac
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl
+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 "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
   fi
-  test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:798: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+  test -n "$ac_ct_CC" && break
+done
 
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-cat > conftest.$ac_ext << EOF
-
-#line 809 "configure"
-#include "confdefs.h"
-
-main(){return(0);}
-EOF
-if { (eval echo configure:814: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  ac_cv_prog_cc_works=yes
-  # If we can't run a trivial program, we are probably using a cross compiler.
-  if (./conftest; exit) 2>/dev/null; then
-    ac_cv_prog_cc_cross=no
+  CC=$ac_ct_CC
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+     "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+  (eval $ac_compiler --version </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+  (eval $ac_compiler -v </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+  (eval $ac_compiler -V </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
+  (eval $ac_link_default) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Find the output, starting from the most likely.  This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+       ;;
+    conftest.$ac_ext )
+       # This is the source file.
+       ;;
+    [ab].out )
+       # We found the default executable, but exeext='' is most
+       # certainly right.
+       break;;
+    *.* )
+       ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+       # FIXME: I believe we export ac_cv_exeext for Libtool,
+       # but it would be cool to find out if it's true.  Does anybody
+       # maintain Libtool? --akim.
+       export ac_cv_exeext
+       break;;
+    * )
+       break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+  if { ac_try='./$ac_file'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+    cross_compiling=no
   else
-    ac_cv_prog_cc_cross=yes
+    if test "$cross_compiling" = maybe; then
+       cross_compiling=yes
+    else
+       { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+    fi
   fi
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_cv_prog_cc_works=no
 fi
-rm -fr conftest*
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
-if test $ac_cv_prog_cc_works = no; then
-  { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
-fi
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:840: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
-echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:845: checking whether we are using GNU C" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.c <<EOF
-#ifdef __GNUC__
-  yes;
-#endif
-EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:854: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
-  ac_cv_prog_gcc=yes
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+         export ac_cv_exeext
+         break;;
+    * ) break;;
+  esac
+done
 else
-  ac_cv_prog_gcc=no
-fi
+  { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 fi
 
-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+rm -f conftest$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
 
-if test $ac_cv_prog_gcc = yes; then
-  GCC=yes
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
 else
-  GCC=
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 fi
 
-ac_test_CFLAGS="${CFLAGS+set}"
-ac_save_CFLAGS="$CFLAGS"
-CFLAGS=
-echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:873: checking whether ${CC-cc} accepts -g" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
-  ac_cv_prog_cc_g=yes
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_compiler_gnu=yes
 else
-  ac_cv_prog_cc_g=no
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
 if test "$ac_test_CFLAGS" = set; then
-  CFLAGS="$ac_save_CFLAGS"
+  CFLAGS=$ac_save_CFLAGS
 elif test $ac_cv_prog_cc_g = yes; then
   if test "$GCC" = yes; then
     CFLAGS="-g -O2"
@@ -899,6 +2120,269 @@ else
     CFLAGS=
   fi
 fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std1 is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std1.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX                  -qlanglvl=ansi
+# Ultrix and OSF/1     -std1
+# HP-UX 10.20 and later        -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4                 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+  x|xno)
+    echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+  *)
+    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+    CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+# Some people use a C++ compiler to compile C.  Since we use `exit',
+# in C++ we need to declare it.  In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+  choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  for ac_declaration in \
+   '' \
+   'extern "C" void std::exit (int) throw (); using std::exit;' \
+   'extern "C" void std::exit (int); using std::exit;' \
+   'extern "C" void exit (int) throw ();' \
+   'extern "C" void exit (int);' \
+   'void exit (int);'
+do
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_declaration
+#include <stdlib.h>
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+  echo '#ifdef __cplusplus' >>confdefs.h
+  echo $ac_declaration      >>confdefs.h
+  echo '#endif'             >>confdefs.h
+fi
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
 # SunOS /usr/etc/install
 # IRIX /sbin/install
 # AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
 # ./install, which can be erroneously created by make from ./install.sh.
-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:916: checking for a BSD compatible install" >&5
+echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
 if test -z "$INSTALL"; then
-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-    IFS="${IFS=        }"; ac_save_IFS="$IFS"; IFS=":"
-  for ac_dir in $PATH; do
-    # Account for people who put trailing slashes in PATH elements.
-    case "$ac_dir/" in
-    /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
-    *)
-      # OSF1 and SCO ODT 3.0 have their own names for install.
-      # Don't use installbsd from OSF since it installs stuff as root
-      # by default.
-      for ac_prog in ginstall scoinst install; do
-        if test -f $ac_dir/$ac_prog; then
+if test "${ac_cv_path_install+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+  ./ | .// | /cC/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+       if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
          if test $ac_prog = install &&
-            grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
            # AIX install.  It has an incompatible calling convention.
            :
+         elif test $ac_prog = install &&
+           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
          else
-           ac_cv_path_install="$ac_dir/$ac_prog -c"
-           break 2
+           ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+           break 3
          fi
        fi
       done
-      ;;
-    esac
-  done
-  IFS="$ac_save_IFS"
+    done
+    ;;
+esac
+done
+
 
 fi
   if test "${ac_cv_path_install+set}" = set; then
-    INSTALL="$ac_cv_path_install"
+    INSTALL=$ac_cv_path_install
   else
     # As a last resort, use the slow shell script.  We don't cache a
     # path for INSTALL within a source directory, because that will
     # break other packages using the cache if that directory is
     # removed, or if the path is relative.
-    INSTALL="$ac_install_sh"
+    INSTALL=$ac_install_sh
   fi
 fi
-echo "$ac_t""$INSTALL" 1>&6
+echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
 # It thinks the first close brace ends the variable substitution.
 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
 
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
 
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
+# Extract the first word of "objcopy", so it can be a program name with args.
+set dummy objcopy; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_USE_OBJCOPY+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$USE_OBJCOPY"; then
+  ac_cv_prog_USE_OBJCOPY="$USE_OBJCOPY" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_USE_OBJCOPY="yes"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_prog_USE_OBJCOPY" && ac_cv_prog_USE_OBJCOPY="no"
+fi
+fi
+USE_OBJCOPY=$ac_cv_prog_USE_OBJCOPY
+if test -n "$USE_OBJCOPY"; then
+  echo "$as_me:$LINENO: result: $USE_OBJCOPY" >&5
+echo "${ECHO_T}$USE_OBJCOPY" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
 
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:970: checking how to run the C preprocessor" >&5
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
 # 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
+  if test "${ac_cv_prog_CPP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&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"
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
   # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp.
-  cat > conftest.$ac_ext <<EOF
-#line 985 "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:991: \"$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
-  :
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
 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 1002 "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:1008: \"$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
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_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 1019 "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:1025: \"$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
-  :
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
 else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  CPP=/lib/cpp
+  ac_cpp_err=yes
 fi
-rm -f conftest*
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  break
 fi
-rm -f conftest*
-  ac_cv_prog_CPP="$CPP"
+
+    done
+    ac_cv_prog_CPP=$CPP
+
 fi
-  CPP="$ac_cv_prog_CPP"
+  CPP=$ac_cv_prog_CPP
 else
-  ac_cv_prog_CPP="$CPP"
+  ac_cv_prog_CPP=$CPP
 fi
-echo "$ac_t""$CPP" 1>&6
-
-echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1050: 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
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1055 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
+else
+  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <float.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1063: \"$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*
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_header_stdc=yes
 else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_cv_header_stdc=no
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 
 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 1080 "configure"
-#include "confdefs.h"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <string.h>
-EOF
+
+_ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "memchr" >/dev/null 2>&1; then
+  $EGREP "memchr" >/dev/null 2>&1; then
   :
 else
-  rm -rf conftest*
   ac_cv_header_stdc=no
 fi
 rm -f conftest*
@@ -1093,16 +2829,19 @@ fi
 
 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 1098 "configure"
-#include "confdefs.h"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <stdlib.h>
-EOF
+
+_ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "free" >/dev/null 2>&1; then
+  $EGREP "free" >/dev/null 2>&1; then
   :
 else
-  rm -rf conftest*
   ac_cv_header_stdc=no
 fi
 rm -f conftest*
 
 if test $ac_cv_header_stdc = yes; then
   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-if test "$cross_compiling" = yes; then
+  if test "$cross_compiling" = yes; then
   :
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1119 "configure"
-#include "confdefs.h"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <ctype.h>
-#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int main () { int i; for (i = 0; i < 256; i++)
-if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
-exit (0); }
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
 
-EOF
-if { (eval echo configure:1130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      exit(2);
+  exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   :
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  ac_cv_header_stdc=no
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
 fi
-rm -fr conftest*
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-
 fi
 fi
-
-echo "$ac_t""$ac_cv_header_stdc" 1>&6
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
 if test $ac_cv_header_stdc = yes; then
-  cat >> confdefs.h <<\EOF
+
+cat >>confdefs.h <<\_ACEOF
 #define STDC_HEADERS 1
-EOF
+_ACEOF
 
 fi
 
-for ac_hdr in \
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                 inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+for ac_header in \
        unistd.h \
        stdlib.h \
        errno.h \
@@ -1159,10 +3028,11 @@ for ac_hdr in \
        scsi/scsi.h \
        scsi/scsi_ioctl.h \
        scsi/sg.h \
+       sys/gscdds.h \
        camlib.h \
        cam/cam_ccb.h \
        cam/scsi/scsi_message.h \
-        sys/fsid.h \
+       sys/fsid.h \
        sys/fstyp.h \
        sys/stat.h \
        sys/types.h \
@@ -1173,393 +3043,1531 @@ for ac_hdr in \
        sys/scsi.h \
        sys/scsi_ctl.h \
        sys/ioctl.h \
+       sys/mtio.h \
+       sys/param.h \
        dslib.h \
-       du/defs.h
+       du/defs.h \
+       ddk/ntddscsi.h
 do
-ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1182: 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 1187 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1192: \"$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*
-  eval "ac_cv_header_$ac_safe=no"
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 fi
-rm -f conftest*
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
 fi
-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
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
 else
-  echo "$ac_t""no" 1>&6
+  ac_cpp_err=yes
 fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to the AC_PACKAGE_NAME lists.  ##
+## ------------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
 done
 
 
-echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1220: 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 1225 "configure"
-#include "confdefs.h"
-
-int main() {
-
-/* Ultrix mips cc rejects this.  */
-typedef int charset[2]; const charset x;
-/* SunOS 4.1.1 cc rejects this.  */
-char const *const *ccp;
-char **p;
-/* NEC SVR4.0.2 mips cc rejects this.  */
-struct point {int x, y;};
-static struct point const zero = {0,0};
-/* AIX XL C 1.02.0.0 rejects this.
-   It does not let you subtract one const X* pointer from another in an arm
-   of an if-expression whose if-part is not a constant expression */
-const char *g = "string";
-ccp = &g + (g ? g-g : 0);
-/* HPUX 7.0 cc rejects these. */
-++ccp;
-p = (char**) ccp;
-ccp = (char const *const *) p;
-{ /* SCO 3.2v4 cc rejects this.  */
-  char *t;
-  char const *s = 0 ? (char *) 0 : (char const *) 0;
-
-  *t++ = 0;
-}
-{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
-  int x[] = {25, 17};
-  const int *foo = &x[0];
-  ++foo;
-}
-{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
-  typedef const int *iptr;
-  iptr p = 0;
-  ++p;
-}
-{ /* AIX XL C 1.02.0.0 rejects this saying
-     "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
-  struct s { int j; const int *ap[3]; };
-  struct s *b; b->j = 5;
-}
-{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
-  const int foo = 10;
-}
+echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+if test "${ac_cv_c_const+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this.  */
+  typedef int charset[2];
+  const charset x;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *ccp;
+  char **p;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  ccp = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++ccp;
+  p = (char**) ccp;
+  ccp = (char const *const *) p;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+  }
+#endif
 
-; return 0; }
-EOF
-if { (eval echo configure:1274: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_c_const=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_cv_c_const=no
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_const=no
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-
-echo "$ac_t""$ac_cv_c_const" 1>&6
+echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6
 if test $ac_cv_c_const = no; then
-  cat >> confdefs.h <<\EOF
-#define const 
-EOF
+
+cat >>confdefs.h <<\_ACEOF
+#define const
+_ACEOF
 
 fi
 
-echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:1295: 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
+echo "$as_me:$LINENO: checking for size_t" >&5
+echo $ECHO_N "checking for size_t... $ECHO_C" >&6
+if test "${ac_cv_type_size_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1300 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
-  rm -rf conftest*
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((size_t *) 0)
+  return 0;
+if (sizeof (size_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_type_size_t=yes
 else
-  rm -rf conftest*
-  ac_cv_type_size_t=no
-fi
-rm -f conftest*
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+ac_cv_type_size_t=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$ac_t""$ac_cv_type_size_t" 1>&6
-if test $ac_cv_type_size_t = no; then
-  cat >> confdefs.h <<\EOF
+echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
+echo "${ECHO_T}$ac_cv_type_size_t" >&6
+if test $ac_cv_type_size_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
 #define size_t unsigned
-EOF
+_ACEOF
 
 fi
 
-echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:1328: 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
+echo "$as_me:$LINENO: checking for pid_t" >&5
+echo $ECHO_N "checking for pid_t... $ECHO_C" >&6
+if test "${ac_cv_type_pid_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1333 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  egrep "(^|[^a-zA-Z_0-9])pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
-  rm -rf conftest*
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((pid_t *) 0)
+  return 0;
+if (sizeof (pid_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_type_pid_t=yes
 else
-  rm -rf conftest*
-  ac_cv_type_pid_t=no
-fi
-rm -f conftest*
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+ac_cv_type_pid_t=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$ac_t""$ac_cv_type_pid_t" 1>&6
-if test $ac_cv_type_pid_t = no; then
-  cat >> confdefs.h <<\EOF
+echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5
+echo "${ECHO_T}$ac_cv_type_pid_t" >&6
+if test $ac_cv_type_pid_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
 #define pid_t int
-EOF
+_ACEOF
 
 fi
-       
-echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1361: 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
+
+echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
+echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
+if test "${ac_cv_header_time+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1366 "configure"
-#include "confdefs.h"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <sys/types.h>
 #include <sys/time.h>
 #include <time.h>
-int main() {
-struct tm *tp;
-; return 0; }
-EOF
-if { (eval echo configure:1375: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_header_time=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_cv_header_time=no
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_time=no
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-
-echo "$ac_t""$ac_cv_header_time" 1>&6
+echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
+echo "${ECHO_T}$ac_cv_header_time" >&6
 if test $ac_cv_header_time = yes; then
-  cat >> confdefs.h <<\EOF
+
+cat >>confdefs.h <<\_ACEOF
 #define TIME_WITH_SYS_TIME 1
-EOF
+_ACEOF
 
 fi
 
-echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:1396: checking whether struct tm is in sys/time.h or time.h" >&5
-if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5
+echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6
+if test "${ac_cv_struct_tm+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1401 "configure"
-#include "confdefs.h"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <sys/types.h>
 #include <time.h>
-int main() {
+
+int
+main ()
+{
 struct tm *tp; tp->tm_sec;
-; return 0; }
-EOF
-if { (eval echo configure:1409: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_struct_tm=time.h
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_cv_struct_tm=sys/time.h
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_struct_tm=sys/time.h
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-
-echo "$ac_t""$ac_cv_struct_tm" 1>&6
+echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5
+echo "${ECHO_T}$ac_cv_struct_tm" >&6
 if test $ac_cv_struct_tm = sys/time.h; then
-  cat >> confdefs.h <<\EOF
+
+cat >>confdefs.h <<\_ACEOF
 #define TM_IN_SYS_TIME 1
-EOF
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for int" >&5
+echo $ECHO_N "checking for int... $ECHO_C" >&6
+if test "${ac_cv_type_int+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((int *) 0)
+  return 0;
+if (sizeof (int))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_int=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_int=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5
+echo "${ECHO_T}$ac_cv_type_int" >&6
+
+echo "$as_me:$LINENO: checking size of int" >&5
+echo $ECHO_N "checking size of int... $ECHO_C" >&6
+if test "${ac_cv_sizeof_int+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$ac_cv_type_int" = yes; then
+  # The cast to unsigned long works around a bug in the HP C Compiler
+  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+  # This bug is HP SR number 8606223364.
+  if test "$cross_compiling" = yes; then
+  # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+                   if test $ac_lo -le $ac_mid; then
+                     ac_lo= ac_hi=
+                     break
+                   fi
+                   ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+                      if test $ac_mid -le $ac_hi; then
+                        ac_lo= ac_hi=
+                        break
+                      fi
+                      ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+ac_lo= ac_hi=
 fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)];
+test_array [0] = 0
 
-echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:1430: checking size of int" >&5
-if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_int=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; } ;;
+esac
 else
   if test "$cross_compiling" = yes; then
-    { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1438 "configure"
-#include "confdefs.h"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+long longval () { return (long) (sizeof (int)); }
+unsigned long ulongval () { return (long) (sizeof (int)); }
 #include <stdio.h>
-main()
+#include <stdlib.h>
+int
+main ()
 {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  fprintf(f, "%d\n", sizeof(int));
-  exit(0);
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    exit (1);
+  if (((long) (sizeof (int))) < 0)
+    {
+      long i = longval ();
+      if (i != ((long) (sizeof (int))))
+       exit (1);
+      fprintf (f, "%ld\n", i);
+    }
+  else
+    {
+      unsigned long i = ulongval ();
+      if (i != ((long) (sizeof (int))))
+       exit (1);
+      fprintf (f, "%lu\n", i);
+    }
+  exit (ferror (f) || fclose (f) != 0);
+
+  ;
+  return 0;
 }
-EOF
-if { (eval echo configure:1449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
-  ac_cv_sizeof_int=`cat conftestval`
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sizeof_int=`cat conftest.val`
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
   ac_cv_sizeof_int=0
 fi
-rm -fr conftest*
 fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5
+echo "${ECHO_T}$ac_cv_sizeof_int" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+_ACEOF
+
 
+echo "$as_me:$LINENO: checking for long" >&5
+echo $ECHO_N "checking for long... $ECHO_C" >&6
+if test "${ac_cv_type_long+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((long *) 0)
+  return 0;
+if (sizeof (long))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_long=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_long=no
 fi
-echo "$ac_t""$ac_cv_sizeof_int" 1>&6
-cat >> confdefs.h <<EOF
-#define SIZEOF_INT $ac_cv_sizeof_int
-EOF
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5
+echo "${ECHO_T}$ac_cv_type_long" >&6
 
+echo "$as_me:$LINENO: checking size of long" >&5
+echo $ECHO_N "checking size of long... $ECHO_C" >&6
+if test "${ac_cv_sizeof_long+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$ac_cv_type_long" = yes; then
+  # The cast to unsigned long works around a bug in the HP C Compiler
+  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+  # This bug is HP SR number 8606223364.
+  if test "$cross_compiling" = yes; then
+  # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)];
+test_array [0] = 0
 
-echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:1469: checking size of long" >&5
-if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+                   if test $ac_lo -le $ac_mid; then
+                     ac_lo= ac_hi=
+                     break
+                   fi
+                   ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+                      if test $ac_mid -le $ac_hi; then
+                        ac_lo= ac_hi=
+                        break
+                      fi
+                      ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_long=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; } ;;
+esac
 else
   if test "$cross_compiling" = yes; then
-    { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1477 "configure"
-#include "confdefs.h"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+long longval () { return (long) (sizeof (long)); }
+unsigned long ulongval () { return (long) (sizeof (long)); }
 #include <stdio.h>
-main()
+#include <stdlib.h>
+int
+main ()
 {
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  fprintf(f, "%d\n", sizeof(long));
-  exit(0);
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    exit (1);
+  if (((long) (sizeof (long))) < 0)
+    {
+      long i = longval ();
+      if (i != ((long) (sizeof (long))))
+       exit (1);
+      fprintf (f, "%ld\n", i);
+    }
+  else
+    {
+      unsigned long i = ulongval ();
+      if (i != ((long) (sizeof (long))))
+       exit (1);
+      fprintf (f, "%lu\n", i);
+    }
+  exit (ferror (f) || fclose (f) != 0);
+
+  ;
+  return 0;
 }
-EOF
-if { (eval echo configure:1488: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
-  ac_cv_sizeof_long=`cat conftestval`
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  ac_cv_sizeof_long=0
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sizeof_long=`cat conftest.val`
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
 fi
-rm -fr conftest*
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+  ac_cv_sizeof_long=0
 fi
-
 fi
-echo "$ac_t""$ac_cv_sizeof_long" 1>&6
-cat >> confdefs.h <<EOF
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5
+echo "${ECHO_T}$ac_cv_sizeof_long" >&6
+cat >>confdefs.h <<_ACEOF
 #define SIZEOF_LONG $ac_cv_sizeof_long
-EOF
+_ACEOF
 
 
-echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:1508: checking whether byte ordering is bigendian" >&5
-if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
+echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6
+if test "${ac_cv_c_bigendian+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_cv_c_bigendian=unknown
-# See if sys/param.h defines the BYTE_ORDER macro.
-cat > conftest.$ac_ext <<EOF
-#line 1515 "configure"
-#include "confdefs.h"
+  # See if sys/param.h defines the BYTE_ORDER macro.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <sys/types.h>
 #include <sys/param.h>
-int main() {
 
+int
+main ()
+{
 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
  bogus endian macros
 #endif
-; return 0; }
-EOF
-if { (eval echo configure:1526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   # It does; now see whether it defined to BIG_ENDIAN or not.
-cat > conftest.$ac_ext <<EOF
-#line 1530 "configure"
-#include "confdefs.h"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <sys/types.h>
 #include <sys/param.h>
-int main() {
 
+int
+main ()
+{
 #if BYTE_ORDER != BIG_ENDIAN
  not big endian
 #endif
-; return 0; }
-EOF
-if { (eval echo configure:1541: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_c_bigendian=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_cv_c_bigendian=no
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_bigendian=no
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-fi
-rm -f conftest*
-if test $ac_cv_c_bigendian = unknown; then
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+# It does not; compile a test program.
 if test "$cross_compiling" = yes; then
-    { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+  # try to guess the endianness by grepping values into an object file
+  ac_cv_c_bigendian=unknown
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
+short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }
+int
+main ()
+{
+ _ascii (); _ebcdic ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
+  ac_cv_c_bigendian=yes
+fi
+if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+  if test "$ac_cv_c_bigendian" = unknown; then
+    ac_cv_c_bigendian=no
+  else
+    # finding both strings is unlikely to happen, but who knows?
+    ac_cv_c_bigendian=unknown
+  fi
+fi
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1561 "configure"
-#include "confdefs.h"
-main () {
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+int
+main ()
+{
   /* Are we little or big endian?  From Harbison&Steele.  */
   union
   {
@@ -1569,46 +4577,70 @@ main () {
   u.l = 1;
   exit (u.c[sizeof (long) - 1] == 1);
 }
-EOF
-if { (eval echo configure:1574: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_c_bigendian=no
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  ac_cv_c_bigendian=yes
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_c_bigendian=yes
 fi
-rm -fr conftest*
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-
 fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
+echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
+echo "${ECHO_T}$ac_cv_c_bigendian" >&6
+case $ac_cv_c_bigendian in
+  yes)
 
-echo "$ac_t""$ac_cv_c_bigendian" 1>&6
-if test $ac_cv_c_bigendian = yes; then
-  cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\_ACEOF
 #define WORDS_BIGENDIAN 1
-EOF
-
-fi
+_ACEOF
+ ;;
+  no)
+     ;;
+  *)
+    { { echo "$as_me:$LINENO: error: unknown endianness
+presetting ac_cv_c_bigendian=no (or yes) will help" >&5
+echo "$as_me: error: unknown endianness
+presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
+   { (exit 1); exit 1; }; } ;;
+esac
 
 
 
 
 
-echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1602: 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
+echo "$as_me:$LINENO: checking return type of signal handlers" >&5
+echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6
+if test "${ac_cv_type_signal+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1607 "configure"
-#include "confdefs.h"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 #include <sys/types.h>
 #include <signal.h>
 #ifdef signal
-#undef signal
+# undef signal
 #endif
 #ifdef __cplusplus
 extern "C" void (*signal (int, void (*)(int)))(int);
@@ -1616,506 +4648,1385 @@ extern "C" void (*signal (int, void (*)(int)))(int);
 void (*signal ()) ();
 #endif
 
-int main() {
+int
+main ()
+{
 int i;
-; return 0; }
-EOF
-if { (eval echo configure:1624: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_type_signal=void
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_cv_type_signal=int
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_signal=int
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
+echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5
+echo "${ECHO_T}$ac_cv_type_signal" >&6
 
-echo "$ac_t""$ac_cv_type_signal" 1>&6
-cat >> confdefs.h <<EOF
+cat >>confdefs.h <<_ACEOF
 #define RETSIGTYPE $ac_cv_type_signal
-EOF
+_ACEOF
 
 
-echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:1643: checking for vprintf" >&5
-if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+
+for ac_func in vprintf
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1648 "configure"
-#include "confdefs.h"
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char vprintf(); below.  */
-#include <assert.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 vprintf();
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
 
-int main() {
+#undef $ac_func
 
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
-#if defined (__stub_vprintf) || defined (__stub___vprintf)
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
-vprintf();
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
 #endif
 
-; return 0; }
-EOF
-if { (eval echo configure:1671: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_func_vprintf=yes"
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func_vprintf=no"
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
 fi
-
-if eval "test \"`echo '$ac_cv_func_'vprintf`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  cat >> confdefs.h <<\EOF
-#define HAVE_VPRINTF 1
-EOF
-
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+echo "$as_me:$LINENO: checking for _doprnt" >&5
+echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6
+if test "${ac_cv_func__doprnt+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo "$ac_t""no" 1>&6
-fi
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define _doprnt to an innocuous variant, in case <limits.h> declares _doprnt.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define _doprnt innocuous__doprnt
 
-if test "$ac_cv_func_vprintf" != yes; then
-echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:1695: checking for _doprnt" >&5
-if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 1700 "configure"
-#include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char _doprnt(); below.  */
-#include <assert.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 _doprnt();
+    which can conflict with char _doprnt (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
 
-int main() {
+#undef _doprnt
 
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char _doprnt ();
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined (__stub__doprnt) || defined (__stub____doprnt)
 choke me
 #else
-_doprnt();
+char (*f) () = _doprnt;
+#endif
+#ifdef __cplusplus
+}
 #endif
 
-; return 0; }
-EOF
-if { (eval echo configure:1723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_func__doprnt=yes"
+int
+main ()
+{
+return f != _doprnt;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func__doprnt=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func__doprnt=no"
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func__doprnt=no
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
 fi
+echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5
+echo "${ECHO_T}$ac_cv_func__doprnt" >&6
+if test $ac_cv_func__doprnt = yes; then
 
-if eval "test \"`echo '$ac_cv_func_'_doprnt`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\_ACEOF
 #define HAVE_DOPRNT 1
-EOF
+_ACEOF
 
-else
-  echo "$ac_t""no" 1>&6
 fi
 
 fi
+done
+
 
 
 
-trap '' 1 2 15
-cat > confcache <<\EOF
+          ac_config_files="$ac_config_files Makefile"
+cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
-# scripts and configure runs.  It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
 #
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already.  You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
 #
-EOF
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
 # The following way of writing the cache mishandles newlines in values,
 # but we know of no workaround that is simple, portable, and efficient.
 # So, don't put newlines in cache variables' values.
 # Ultrix sh set writes to stderr and can't be redirected directly,
 # and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
-  case `(ac_space=' '; set | grep ac_space) 2>&1` in
-  *ac_space=\ *)
-    # `set' does not quote correctly, so add quotes (double-quote substitution
-    # turns \\\\ into \\, and sed turns \\ into \).
-    sed -n \
-      -e "s/'/'\\\\''/g" \
-      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
-    ;;
-  *)
-    # `set' quotes correctly as required by POSIX, so do not add quotes.
-    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
-    ;;
-  esac >> confcache
-if cmp -s $cache_file confcache; then
-  :
-else
+{
+  (set) 2>&1 |
+    case `(ac_space=' '; set | grep ac_space) 2>&1` in
+    *ac_space=\ *)
+      # `set' does not quote correctly, so add quotes (double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \).
+      sed -n \
+       "s/'/'\\\\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;;
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n \
+       "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+} |
+  sed '
+     t clear
+     : clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     : end' >>confcache
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
   if test -w $cache_file; then
-    echo "updating cache $cache_file"
-    cat confcache > $cache_file
+    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+    cat confcache >$cache_file
   else
     echo "not updating unwritable cache $cache_file"
   fi
 fi
 rm -f confcache
 
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
 test "x$prefix" = xNONE && prefix=$ac_default_prefix
 # Let make expand exec_prefix.
 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
 if test "x$srcdir" = x.; then
-  ac_vpsub='/^[        ]*VPATH[        ]*=[^:]*$/d'
+  ac_vpsub='/^[         ]*VPATH[        ]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[    ]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[      ]*$//;
+}'
 fi
 
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
 DEFS=-DHAVE_CONFIG_H
 
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_i=`echo "$ac_i" |
+        sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+  # 2. Add them.
+  ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
 
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
 # Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
 # Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization.  ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
 
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+  LC_TELEPHONE LC_TIME
 do
-  case "\$ac_option" in
-  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
-    exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-  -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.13"
-    exit 0 ;;
-  -help | --help | --hel | --he | --h)
-    echo "\$ac_cs_usage"; exit 0 ;;
-  *) echo "\$ac_cs_usage"; exit 1 ;;
-  esac
+  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+    eval $as_var=C; export $as_var
+  else
+    $as_unset $as_var
+  fi
 done
 
-ac_given_srcdir=$srcdir
-ac_given_INSTALL="$INSTALL"
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
 
-trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
 
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@SHELL@%$SHELL%g
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@FFLAGS@%$FFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@host@%$host%g
-s%@host_alias@%$host_alias%g
-s%@host_cpu@%$host_cpu%g
-s%@host_vendor@%$host_vendor%g
-s%@host_os@%$host_os%g
-s%@target@%$target%g
-s%@target_alias@%$target_alias%g
-s%@target_cpu@%$target_cpu%g
-s%@target_vendor@%$target_vendor%g
-s%@target_os@%$target_os%g
-s%@build@%$build%g
-s%@build_alias@%$build_alias%g
-s%@build_cpu@%$build_cpu%g
-s%@build_vendor@%$build_vendor%g
-s%@build_os@%$build_os%g
-s%@TARGET@%$TARGET%g
-s%@CPU@%$CPU%g
-s%@CC@%$CC%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@CPP@%$CPP%g
 
-CEOF
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
-
-# Split the substitutions into bite-sized pieces for seds with
-# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
-ac_file=1 # Number of current file.
-ac_beg=1 # First line for current file.
-ac_end=$ac_max_sed_cmds # Line after last line for current file.
-ac_more_lines=:
-ac_sed_cmds=""
-while $ac_more_lines; do
-  if test $ac_beg -gt 1; then
-    sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)$' \| \
+        .     : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+         /^X\/\(\/\/\)$/{ s//\1/; q; }
+         /^X\/\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
   else
-    sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
+  # Find who we are.  Look in the path if we contain no path at all
+  # relative or not.
+  case $0 in
+    *[\\/]* ) as_myself=$0 ;;
+    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+       ;;
+  esac
+  # We did not find ourselves, most probably we were run as `sh COMMAND'
+  # in which case we are not to be found in the path.
+  if test "x$as_myself" = x; then
+    as_myself=$0
+  fi
+  if test ! -f "$as_myself"; then
+    { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+   { (exit 1); exit 1; }; }
   fi
-  if test ! -s conftest.s$ac_file; then
-    ac_more_lines=false
-    rm -f conftest.s$ac_file
+  case $CONFIG_SHELL in
+  '')
+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for as_base in sh bash ksh sh5; do
+        case $as_dir in
+        /*)
+          if ("$as_dir/$as_base" -c '
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
+            $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+            $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+            CONFIG_SHELL=$as_dir/$as_base
+            export CONFIG_SHELL
+            exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+          fi;;
+        esac
+       done
+done
+;;
+  esac
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line before each line; the second 'sed' does the real
+  # work.  The second script uses 'N' to pair each line-number line
+  # with the numbered line, and appends trailing '-' during
+  # substitution so that $LINENO is not a special case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
+  sed '=' <$as_myself |
+    sed '
+      N
+      s,$,-,
+      : loop
+      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      t loop
+      s,-$,,
+      s,^['$as_cr_digits']*\n,,
+    ' >$as_me.lineno &&
+  chmod +x $as_me.lineno ||
+    { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+   { (exit 1); exit 1; }; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensible to this).
+  . ./$as_me.lineno
+  # Exit status is that of the last command.
+  exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T='     ' ;;
+  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  # We could just check for DJGPP; but this test a) works b) is more generic
+  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+  if test -f conf$$.exe; then
+    # Don't use ln at all; we don't have any links
+    as_ln_s='cp -p'
   else
-    if test -z "$ac_sed_cmds"; then
-      ac_sed_cmds="sed -f conftest.s$ac_file"
-    else
-      ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
-    fi
-    ac_file=`expr $ac_file + 1`
-    ac_beg=$ac_end
-    ac_end=`expr $ac_end + $ac_max_sed_cmds`
+    as_ln_s='ln -s'
   fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p=:
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS="  $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+exec 6>&1
+
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.  Logging --version etc. is OK.
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.59.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+  echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+  echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+  echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+  echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number, then exit
+  -q, --quiet      do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+  --file=FILE[:TEMPLATE]
+                  instantiate the configuration file FILE
+  --header=FILE[:TEMPLATE]
+                  instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to <bug-autoconf@gnu.org>."
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.59,
+  with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+INSTALL="$INSTALL"
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value.  By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "x$1" : 'x\([^=]*\)='`
+    ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  -*)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  *) # This is not an option, so the user has probably given explicit
+     # arguments.
+     ac_option=$1
+     ac_need_defaults=false;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --vers* | -V )
+    echo "$ac_cs_version"; exit 0 ;;
+  --he | --h)
+    # Conflict between --help and --header
+    { { echo "$as_me:$LINENO: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+   { (exit 1); exit 1; }; };;
+  --help | --hel | -h )
+    echo "$ac_cs_usage"; exit 0 ;;
+  --debug | --d* | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+    ac_need_defaults=false;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+   { (exit 1); exit 1; }; } ;;
+
+  *) ac_config_targets="$ac_config_targets $1" ;;
+
+  esac
+  shift
 done
-if test -z "$ac_sed_cmds"; then
-  ac_sed_cmds=cat
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+  echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+  exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
 fi
-EOF
 
-cat >> $CONFIG_STATUS <<EOF
+_ACEOF
 
-CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
-  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case "$ac_file" in
-  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
-       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
-  *) ac_file_in="${ac_file}.in" ;;
+
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+  case "$ac_config_target" in
+  # Handling of arguments.
+  "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+  "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+   { (exit 1); exit 1; }; };;
   esac
+done
 
-  # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
 
-  # Remove last slash and all that follows it.  Not all systems have dirname.
-  ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
-  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
-    # The file is in a subdirectory.
-    test ! -d "$ac_dir" && mkdir "$ac_dir"
-    ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
-    # A "../" for each directory in $ac_dir_suffix.
-    ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
-  else
-    ac_dir_suffix= ac_dots=
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./confstat$$-$RANDOM
+  (umask 077 && mkdir $tmp)
+} ||
+{
+   echo "$me: cannot create a temporary directory in ." >&2
+   { (exit 1); exit 1; }
+}
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+  # Protect against being on the right side of a sed subst in config.status.
+  sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@DEFS@,$DEFS,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@LIBS@,$LIBS,;t t
+s,@build@,$build,;t t
+s,@build_cpu@,$build_cpu,;t t
+s,@build_vendor@,$build_vendor,;t t
+s,@build_os@,$build_os,;t t
+s,@host@,$host,;t t
+s,@host_cpu@,$host_cpu,;t t
+s,@host_vendor@,$host_vendor,;t t
+s,@host_os@,$host_os,;t t
+s,@target@,$target,;t t
+s,@target_cpu@,$target_cpu,;t t
+s,@target_vendor@,$target_vendor,;t t
+s,@target_os@,$target_os,;t t
+s,@TARGET@,$TARGET,;t t
+s,@CPU@,$CPU,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
+s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
+s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@USE_OBJCOPY@,$USE_OBJCOPY,;t t
+s,@CPP@,$CPP,;t t
+s,@EGREP@,$EGREP,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
+s,@LTLIBOBJS@,$LTLIBOBJS,;t t
+CEOF
+
+_ACEOF
+
+  cat >>$CONFIG_STATUS <<\_ACEOF
+  # Split the substitutions into bite-sized pieces for seds with
+  # small command number limits, like on Digital OSF/1 and HP-UX.
+  ac_max_sed_lines=48
+  ac_sed_frag=1 # Number of current file.
+  ac_beg=1 # First line for current file.
+  ac_end=$ac_max_sed_lines # Line after last line for current file.
+  ac_more_lines=:
+  ac_sed_cmds=
+  while $ac_more_lines; do
+    if test $ac_beg -gt 1; then
+      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+    else
+      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+    fi
+    if test ! -s $tmp/subs.frag; then
+      ac_more_lines=false
+    else
+      # The purpose of the label and of the branching condition is to
+      # speed up the sed processing (if there are no `@' at all, there
+      # is no need to browse any of the substitutions).
+      # These are the two extra sed commands mentioned above.
+      (echo ':t
+  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+      if test -z "$ac_sed_cmds"; then
+       ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+      else
+       ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+      fi
+      ac_sed_frag=`expr $ac_sed_frag + 1`
+      ac_beg=$ac_end
+      ac_end=`expr $ac_end + $ac_max_sed_lines`
+    fi
+  done
+  if test -z "$ac_sed_cmds"; then
+    ac_sed_cmds=cat
   fi
+fi # test -n "$CONFIG_FILES"
 
-  case "$ac_given_srcdir" in
-  .)  srcdir=.
-      if test -z "$ac_dots"; then top_srcdir=.
-      else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
-  /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
-  *) # Relative path.
-    srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
-    top_srcdir="$ac_dots$ac_given_srcdir" ;;
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+       cat >$tmp/stdin
+       ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+       ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+       ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
   esac
 
-  case "$ac_given_INSTALL" in
-  [/$]*) INSTALL="$ac_given_INSTALL" ;;
-  *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
-  esac
+  # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+  ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_file" : 'X\(//\)[^/]' \| \
+        X"$ac_file" : 'X\(//\)$' \| \
+        X"$ac_file" : 'X\(/\)' \| \
+        .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+         /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+         /^X\(\/\/\)$/{ s//\1/; q; }
+         /^X\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
+  { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
+  else
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| \
+        .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+         /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+         /^X\(\/\/\)$/{ s//\1/; q; }
+         /^X\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
+
+  ac_builddir=.
+
+if test "$ac_dir" != .; then
+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+  # A "../" for each directory in $ac_dir_suffix.
+  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+  ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+  .)  # No --srcdir option.  We are building in place.
+    ac_srcdir=.
+    if test -z "$ac_top_builddir"; then
+       ac_top_srcdir=.
+    else
+       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+    fi ;;
+  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir ;;
+  *) # Relative path.
+    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+  case "$ac_dir" in
+  .) ac_abs_builddir=`pwd`;;
+  [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+  *) ac_abs_builddir=`pwd`/"$ac_dir";;
+  esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+  case ${ac_top_builddir}. in
+  .) ac_abs_top_builddir=$ac_abs_builddir;;
+  [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+  *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+  esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+  case $ac_srcdir in
+  .) ac_abs_srcdir=$ac_abs_builddir;;
+  [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+  *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+  esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+  case $ac_top_srcdir in
+  .) ac_abs_top_srcdir=$ac_abs_builddir;;
+  [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+  *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+  esac;;
+esac
 
-  echo creating "$ac_file"
-  rm -f "$ac_file"
-  configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
-  case "$ac_file" in
-  *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
-  *) ac_comsub= ;;
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
   esac
 
-  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
-  sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-s%@INSTALL@%$INSTALL%g
-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
-fi; done
-rm -f conftest.s*
+  if test x"$ac_file" != x-; then
+    { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+    rm -f "$ac_file"
+  fi
+  # Let's still pretend it is `configure' which instantiates (i.e., don't
+  # use $as_me), people would be surprised to read:
+  #    /* config.h.  Generated by config.status.  */
+  if test x"$ac_file" = x-; then
+    configure_input=
+  else
+    configure_input="$ac_file.  "
+  fi
+  configure_input=$configure_input"Generated from `echo $ac_file_in |
+                                    sed 's,.*/,,'` by configure."
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+        # Absolute (can't be DOS-style, as IFS=:)
+        test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+        echo "$f";;
+      *) # Relative
+        if test -f "$f"; then
+          # Build tree
+          echo "$f"
+        elif test -f "$srcdir/$f"; then
+          # Source tree
+          echo "$srcdir/$f"
+        else
+          # /dev/null tree
+          { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+        fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+  sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;t t
+s,@srcdir@,$ac_srcdir,;t t
+s,@abs_srcdir@,$ac_abs_srcdir,;t t
+s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s,@builddir@,$ac_builddir,;t t
+s,@abs_builddir@,$ac_abs_builddir,;t t
+s,@top_builddir@,$ac_top_builddir,;t t
+s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
+s,@INSTALL@,$ac_INSTALL,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+  rm -f $tmp/stdin
+  if test x"$ac_file" != x-; then
+    mv $tmp/out $ac_file
+  else
+    cat $tmp/out
+    rm -f $tmp/out
+  fi
+
+done
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
+# CONFIG_HEADER section.
+#
 
 # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
 # NAME is the cpp macro being defined and VALUE is the value it is being given.
 #
 # ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([  ]*\)#\([        ]*define[       ][      ]*\)'
-ac_dB='\([     ][      ]*\)[^  ]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([  ]*\)#\([        ]*\)undef\([    ][      ]*\)'
-ac_uB='\([     ]\)%\1#\2define\3'
+ac_dA='s,^\([   ]*\)#\([        ]*define[       ][      ]*\)'
+ac_dB='[        ].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([   ]*\)#\([        ]*\)undef\([    ][      ]*\)'
+ac_uB='$,\1#\2define\3'
 ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([  ]*\)#\([        ]*\)undef\([    ][      ]*\)'
-ac_eB='$%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
-
-if test "${CONFIG_HEADERS+set}" != set; then
-EOF
-cat >> $CONFIG_STATUS <<EOF
-  CONFIG_HEADERS="config.h"
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-fi
-for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ac_uD=',;t'
+
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case "$ac_file" in
-  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
-       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
-  *) ac_file_in="${ac_file}.in" ;;
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+       cat >$tmp/stdin
+       ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+       ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+       ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
   esac
 
-  echo creating $ac_file
-
-  rm -f conftest.frag conftest.in conftest.out
-  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
-  cat $ac_file_inputs > conftest.in
-
-EOF
-
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h.  And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-cat > conftest.hdr <<\EOF
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
-EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
+  test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+        # Absolute (can't be DOS-style, as IFS=:)
+        test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+        # Do quote $f, to prevent DOS paths from being IFS'd.
+        echo "$f";;
+      *) # Relative
+        if test -f "$f"; then
+          # Build tree
+          echo "$f"
+        elif test -f "$srcdir/$f"; then
+          # Source tree
+          echo "$srcdir/$f"
+        else
+          # /dev/null tree
+          { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+        fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+  # Remove the trailing spaces.
+  sed 's/[      ]*$//' $ac_file_inputs >$tmp/in
+
+_ACEOF
+
+# Transform confdefs.h into two sed scripts, `conftest.defines' and
+# `conftest.undefs', that substitutes the proper values into
+# config.h.in to produce config.h.  The first handles `#define'
+# templates, and the second `#undef' templates.
+# And first: Protect against being on the right side of a sed subst in
+# config.status.  Protect against being in an unquoted here document
+# in config.status.
+rm -f conftest.defines conftest.undefs
+# Using a here document instead of a string reduces the quoting nightmare.
+# Putting comments in sed scripts is not portable.
+#
+# `end' is used to avoid that the second main sed command (meant for
+# 0-ary CPP macros) applies to n-ary macro definitions.
+# See the Autoconf documentation for `clear'.
+cat >confdef2sed.sed <<\_ACEOF
+s/[\\&,]/\\&/g
+s,[\\$`],\\&,g
+t clear
+: clear
+s,^[    ]*#[    ]*define[       ][      ]*\([^  (][^    (]*\)\(([^)]*)\)[       ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
+t end
+s,^[    ]*#[    ]*define[       ][      ]*\([^  ][^     ]*\)[   ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
+: end
+_ACEOF
+# If some macros were called several times there might be several times
+# the same #defines, which is useless.  Nevertheless, we may not want to
+# sort them, since we want the *last* AC-DEFINE to be honored.
+uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
+sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
+rm -f confdef2sed.sed
 
 # This sed command replaces #undef with comments.  This is necessary, for
 # example, in the case of _POSIX_SOURCE, which is predefined and required
 # on some systems where configure will not decide to define it.
-cat >> conftest.vals <<\EOF
-s%^[   ]*#[    ]*undef[        ][      ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
-EOF
-
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
+cat >>conftest.undefs <<\_ACEOF
+s,^[    ]*#[    ]*undef[        ][      ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
+_ACEOF
+
+# Break up conftest.defines because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
+echo '  if grep "^[     ]*#[    ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
+echo '  :' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.defines >/dev/null
+do
+  # Write a limited-size here document to $tmp/defines.sed.
+  echo '  cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#define' lines.
+  echo '/^[     ]*#[    ]*define/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+  echo 'CEOF
+  sed -f $tmp/defines.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+  rm -f conftest.defines
+  mv conftest.tail conftest.defines
+done
+rm -f conftest.defines
+echo '  fi # grep' >>$CONFIG_STATUS
+echo >>$CONFIG_STATUS
 
+# Break up conftest.undefs because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #undef templates' >>$CONFIG_STATUS
 rm -f conftest.tail
-while :
+while grep . conftest.undefs >/dev/null
 do
-  ac_lines=`grep -c . conftest.vals`
-  # grep -c gives empty output for an empty file on some AIX systems.
-  if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
-  # Write a limited-size here document to conftest.frag.
-  echo '  cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
-  sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+  # Write a limited-size here document to $tmp/undefs.sed.
+  echo '  cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#undef'
+  echo '/^[     ]*#[    ]*undef/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
   echo 'CEOF
-  sed -f conftest.frag conftest.in > conftest.out
-  rm -f conftest.in
-  mv conftest.out conftest.in
-' >> $CONFIG_STATUS
-  sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
-  rm -f conftest.vals
-  mv conftest.tail conftest.vals
+  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
+  rm -f conftest.undefs
+  mv conftest.tail conftest.undefs
 done
-rm -f conftest.vals
-
-cat >> $CONFIG_STATUS <<\EOF
-  rm -f conftest.frag conftest.h
-  echo "/* $ac_file.  Generated automatically by configure.  */" > conftest.h
-  cat conftest.in >> conftest.h
-  rm -f conftest.in
-  if cmp -s $ac_file conftest.h 2>/dev/null; then
-    echo "$ac_file is unchanged"
-    rm -f conftest.h
+rm -f conftest.undefs
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+  # Let's still pretend it is `configure' which instantiates (i.e., don't
+  # use $as_me), people would be surprised to read:
+  #    /* config.h.  Generated by config.status.  */
+  if test x"$ac_file" = x-; then
+    echo "/* Generated by configure.  */" >$tmp/config.h
+  else
+    echo "/* $ac_file.  Generated by configure.  */" >$tmp/config.h
+  fi
+  cat $tmp/in >>$tmp/config.h
+  rm -f $tmp/in
+  if test x"$ac_file" != x-; then
+    if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+      { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_file" : 'X\(//\)[^/]' \| \
+        X"$ac_file" : 'X\(//\)$' \| \
+        X"$ac_file" : 'X\(/\)' \| \
+        .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+         /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+         /^X\(\/\/\)$/{ s//\1/; q; }
+         /^X\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
+      { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
   else
-    # Remove last slash and all that follows it.  Not all systems have dirname.
-      ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
-      if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
-      # The file is in a subdirectory.
-      test ! -d "$ac_dir" && mkdir "$ac_dir"
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| \
+        .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+         /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+         /^X\(\/\/\)$/{ s//\1/; q; }
+         /^X\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
+
+      rm -f $ac_file
+      mv $tmp/config.h $ac_file
     fi
-    rm -f $ac_file
-    mv conftest.h $ac_file
+  else
+    cat $tmp/config.h
+    rm -f $tmp/config.h
   fi
-fi; done
-
-EOF
-cat >> $CONFIG_STATUS <<EOF
+done
+_ACEOF
 
-EOF
-cat >> $CONFIG_STATUS <<\EOF
+cat >>$CONFIG_STATUS <<\_ACEOF
 
-exit 0
-EOF
+{ (exit 0); exit 0; }
+_ACEOF
 chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || { (exit 1); exit 1; }
+fi
 
index 52160e999572b71c29a208ed6803ae6ae419849a..10aa09d32716a12c24fed393eb9e223a7c583b89 100755 (executable)
@@ -20,6 +20,8 @@ case "$host_os" in
         ;;
   *freebsd*) TARGET=freebsd86
        ;;
+  *aix*) TARGET=aix
+       ;;
   *irix*) TARGET=sgi
       ;;
   *hp*) TARGET=hpux
@@ -28,6 +30,12 @@ case "$host_os" in
      ;;
   *sequent*) AC_DEFINE(SEQUENT) 
        ;;
+  *MINGW*) TARGET=mingw
+     ;;
+  *MinGW*) TARGET=mingw
+     ;;
+  *mingw*) TARGET=mingw
+     ;;
   *) TARGET=$host_os
      ;;
 esac
@@ -47,6 +55,7 @@ AC_SUBST(CPU)
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_INSTALL
+AC_CHECK_PROG(USE_OBJCOPY, objcopy, yes, no)
 
 dnl Checks for header files.
 AC_HEADER_STDC
@@ -60,10 +69,11 @@ AC_CHECK_HEADERS(\
        scsi/scsi.h \
        scsi/scsi_ioctl.h \
        scsi/sg.h \
+       sys/gscdds.h \
        camlib.h \
        cam/cam_ccb.h \
        cam/scsi/scsi_message.h \
-        sys/fsid.h \
+       sys/fsid.h \
        sys/fstyp.h \
        sys/stat.h \
        sys/types.h \
@@ -74,8 +84,11 @@ AC_CHECK_HEADERS(\
        sys/scsi.h \
        sys/scsi_ctl.h \
        sys/ioctl.h \
+       sys/mtio.h \
+       sys/param.h \
        dslib.h \
-       du/defs.h)
+       du/defs.h \
+       ddk/ntddscsi.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
index 1d8938bebc6106af4a74376ec89185e006300093..080c1270c67781dfabff74a22f1bc315e2829187 100755 (executable)
@@ -5,11 +5,9 @@
 # This software is licensed under the terms of the Free Software Foundation's
 # General Public License, version 2. See http://www.fsf.org for more
 # inforation on the General Public License. It is released for public use in
-# the hope that others will find it useful. [NOTE FROM ERIC: Note that
-# this is now unmaintained, unless someone wishes to volunteer. In other
-# words, if you have a problem with this script, please fix it and forward
-# a new version of the script with your EMAIL address as the one to contact
-# about it :-) ]
+# the hope that others will find it useful. Please contact eric@estinc.com
+# if you have problems. Also check out our backup products at
+# http://www.estinc.com (grin). 
 #
 # usage: config_sgen_solaris.sh check|[un]install
 #
@@ -150,4 +148,4 @@ case "$mode" in
        ;;
 esac
 
-exit $?
+exit $?
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 43564c3faf5690a318be32cd694bfeae581829c2..1e60c15a168af8b630995926e18f6a36f74e2b14 100644 (file)
@@ -263,9 +263,9 @@ def wait_for_inventory(device):
     return 0  # we succeeded!
 
 # RCS REVISION LOG:
-# $Log: mtx.py,v $
-# Revision 1.1.1.1  2001/06/05 17:10:51  elgreen
-# Initial import into SourceForge
+# $Log$
+# Revision 1.1  2001/06/05 17:10:51  elgreen
+# Initial revision
 #
 # Revision 1.2  2000/12/22 14:17:19  eric
 # mtx 1.2.11pre1
diff --git a/contrib/qdback.tar.gz b/contrib/qdback.tar.gz
new file mode 100644 (file)
index 0000000..761a216
Binary files /dev/null and b/contrib/qdback.tar.gz differ
index 879bdbedc0d4a1cffa8442a8f8afaa9e9b2788fc..4c34a08f6ca751e67a57095037ed834f08332bec 100644 (file)
@@ -1,3 +1,10 @@
+mtx (1.3.11-1) unstable; urgency=low
+
+  * new upstream version, closes: #425687, #425688
+  * don't let Makefile.in strip binaries, let dh_strip do it, closes: #437589
+
+ -- Bdale Garbee <bdale@gag.com>  Tue, 15 Apr 2008 14:34:32 -0600
+
 mtx (1.2.17rel-2) unstable; urgency=low
 
   * update config.sub and config.guess in rules clean target using the
index dadad6b014c45d2d3dc5631edf8da976b73bcb6f..24e44d1d647b6b4cbdae15341801571be77afca9 100644 (file)
@@ -3,7 +3,7 @@ Section: admin
 Priority: extra
 Maintainer: Bdale Garbee <bdale@gag.com>
 Build-Depends: debhelper (>= 5), libcam-dev [kfreebsd-i386 kfreebsd-amd64], autotools-dev
-Standards-Version: 3.7.2.1
+Standards-Version: 3.7.3
 
 Package: mtx
 Architecture: any
index 2284114d2068522208aefad5ca66106d094dbfbe..79c0cb276b40dc43d5637737a4130af4653983cc 100755 (executable)
@@ -21,7 +21,7 @@ clean:
        dh_testdir
        dh_testroot
        rm -f build-stamp configure-stamp
-       -$(MAKE) distclean
+       [ ! -f Makefile ] || $(MAKE) distclean
 
        -test -r /usr/share/misc/config.sub && \
                cp -f /usr/share/misc/config.sub config.sub
index 7fc17456a494e4cd8627557a758fe9ddbb7244f0..8f11e16d00d5f7c236d0dfadf9222a627525aa65 100644 (file)
--- a/du/scsi.c
+++ b/du/scsi.c
@@ -46,7 +46,7 @@
  *   purposes only.
  */
 
-static int             bus = -1,
+static int     bus = -1,
                        target = -1,
                        lun = -1;
 
@@ -57,17 +57,21 @@ static int SCSI_OpenDevice(char *DeviceName)
        int             saverr;
 
        /* Check for validity of device node */
-       if (stat(DeviceName, &stbuf) < 0) {
+       if (stat(DeviceName, &stbuf) < 0)
+       {
                FatalError("cannot stat SCSI device '%s' - %m\n", DeviceName);
        }
-       if (!S_ISCHR(stbuf.st_mode)) {
+       if (!S_ISCHR(stbuf.st_mode))
+       {
                FatalError("device '%s': not appropriate device type - %m\n", DeviceName);
        }
 
-       if ((fd = open(DeviceName, O_RDONLY | O_NDELAY, 0)) >= 0) {
+       if ((fd = open(DeviceName, O_RDONLY | O_NDELAY, 0)) >= 0)
+       {
                struct devget   devget;
 
-               if (ioctl(fd, DEVIOCGET, &devget) >= 0) {
+               if (ioctl(fd, DEVIOCGET, &devget) >= 0)
+               {
 #ifdef __osf__
                        lun = devget.slave_num % 8;
                        devget.slave_num /= 8;
@@ -80,21 +84,24 @@ static int SCSI_OpenDevice(char *DeviceName)
                        (void) close(fd);
 
                        if ((fd = open(DEV_CAM, O_RDWR, 0)) >= 0 ||
-                           (fd = open(DEV_CAM, O_RDONLY, 0)) >= 0) {
+                               (fd = open(DEV_CAM, O_RDONLY, 0)) >= 0)
+                       {
                                return (fd);
                        }
                        fd = bus = target = lun = -1;
                        FatalError("error %d opening SCSI device '%s' - %m\n",
                                         errno, DEV_CAM);
                }
-               else {
+               else
+               {
                        (void) close(fd);
                        fd = bus = target = lun = -1;
                        FatalError("error %d on DEVIOCGET ioctl for '%s' - %m\n",
                                         errno, DeviceName);
                }
        }
-       else {
+       else
+       {
                saverr = errno;
                fd = bus = target = lun = -1;
                FatalError("cannot open SCSI device '%s', error %d - %m\n",
@@ -106,8 +113,7 @@ static int SCSI_OpenDevice(char *DeviceName)
 }
 
 
-static void SCSI_CloseDevice(char *DeviceName,
-                            int DeviceFD)
+static void SCSI_CloseDevice(char *DeviceName, int DeviceFD)
 {
        (void) close(DeviceFD);
        bus = target = lun = -1;
@@ -115,14 +121,12 @@ static void SCSI_CloseDevice(char *DeviceName,
 
 
 static int SCSI_ExecuteCommand(int DeviceFD,
-                              Direction_T Direction,
-                              CDB_T *CDB,
-                              int CDB_Length,
-                              void *DataBuffer,
-                              int DataBufferLength,
-                              RequestSense_T *RequestSense)
-
-
+                                                               Direction_T Direction,
+                                                               CDB_T *CDB,
+                                                               int CDB_Length,
+                                                               void *DataBuffer,
+                                                               int DataBufferLength,
+                                                               RequestSense_T *RequestSense)
 {
        UAGT_CAM_CCB    uagt;
        CCB_SCSIIO      ccb;
@@ -145,9 +149,10 @@ static int SCSI_ExecuteCommand(int DeviceFD,
        ccb.cam_ch.cam_ccb_len = sizeof(CCB_SCSIIO);
        ccb.cam_ch.cam_func_code = XPT_SCSI_IO;
 
-       if (DataBuffer != NULL && DataBufferLength > 0) {
-               ccb.cam_ch.cam_flags |=
-                       (Direction == Input) ? CAM_DIR_IN : CAM_DIR_OUT;
+       if (DataBuffer != NULL && DataBufferLength > 0)
+       {
+               ccb.cam_ch.cam_flags |= (Direction == Input) ?
+                       CAM_DIR_IN : CAM_DIR_OUT;
                uagt.uagt_buffer = (u_char *) DataBuffer;
                uagt.uagt_buflen = DataBufferLength;
        }
@@ -165,14 +170,17 @@ static int SCSI_ExecuteCommand(int DeviceFD,
        ccb.cam_ch.cam_path_id = bus;
        ccb.cam_ch.cam_target_id = target;
        ccb.cam_ch.cam_target_lun = lun;
-    
-       if (ioctl(DeviceFD, UAGT_CAM_IO, (caddr_t) &uagt) < 0) {
+
+       if (ioctl(DeviceFD, UAGT_CAM_IO, (caddr_t) &uagt) < 0)
+       {
                return -1;
-       }
+       }
 
        /* Check return status */
-       if ((ccb.cam_ch.cam_status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
-               if (ccb.cam_ch.cam_status & CAM_SIM_QFRZN) {
+       if ((ccb.cam_ch.cam_status & CAM_STATUS_MASK) != CAM_REQ_CMP)
+       {
+               if (ccb.cam_ch.cam_status & CAM_SIM_QFRZN)
+               {
                        (void) memset(&ccb, 0, sizeof(ccb));
                        (void) memset(&uagt, 0, sizeof(uagt));
 
@@ -193,12 +201,12 @@ static int SCSI_ExecuteCommand(int DeviceFD,
                                return -1;
                }
 
-               printf("mtx: %s:\n%s=0x%x %s=0x%x\n",
-                                      "SCSI command fault",
-                                      "Opcode",
-                                      CDB[0],
-                                      "Status",
-                                      ccb.cam_scsi_status);
+               printf( "mtx: %s:\n%s=0x%x %s=0x%x\n",
+                               "SCSI command fault",
+                               "Opcode",
+                               CDB[0],
+                               "Status",
+                               ccb.cam_scsi_status);
                return -1;
        }
 
index 6d7f9dc4aeb7fb6debe94907d6bb787b08e4f768..b66097a9033064d6c34f66e5f68129937b4ee345 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
-# $Date: 2001/06/05 17:10:21 $
-# $Revision: 1.1.1.1 $
+# $Date: 2001-06-05 10:10:15 -0700 (Tue, 05 Jun 2001) $
+# $Revision: 2 $
 #
 # install - install a program, script, or datafile
 # This comes from X11R5 (mit/util/scripts/install.sh).
index b25d72ab32f6fe2d26331c192bd63e2320cd5963..93b9676e21659973e7fe676f941fe9290cee6dbe 100644 (file)
@@ -80,11 +80,10 @@ loaders (Ecrix Autopack, Exabyte 220).
 .P
 .SH AVAILABILITY
 .B loaderinfo
-is currently being maintained by Eric Lee Green <eric@badtux.org> formerly of
-Enhanced Software Technologies Inc. The 'mtx' home page is
-http://mtx.sourceforge.net and the actual code
-is currently available there and via CVS from 
-http://sourceforge.net/projects/mtx/ . 
+is currently being maintained by Robert Nelson <robertnelson@users.sourceforge.net> 
+as part of the 'mtx' suite of programs. The 'mtx' home page is 
+http://mtx.sourceforge.net and the actual code is currently available there and via 
+SVN from http://sourceforge.net/projects/mtx. 
 
 .SH SEE ALSO
 .BR mt (1), tapeinfo (1), mtx (1)
index 1c7fcfe936ee3e025cf415ddc4e4291f70ab8f29..8992fa24d49287098640b2ed03f5e5def0979c90 100644 (file)
@@ -4,8 +4,8 @@
  */
 
 /* 
-* $Date: 2001/06/05 17:10:21 $
-* $Revision: 1.1.1.1 $
+* $Date: 2007-03-24 18:38:20 -0700 (Sat, 24 Mar 2007) $
+* $Revision: 167 $
 */
 
 /* What this does: Basically dumps out contents of:
@@ -44,80 +44,89 @@ DEVICE_TYPE MediumChangerFD;  /* historic purposes... */
 char *argv0;
 
 /* A table for printing out the peripheral device type as ASCII. */ 
-static char *PeripheralDeviceType[32] = {
-  "Disk Drive",
-  "Tape Drive",
-  "Printer",
-  "Processor",
-  "Write-once",
-  "CD-ROM",
-  "Scanner",
-  "Optical",
-  "Medium Changer",
-  "Communications",
-  "ASC IT8",
-  "ASC IT8",
-  "RAID Array",
-  "Enclosure Services",
-  "OCR/W",
-  "Bridging Expander", /* 0x10 */
-  "Reserved",  /* 0x11 */
-  "Reserved", /* 0x12 */
-  "Reserved",  /* 0x13 */
-  "Reserved",  /* 0x14 */
-  "Reserved",  /* 0x15 */
-  "Reserved",  /* 0x16 */
-  "Reserved",  /* 0x17 */
-  "Reserved",  /* 0x18 */
-  "Reserved",  /* 0x19 */
-  "Reserved",  /* 0x1a */
-  "Reserved",  /* 0x1b */
-  "Reserved",  /* 0x1c */
-  "Reserved",  /* 0x1d */
-  "Reserved",  /* 0x1e */
-  "Unknown"    /* 0x1f */
+static char *PeripheralDeviceType[32] =
+{
+       "Disk Drive",
+       "Tape Drive",
+       "Printer",
+       "Processor",
+       "Write-once",
+       "CD-ROM",
+       "Scanner",
+       "Optical",
+       "Medium Changer",
+       "Communications",
+       "ASC IT8",
+       "ASC IT8",
+       "RAID Array",
+       "Enclosure Services",
+       "OCR/W",
+       "Bridging Expander", /* 0x10 */
+       "Reserved",  /* 0x11 */
+       "Reserved", /* 0x12 */
+       "Reserved",  /* 0x13 */
+       "Reserved",  /* 0x14 */
+       "Reserved",  /* 0x15 */
+       "Reserved",  /* 0x16 */
+       "Reserved",  /* 0x17 */
+       "Reserved",  /* 0x18 */
+       "Reserved",  /* 0x19 */
+       "Reserved",  /* 0x1a */
+       "Reserved",  /* 0x1b */
+       "Reserved",  /* 0x1c */
+       "Reserved",  /* 0x1d */
+       "Reserved",  /* 0x1e */
+       "Unknown"    /* 0x1f */
 };
 
 
 /* okay, now for the structure of an Element Address Assignment Page:  */
 
-typedef struct EAAP {
-  unsigned char Page_Code;
-  unsigned char Parameter_Length;
-  unsigned char MediumTransportElementAddress[2];
-  unsigned char NumMediumTransportElements[2];
-  unsigned char FirstStorageElementAdddress[2];
-  unsigned char NumStorageElements[2];
-  unsigned char FirstImportExportElementAddress[2];
-  unsigned char NumImportExportElements[2];
-  unsigned char FirstDataTransferElementAddress[2];
-  unsigned char NumDataTransferElements[2];
-  unsigned char Reserved[2];
-} EAAP_Type;
+typedef struct EAAP
+{
+       unsigned char Page_Code;
+       unsigned char Parameter_Length;
+       unsigned char MediumTransportElementAddress[2];
+       unsigned char NumMediumTransportElements[2];
+       unsigned char FirstStorageElementAdddress[2];
+       unsigned char NumStorageElements[2];
+       unsigned char FirstImportExportElementAddress[2];
+       unsigned char NumImportExportElements[2];
+       unsigned char FirstDataTransferElementAddress[2];
+       unsigned char NumDataTransferElements[2];
+       unsigned char Reserved[2];
+}      EAAP_Type;
 
 /* okay, now for the structure of a transport geometry
  * descriptor page:
  */
-typedef struct TGDP {
-  unsigned char Page_Code;
-  unsigned char ParameterLength;
-  unsigned char Rotate;
-  unsigned char ElementNumber;  /* we don't care about this... */
-} TGDP_Type;
+typedef struct TGDP
+{
+       unsigned char Page_Code;
+       unsigned char ParameterLength;
+       unsigned char Rotate;
+       unsigned char ElementNumber;  /* we don't care about this... */
+}      TGDP_Type;
 
 
 /* Structure of the Device Capabilities Page: */
-typedef struct DCP {
-  unsigned char Page_Code;
-  unsigned char ParameterLength;
-  unsigned char CanStore;  /* bits about whether elements can store carts */
-  unsigned char Reserved; 
-  unsigned char MT_Xfer;  /* bits about whether mt->xx xfers work. */
-  unsigned char ST_Xfer;  /* bits about whether st->xx xfers work. */
-  unsigned char IE_Xfer;  /* bits about whether id->xx xfers work. */
-  unsigned char DT_Xfer; /* bits about whether DT->xx xfers work. */
-  unsigned char Reserved2[12];  /* more reserved data */
-} DCP_Type ; 
+typedef struct DCP 
+{
+       unsigned char Page_Code;
+       unsigned char ParameterLength;
+       unsigned char CanStore;         /* bits about whether elements can store carts */
+       unsigned char SMC2_Caps;
+       unsigned char MT_Transfer;      /* bits about whether mt->xx transfers work. */
+       unsigned char ST_Transfer;      /* bits about whether st->xx transfers work. */
+       unsigned char IE_Transfer;      /* bits about whether id->xx transfers work. */
+       unsigned char DT_Transfer;      /* bits about whether DT->xx transfers work. */
+       unsigned char Reserved[4];      /* more reserved data */
+       unsigned char MT_Exchange;      /* bits about whether mt->xx exchanges work. */
+       unsigned char ST_Exchange;      /* bits about whether st->xx exchanges work. */
+       unsigned char IE_Exchange;      /* bits about whether id->xx exchanges work. */
+       unsigned char DT_Exchange;      /* bits about whether DT->xx exchanges work. */
+       unsigned char Reserved2[4];     /* more reserved data */
+}      DCP_Type;
 
 #define MT_BIT 0x01
 #define ST_BIT 0x02
@@ -128,44 +137,58 @@ typedef struct DCP {
 
 static void ReportInquiry(DEVICE_TYPE MediumChangerFD)
 {
-  RequestSense_T RequestSense;
-  Inquiry_T *Inquiry;
-  int i;
-
-  Inquiry = RequestInquiry(MediumChangerFD,&RequestSense);
-  if (Inquiry == NULL) 
-    {
-      PrintRequestSense(&RequestSense);
-      FatalError("INQUIRY Command Failed\n");
-    }
-  
-  printf("Product Type: %s\n",PeripheralDeviceType[Inquiry->PeripheralDeviceType]);
-  printf("Vendor ID: '");
-  for (i = 0; i < sizeof(Inquiry->VendorIdentification); i++)
-    printf("%c", Inquiry->VendorIdentification[i]);
-  printf("'\nProduct ID: '");
-  for (i = 0; i < sizeof(Inquiry->ProductIdentification); i++)
-    printf("%c", Inquiry->ProductIdentification[i]);
-  printf("'\nRevision: '");
-  for (i = 0; i < sizeof(Inquiry->ProductRevisionLevel); i++)
-    printf("%c", Inquiry->ProductRevisionLevel[i]);
-  printf("'\n");\
-  if (Inquiry->MChngr) {  /* check the attached-media-changer bit... */
-    printf("Attached Changer: Yes\n");
-  } else {
-    printf("Attached Changer: No\n");
-  }
-  /* Now see if we have a bar code flag: */
-  if (Inquiry->AdditionalLength > 50) {  /* see if we have 56 bytes: */
-    if (Inquiry->VendorFlags & 1) {
-      printf("Bar Code Reader: Yes\n");
-    } else {
-      printf("Bar Code Reader: No\n");
-    }
-  }
-  
-  free(Inquiry);  /* well, we're about to exit, but ... */
-  return; /* done! */
+       RequestSense_T RequestSense;
+       Inquiry_T *Inquiry;
+       int i;
+
+       Inquiry = RequestInquiry(MediumChangerFD,&RequestSense);
+       if (Inquiry == NULL) 
+       {
+               PrintRequestSense(&RequestSense);
+               FatalError("INQUIRY Command Failed\n");
+       }
+
+       printf("Product Type: %s\n",PeripheralDeviceType[Inquiry->PeripheralDeviceType]);
+
+       printf("Vendor ID: '");
+       for (i = 0; i < sizeof(Inquiry->VendorIdentification); i++)
+               printf("%c", Inquiry->VendorIdentification[i]);
+
+       printf("'\nProduct ID: '");
+       for (i = 0; i < sizeof(Inquiry->ProductIdentification); i++)
+               printf("%c", Inquiry->ProductIdentification[i]);
+
+       printf("'\nRevision: '");
+       for (i = 0; i < sizeof(Inquiry->ProductRevisionLevel); i++)
+               printf("%c", Inquiry->ProductRevisionLevel[i]);
+
+       printf("'\n");
+
+       if (Inquiry->MChngr) 
+       {
+               /* check the attached-media-changer bit... */
+               printf("Attached Changer: Yes\n");
+       }
+       else
+       {
+               printf("Attached Changer: No\n");
+       }
+
+       /* Now see if we have a bar code flag: */
+       if (Inquiry->AdditionalLength > 50) 
+       {
+               /* see if we have 56 bytes: */
+               if (Inquiry->VendorFlags & 1)
+               {
+                       printf("Bar Code Reader: Yes\n");
+               }
+               else
+               {
+                       printf("Bar Code Reader: No\n");
+               }
+       }
+
+       free(Inquiry);          /* well, we're about to exit, but ... */
 }
 
 /*********** MODE SENSE *******************/
@@ -174,102 +197,113 @@ static void ReportInquiry(DEVICE_TYPE MediumChangerFD)
  */
 
 static unsigned char
-*mode_sense(DEVICE_TYPE fd, int pagenum, int alloc_len,  RequestSense_T *RequestSense) {
-  CDB_T CDB;
-  unsigned char *input_buffer; /*the input buffer -- has junk prepended to
-                               * actual sense page. 
-                               */
-  unsigned char *tmp;
-  unsigned char *retval;  /* the return value. */
-  int i,pagelen;
-
-  if (alloc_len > 255) {
-    FatalError("mode_sense(6) can only read up to 255 characters!\n");
-  }
-
-  input_buffer=(unsigned char *)xzmalloc(256); /* overdo it, eh? */
-
-  /* clear the sense buffer: */
-  slow_bzero((char *)RequestSense,sizeof(RequestSense_T));
-  
-
-  /* returns an array of bytes in the page, or, if not possible, NULL. */
-  CDB[0]=0x1a; /* Mode Sense(6) */
-  CDB[1]=0; 
-  CDB[2]=pagenum; /* the page to read. */
-  CDB[3]=0;
-  CDB[4]=255; /* allocation length. This does max of 256 bytes! */
-  CDB[5]=0;
-  
-  if (SCSI_ExecuteCommand(fd,Input,&CDB,6,
-                         input_buffer,255,RequestSense) != 0) {
+*mode_sense(DEVICE_TYPE fd, char pagenum, int alloc_len,  RequestSense_T *RequestSense)
+{
+       CDB_T CDB;
+       unsigned char *input_buffer;    /*the input buffer -- has junk prepended to
+                                                                        * actual sense page. 
+                                                                        */
+       unsigned char *tmp;
+       unsigned char *retval;                  /* the return value. */
+       int i,pagelen;
+
+       if (alloc_len > 255)
+       {
+               FatalError("mode_sense(6) can only read up to 255 characters!\n");
+       }
+
+       input_buffer = (unsigned char *)xzmalloc(256); /* overdo it, eh? */
+
+       /* clear the sense buffer: */
+       slow_bzero((char *)RequestSense, sizeof(RequestSense_T));
+
+       /* returns an array of bytes in the page, or, if not possible, NULL. */
+       CDB[0] = 0x1a; /* Mode Sense(6) */
+       CDB[1] = 0x08; 
+       CDB[2] = pagenum; /* the page to read. */
+       CDB[3] = 0;
+       CDB[4] = 255; /* allocation length. This does max of 256 bytes! */
+       CDB[5] = 0;
+
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 6,
+                                                       input_buffer, 255, RequestSense) != 0)
+       {
 #ifdef DEBUG_MODE_SENSE
-    fprintf(stderr,"Could not execute mode sense...\n");
-    fflush(stderr);
+               fprintf(stderr,"Could not execute mode sense...\n");
+               fflush(stderr);
 #endif
-    return NULL; /* sorry, couldn't do it. */
-  }
-  
-  /* First skip past any header.... */
-  tmp=input_buffer+4+input_buffer[3];
-  /* now find out real length of page... */
-  pagelen=tmp[1]+2;
-  retval=xmalloc(pagelen);
-  /* and copy our data to the new page. */
-  for (i=0;i<pagelen;i++) {
-    retval[i]=tmp[i];
-  }
-  /* okay, free our input buffer: */
-  free(input_buffer);
-  return retval;
+               return NULL; /* sorry, couldn't do it. */
+       }
+
+       /* First skip past any header.... */
+       tmp = input_buffer + 4 + input_buffer[3];
+       /* now find out real length of page... */
+       pagelen=tmp[1] + 2;
+       retval = xmalloc(pagelen);
+       /* and copy our data to the new page. */
+       for (i = 0; i < pagelen; i++)
+       {
+               retval[i] = tmp[i];
+       }
+       /* okay, free our input buffer: */
+       free(input_buffer);
+       return retval;
 }
 
 /* Report the Element Address Assignment Page */
-static EAAP_Type *ReportEAAP(DEVICE_TYPE MediumChangerFD) {
-  EAAP_Type *EAAP; 
-  RequestSense_T RequestSense;
-
-  EAAP=(EAAP_Type *)mode_sense(MediumChangerFD,0x1d,sizeof(EAAP_Type),&RequestSense);
-  
-  if (EAAP==NULL) {
-    printf("EAAP: No\n");
-    return NULL;
-  }
-
-  /* we did get an EAAP, so do our thing: */
-  printf("EAAP: Yes\n");
-  printf("Number of Medium Transport Elements: %d\n", ( ((unsigned int)EAAP->NumMediumTransportElements[0]<<8) + (unsigned int)EAAP->NumMediumTransportElements[1]));
-  printf("Number of Storage Elements: %d\n", ( ((unsigned int)EAAP->NumStorageElements[0]<<8) + (unsigned int)EAAP->NumStorageElements[1]));
-  printf("Number of Import/Export Element Elements: %d\n", ( ((unsigned int)EAAP->NumImportExportElements[0]<<8) + (unsigned int)EAAP->NumImportExportElements[1]));
-  printf("Number of Data Transfer Elements: %d\n", ( ((unsigned int)EAAP->NumDataTransferElements[0]<<8) + (unsigned int)EAAP->NumDataTransferElements[1]));
-  
-  return EAAP;
+static void ReportEAAP(DEVICE_TYPE MediumChangerFD)
+{
+       EAAP_Type *EAAP; 
+       RequestSense_T RequestSense;
+
+       EAAP = (EAAP_Type *)mode_sense(MediumChangerFD, 0x1d, sizeof(EAAP_Type), &RequestSense);
+
+       if (EAAP == NULL)
+       {
+               PrintRequestSense(&RequestSense);
+               printf("EAAP: No\n");
+               return;
+       }
+
+       /* we did get an EAAP, so do our thing: */
+       printf("EAAP: Yes\n");
+       printf("Number of Medium Transport Elements: %d\n", ( ((unsigned int)EAAP->NumMediumTransportElements[0]<<8) + (unsigned int)EAAP->NumMediumTransportElements[1]));
+       printf("Number of Storage Elements: %d\n", ( ((unsigned int)EAAP->NumStorageElements[0]<<8) + (unsigned int)EAAP->NumStorageElements[1]));
+       printf("Number of Import/Export Elements: %d\n", ( ((unsigned int)EAAP->NumImportExportElements[0]<<8) + (unsigned int)EAAP->NumImportExportElements[1]));
+       printf("Number of Data Transfer Elements: %d\n", ( ((unsigned int)EAAP->NumDataTransferElements[0]<<8) + (unsigned int)EAAP->NumDataTransferElements[1]));
+
+       free(EAAP);
 }
 
 /* See if we can get some invert information: */
 
-static void Report_TGDP(DEVICE_TYPE MediumChangerFD) {
-  TGDP_Type *result;
-  
-  RequestSense_T RequestSense;
-
-  result=(TGDP_Type *)mode_sense(MediumChangerFD,0x1e,255,&RequestSense);
-  
-  if (!result) {
-    printf("Transport Geometry Descriptor Page: No\n");
-    return;
-  }
-
-  printf("Transport Geometry Descriptor Page: Yes\n");
-  
-  /* Now print out the invert bit: */
-  if ( result->Rotate & 1 ) {
-    printf("Invertable: Yes\n");
-  } else {
-    printf("Invertable: No\n");
-  }
-
-  return;  /* done. */
+static void Report_TGDP(DEVICE_TYPE MediumChangerFD)
+{
+       TGDP_Type *result;
+
+       RequestSense_T RequestSense;
+
+       result=(TGDP_Type *)mode_sense(MediumChangerFD,0x1e,255,&RequestSense);
+
+       if (!result)
+       {
+               printf("Transport Geometry Descriptor Page: No\n");
+               return;
+       }
+
+       printf("Transport Geometry Descriptor Page: Yes\n");
+
+       /* Now print out the invert bit: */
+       if ( result->Rotate & 1 )
+       {
+               printf("Invertable: Yes\n");
+       }
+       else
+       {
+               printf("Invertable: No\n");
+       }
+
+       free(result);
 }
 
 /* Okay, let's get the Device Capabilities Page. We don't care
@@ -277,59 +311,199 @@ static void Report_TGDP(DEVICE_TYPE MediumChangerFD) {
  * ST->ST).
  */
 
-static void Report_DCP(DEVICE_TYPE MediumChangerFD) {
-  DCP_Type *result;
-  RequestSense_T RequestSense;
-
-  /* Get the page. */
-  result=(DCP_Type *)mode_sense(MediumChangerFD,0x1f,sizeof(DCP_Type),&RequestSense);
-  if (!result) {
-    printf("Device Configuration Page: No\n");
-    return;
-  }
-  
-  printf("Device Configuration Page: Yes\n");
-
-  /* okay, now see if we can do xfers: */
-  if (result->ST_Xfer & ST_BIT) {
-    printf("Can Transfer: Yes\n");
-  } else {
-    printf("Can Transfer: No\n");
-  }
-  /* We don't care about anything else at the moment, eventually we
-   * do want to add the inport/export stuff here too...
-   */
-
-  return;
+void TransferExchangeTargets(unsigned char ucValue, char *szPrefix)
+{
+       if (ucValue & DT_BIT)
+       {
+               printf("%sData Transfer", szPrefix);
+       }
+
+       if (ucValue & IE_BIT)
+       {
+               printf("%s%sImport/Export", ucValue > (IE_BIT | (IE_BIT - 1)) ? ", " : "", szPrefix);
+       }
+
+       if (ucValue & ST_BIT)
+       {
+               printf("%s%sStorage", ucValue > (ST_BIT | (ST_BIT - 1)) ? ", " : "", szPrefix);
+       }
+
+       if (ucValue & MT_BIT)
+       {
+               printf("%s%sMedium Transfer", ucValue  > (MT_BIT | (MT_BIT - 1)) ? ", " : "", szPrefix);
+       }
 }
 
-void usage(void) {
-  FatalError("Usage: loaderinfo -f <generic-device>\n");
+static void Report_DCP(DEVICE_TYPE MediumChangerFD)
+{
+       DCP_Type *result;
+       RequestSense_T RequestSense;
+
+       /* Get the page. */
+       result=(DCP_Type *)mode_sense(MediumChangerFD,0x1f,sizeof(DCP_Type),&RequestSense);
+       if (!result) 
+       {
+               printf("Device Configuration Page: No\n");
+               return;
+       }
+
+       printf("Device Configuration Page: Yes\n");
+
+       printf("Storage: ");
+
+       if (result->CanStore & DT_BIT)
+       {
+               printf("Data Transfer");
+       }
+
+       if (result->CanStore & IE_BIT)
+       {
+               printf("%sImport/Export", result->CanStore > (IE_BIT | (IE_BIT - 1)) ? ", " : "");
+       }
+
+       if (result->CanStore & ST_BIT)
+       {
+               printf("%sStorage", result->CanStore > (ST_BIT | (ST_BIT - 1)) ? ", " : "");
+       }
+
+       if (result->CanStore & MT_BIT)
+       {
+               printf("%sMedium Transfer", result->CanStore > (MT_BIT | (MT_BIT - 1)) ? ", " : "");
+       }
+
+       printf("\n");
+
+       printf("SCSI Media Changer (rev 2): ");
+
+       if (result->SMC2_Caps & 0x01)
+       {
+               printf("Yes\n");
+
+               printf("Volume Tag Reader Present: %s\n", result->SMC2_Caps & 0x02 ? "Yes" : "No");
+               printf("Auto-Clean Enabled: %s\n", result->SMC2_Caps & 0x04 ? "Yes" : "No");
+       }
+       else
+       {
+               printf("No\n");
+       }
+
+       printf("Transfer Medium Transport: ");
+       if ((result->MT_Transfer & 0x0F) != 0)
+       {
+               TransferExchangeTargets(result->MT_Transfer, "->");
+       }
+       else
+       {
+               printf("None");
+       }
+
+       printf("\nTransfer Storage: ");
+       if ((result->ST_Transfer & 0x0F) != 0)
+       {
+               TransferExchangeTargets(result->ST_Transfer, "->");
+       }
+       else
+       {
+               printf("None");
+       }
+
+       printf("\nTransfer Import/Export: ");
+       if ((result->IE_Transfer & 0x0F) != 0)
+       {
+               TransferExchangeTargets(result->IE_Transfer, "->");
+       }
+       else
+       {
+               printf("None");
+       }
+
+       printf("\nTransfer Data Transfer: ");
+       if ((result->DT_Transfer & 0x0F) != 0)
+       {
+               TransferExchangeTargets(result->DT_Transfer, "->");
+       }
+       else
+       {
+               printf("None");
+       }
+
+       printf("\nExchange Medium Transport: ");
+       if ((result->MT_Exchange & 0x0F) != 0)
+       {
+               TransferExchangeTargets(result->MT_Exchange, "<>");
+       }
+       else
+       {
+               printf("None");
+       }
+
+       printf("\nExchange Storage: ");
+       if ((result->ST_Exchange & 0x0F) != 0)
+       {
+               TransferExchangeTargets(result->ST_Exchange, "<>");
+       }
+       else
+       {
+               printf("None");
+       }
+
+       printf("\nExchange Import/Export: ");
+       if ((result->IE_Exchange & 0x0F) != 0)
+       {
+               TransferExchangeTargets(result->IE_Exchange, "<>");
+       }
+       else
+       {
+               printf("None");
+       }
+
+       printf("\nExchange Data Transfer: ");
+       if ((result->DT_Exchange & 0x0F) != 0)
+       {
+               TransferExchangeTargets(result->DT_Exchange, "<>");
+       }
+       else
+       {
+               printf("None");
+       }
+
+       printf("\n");
+
+       free(result);
+}
+
+void usage(void)
+{
+       FatalError("Usage: loaderinfo -f <generic-device>\n");
 }
 
 
 /* we only have one argument: "-f <device>". */
-int main(int argc, char **argv) {
-  DEVICE_TYPE fd;
-  char *filename;
-
-  argv0=argv[0];
-  if (argc != 3) {
-    fprintf(stderr,"argc=%d",argc);
-    usage();
-  }
-
-  if (strcmp(argv[1],"-f")!=0) {
-    usage();
-  }
-  filename=argv[2];
-  
-  fd=SCSI_OpenDevice(filename);
-  
-  /* Now to call the various routines: */
-  ReportInquiry(fd);
-  ReportEAAP(fd);
-  Report_TGDP(fd);
-  Report_DCP(fd);
-  exit(0);
+int main(int argc, char **argv)
+{
+       DEVICE_TYPE fd;
+       char *filename;
+
+       argv0=argv[0];
+       if (argc != 3)
+       {
+               fprintf(stderr,"argc=%d",argc);
+               usage();
+       }
+
+       if (strcmp(argv[1],"-f")!=0)
+       {
+               usage();
+       }
+
+       filename=argv[2];
+
+       fd=SCSI_OpenDevice(filename);
+
+       /* Now to call the various routines: */
+       ReportInquiry(fd);
+       ReportEAAP(fd);
+       Report_TGDP(fd);
+       Report_DCP(fd);
+       exit(0);
 }
index 0af64fac950e6e3f9b57dc934ee141915dd208d1..93f812141a9d0d6162a9145fd8a67b15cf681368 100755 (executable)
--- a/makedist
+++ b/makedist
@@ -15,5 +15,5 @@ then
 fi
 
 
-tar --exclude CVS -czvhf mtx-${1}.tar.gz mtx-${1}
+tar --exclude CVS --exclude .svn -czvhf mtx-${1}.tar.gz mtx-${1}
 
index 4b1efc062c544b279ae59f832e411253336148f3..4f99eaec8ac716237723b68932afa5fc030dcfd5 100644 (file)
@@ -1,10 +1,10 @@
 /* Mammoth 2 Debug Buffer Dumper
    Copyright 2000 Enhanced Software Technologies Inc.
 
-$Date: 2001/06/05 17:10:21 $
-$Revision: 1.1.1.1 $
+$Date: 2006-02-20 19:08:53 -0800 (Mon, 20 Feb 2006) $
+$Revision: 123 $
 
-   Written by Eric Lee Green <eric@estinc.com>
+   Written by Eric Lee Green <eric@badtux.org>
    Released under the terms of the GNU General Public License v2 or
     above.
 
index 9c30e4e5b420b279dac838acfbdb8bcdc33df2b4..e4e44678faab928b9002eb44d93a90f65f472b8c 100644 (file)
@@ -1,10 +1,10 @@
 /* Mammoth 2 Debug Buffer Dumper
    Copyright 2000 Enhanced Software Technologies Inc.
 
-$Date: 2001/06/05 17:10:21 $
-$Revision: 1.1.1.1 $
+$Date: 2006-02-20 19:08:53 -0800 (Mon, 20 Feb 2006) $
+$Revision: 123 $
 
-   Written by Eric Lee Green <eric@estinc.com>
+   Written by Eric Lee Green <eric@badtux.org>
    Released under the terms of the GNU General Public License v2 or
     above.
 
diff --git a/msvc/config.h b/msvc/config.h
new file mode 100644 (file)
index 0000000..08902cb
--- /dev/null
@@ -0,0 +1,37 @@
+/* config.h.  Generated by configure.  */
+/* Copyright 2001 Enhanced Software Technologies Inc.
+ * Released under GNU General Public License V2 or Above
+ * See http://www.gnu.org for more information about the terms of
+ * the GNU General Public License.
+ * $Date: 2007-01-28 19:23:33 -0800 (Sun, 28 Jan 2007) $
+ * $Revision: 125 $
+ */
+
+#ifndef CONFIG_H
+#define CONFIG_H 1
+
+/* autoconf changes these. */
+#define HAVE_STRING_H 1
+#define HAVE_UNISTD_H 0
+#define HAVE_STDLIB_H 1
+#define HAVE_STDARG_H 1
+#define HAVE_SCSI_SCSI_H 0
+#define HAVE_SCSI_SCSI_IOCTL_H 0
+#define HAVE_SCSI_SG_H 0
+#define HAVE_SYS_GSCDDS_H 0
+#define HAVE_CAMLIB_H 0
+#define HAVE_SYS_SCSI_IMPL_USCSI_H 0
+#define HAVE_SYS_SCSI_CTL_H 0
+#define HAVE_DSLIB_H 0
+#define HAVE_DU_DEFS_H 0
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_FCNTL_H 1
+#define HAVE_SYS_IOCTL_H 0
+#define HAVE_SYS_MTIO_H 0
+#define HAVE_DDK_NTDDSCSI_H 0
+
+#define WORDS_BIGENDIAN 0
+
+#endif
+
diff --git a/msvc/loaderinfo/loaderinfo.vcproj b/msvc/loaderinfo/loaderinfo.vcproj
new file mode 100644 (file)
index 0000000..4d3df91
--- /dev/null
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="loaderinfo"\r
+       ProjectGUID="{13712060-F1FC-4498-97A7-5DA5A38F04DD}"\r
+       RootNamespace="loaderinfo"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="4"\r
+                               DisableSpecificWarnings="4214"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               RuntimeLibrary="0"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="4"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="3"\r
+                               DisableSpecificWarnings="4214"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\loaderinfo.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\mtxl.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/msvc/mtx.sln b/msvc/mtx.sln
new file mode 100644 (file)
index 0000000..3b39f7f
--- /dev/null
@@ -0,0 +1,50 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 9.00\r
+# Visual Studio 2005\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loaderinfo", "loaderinfo\loaderinfo.vcproj", "{13712060-F1FC-4498-97A7-5DA5A38F04DD}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mtx", "mtx\mtx.vcproj", "{7DD926F5-30EA-47D4-B67B-E32C0E221440}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scsitape", "scsitape\scsitape.vcproj", "{D19E95BD-87C6-4C91-A208-FB8338580F75}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tapeinfo", "tapeinfo\tapeinfo.vcproj", "{A1C8D34F-66EC-4F74-8261-C96B97727218}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nsmhack", "nsmhack\nsmhack.vcproj", "{1B3C0A23-4021-4928-92FA-76743B7F7F76}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scsieject", "scsieject\scsieject.vcproj", "{E3B77A78-FD72-4AD7-933A-0503FB21551D}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {13712060-F1FC-4498-97A7-5DA5A38F04DD}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {13712060-F1FC-4498-97A7-5DA5A38F04DD}.Debug|Win32.Build.0 = Debug|Win32\r
+               {13712060-F1FC-4498-97A7-5DA5A38F04DD}.Release|Win32.ActiveCfg = Release|Win32\r
+               {13712060-F1FC-4498-97A7-5DA5A38F04DD}.Release|Win32.Build.0 = Release|Win32\r
+               {7DD926F5-30EA-47D4-B67B-E32C0E221440}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {7DD926F5-30EA-47D4-B67B-E32C0E221440}.Debug|Win32.Build.0 = Debug|Win32\r
+               {7DD926F5-30EA-47D4-B67B-E32C0E221440}.Release|Win32.ActiveCfg = Release|Win32\r
+               {7DD926F5-30EA-47D4-B67B-E32C0E221440}.Release|Win32.Build.0 = Release|Win32\r
+               {D19E95BD-87C6-4C91-A208-FB8338580F75}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {D19E95BD-87C6-4C91-A208-FB8338580F75}.Debug|Win32.Build.0 = Debug|Win32\r
+               {D19E95BD-87C6-4C91-A208-FB8338580F75}.Release|Win32.ActiveCfg = Release|Win32\r
+               {D19E95BD-87C6-4C91-A208-FB8338580F75}.Release|Win32.Build.0 = Release|Win32\r
+               {A1C8D34F-66EC-4F74-8261-C96B97727218}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {A1C8D34F-66EC-4F74-8261-C96B97727218}.Debug|Win32.Build.0 = Debug|Win32\r
+               {A1C8D34F-66EC-4F74-8261-C96B97727218}.Release|Win32.ActiveCfg = Release|Win32\r
+               {A1C8D34F-66EC-4F74-8261-C96B97727218}.Release|Win32.Build.0 = Release|Win32\r
+               {1B3C0A23-4021-4928-92FA-76743B7F7F76}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {1B3C0A23-4021-4928-92FA-76743B7F7F76}.Debug|Win32.Build.0 = Debug|Win32\r
+               {1B3C0A23-4021-4928-92FA-76743B7F7F76}.Release|Win32.ActiveCfg = Release|Win32\r
+               {1B3C0A23-4021-4928-92FA-76743B7F7F76}.Release|Win32.Build.0 = Release|Win32\r
+               {E3B77A78-FD72-4AD7-933A-0503FB21551D}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {E3B77A78-FD72-4AD7-933A-0503FB21551D}.Debug|Win32.Build.0 = Debug|Win32\r
+               {E3B77A78-FD72-4AD7-933A-0503FB21551D}.Release|Win32.ActiveCfg = Release|Win32\r
+               {E3B77A78-FD72-4AD7-933A-0503FB21551D}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/msvc/mtx/Distributions.txt b/msvc/mtx/Distributions.txt
new file mode 100644 (file)
index 0000000..7f13a59
--- /dev/null
@@ -0,0 +1,49 @@
+Debian
+======
+
+Maintainer: BDale Garbee (bdale@gag.com) (Official)
+Stable Version: 1.2.16rel-4
+Testing Version: 1.2.17rel-2
+
+Merged: Yes
+
+FreeBSD
+
+Maintainer: mbr@freebsd.org
+Stable Version: 1.2.17rel
+
+Merged: Yes
+
+Gentoo
+======
+
+Maintainer: Tom Gall (tgall@gentoo.org) (Last change)
+Stable Version: 1.2.18
+
+Merged: No changes
+
+Mandriva
+========
+
+Maintainer: Buchan Milne <bgmilne@linux-mandrake.com>
+Stable Version: 1.2.18-1mdk
+
+Merged: No changes
+
+
+Redhat
+======
+
+Maintainer: Jesse Keating <jkeating@redhat.com> (Last change) (jnovy@redhat.com)
+Stable Version: 1.2.18-8
+
+Merged: No additional changes
+
+
+SuSE
+====
+
+Maintainer http://www.suse.de/feedback
+Stable Version: 1.2.18rel-119
+
+Merged: No additional changes
diff --git a/msvc/mtx/mtx.vcproj b/msvc/mtx/mtx.vcproj
new file mode 100644 (file)
index 0000000..bffae8e
--- /dev/null
@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="mtx"\r
+       ProjectGUID="{7DD926F5-30EA-47D4-B67B-E32C0E221440}"\r
+       RootNamespace="mtx"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               PreprocessorDefinitions="VERSION=\&quot;1.3.9-rbn\&quot;;LONG_PRINT_REQUEST_SENSE;WIN32;_DEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="4"\r
+                               DisableSpecificWarnings="4214"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               PreprocessorDefinitions="VERSION=\&quot;1.3.11\&quot;;WIN32;NDEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               RuntimeLibrary="0"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="4"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="3"\r
+                               DisableSpecificWarnings="4214"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\mtx.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               CompileAs="1"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               CompileAs="1"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\mtxl.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               CompileAs="1"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               CompileAs="1"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\mtx.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\mtxl.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+               <File\r
+                       RelativePath=".\Distributions.txt"\r
+                       >\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/msvc/nsmhack/nsmhack.vcproj b/msvc/nsmhack/nsmhack.vcproj
new file mode 100644 (file)
index 0000000..9bebb9c
--- /dev/null
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="nsmhack"\r
+       ProjectGUID="{1B3C0A23-4021-4928-92FA-76743B7F7F76}"\r
+       RootNamespace="nsmhack"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="4"\r
+                               DisableSpecificWarnings="4214"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               RuntimeLibrary="0"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="3"\r
+                               DisableSpecificWarnings="4214"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\mtxl.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\nsmhack.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\mtx.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\mtxl.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/msvc/scsieject/scsieject.vcproj b/msvc/scsieject/scsieject.vcproj
new file mode 100644 (file)
index 0000000..ca08707
--- /dev/null
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="scsieject"\r
+       ProjectGUID="{E3B77A78-FD72-4AD7-933A-0503FB21551D}"\r
+       RootNamespace="scsieject"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="4"\r
+                               DisableSpecificWarnings="4214;4996"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               RuntimeLibrary="0"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="4"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="3"\r
+                               DisableSpecificWarnings="4214;4996"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\mtxl.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\scsieject.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/msvc/scsitape/scsitape.vcproj b/msvc/scsitape/scsitape.vcproj
new file mode 100644 (file)
index 0000000..cc2d55b
--- /dev/null
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="scsitape"\r
+       ProjectGUID="{D19E95BD-87C6-4C91-A208-FB8338580F75}"\r
+       RootNamespace="scsitape"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="4"\r
+                               DisableSpecificWarnings="4214;4996"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               RuntimeLibrary="0"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="4"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="3"\r
+                               DisableSpecificWarnings="4214;4996"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\mtxl.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\scsitape.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/msvc/tapeinfo/tapeinfo.vcproj b/msvc/tapeinfo/tapeinfo.vcproj
new file mode 100644 (file)
index 0000000..07e8ecc
--- /dev/null
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="tapeinfo"\r
+       ProjectGUID="{A1C8D34F-66EC-4F74-8261-C96B97727218}"\r
+       RootNamespace="tapeinfo"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="4"\r
+                               DisableSpecificWarnings="4214"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="2"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_DEPRECATE"\r
+                               RuntimeLibrary="0"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="4"\r
+                               Detect64BitPortabilityProblems="false"\r
+                               DebugInformationFormat="3"\r
+                               DisableSpecificWarnings="4214"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\mtxl.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\tapeinfo.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\mtx.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\mtxl.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/mtx.1 b/mtx.1
index 936205357f84ba9945923fbf3854b9fd9ce2792a..893825450fb2d076239093cbbd2bc39cd1981561 100644 (file)
--- a/mtx.1
+++ b/mtx.1
@@ -1,6 +1,6 @@
 .\" mtx.1  Document copyright 2000 Eric Lee Green
 .\"  Program Copyright 1996, 1997 Leonard Zubkoff
-.\"  Extensive changes 2000 by Eric Lee Green <eric@estinc.com>
+.\"  Extensive changes 2000 by Eric Lee Green <eric@badtux.org>
 .\"
 .\" This is free documentation; you can redistribute it and/or
 .\" modify it under the terms of the GNU General Public License as
@@ -22,7 +22,7 @@
 .\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
 .\" USA.
 .\"
-.TH MTX 1 MTX1.2
+.TH MTX 1 MTX1.3
 .SH NAME
 mtx \- control SCSI media changer devices 
 .SH SYNOPSIS
@@ -116,27 +116,39 @@ Valid values for eepos <operation>
 are 0 (do nothing to the import/export tray), 1, and 2 (what 1 and 2 do varies
 depending upon the library, consult your library's SCSI-level 
 documentation). 
+.TP 10
+.B [eepos <operation>] [invert] [invert2] exchange <slotnum> <slotnum> [<slotnum>]
+Move medium from the first slot to the second slot, placing the medium
+currently in the second slot either back into the first slot or into the
+optional third slot. 
+
 .TP 10
 .B first  [<drivenum>]
-Loads drive <drivenum> from the first slot in the media changer. Unloads
-the drive if there is already media in it.  Note that
-this command may not be what you want on large tape libraries -- e.g. on Exabyte 220, the first slot is
-usually a cleaning tape. If <drivenum> is omitted, defaults to first drive.
+Loads drive <drivenum> from the first slot in the media
+changer. Unloads the drive if there is already media in it (note: you
+may need to eject the tape using your OS's tape control commands
+first).  Note that this command may not be what you want on large
+tape libraries -- e.g. on Exabyte 220, the first slot is usually a
+cleaning tape. If <drivenum> is omitted, defaults to first drive.
 
 .TP 10
 .B last [<drivenum>]
 Loads drive <drivenum> from the last slot in the media changer. Unloads
-the drive if there is already a tape in it. 
+the drive if there is already a tape in it. (Note: you may need to eject
+the tape using your OS's tape control commands first).  
 .TP 10
 .B next [<drivenum>]
 Unloads the drive and loads the next tape in sequence. If the drive was
 empty, loads the first tape into the drive.
+.TP 10
+.B position <slotnum>
+Positions the robot at a specific slot. Needed by some changers to
+move to and open the import/export, or mailbox, slot.
 
 .SH AUTHORS
 The original 'mtx' program was written by Leonard Zubkoff and extensively
 revised for large multi-drive libraries with bar code readers 
-by Eric Lee Green <eric@badtux.org>, to whom all problems should
-be reported for this revision. See 'mtx.c' for other contributors. 
+by Eric Lee Green <eric@badtux.org>. See 'mtx.c' for other contributors. 
 .SH BUGS AND LIMITATIONS
 .P
 You may need to do a 'mt offline' on the tape drive to eject the tape
@@ -191,7 +203,8 @@ reader and 21 slots, an Exabyte EZ-17 7-slot autoloader, and a Seagate
 DDS-4 autochanger with 6 slots). It may not work on other operating systems 
 with larger libraries,
 due to the big SCSI request size. 
-Report problems to Eric Lee Green <eric@badtux.org>.  
+Please see the projecdt page http://sourceforge.net/projects/mtx for information 
+on reporting bugs, requesting features and the mailing list for peer support.
 .SH HINTS
 Under Linux, 
 .B cat /proc/scsi/scsi
@@ -215,14 +228,14 @@ tape changers (see /kernel/drv/sgen.conf and the sgen man page), type
 then reboot. You can find your changer in /devices by typing
 .B /usr/sbin/devfsadm -C
 to clean out no-longer-extant entries in your /devices directory, then
-.B find /devices -name \*changer -print
+.B find /devices -name \e\(**changer -print
 to find the device name. Set the symbolic link 
 .B /dev/changer 
 to point
 to that device name (if it is not doing so already).
 .P
-With BRU, set your mount and unmount commands as described on the EST
-web site at http://www.estinc.com to move to the next tape when backing up
+With BRU, set your mount and unmount commands as described on the BRU
+web site at http://www.bru.com to move to the next tape when backing up
 or restoring. With GNU 
 .B tar,
 see 
@@ -236,11 +249,8 @@ to make multi-tape backups.
 .SH AVAILABILITY
 This version of 
 .B mtx
-is currently being maintained by Eric Lee Green <eric@badtux.org> formerly of
-Enhanced Software Technologies Inc. The 'mtx' home page is
-http://mtx.sourceforge.net and the actual code
-is currently available there and via CVS from 
-http://sourceforge.net/projects/mtx/ . 
-
+is currently being maintained by Robert Nelson <robertnelson@users.sourceforge.net> .
+The 'mtx' home page is http://mtx.sourceforge.net and the actual code is currently available
+there and via SVN from http://sourceforge.net/projects/mtx. 
 .SH SEE ALSO
-.BR mt (1), tapeinfo (1), scsitape(1), loaderinfo(1)
+.BR mt (1), loaderinfo (1), tapeinfo (1), scsitape (1), scsieject (1)
diff --git a/mtx.c b/mtx.c
index 7eed0bad59b7c9c8d8f0b9929b1f9abc40bdb44d..58140e703671b40c0db8f5cccd3356c4e0f1523d 100644 (file)
--- a/mtx.c
+++ b/mtx.c
 /*
 
-  MTX -- SCSI Tape Attached Medium Changer Control Program
-  $Date: 2001/11/06 21:20:40 $
-  $Revision: 1.2.2.1 $
+       MTX -- SCSI Tape Attached Medium Changer Control Program
+       $Date: 2007-03-24 18:14:01 -0700 (Sat, 24 Mar 2007) $
+       $Revision: 166 $
 
-  Copyright 1997-1998 by Leonard N. Zubkoff <lnz@dandelion.com>
-  Now maintained by Eric Lee Green <eric@estinc.com>
+       Copyright 1997-1998 by Leonard N. Zubkoff.
+       Copyright 1999-2006 by Eric Lee Green.
+       Copyright 2007 by Robert Nelson <robertn@the-nelsons.org>
 
-  This program is free software; you may redistribute and/or modify it under
-  the terms of the GNU General Public License Version 2 as published by the
-  Free Software Foundation.
+       This program is free software; you may redistribute and/or modify it under
+       the terms of the GNU General Public License Version 2 as published by the
+       Free Software Foundation.
 
-  This program is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
-  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-  for complete details.
+       This program is distributed in the hope that it will be useful, but
+       WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
+       or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+       for complete details.
 
-  The author respectfully requests that any modifications to this software be
-  sent directly to him for evaluation and testing.
+       The author respectfully requests that any modifications to this software be
+       sent directly to him for evaluation and testing.
 
-  Thanks to Philip A. Prindeville <philipp@enteka.com> of Enteka Enterprise
-  Technology Service for porting MTX to Solaris/SPARC.
+       Thanks to Philip A. Prindeville <philipp@enteka.com> of Enteka Enterprise
+       Technology Service for porting MTX to Solaris/SPARC.
 
-  Thanks to Carsten Koch <Carsten.Koch@icem.de> for porting MTX to SGI IRIX.
+       Thanks to Carsten Koch <Carsten.Koch@icem.de> for porting MTX to SGI IRIX.
 
-  Thanks to TECSys Development, Inc. for porting MTX to Digital Unix and
-  OpenVMS.
-
-  Changes Feb 2000 Eric Lee Green <eric@estinc.com> to add support for
-  multi-drive tape changers, extract out library stuff into mtxl.c,
-  and otherwise bring things up to date for dealing with LARGE tape jukeboxes
-  and other such enterprise-class storage subsystems. 
+       Thanks to TECSys Development, Inc. for porting MTX to Digital Unix and
+       OpenVMS.
 
+       Near complete re-write Feb 2000 Eric Lee Green <eric@badtux.org> to add support for
+       multi-drive tape changers, extract out library stuff into mtxl.c,
+       and otherwise bring things up to date for dealing with LARGE tape jukeboxes
+       and other such enterprise-class storage subsystems. 
 */
 
 char *argv0;
 
-#include "mtx.h"   /* various defines for bit order etc. */
+#include "mtx.h"       /* various defines for bit order etc. */
 #include "mtxl.h"
 
 /* A table for printing out the peripheral device type as ASCII. */ 
-static char *PeripheralDeviceType[32] = {
-  "Disk Drive",  /* 0 */
-  "Tape Drive",   /* 1 */
-  "Printer",   /* 2 */
-  "Processor",   /* 3 */
-  "Write-once",   /* 4 */
-  "CD-ROM",       /* 5 */
-  "Scanner",      /* 6 */
-  "Optical",      /* 7 */ 
-  "Medium Changer",  /* 8 */
-  "Communications",  /* 9 */
-  "ASC IT8",           /* a */ 
-  "ASC IT8",            /* b */
-  "RAID Array",         /* c */
-  "Enclosure Services",  /* d */
-  "RBC Simplified Disk", /* e */
-  "OCR/W",           /* f */
-  "Bridging Expander", /* 0x10 */
-  "Reserved",  /* 0x11 */
-  "Reserved", /* 0x12 */
-  "Reserved",  /* 0x13 */
-  "Reserved",  /* 0x14 */
-  "Reserved",  /* 0x15 */
-  "Reserved",  /* 0x16 */
-  "Reserved",  /* 0x17 */
-  "Reserved",  /* 0x18 */
-  "Reserved",  /* 0x19 */
-  "Reserved",  /* 0x1a */
-  "Reserved",  /* 0x1b */
-  "Reserved",  /* 0x1c */
-  "Reserved",  /* 0x1d */
-  "Reserved",  /* 0x1e */
-  "Unknown"    /* 0x1f */
+static char *PeripheralDeviceType[32] =
+{
+       "Disk Drive",                   /* 0 */
+       "Tape Drive",                   /* 1 */
+       "Printer",                              /* 2 */
+       "Processor",                    /* 3 */
+       "Write-once",                   /* 4 */
+       "CD-ROM",                               /* 5 */
+       "Scanner",                              /* 6 */
+       "Optical",                              /* 7 */ 
+       "Medium Changer",               /* 8 */
+       "Communications",               /* 9 */
+       "ASC IT8",                              /* a */ 
+       "ASC IT8",                              /* b */
+       "RAID Array",                   /* c */
+       "Enclosure Services",   /* d */
+       "RBC Simplified Disk",  /* e */
+       "OCR/W",                                /* f */
+       "Bridging Expander",    /* 0x10 */
+       "Reserved",                             /* 0x11 */
+       "Reserved",                             /* 0x12 */
+       "Reserved",                             /* 0x13 */
+       "Reserved",                             /* 0x14 */
+       "Reserved",                             /* 0x15 */
+       "Reserved",                             /* 0x16 */
+       "Reserved",                             /* 0x17 */
+       "Reserved",                             /* 0x18 */
+       "Reserved",                             /* 0x19 */
+       "Reserved",                             /* 0x1a */
+       "Reserved",                             /* 0x1b */
+       "Reserved",                             /* 0x1c */
+       "Reserved",                             /* 0x1d */
+       "Reserved",                             /* 0x1e */
+       "Unknown"                               /* 0x1f */
 };
-  
+
 static int argc;
 static char **argv;
 
+static char *device=NULL;              /* the device name passed as argument */
 
-
-
-static char *device=NULL; /* the device name passed as argument */
-
-/* Unfortunately this must be true for SGI, because SGI does not
-   use an int :-(. 
+/*     Unfortunately this must be true for SGI, because SGI does not
+       use an int :-(.
 */
 
-static DEVICE_TYPE MediumChangerFD = (DEVICE_TYPE) 0;
-static int device_opened = 0;  /* okay, replace check here. */
+static DEVICE_TYPE MediumChangerFD = (DEVICE_TYPE) -1;
+static int device_opened = 0;  /* okay, replace check here. */
 
-/* was: static int MediumChangerFD=-1; *//* open filehandle to that device */
-static int arg1=-1;       /* first arg to command */
-static int arg2=-1;       /* second arg to command */
+static int arg1 = -1;                  /* first arg to command */
+static int arg2 = -1;                  /* second arg to command */
+static int arg3 = -1;                  /* third arg to command, if exchange. */
 
-static SCSI_Flags_T SCSI_Flags = { 0, 0, 0,0 };
-  
-/* static int invert_bit=0;*/  /* we by default do not invert... */
-/* static int eepos=0;     */  /* the extend thingy for import/export. */
-static Inquiry_T *inquiry_info;  /* needed by MoveMedium etc... */
-static ElementStatus_T *ElementStatus = NULL;
+static SCSI_Flags_T SCSI_Flags = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
+static Inquiry_T *inquiry_info;                /* needed by MoveMedium etc... */
+static ElementStatus_T *ElementStatus = NULL;
+void Position(int dest);
 
 /* pre-defined commands: */
 static void ReportInquiry(void);
@@ -110,7 +106,7 @@ static void Unload(void);
 static void First(void);
 static void Last(void);
 static void Next(void);
-/* static void Previous(void); */
+static void Previous(void);
 static void InvertCommand(void);
 static void Transfer(void);
 static void Eepos(void);
@@ -120,433 +116,739 @@ static void do_Inventory(void);
 static void do_Unload(void);
 static void do_Erase(void);
 static void NoBarCode(void);
+static void do_Position(void);
+static void Invert2(void);
+static void Exchange(void);
+static void AltReadElementStatus(void);
 
-struct command_table_struct {
-  int num_args;
-  char *name;
-  void (*command)(void);
-  int need_device;
-  int need_status;
-} command_table[] = {
-  { 0, "inquiry",ReportInquiry, 1,0},
-  { 0, "status", Status, 1,1 },
-  { 0, "invert", InvertCommand, 0,0},
-  { 0, "noattach",NoAttach,0,0},
-  { 1, "eepos", Eepos, 0,0},
-  { 2, "load", Load, 1,1 },
-  { 2, "unload", Unload, 1,1 },
-  { 2, "transfer", Transfer, 1,1 },
-  { 1, "first", First, 1,1 },
-  { 1, "last", Last, 1,1 },
-  { 1, "next", Next, 1,1 },
-  { 0, "--version", Version, 0,0 },
-  { 0, "inventory", do_Inventory, 1,0},
-  { 0, "eject", do_Unload, 1, 0},
-  { 0, "erase", do_Erase, 1, 0},
-  { 0, "nobarcode", NoBarCode, 0,0},
-  { 0, NULL, NULL }
+struct command_table_struct
+{
+       int num_args;
+       char *name;
+       void (*command)(void);
+       int need_device;
+       int need_status;
+}
+command_table[] =
+{
+       { 0, "inquiry",ReportInquiry, 1,0},
+       { 0, "status", Status, 1,1 },
+       { 0, "invert", InvertCommand, 0,0},
+       { 0, "noattach",NoAttach,0,0},
+       { 1, "eepos", Eepos, 0,0},
+       { 2, "load", Load, 1,1 },
+       { 2, "unload", Unload, 1,1 },
+       { 2, "transfer", Transfer, 1,1 },
+       { 1, "first", First, 1,1 },
+       { 1, "last", Last, 1,1 },
+       { 1, "previous", Previous, 1,1 },
+       { 1, "next", Next, 1,1 },
+       { 0, "--version", Version, 0,0 },
+       { 0, "inventory", do_Inventory, 1,0},
+       { 0, "eject", do_Unload, 1, 0},
+       { 0, "erase", do_Erase, 1, 0},
+       { 0, "nobarcode", NoBarCode, 0,0},
+       { 1, "position", do_Position, 1, 1},
+       { 0, "invert2", Invert2, 0, 0}, 
+       { 3, "exchange", Exchange, 1, 1 },
+       { 0, "altres", AltReadElementStatus, 0,0},
+       { 0, NULL, NULL }
 };
 
 static void Usage()
 {
-  fprintf(stderr, "Usage:\n\
-  mtx --version\n\
-  mtx [ -f <loader-dev> ] noattach <more commands>\n\
-  mtx [ -f <loader-dev> ] inquiry | inventory \n\
-  mtx [ -f <loader-dev> ] [nobarcode] status\n\
-  mtx [ -f <loader-dev> ] first [<drive#>]\n\
-  mtx [ -f <loader-dev> ] last [<drive#>]\n\
-  mtx [ -f <loader-dev> ] next [<drive#>]\n\
-  mtx [ -f <loader-dev> ] [invert] load <storage-element-number> [<drive#>]\n\
-  mtx [ -f <loader-dev> ] [invert] unload [<storage-element-number>][<drive#>]\n\
-  mtx [ -f <loader-dev> ] [eepos eepos-number] transfer <storage-element-number> <storage-element-number>\n\
-  mtx [ -f <device> ] eject\n");
+       fprintf(stderr, "Usage:\n\
+       mtx --version\n\
+       mtx [ -f <loader-dev> ] noattach <more commands>\n\
+       mtx [ -f <loader-dev> ] inquiry | inventory \n\
+       mtx [ -f <loader-dev> ] [altres] [nobarcode] status\n\
+       mtx [ -f <loader-dev> ] [altres] first [<drive#>]\n\
+       mtx [ -f <loader-dev> ] [altres] last [<drive#>]\n\
+       mtx [ -f <loader-dev> ] [altres] previous [<drive#>]\n\
+       mtx [ -f <loader-dev> ] [altres] next [<drive#>]\n\
+       mtx [ -f <loader-dev> ] [altres] [invert] load <storage-element-number> [<drive#>]\n\
+       mtx [ -f <loader-dev> ] [altres] [invert] unload [<storage-element-number>][<drive#>]\n\
+       mtx [ -f <loader-dev> ] [altres] [eepos eepos-number] transfer <storage-element-number> <storage-element-number>\n\
+       mtx [ -f <loader-dev> ] [altres] [eepos eepos-number][invert][invert2] exchange <storage-element-number> <storage-element-number>\n\
+       mtx [ -f <loader-dev> ] [altres] position <storage-element-number>\n\
+       mtx [ -f <loader-dev> ] eject\n");
 
 #ifndef VMS
-  exit(1);
+       exit(1);
 #else
-  sys$exit(VMS_ExitCode);
+       sys$exit(VMS_ExitCode);
 #endif
 }
 
 
+static void Version(void)
+{
+       fprintf(stderr, "mtx version %s\n\n", VERSION);
+       Usage(); 
+}
+
+
+static void NoAttach(void)
+{
+       SCSI_Flags.no_attached = 1;
+}
+
+
+static void InvertCommand(void)
+{
+       SCSI_Flags.invert = 1;          /* invert_bit=1;*/
+}
+
+
+static void Invert2(void)
+{
+       SCSI_Flags.invert2 = 1;         /* invert2_bit=1;*/
+}
+
 
-static void Version(void) {
-  fprintf(stderr,"mtx version %s\n\n",VERSION);
-  Usage(); 
+static void NoBarCode(void)
+{
+       SCSI_Flags.no_barcodes = 1;     /* don't request barcodes */
 }
 
-static void NoAttach(void) {
-  SCSI_Flags.no_attached=1;
+
+static void do_Position(void)
+{
+       int driveno,src;
+
+       if (arg1 >= 0 && arg1 <= ElementStatus->StorageElementCount)
+       {
+               driveno = arg1 - 1;
+       }
+       else
+       {
+               driveno = 0;
+       }
+
+       src = ElementStatus->StorageElementAddress[driveno];
+       Position(src);
 }
 
-static void InvertCommand(void) {
-  SCSI_Flags.invert=1;
-  /* invert_bit=1;*/
+
+static void AltReadElementStatus(void)
+{
+       /* use alternative way to read element status from device - used to support XL1B2 */
+       SCSI_Flags.querytype = MTX_ELEMENTSTATUS_READALL;
 }
 
-static void NoBarCode(void) {
-  SCSI_Flags.no_barcodes=1;  /* don't request barcodes, sigh! */
-} 
 
 /* First and Last are easy. Next is the bitch. */
-static void First(void){
-  int driveno;
-  /* okay, first see if we have a drive#: */
-  if (arg1 >= 0 && arg1 < ElementStatus->DataTransferElementCount) {
-    driveno=arg1;
-  } else {
-    driveno = 0;
-  }
-  /* now see if there's anything *IN* that drive: */
-  if (ElementStatus->DataTransferElementFull[driveno]) {
-    /* if so, then unload it... */
-    arg1=ElementStatus->DataTransferElementSourceStorageElementNumber[driveno]+1;
-    if (arg1==1) {
-      printf("loading...done.\n");  /* it already has tape #1 in it! */ 
-      return;
-    }
-    arg2=driveno;
-    Unload();
-  }
-  /* and now to actually do the Load(): */
-  arg2=driveno;
-  arg1=1; /* first! */
-  Load(); /* and voila! */
-  
+static void First(void)
+{
+       int driveno;
+       /* okay, first see if we have a drive#: */
+       if (arg1 >= 0 && arg1 < ElementStatus->DataTransferElementCount)
+       {
+               driveno = arg1;
+       }
+       else
+       {
+               driveno = 0;
+       }
+
+       /* now see if there's anything *IN* that drive: */
+       if (ElementStatus->DataTransferElementFull[driveno])
+       {
+               /* if so, then unload it... */
+               arg1 = ElementStatus->DataTransferElementSourceStorageElementNumber[driveno] + 1;
+               if (arg1 == 1)
+               {
+                       printf("loading...done.\n");  /* it already has tape #1 in it! */ 
+                       return;
+               }
+               arg2 = driveno;
+               Unload();
+       }
+
+       /* and now to actually do the Load(): */
+       arg1 = 1;       /* first! */
+       arg2 = driveno;
+       Load();         /* and voila! */
 }
 
-static void Last(void) {
-  int driveno;
-  /* okay, first see if we have a drive#: */
-  if (arg1 >= 0 && arg1 < ElementStatus->DataTransferElementCount) {
-    driveno=arg1;
-  } else {
-    driveno = 0;
-  }
-
-  /* now see if there's anything *IN* that drive: */
-  if (ElementStatus->DataTransferElementFull[driveno]) {
-    /* if so, then unload it... */
-    arg1=ElementStatus->DataTransferElementSourceStorageElementNumber[driveno]+1;
-    if (arg1==ElementStatus->StorageElementCount) {
-      printf("loading...done.\n");  /* it already has last tape in it! */ 
-      return;
-    }
-    arg2=driveno;
-    Unload();
-  }
-
-  arg1 = ElementStatus->StorageElementCount; /* the last slot... */
-  arg2=driveno;
-  Load(); /* and load it, sigh! */
+static void Last(void)
+{
+       int driveno;
+
+       /* okay, first see if we have a drive#: */
+       if (arg1 >= 0 && arg1 < ElementStatus->DataTransferElementCount)
+       {
+               driveno = arg1;
+       }
+       else
+       {
+               driveno = 0;
+       }
+
+       /* now see if there's anything *IN* that drive: */
+       if (ElementStatus->DataTransferElementFull[driveno])
+       {
+               /* if so, then unload it... */
+               arg1 = ElementStatus->DataTransferElementSourceStorageElementNumber[driveno] + 1;
+               if (arg1 >= (ElementStatus->StorageElementCount - ElementStatus->ImportExportCount))
+               {
+                       printf("loading...done.\n");    /* it already has last tape in it! */ 
+                       return;
+               }
+               arg2 = driveno;
+               Unload();
+       }
+
+       arg1 = ElementStatus->StorageElementCount - ElementStatus->ImportExportCount;   /* the last slot... */
+       arg2 = driveno;
+       Load();
+}
+
+
+static void Previous(void)
+{
+       int driveno;
+       int current = ElementStatus->StorageElementCount - ElementStatus->ImportExportCount + 1;
+
+       /* okay, first see if we have a drive#: */
+       if (arg1 >= 0 && arg1 < ElementStatus->DataTransferElementCount)
+       {
+               driveno = arg1;
+       }
+       else
+       {
+               driveno = 0;
+       }
+
+       /* Now to see if there's anything in that drive! */
+       if (ElementStatus->DataTransferElementFull[driveno])
+       {
+               /* if so, unload it! */
+               current = ElementStatus->DataTransferElementSourceStorageElementNumber[driveno];
+               if (current == 0)
+               {
+                       FatalError("No More Media\n");          /* Already at the 1st slot...*/
+               }
+               arg1 = current + 1;             /* Args are 1 based */
+               arg2 = driveno;
+               Unload();
+       }
+
+       /* Position current to previous element */
+       for (current--; current >= 0; current--)
+       {
+               if (ElementStatus->StorageElementFull[current])
+               {
+                       arg1 = current + 1;
+                       arg2 = driveno;
+                       Load();
+                       return;
+               }
+       }
 
+       FatalError("No More Media\n");          /* First slot */
 }
 
 
-static void Next(void) {
-  int driveno;
-  int current=0; 
-  /* okay, first see if we have a drive#: */
-  if (arg1 >= 0 && arg1 < ElementStatus->DataTransferElementCount) {
-    driveno=arg1;
-  } else {
-    driveno = 0;
-  }
-
-  /* Now to see if there's anything in that drive! */
-  if (ElementStatus->DataTransferElementFull[driveno]) {
-    /* if so, unload it! */
-    arg1=ElementStatus->DataTransferElementSourceStorageElementNumber[driveno]+1;
-    current=arg1;
-    arg2=driveno;
-    Unload();
-  }
-  
-  /* okay, now to load, if we can... */
-  current++;
-  if (current > ElementStatus->StorageElementCount) { /* the last slot... */
-    FatalError("No More Tapes\n");
-  }
-  arg1=current;
-  arg2=driveno;
-  Load();
+static void Next(void)
+{
+       int driveno;
+       int current = -1;
+
+       /* okay, first see if we have a drive#: */
+       if (arg1 >= 0 && arg1 < ElementStatus->DataTransferElementCount)
+       {
+               driveno = arg1;
+       }
+       else
+       {
+               driveno = 0;
+       }
+
+       /* Now to see if there's anything in that drive! */
+       if (ElementStatus->DataTransferElementFull[driveno])
+       {
+               /* if so, unload it! */
+               current = ElementStatus->DataTransferElementSourceStorageElementNumber[driveno];
+
+               arg1 = current + 1;
+               arg2 = driveno;
+               Unload();
+       }
+
+       for (current++;
+                current < (ElementStatus->StorageElementCount - ElementStatus->ImportExportCount);
+                current++)
+       {
+               if (ElementStatus->StorageElementFull[current])
+               {
+                       arg1 = current + 1;
+                       arg2 = driveno;
+                       Load();
+                       return;
+               }
+       }
+
+       FatalError("No More Media\n");          /* last slot */
 }
 
 static void do_Inventory(void) 
 {
-  int i;
-  i=Inventory(MediumChangerFD);
-  if (i < 0) {
-    fprintf(stderr,"mtx:inventory failed\n");
-    fflush(stderr);
-    exit(1); /*  exit with an error status. */
-  }
-  return;  /* if it failed, well, sigh.... */
+       if (Inventory(MediumChangerFD) < 0)
+       {
+               fprintf(stderr,"mtx:inventory failed\n");
+               fflush(stderr);
+               exit(1);        /*  exit with an error status. */
+       }
 }
 
-/* For Linux, this allows us to do a short erase on a tape (sigh!).
+/*
+ * For Linux, this allows us to do a short erase on a tape (sigh!).
  * Note that you'll need to do a 'mt status' on the tape afterwards in
  * order to get the tape driver in sync with the tape drive again. Also
  * note that on other OS's, this might do other evil things to the tape
  * driver. Note that to do an erase, you must first rewind using the OS's
  * native tools!
  */
-static void do_Erase(void) {
-  RequestSense_T *RequestSense;
-  RequestSense=Erase(MediumChangerFD);
-  if (RequestSense) {
-    PrintRequestSense(RequestSense);
-    exit(1);  /* exit with an error status. */
-  }
-  return;
+static void do_Erase(void)
+{
+       RequestSense_T *RequestSense;
+       RequestSense = Erase(MediumChangerFD);
+       if (RequestSense)
+       {
+               PrintRequestSense(RequestSense);
+               exit(1);        /* exit with an error status. */
+       }
 }
-  
+       
 
 /* This should eject a tape or magazine, depending upon the device sent
  * to.
  */
 static void do_Unload(void)
 {
-  int i;
-  i=Eject(MediumChangerFD);
-  if (i<0) {
-    fprintf(stderr,"mtx:eject failed\n");
-    fflush(stderr);
-  }
-  return;  /* if it failed, well, sigh.... */
+       if (LoadUnload(MediumChangerFD, 0) < 0)
+       {
+               fprintf(stderr, "mtx:eject failed\n");
+               fflush(stderr);
+       }
 }
 
 static void ReportInquiry(void)
 {
-  RequestSense_T RequestSense;
-  Inquiry_T *Inquiry;
-  int i;
-
-  Inquiry = RequestInquiry(MediumChangerFD,&RequestSense);
-  if (Inquiry == NULL) 
-    {
-      PrintRequestSense(&RequestSense);
-      FatalError("INQUIRY Command Failed\n");
-    }
-  
-  printf("Product Type: %s\n",PeripheralDeviceType[Inquiry->PeripheralDeviceType]);
-  printf("Vendor ID: '");
-  for (i = 0; i < sizeof(Inquiry->VendorIdentification); i++)
-    printf("%c", Inquiry->VendorIdentification[i]);
-  printf("'\nProduct ID: '");
-  for (i = 0; i < sizeof(Inquiry->ProductIdentification); i++)
-    printf("%c", Inquiry->ProductIdentification[i]);
-  printf("'\nRevision: '");
-  for (i = 0; i < sizeof(Inquiry->ProductRevisionLevel); i++)
-    printf("%c", Inquiry->ProductRevisionLevel[i]);
-  printf("'\n");\
-  if (Inquiry->MChngr) {  /* check the attached-media-changer bit... */
-    printf("Attached Changer: Yes\n");
-  } else {
-    printf("Attached Changer: No\n");
-  }
-  free(Inquiry);  /* well, we're about to exit, but ... */
+       RequestSense_T RequestSense;
+       Inquiry_T *Inquiry;
+       int i;
+
+       Inquiry = RequestInquiry(MediumChangerFD,&RequestSense);
+       if (Inquiry == NULL) 
+       {
+               PrintRequestSense(&RequestSense);
+               FatalError("INQUIRY Command Failed\n");
+       }
+       
+       printf("Product Type: %s\n", PeripheralDeviceType[Inquiry->PeripheralDeviceType]);
+       printf("Vendor ID: '");
+       for (i = 0; i < sizeof(Inquiry->VendorIdentification); i++)
+       {
+               printf("%c", Inquiry->VendorIdentification[i]);
+       }
+
+       printf("'\nProduct ID: '");
+       for (i = 0; i < sizeof(Inquiry->ProductIdentification); i++)
+       {
+               printf("%c", Inquiry->ProductIdentification[i]);
+       }
+
+       printf("'\nRevision: '");
+       for (i = 0; i < sizeof(Inquiry->ProductRevisionLevel); i++)
+       {
+               printf("%c", Inquiry->ProductRevisionLevel[i]);
+       }
+       printf("'\n");
+
+       if (Inquiry->MChngr)
+       {
+               /* check the attached-media-changer bit... */
+               printf("Attached Changer API: Yes\n");
+       }
+       else
+       {
+               printf("Attached Changer API: No\n");
+       }
+
+       free(Inquiry);          /* well, we're about to exit, but ... */
 }
 
 static void Status(void)
 {
-  int StorageElementNumber;
-  int TransferElementNumber;
-  printf("  Storage Changer %s:%d Drives, %d Slots ( %d Import/Export )\n",
-        device,
-        ElementStatus->DataTransferElementCount,
-        ElementStatus->StorageElementCount,
-        ElementStatus->ImportExportCount);
-
-
-  for (TransferElementNumber=0;TransferElementNumber <
-        ElementStatus->DataTransferElementCount;TransferElementNumber++) {
-    
-    printf("Data Transfer Element %d:",TransferElementNumber);
-    if (ElementStatus->DataTransferElementFull[TransferElementNumber])
-      {
-       if (ElementStatus->DataTransferElementSourceStorageElementNumber[TransferElementNumber] > -1) 
-         printf("Full (Storage Element %d Loaded)",
-                ElementStatus->DataTransferElementSourceStorageElementNumber[TransferElementNumber]+1);
-       else printf("Full (Unknown Storage Element Loaded)");
-       if
-         (ElementStatus->DataTransferPrimaryVolumeTag[TransferElementNumber][0])
-         printf(":VolumeTag = %s",ElementStatus->DataTransferPrimaryVolumeTag[TransferElementNumber]);
-       if
-         (ElementStatus->DataTransferAlternateVolumeTag[TransferElementNumber][0])
-         
-         printf(":AlternateVolumeTag = %s",ElementStatus->DataTransferAlternateVolumeTag[TransferElementNumber]); 
-       putchar('\n');
-      }
-    else printf("Empty\n");
-  }
-
-  for (StorageElementNumber = 0;
-       StorageElementNumber < ElementStatus->StorageElementCount;
-       StorageElementNumber++) {
-    printf("      Storage Element %d%s:%s", StorageElementNumber+1, 
-          (ElementStatus->StorageElementIsImportExport[StorageElementNumber]) ? " IMPORT/EXPORT" : "",
-          (ElementStatus->StorageElementFull[StorageElementNumber] ? "Full " : "Empty"));
-    if (ElementStatus->PrimaryVolumeTag[StorageElementNumber][0]) {
-      printf(":VolumeTag=%s",ElementStatus->PrimaryVolumeTag[StorageElementNumber]);
-    }
-    if (ElementStatus->AlternateVolumeTag[StorageElementNumber][0]) {
-            printf(":AlternateVolumeTag=%s",ElementStatus->AlternateVolumeTag[StorageElementNumber]);
-    }
-    putchar('\n');
-  }
-  
+       int StorageElementNumber;
+       int TransferElementNumber;
+
+       printf( "  Storage Changer %s:%d Drives, %d Slots ( %d Import/Export )\n",
+                       device,
+                       ElementStatus->DataTransferElementCount,
+                       ElementStatus->StorageElementCount,
+                       ElementStatus->ImportExportCount);
+
+
+       for (TransferElementNumber = 0; 
+                TransferElementNumber < ElementStatus->DataTransferElementCount;
+                TransferElementNumber++)
+       {
+               
+               printf("Data Transfer Element %d:", TransferElementNumber);
+               if (ElementStatus->DataTransferElementFull[TransferElementNumber])
+               {
+                       if (ElementStatus->DataTransferElementSourceStorageElementNumber[TransferElementNumber] > -1)
+                       {
+                               printf("Full (Storage Element %d Loaded)",
+                                               ElementStatus->DataTransferElementSourceStorageElementNumber[TransferElementNumber]+1);
+                       }
+                       else
+                       {
+                               printf("Full (Unknown Storage Element Loaded)");
+                       }
+
+                       if (ElementStatus->DataTransferPrimaryVolumeTag[TransferElementNumber][0])
+                       {
+                               printf(":VolumeTag = %s", ElementStatus->DataTransferPrimaryVolumeTag[TransferElementNumber]);
+                       }
+
+                       if (ElementStatus->DataTransferAlternateVolumeTag[TransferElementNumber][0])
+                       {
+                               printf(":AlternateVolumeTag = %s", ElementStatus->DataTransferAlternateVolumeTag[TransferElementNumber]); 
+                       }
+                       putchar('\n');
+               }
+               else
+               {
+                       printf("Empty\n");
+               }
+       }
+
+       for (StorageElementNumber = 0;
+                StorageElementNumber < ElementStatus->StorageElementCount;
+                StorageElementNumber++)
+       {
+               printf( "      Storage Element %d%s:%s", StorageElementNumber + 1,
+                               (ElementStatus->StorageElementIsImportExport[StorageElementNumber]) ? " IMPORT/EXPORT" : "",
+                               (ElementStatus->StorageElementFull[StorageElementNumber] ? "Full " : "Empty"));
+
+               if (ElementStatus->PrimaryVolumeTag[StorageElementNumber][0])
+               {
+                       printf(":VolumeTag=%s", ElementStatus->PrimaryVolumeTag[StorageElementNumber]);
+               }
+
+               if (ElementStatus->AlternateVolumeTag[StorageElementNumber][0])
+               {
+                       printf(":AlternateVolumeTag=%s", ElementStatus->AlternateVolumeTag[StorageElementNumber]);
+               }
+               putchar('\n');
+       }
+
 #ifdef VMS
-  VMS_DefineStatusSymbols();
+       VMS_DefineStatusSymbols();
 #endif
 }
 
+void Position(int dest)
+{
+       if (PositionElement(MediumChangerFD,dest,ElementStatus) != NULL)
+       {
+               FatalError("Could not position transport\n");
+       }
+}
+
 void Move(int src, int dest) {
-  RequestSense_T *result; /* from MoveMedium */
-  
-  result=MoveMedium(MediumChangerFD,src,dest,ElementStatus,inquiry_info,&SCSI_Flags);
-  if (result)   /* we have an error! */
-     {
-      if (result->AdditionalSenseCode == 0x3B &&
-         result->AdditionalSenseCodeQualifier == 0x0E)
-       FatalError("source Element Address %d is Empty\n", src);
-      if (result->AdditionalSenseCode == 0x3B &&
-         result->AdditionalSenseCodeQualifier == 0x0D)
-       FatalError("destination Element Address %d is Already Full\n",
-                  dest);
-      if (result->AdditionalSenseCode == 0x30 &&
-         result->AdditionalSenseCodeQualifier == 0x03)
-       FatalError("Cleaning Cartridge Installed and Ejected\n");
-      PrintRequestSense(result);
-      FatalError("MOVE MEDIUM from Element Address %d to %d Failed\n",
-                src,dest);
-    }
-}   
+       RequestSense_T *result; /* from MoveMedium */
+       
+       result = MoveMedium(MediumChangerFD, src, dest, ElementStatus, inquiry_info, &SCSI_Flags);
+       if (result)
+       {
+               /* we have an error! */
+
+               if (result->AdditionalSenseCode == 0x30 &&
+                       result->AdditionalSenseCodeQualifier == 0x03)
+               {
+                       FatalError("Cleaning Cartridge Installed and Ejected\n");
+               }
+
+               if (result->AdditionalSenseCode == 0x3A &&
+                       result->AdditionalSenseCodeQualifier == 0x00)
+               {
+                       FatalError("Drive needs offline before move\n");
+               }
+
+               if (result->AdditionalSenseCode == 0x3B &&
+                       result->AdditionalSenseCodeQualifier == 0x0D)
+               {
+                       FatalError("Destination Element Address %d is Already Full\n", dest);
+               }
+
+               if (result->AdditionalSenseCode == 0x3B &&
+                       result->AdditionalSenseCodeQualifier == 0x0E)
+               {
+                       FatalError("Source Element Address %d is Empty\n", src);
+               }
+
+               PrintRequestSense(result);
+               FatalError("MOVE MEDIUM from Element Address %d to %d Failed\n", src, dest);
+       }
+}
+
 
 /* okay, now for the Load, Unload, etc. logic: */
 
-static void Load(void) {
-  int src, dest;
-  /* okay, check src, dest: arg1=src, arg2=dest */
-  if (arg1 < 1) {
-    FatalError("No source specified\n");
-  }
-  if (arg2 < 0) {
-    arg2 = 0; /* default to 1st drive :-( */
-  }
-  arg1--;  /* we use zero-based arrays, sigh, not 1 base like some lusers */
-  /* check for filehandle: */
-  if (!device_opened) {
-    FatalError("No Media Changer Device Specified\n");
-  } 
-  /* okay, we should be there: */
-  if (arg1 < 0 || arg1 >= ElementStatus->StorageElementCount) {
-       FatalError(
-         "illegal <storage-element-number> argument '%s' to 'load' command\n",
-         arg1+1);
-  }
-  if (arg2 < 0 || arg2 >= ElementStatus->DataTransferElementCount) {
-    FatalError(
-              "illegal <drive-number> argument '%s' to 'load' command\n",
-              arg2);
-  }
-  if (ElementStatus->DataTransferElementFull[arg2])  {
-    FatalError("Drive %d Full (Storage Element %d loaded)\n",arg2,
-              ElementStatus->DataTransferElementSourceStorageElementNumber[arg2]+1);
-  }
-  /* Now look up the actual devices: */
-  dest=ElementStatus->DataTransferElementAddress[arg2];
-  src=ElementStatus->StorageElementAddress[arg1];
-  Move(src,dest);  /* load it into the particular slot, if possible! */
-  /* now set the status for further command son this line... */
-  ElementStatus->StorageElementFull[arg1] = false;
-  ElementStatus->DataTransferElementFull[arg2] = true;
-
-  return; /* and done! */
+static void Load(void)
+{
+       int src, dest;
+
+       /* okay, check src, dest: arg1=src, arg2=dest */
+       if (arg1 < 1)
+       {
+               FatalError("No source specified\n");
+       }
+
+       if (arg2 < 0)
+       {
+               arg2 = 0;       /* default to 1st drive :-( */
+       }
+
+       arg1--;                 /* we use zero-based arrays */
+
+       if (!device_opened)
+       {
+               FatalError("No Media Changer Device Specified\n");
+       } 
+
+       if (arg1 < 0 || arg1 >= ElementStatus->StorageElementCount)
+       {
+               FatalError(     "Invalid <storage-element-number> argument '%d' to 'load' command\n",
+                                       arg1 + 1);
+       }
+
+       if (arg2 < 0 || arg2 >= ElementStatus->DataTransferElementCount)
+       {
+               FatalError(     "illegal <drive-number> argument '%d' to 'load' command\n",
+                                       arg2);
+       }
+
+       if (ElementStatus->DataTransferElementFull[arg2])
+       {
+               FatalError(     "Drive %d Full (Storage Element %d loaded)\n", arg2,
+                                       ElementStatus->DataTransferElementSourceStorageElementNumber[arg2] + 1);
+       }
+
+       /* Now look up the actual devices: */
+       src = ElementStatus->StorageElementAddress[arg1];
+       dest = ElementStatus->DataTransferElementAddress[arg2];
+
+       fprintf(stdout, "Loading media from Storage Element %d into drive %d...", arg1 + 1, arg2);
+       fflush(stdout);
+
+       Move(src,dest);  /* load it into the particular slot, if possible! */
+
+       fprintf(stdout,"done\n");
+       fflush(stdout);
+
+       /* now set the status for further commands on this line... */
+       ElementStatus->StorageElementFull[arg1] = false;
+       ElementStatus->DataTransferElementFull[arg2] = true;
 }
 
-static void Transfer(void) {
-  int src,dest;
-  if (arg1 < 1 ) {
-    FatalError("No source specified\n");
-  } 
-  if (arg2 < 1) {
-    FatalError("No destination specified\n");
-  }
-  if (arg1 > ElementStatus->StorageElementCount) {
-    FatalError("Invalid source\n");
-  }
-  if (arg2 > ElementStatus->StorageElementCount) {
-    FatalError("Invalid destination\n");
-  }
-  /* okay, that's done... */
-  src=ElementStatus->StorageElementAddress[arg1-1];
-  dest=ElementStatus->StorageElementAddress[arg2-1];
-  Move(src,dest);
+static void Transfer(void)
+{
+       int src,dest;
+
+       if (arg1 < 1)
+       {
+               FatalError("No source specified\n");
+       }
+
+       if (arg2 < 1)
+       {
+               FatalError("No destination specified\n");
+       }
+
+       if (arg1 > ElementStatus->StorageElementCount)
+       {
+               FatalError("Invalid source\n");
+       }
+
+       if (arg2 > ElementStatus->StorageElementCount)
+       {
+               FatalError("Invalid destination\n");
+       }
+
+       src = ElementStatus->StorageElementAddress[arg1 - 1];
+       dest = ElementStatus->StorageElementAddress[arg2 - 1];
+       Move(src,dest);
 }
 
-static void Eepos(void) {
-  if (arg1 < 0 || arg1 > 3) {
-    FatalError("eepos equires argument between 0 and 3.\n");
-  }
-  SCSI_Flags.eepos=arg1;
+/****************************************************************
+ * Exchange() -- exchange medium in two slots, if so
+ * supported by the jukebox in question.
+ ***************************************************************/
+
+static void Exchange(void)
+{
+       RequestSense_T *result; /* from ExchangeMedium */
+       int src,dest,dest2;
+
+       if (arg1 < 1)
+       {
+               FatalError("No source specified\n");
+       }
+
+       if (arg2 < 1)
+       {
+               FatalError("No destination specified\n");
+       }
+
+       if (arg1 > ElementStatus->StorageElementCount)
+       {
+               FatalError("Invalid source\n");
+       }
+
+       if (arg2 > ElementStatus->StorageElementCount)
+       {
+               FatalError("Invalid destination\n");
+       }
+
+       if (arg3 == -1)
+       {
+               arg3 = arg1;  /* true exchange of medium */
+       }
+
+       src = ElementStatus->StorageElementAddress[arg1 - 1];
+       dest = ElementStatus->StorageElementAddress[arg2 - 1];
+       dest2 = ElementStatus->StorageElementAddress[arg3 - 1];
+       
+       result = ExchangeMedium(MediumChangerFD, src, dest, dest2, ElementStatus, &SCSI_Flags);
+       if (result)
+       {
+               /* we have an error! */
+               if (result->AdditionalSenseCode == 0x30 &&
+                       result->AdditionalSenseCodeQualifier == 0x03)
+               {
+                       FatalError("Cleaning Cartridge Installed and Ejected\n");
+               }
+
+               if (result->AdditionalSenseCode == 0x3A &&
+                       result->AdditionalSenseCodeQualifier == 0x00)
+               {
+                       FatalError("Drive needs offline before move\n");
+               }
+
+               if (result->AdditionalSenseCode == 0x3B &&
+                       result->AdditionalSenseCodeQualifier == 0x0D)
+               {
+                       FatalError("Destination Element Address %d is Already Full\n", dest);
+               }
+
+               if (result->AdditionalSenseCode == 0x3B &&
+                       result->AdditionalSenseCodeQualifier == 0x0E)
+               {
+                       FatalError("Source Element Address %d is Empty\n", src);
+               }
+
+               PrintRequestSense(result);
+
+               FatalError("EXCHANGE MEDIUM from Element Address %d to %d Failed\n", src, dest);
+       }
 }
 
+static void Eepos(void)
+{
+       if (arg1 < 0 || arg1 > 3)
+       {
+               FatalError("eepos equires argument between 0 and 3.\n");
+       }
 
-static void Unload(void) {
-  int src,dest;  /* the actual SCSI-level numbers */
-  if (arg2 < 0) {
-    arg2 = 0; /* default to 1st drive :-( */
-  }
-  /* check for filehandle: */
-  if (!device_opened) {
-    FatalError("No Media Changer Device Specified\n");
-  } 
-  /* okay, we should be there: */
-  if (arg1 < 0) {
-    arg1 = ElementStatus->DataTransferElementSourceStorageElementNumber[arg2];
-    if (arg1 < 0) {
-      FatalError("No Source for tape in drive %d!\n");
-    }
-  } else {
-    arg1--; /* go from bogus 1-base to zero-base */
-  }
-
-  if (arg1 >= ElementStatus->StorageElementCount) {
-       FatalError(
-         "illegal <storage-element-number> argument '%s' to 'unload' command\n",
-         arg1+1);
-  }
-    
-  if (arg2 < 0 || arg2 >= ElementStatus->DataTransferElementCount) {
-    FatalError(
-              "illegal <drive-number> argument '%s' to 'unload' command\n",
-              arg2);
-  }
-  if (ElementStatus->DataTransferElementFull[arg2] < 0 ) {
-    FatalError("Data Transfer Element %d is Empty\n", arg2);
-  }    
-  /* Now see if something already lives where  we wanna go... */
-  if (ElementStatus->StorageElementFull[arg1]) {
-    FatalError("Storage Element %d is Already Full\n", arg1+1);
-  }
-  /* okay, now to get src, dest: */
-  src=ElementStatus->DataTransferElementAddress[arg2];
-  if (arg1 >=0) {
-    dest=ElementStatus->StorageElementAddress[arg1];
-  } else {
-    dest=ElementStatus->DataTransferElementSourceStorageElementNumber[arg2];
-  }
-  if (dest < 0) { /* we STILL don't know, sigh... */
-    FatalError("Do not know which slot to unload tape into!\n");
-  }
-  fprintf(stderr, "Unloading Data Transfer Element into Storage Element %d...", arg1+1);
-  fflush(stderr); /* make it real-time :-( */ 
-  Move(src,dest);
-  fprintf(stderr, "done\n");
-  ElementStatus->StorageElementFull[arg1] = true;
-  ElementStatus->DataTransferElementFull[arg2] = false;
+       SCSI_Flags.eepos = (unsigned char)arg1;
+}
+
+
+static void Unload(void)
+{
+       int src, dest;          /* the actual SCSI-level numbers */
+
+       if (arg2 < 0)
+       {
+               arg2 = 0;               /* default to 1st drive :-( */
+       }
+
+       /* check for filehandle: */
+       if (!device_opened)
+       {
+               FatalError("No Media Changer Device Specified\n");
+       } 
+
+       /* okay, we should be there: */
+       if (arg1 < 0)
+       {
+               arg1 = ElementStatus->DataTransferElementSourceStorageElementNumber[arg2];
+               if (arg1 < 0)
+               {
+                       FatalError("No Source for tape in drive %d!\n",arg2);
+               }
+       }
+       else
+       {
+               arg1--;         /* go from bogus 1-base to zero-base */
+       }
+
+       if (arg1 >= ElementStatus->StorageElementCount)
+       {
+               FatalError( "illegal <storage-element-number> argument '%d' to 'unload' command\n",
+                                       arg1 + 1);
+       }
+
+       if (arg2 < 0 || arg2 >= ElementStatus->DataTransferElementCount)
+       {
+               FatalError(     "illegal <drive-number> argument '%d' to 'unload' command\n",
+                                       arg2);
+       }
+
+       if (!ElementStatus->DataTransferElementFull[arg2])
+       {
+               FatalError("Data Transfer Element %d is Empty\n", arg2);
+       }
+
+       /* Now see if something already lives where  we wanna go... */
+       if (ElementStatus->StorageElementFull[arg1])
+       {
+               FatalError("Storage Element %d is Already Full\n", arg1 + 1);
+       }
+
+       /* okay, now to get src, dest: */
+       src=ElementStatus->DataTransferElementAddress[arg2];
+       if (arg1 >= 0)
+       {
+               dest = ElementStatus->StorageElementAddress[arg1];
+       }
+       else
+       {
+               dest = ElementStatus->DataTransferElementSourceStorageElementNumber[arg2];
+       }
+
+       if (dest < 0)
+       {
+               /* we STILL don't know... */
+               FatalError("Do not know which slot to unload tape into!\n");
+       }
+
+       fprintf(stdout, "Unloading drive %d into Storage Element %d...", arg2, arg1 + 1);
+       fflush(stdout); /* make it real-time :-( */ 
+
+       Move(src,dest);
+
+       fprintf(stdout, "done\n");
+       fflush(stdout);
+
+       ElementStatus->StorageElementFull[arg1] = true;
+       ElementStatus->DataTransferElementFull[arg2] = false;
 }
 
 /*****************************************************************
@@ -562,66 +864,80 @@ static void Unload(void) {
  * we return -1. Note that 'get_arg' is kind of misleading, we only accept 
  * numeric arguments, not any other kind. 
  */
-int get_arg(int idx) {
-  char *arg;
-  int retval=-1;
-
-  if (idx >= argc) return -1;  /* sorry! */
-  arg=argv[idx];
-  if (*arg < '0' || *arg > '9') {
-    return -1;  /* sorry! */
-  }
-
-  retval=atoi(arg);
-  return retval;
-}
+int get_arg(int idx)
+{
+       char *arg;
+       int retval = -1;
 
-/* open_device() -- set the 'fh' variable.... */
-void open_device(void) {
+       if (idx >= argc)
+       {
+               return -1;  /* sorry! */
+       }
 
+       arg=argv[idx];
+       if (*arg < '0' || *arg > '9')
+       {
+               return -1;  /* sorry! */
+       }
 
-  if (device_opened) {
-    SCSI_CloseDevice("Unknown",MediumChangerFD);  /* close it, sigh...  new device now! */
-  }
+       retval = atoi(arg);
+       return retval;
+}
 
-  MediumChangerFD = SCSI_OpenDevice(device);
-  device_opened=1; /* SCSI_OpenDevice does an exit() if not. */
+/* open_device() -- set the 'fh' variable.... */
+void open_device(void)
+{
+       if (device_opened)
+       {
+               SCSI_CloseDevice("Unknown", MediumChangerFD);  /* close it, sigh...  new device now! */
+       }
+
+       MediumChangerFD = SCSI_OpenDevice(device);
+       device_opened = 1; /* SCSI_OpenDevice does an exit() if not. */
 }
-  
+
 
 /* we see if we've got a file open. If not, we open one :-(. Then
  * we execute the actual command. Or not :-(. 
  */ 
-void execute_command(struct command_table_struct *command) {
-  RequestSense_T RequestSense;
-
-
-  if ((device==NULL) && command->need_device) {
-   /* try to get it from TAPE environment variable... */
-    device=getenv("CHANGER");
-    if (device==NULL) {
-      device=getenv("TAPE");
-      if (device==NULL) {
-       device="/dev/changer"; /* Usage(); */
-      }
-    }
-    open_device();
-  }
-  if (!ElementStatus && command->need_status) {
-    inquiry_info=RequestInquiry(MediumChangerFD,&RequestSense);
-    if (!inquiry_info) {
-      PrintRequestSense(&RequestSense);
-      FatalError("INQUIRY command Failed\n");
-    }
-    ElementStatus = ReadElementStatus(MediumChangerFD,&RequestSense,inquiry_info,&SCSI_Flags);
-    if (!ElementStatus) {
-      PrintRequestSense(&RequestSense);                   
-      FatalError("READ ELEMENT STATUS Command Failed\n"); 
-    }
-  }
-
-  /* okay, now to execute the command... */
-  command->command();
+void execute_command(struct command_table_struct *command)
+{
+       RequestSense_T RequestSense;
+
+       if (device == NULL && command->need_device)
+       {
+               /* try to get it from TAPE environment variable... */
+               device = getenv("CHANGER");
+               if (device == NULL)
+               {
+                       device = getenv("TAPE");
+                       if (device == NULL)
+                       {
+                               device = "/dev/changer"; /* Usage(); */
+                       }
+               }
+               open_device();
+       }
+
+       if (!ElementStatus && command->need_status)
+       {
+               inquiry_info = RequestInquiry(MediumChangerFD,&RequestSense);
+               if (!inquiry_info)
+               {
+                       PrintRequestSense(&RequestSense);
+                       FatalError("INQUIRY command Failed\n");
+               }
+
+               ElementStatus = ReadElementStatus(MediumChangerFD, &RequestSense, inquiry_info, &SCSI_Flags);
+               if (!ElementStatus)
+               {
+                       PrintRequestSense(&RequestSense);
+                       FatalError("READ ELEMENT STATUS Command Failed\n"); 
+               }
+       }
+
+       /* okay, now to execute the command... */
+       command->command();
 }
 
 /* parse_args():
@@ -633,145 +949,127 @@ void execute_command(struct command_table_struct *command) {
  * in the cabinet). 
  */ 
 
-int parse_args(void) {
-  int i,cmd_tbl_idx;
-  struct command_table_struct *command;
-
-  i=1;
-  while (i<argc) {
-    if (strcmp(argv[i],"-f") == 0) {
-      i++;
-      if (i>=argc) {
-       Usage();
-      }
-      device=argv[i++];
-      open_device(); /* open the device and do a status scan on it... */
-    } else {
-      cmd_tbl_idx=0;
-      command=&command_table[0]; /* default to the first command... */
-      command=&command_table[cmd_tbl_idx];
-      while (command->name) {
-       if (!strcmp(command->name,argv[i])) {
-         /* we have a match... */
-         break;
-       }
-       /* otherwise we don't have a match... */
-       cmd_tbl_idx++;
-       command=&command_table[cmd_tbl_idx];
-      }
-      /* if it's not a command, exit.... */
-      if (!command->name) {
-       Usage();
-      }
-      i++;  /* go to the next argument, if possible... */
-      /* see if we need to gather arguments, though! */
-      if (command->num_args == 0) {
-       execute_command(command);  /* execute_command handles 'stuff' */
-      }
-      else {
-       arg1=get_arg(i);  /* checks i... */
-       if (arg1 != -1) {
-         i++;  /* next! */
-       }
-       if (command->num_args==2 && arg1 != -1) {
-         arg2=get_arg(i); 
-         if (arg2 != -1) {
-           i++;
-         }
-       }
-       execute_command(command);
-      }
-      arg1=-1;
-      arg2=-1;
-    }
-  }
-  return 0; /* should never get here. */
+int parse_args(void)
+{
+       int i, cmd_tbl_idx;
+       struct command_table_struct *command;
+
+       i = 1;
+       while (i < argc)
+       {
+               if (strcmp(argv[i], "-f") == 0)
+               {
+                       i++;
+                       if (i >= argc)
+                       {
+                               Usage();
+                       }
+
+                       device = argv[i++];
+                       open_device(); /* open the device and do a status scan on it... */
+               }
+               else
+               {
+                       cmd_tbl_idx = 0;                /* default to the first command... */
+                       command = &command_table[cmd_tbl_idx];
+
+                       while (command->name != NULL)
+                       {
+                               if (strcmp(command->name, argv[i]) == 0)
+                               {
+                                       /* we have a match... */
+                                       break;
+                               }
+                               /* otherwise we don't have a match... */
+                               cmd_tbl_idx++;
+                               command = &command_table[cmd_tbl_idx];
+                       }
+
+                       /* if it's not a command, exit.... */
+                       if (!command->name)
+                       {
+                               Usage();
+                       }
+
+                       i++;  /* go to the next argument, if possible... */
+                       /* see if we need to gather arguments, though! */
+                       if (command->num_args == 0)
+                       {
+                               execute_command(command);       /* execute_command handles 'stuff' */
+                       }
+                       else
+                       {
+                               arg1 = get_arg(i);                      /* checks i... */
+
+                               if (arg1 != -1)
+                               {
+                                       i++;    /* next! */
+                               }
+
+                               if (command->num_args>=2 && arg1 != -1)
+                               {
+                                       arg2 = get_arg(i); 
+                                       if (arg2 != -1)
+                                       {
+                                               i++;
+                                       }
+
+                                       if (command->num_args==3 && arg2 != -1)
+                                       {
+                                               arg3 = get_arg(i);
+                                               if (arg3 != -1)
+                                               {
+                                                       i++;
+                                               }
+                                       }
+                               }
+                               execute_command(command);
+                       }
+                       arg1 = -1;
+                       arg2 = -1;
+                       arg3 = -1;
+               }
+       }
+
+       /* should never get here. */
+       return 0;
 }
 
 
 
-int main(int ArgCount,
-        char *ArgVector[],
-        char *Environment[])
+int main(int ArgCount, char *ArgVector[])
 {
-
-
 #ifdef VMS
-  RequestSense_T RequestSense;
+       RequestSense_T RequestSense;
 #endif
-   
- /* save these where we can get at them elsewhere... */
-  argc=ArgCount;
-  argv=ArgVector;
 
-  argv0=argv[0];
+       /* save these where we can get at them elsewhere... */
+       argc = ArgCount;
+       argv = ArgVector;
 
-   
+       argv0 = argv[0];
 
-
-  parse_args();  /* also executes them as it sees them, sigh. */
+       parse_args();   /* also executes them as it sees them */
 
 #ifndef VMS
-  if (device) 
-    SCSI_CloseDevice(device, MediumChangerFD);
-  return 0;
+       if (device)
+       {
+               SCSI_CloseDevice(device, MediumChangerFD);
+       }
+       return 0;
 #else
-  if (device) {
-    ElementStatus = ReadElementStatus(MediumChangerFD,&RequestSense);
-    if (!ElementStatus) {
-      PrintRequestSense(&RequestSense);                   
-      FatalError("READ ELEMENT STATUS Command Failed\n"); 
-    }
-    VMS_DefineStatusSymbols();
-    SCSI_CloseDevice(device, MediumChangerFD);
-  }
-  return SS$_NORMAL;
-#endif
-
+       if (device)
+       {
+               ElementStatus = ReadElementStatus(MediumChangerFD,&RequestSense);
+               if (!ElementStatus)
+               {
+                       PrintRequestSense(&RequestSense);
+                       FatalError("READ ELEMENT STATUS Command Failed\n"); 
+               }
+               VMS_DefineStatusSymbols();
+               SCSI_CloseDevice(device, MediumChangerFD);
+       }
 
+       return SS$_NORMAL;
+#endif
 }
-/*
- *$Log: mtx.c,v $
- *Revision 1.2.2.1  2001/11/06 21:20:40  elgreen
- *Hopefully a fix to the problem with the 0 return for open in crontabs
- *
- *Revision 1.2  2001/06/09 17:26:26  elgreen
- *Added 'nobarcode' command to mtx (to skip the initial request asking for
- *barcodes for mtx status purposes).
- *
- *Revision 1.1.1.1  2001/06/05 17:10:22  elgreen
- *Initial import into SourceForge
- *
- *Revision 1.15  2001/04/18 16:32:59  eric
- *Cleaned up all -Wall messages.
- *
- *Revision 1.14  2001/04/18 16:08:08  eric
- *after re-arranging & fixing bugs
- *
- *Revision 1.13  2001/03/06 01:37:05  eric
- *Solaris changes
- *
- *Revision 1.12  2001/01/24 22:04:08  eric
- *added /dev/changer as default file name.
- *
- *Revision 1.11  2001/01/15 22:21:06  eric
- *added autoconf stuff.
- *
- *Revision 1.10  2000/11/30 20:37:17  eric
- *Added quicky 'erase' command because I needed blank tapes and Linux
- *only does long erases. (Not documented on purpose, because of rather
- *bizarre interactions with the native tape driver if you don't know
- *what you are doing).
- *
- *Revision 1.9  2000/11/28 01:10:50  eric
- *Fixed syntax error in mtx.c...
- *
- *Revision 1.8  2000/10/28 00:10:35  eric
- *Fixed stupid typo
- *
- *Revision 1.7  2000/10/27 23:36:57  eric
- *make mtx inventory return an error code if the inventory fails, so that
- *we can wait for inventory to be completed at system startup
- *
- *
- */
diff --git a/mtx.h b/mtx.h
index 1144ea61f1a63d3243a1488a09bc8e30b4bedb9e..12a6a144cbc9c2c991bc43f4af884e6a4237a265 100644 (file)
--- a/mtx.h
+++ b/mtx.h
@@ -1,12 +1,12 @@
 /* MTX -- SCSI Tape Attached Medium Control Program
 
-   Copyright 1997-1998 Leonard N. Zubkoff <lnz@dandelion.com>
-   Changes 1999 Eric Lee Green to add support for multi-drive tape changers.
+       Copyright 1997-1998 Leonard N. Zubkoff <lnz@dandelion.com>
 
-   $Date: 2001/06/19 21:51:32 $
-   $Revision: 1.3 $
-   See mtx.c for licensing information. 
+       Changes 1999 Eric Lee Green to add support for multi-drive tape changers.
+
+       $Date: 2007-03-04 15:27:11 -0800 (Sun, 04 Mar 2007) $
+       $Revision: 164 $
+       See mtx.c for licensing information. 
 
 */
 
 #include "[.vms]defs.h"
 #else /* all the Unix stuff:  */
 
+#ifdef _MSC_VER
+#include "msvc/config.h"  /* all the autoconf stuff. */
+#else
 #include "config.h"  /* all the autoconf stuff. */
+#endif
 
 /* all the general Unix includes: */
 
 #  include <sys/ioctl.h>
 #endif
 
-/* Now greately modified to use GNU Autoconf stuff: */
+#if HAVE_SYS_PARAM_H
+#  include <sys/param.h>
+#endif
+
+/* Now greatly modified to use GNU Autoconf stuff: */
 /* If we use the 'sg' interface, like Linux, do this: */
 #if HAVE_SCSI_SG_H
 #  include <scsi/scsi.h>
@@ -69,6 +77,25 @@ typedef int DEVICE_TYPE; /* the sg interface uses this. */
 #  define HAVE_GET_ID_LUN 1  /* signal that we have it... */
 #endif
 
+/* Windows Native programs built using MinGW */
+#if HAVE_DDK_NTDDSCSI_H
+#  include <windows.h>
+#  include <ddk/ntddscsi.h>
+#  undef DEVICE_TYPE
+
+typedef int DEVICE_TYPE;
+#endif
+
+/* Windows Native programs built using Microsoft Visual C */
+#ifdef _MSC_VER
+#  include <windows.h>
+#  include <winioctl.h>
+#  include <ntddscsi.h>
+#  undef DEVICE_TYPE
+
+typedef int DEVICE_TYPE;
+#endif
+
 /* The 'cam' interface, like FreeBSD: */
 #if HAVE_CAMLIB_H
 #  include <camlib.h> /* easy (?) access to the CAM user library. */
@@ -96,19 +123,10 @@ typedef int DEVICE_TYPE;
 #  endif
 #endif
 
-
-/* The 'tm_buf' interface, as used on AIX. */
-#ifdef HAVE_SYS_SCSI_H
-#include <sys/scsi.h>
-#include <sys/scsi_buf.h>
-#include <sys/devinfo.h> /* devinfo. */
-typedef struct tm_device_type {
-  int filenum;
-  int id;
-  int lun;
-  char *DeviceName;
-} *DEVICE_TYPE;
-    
+/* the 'gsc' interface, as used on AIX: */
+#if HAVE_SYS_GSCDDS_H
+#   include <sys/gscdds.h>
+    typedef int DEVICE_TYPE;
 #endif
 
    /* the 'dslib' interface, as used on SGI.  */
@@ -169,25 +187,42 @@ typedef dsreq_t *DEVICE_TYPE; /* 64-bit pointers/32bit int on later sgi? */
 #define MAX_TRANSFER_ELEMENTS 2  /* we just do dual-drive for now :-} */
 #define MAX_TRANSPORT_ELEMENTS 1 /* we just do one arm for now... */
 
+#define MTX_ELEMENTSTATUS_ORIGINAL 0
+#define MTX_ELEMENTSTATUS_READALL 1
+
 /* These are flags used for the READ_ELEMENT_STATUS and MOVE_MEDIUM
  * commands:
  */
-typedef struct SCSI_Flags_Struct {
-  unsigned char eepos;
-  unsigned char invert;
-  unsigned char no_attached; /* ignore _attached bit */
-  unsigned char no_barcodes;  /* don't try to get barcodes. */
-  int numbytes;
-  int elementtype;
-  int numelements;
-  int attached;
-  int has_barcodes;
-} SCSI_Flags_T;
-
+typedef struct SCSI_Flags_Struct
+{
+       unsigned char eepos;
+       unsigned char invert;
+       unsigned char no_attached; /* ignore _attached bit */
+       unsigned char no_barcodes;  /* don't try to get barcodes. */
+       int numbytes;
+       int elementtype;
+       int numelements;
+       int attached;
+       int has_barcodes;
+       int querytype; //MTX_ELEMENTSTATUS
+       unsigned char invert2; /* used for EXCHANGE command, sigh. */
+}      SCSI_Flags_T;
+
+#ifdef _MSC_VER
+typedef unsigned char boolean;
+
+#define false   0
+#define true    1
+
+typedef unsigned char Direction_T;
+
+#define Input   0
+#define Output  1
+#else
 typedef enum { false, true } boolean;
 
-
 typedef enum { Input, Output } Direction_T;
+#endif
 
 
 typedef unsigned char CDB_T[12];
@@ -362,6 +397,15 @@ typedef struct ElementModeSenseHeader {
 } ElementModeSense_T;
 
 
+#ifdef _MSC_VER
+typedef char ElementTypeCode_T;
+
+#define AllElementTypes                0
+#define MediumTransportElement  1
+#define StorageElement         2
+#define ImportExportElement     3
+#define DataTransferElement     4
+#else
 typedef enum ElementTypeCode
 {
   AllElementTypes =            0,
@@ -371,6 +415,7 @@ typedef enum ElementTypeCode
   DataTransferElement =                4
 }
 ElementTypeCode_T;
+#endif
 
 
 typedef struct ElementStatusDataHeader
@@ -445,6 +490,9 @@ typedef struct TransportElementDescriptorShort
   unsigned char :6;                                    /* Byte 9 Bits 0-5 */
 #endif
   unsigned char SourceStorageElementAddress[2];                /* Bytes 10-11 */
+#ifdef HAS_LONG_DESCRIPTORS
+  unsigned char Reserved[4];                            /* Bytes 12-15 */
+#endif
 }
 TransportElementDescriptorShort_T;
 
@@ -480,12 +528,17 @@ typedef struct TransportElementDescriptor
 #endif
   unsigned char SourceStorageElementAddress[2];                /* Bytes 10-11 */
   unsigned char PrimaryVolumeTag[36];          /* barcode */
-  unsigned char AlternateVolumeTag[36];        
+  unsigned char AlternateVolumeTag[36];   
+#ifdef HAS_LONG_DESCRIPTORS
+  unsigned char Reserved[4];                           /* 4 extra bytes? */
+#endif
+     
 }
 TransportElementDescriptor_T;
 
 
 
+
 /* Now for element status data; */
 
 typedef unsigned char barcode[37];
@@ -520,4 +573,32 @@ typedef struct scsi_id {
 
 #define MEDIUM_CHANGER_TYPE 8  /* what type bits are set for medium changers. */
 
+/* The following two structs are used for the brain-dead functions of the
+ * NSM jukebox. 
+ */
+
+typedef struct NSM_Param {
+  unsigned char page_code;
+  unsigned char reserved;
+  unsigned char page_len_msb;
+  unsigned char page_len_lsb;
+  unsigned char allocation_msb;
+  unsigned char allocation_lsb;
+  unsigned char reserved2[2];
+  unsigned char command_code[4];
+  unsigned char command_params[2048]; /* egregious overkill. */
+} NSM_Param_T;
+
+extern RequestSense_T scsi_error_sense; 
+
+typedef struct NSM_Result {
+  unsigned char page_code;
+  unsigned char reserved;
+  unsigned char page_len_msb;
+  unsigned char page_len_lsb;
+  unsigned char command_code[4];
+  unsigned char ces_code[2]; 
+  unsigned char return_data[0xffff]; /* egregioius overkill */
+} NSM_Result_T;
+
 #endif  /* of multi-include protection. */
index 7327935df776a64118636c4750656ca5dc2209e8..063cc5f7a7ecceffd51b131cb1e6320c4140af80 100644 (file)
--- a/mtx.spec
+++ b/mtx.spec
@@ -1,10 +1,10 @@
 Name: mtx
-Version: 1.2.17rel
+Version: 1.3.11
 Release: 1
 Summary: SCSI media changer control program
-Copyright: Redistributable
+License: GPL
 Group: Utilities/System
-Source0: ftp://ftp.badtux.org/pub/storage/mtx/%{name}-%{version}.tar.gz
+Source0: ftp://ftp.opensource-sw.net/pub/mtx/development/%{name}-%{version}.tar.gz
 Url: http://%{name}.sourceforge.net
 BuildRoot: /var/tmp/%{name}-%{version}
 
@@ -28,10 +28,13 @@ mkdir -p $RPM_BUILD_ROOT/sbin
 install mtx $RPM_BUILD_ROOT/sbin/mtx
 mkdir -p $RPM_BUILD_ROOT/usr/sbin
 install loaderinfo $RPM_BUILD_ROOT/usr/sbin/loaderinfo
+install scsieject $RPM_BUILD_ROOT/usr/sbin/scsieject
 install scsitape $RPM_BUILD_ROOT/usr/sbin/scsitape
 install tapeinfo $RPM_BUILD_ROOT/usr/sbin/tapeinfo
 mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1
 install mtx.1 $RPM_BUILD_ROOT/%{_mandir}/man1/mtx.1
+install loaderinfo.1 $RPM_BUILD_ROOT/%{_mandir}/man1/loaderinfo.1
+install scsieject.1 $RPM_BUILD_ROOT/%{_mandir}/man1/scsieject.1
 install scsitape.1 $RPM_BUILD_ROOT/%{_mandir}/man1/scsitape.1
 install tapeinfo.1 $RPM_BUILD_ROOT/%{_mandir}/man1/tapeinfo.1
 
@@ -48,10 +51,11 @@ rm -rf $RPM_BUILD_ROOT
 /usr/sbin/*
 
 %changelog
-* Fri Nov 18 2001 Eric Green <eric@badtux.org>
-- 1.2.14
-- Moved changelog to end of spec file so it doesn't interfere
-- 
+* Fri Sep 27 2002 Eric Green <eric@badtux.org>
+- 1.3.0rel
+- move changelog to end.
+- change source directory to ftp.badtux.net. 
+- use * for files to catch new files. 
 
 * Wed Apr 18 2001 Kenneth Porter <shiva@well.com>
 - 1.2.12pre1
index 4e2c191a58fadd067b245477def061b0283af357..c19ae1eb9fdc2ee5ff633f29d9f2cd5b93231131 100644 (file)
@@ -2,9 +2,9 @@ Name: mtx
 Version: @@VERSION@@
 Release: 1
 Summary: SCSI media changer control program
-Copyright: Redistributable
+License: GPL
 Group: Utilities/System
-Source0: ftp://ftp.badtux.org/pub/storage/mtx/%{name}-%{version}.tar.gz
+Source0: ftp://ftp.opensource-sw.net/pub/mtx/development/%{name}-%{version}.tar.gz
 Url: http://%{name}.sourceforge.net
 BuildRoot: /var/tmp/%{name}-%{version}
 
@@ -28,10 +28,13 @@ mkdir -p $RPM_BUILD_ROOT/sbin
 install mtx $RPM_BUILD_ROOT/sbin/mtx
 mkdir -p $RPM_BUILD_ROOT/usr/sbin
 install loaderinfo $RPM_BUILD_ROOT/usr/sbin/loaderinfo
+install scsieject $RPM_BUILD_ROOT/usr/sbin/scsieject
 install scsitape $RPM_BUILD_ROOT/usr/sbin/scsitape
 install tapeinfo $RPM_BUILD_ROOT/usr/sbin/tapeinfo
 mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1
 install mtx.1 $RPM_BUILD_ROOT/%{_mandir}/man1/mtx.1
+install loaderinfo.1 $RPM_BUILD_ROOT/%{_mandir}/man1/loaderinfo.1
+install scsieject.1 $RPM_BUILD_ROOT/%{_mandir}/man1/scsieject.1
 install scsitape.1 $RPM_BUILD_ROOT/%{_mandir}/man1/scsitape.1
 install tapeinfo.1 $RPM_BUILD_ROOT/%{_mandir}/man1/tapeinfo.1
 
@@ -48,10 +51,11 @@ rm -rf $RPM_BUILD_ROOT
 /usr/sbin/*
 
 %changelog
-* Fri Nov 18 2001 Eric Green <eric@badtux.org>
-- 1.2.14
-- Moved changelog to end of spec file so it doesn't interfere
-- 
+* Fri Sep 27 2002 Eric Green <eric@badtux.org>
+- 1.3.0rel
+- move changelog to end.
+- change source directory to ftp.badtux.net. 
+- use * for files to catch new files. 
 
 * Wed Apr 18 2001 Kenneth Porter <shiva@well.com>
 - 1.2.12pre1
index 48d153747ae258c0b50c60f310a3c39fb1b7ca53..7f7e6d41fc22e4dbf99433892cb0adffa234feeb 100644 (file)
@@ -61,9 +61,9 @@ and there only with a limited set of hardware. See the COMPATIBILITY
 list in the source code.
 </ul>
 <h2> Source Code </h2>
-The current source code is at:
+The current source code is:
 <ul>
-<li> <a href="http://sourceforge.net/project/showfiles.php?group_id=4626">Sourceforge Download Page for 'mtx'</a>
+<li> <a href="http://mtx.sourceforge.net/mtx-1.2.13.tar.gz">http://mtx.sourceforge.net/mtx-1.2.13.tar.gz</a>
 </ul>
 RPMs may be available from the following place:
 <ul>
@@ -159,7 +159,7 @@ href="mailto:eric@badtux.org">eric@badtux.org</a>). READ THE FAQ FIRST!
 
 <!-- Created: Fri Mar  3 12:19:38 MST 2000 -->
 <!-- hhmts start -->
-Last modified: Fri Nov 16 11:09:19 MST 2001
+Last modified: Mon Jun 25 15:37:22 MST 2001
 <!-- hhmts end -->
   </body>
 </html>
diff --git a/mtxl.c b/mtxl.c
index c92c3480403e32d60441a7235a7772bd49ecd524..f3beea343aa7abc484a24e9359466d9d8a2c8c3f 100644 (file)
--- a/mtxl.c
+++ b/mtxl.c
@@ -1,34 +1,40 @@
 /*  MTX -- SCSI Tape Attached Medium Changer Control Program
 
-  Copyright 1997-1998 by Leonard N. Zubkoff <lnz@dandelion.com>
+       Copyright 1997-1998 by Leonard N. Zubkoff.
+       Copyright 1999-2006 by Eric Lee Green.
+       Copyright 2007 by Robert Nelson <robertn@the-nelsons.org>
 
-$Date: 2002/09/27 17:23:28 $
-$Revision: 1.8.2.7 $
+       $Date: 2007-03-24 18:14:01 -0700 (Sat, 24 Mar 2007) $
+       $Revision: 166 $
 
-  This file created Feb 2000 by Eric Lee Green <eric@badtux.org> from pieces
-  extracted from mtx.c, plus some additional routines. 
+       This file created Feb 2000 by Eric Lee Green <eric@badtux.org> from pieces
+       extracted from mtx.c, plus a near total re-write of most of the beast.
 
-  This program is free software; you may redistribute and/or modify it under
-  the terms of the GNU General Public License Version 2 as published by the
-  Free Software Foundation.
+       This program is free software; you may redistribute and/or modify it under
+       the terms of the GNU General Public License Version 2 as published by the
+       Free Software Foundation.
 
-  This program is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
-  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-  for complete details.
+       This program is distributed in the hope that it will be useful, but
+       WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
+       or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+       for complete details.
 */
 
 
-/* FatalError: changed Feb. 2000 elg@estinc.com to eliminate a buffer
-   overflow :-(. That could be important if mtxl is SUID for some reason. 
+/*
+ *     FatalError: changed Feb. 2000 elg@badtux.org to eliminate a buffer
+ *     overflow :-(. That could be important if mtxl is SUID for some reason. 
 */
 
 #include "mtx.h"
 #include "mtxl.h"
 
+/* #define DEBUG_NSM 1 */
+
 /* #define DEBUG_MODE_SENSE 1 */
 /* #define DEBUG */
 /* #define DEBUG_SCSI */
+#define __WEIRD_CHAR_SUPPRESS 1 
 
 /* zap the following define when we finally add real import/export support */
 #define IMPORT_EXPORT_HACK 1 /* for the moment, import/export == storage */
@@ -37,774 +43,1063 @@ $Revision: 1.8.2.7 $
 
 /* the camlib is used on FreeBSD. */
 #if HAVE_CAMLIB_H
-#  include "scsi_freebsd.c"
+#      include "scsi_freebsd.c"
 #endif
 
 /* the scsi_ctl interface is used on HP/UX. */
 #if HAVE_SYS_SCSI_CTL_H
-#  include "scsi_hpux.c"
+#      include "scsi_hpux.c"
 #endif
 
 /* the 'sg' interface is used on Linux. */
 #if HAVE_SCSI_SG_H
-#  include "scsi_linux.c"
+#      include "scsi_linux.c"
+#endif
+
+/* the IOCTL_SCSI_PASSTHROUGH interface is used on Windows. */
+#if HAVE_DDK_NTDDSCSI_H || defined(_MSC_VER)
+#      include "scsi_win32.c"
 #endif
 
 /* The 'uscsi' interface is used on Solaris. */
 #if HAVE_SYS_SCSI_IMPL_USCSI_H
-#  include "scsi_sun.c"
+#      include "scsi_sun.c"
 #endif
 
-/* The 'tm_buf' interface, as used on AIX. */
-#ifdef HAVE_SYS_SCSI_H
-#  include "scsi_aix.c"
+/* The 'gsc' interface, is used on AIX. */
+#if HAVE_SYS_GSCDDS_H
+#      include "scsi_aix.c"
 #endif
 
 /* The 'dslib' interface is used on SGI. */
 #if HAVE_DSLIB_H
-#  include "scsi_sgi.c"
+#      include "scsi_sgi.c"
 #endif
 
 /* Hmm, dunno what to do about Digital Unix at the moment. */
 #ifdef DIGITAL_UNIX
-#include "du/scsi.c"
+#      include "du/scsi.c"
 #endif
 
-
 #ifdef VMS
-#include "[.vms]scsi.c"
+#      include "[.vms]scsi.c"
 #endif
 
 extern char *argv0; /* something to let us do good error messages. */
 
+/* create a global RequestSenseT value. */
+RequestSense_T scsi_error_sense;
+
 /* Now for some low-level SCSI stuff: */
 
-Inquiry_T *RequestInquiry(DEVICE_TYPE fd, RequestSense_T *RequestSense) {
-  Inquiry_T *Inquiry;
-  CDB_T CDB;
-
-  Inquiry = (Inquiry_T *) xmalloc(sizeof(Inquiry_T));  
-  
-  CDB[0] = 0x12;               /* INQUIRY */
-  CDB[1] = 0;                  /* EVPD = 0 */
-  CDB[2] = 0;                  /* Page Code */
-  CDB[3] = 0;                  /* Reserved */
-  CDB[4] = sizeof(Inquiry_T);  /* Allocation Length */
-  CDB[5] = 0;                  /* Control */
-
-  /* set us a very short timeout, sigh... */
-  SCSI_Set_Timeout(30); /* 30 seconds, sigh! */
-
-  if (SCSI_ExecuteCommand(fd, Input, &CDB, 6,
-                         Inquiry, sizeof(Inquiry_T), RequestSense) != 0)
-    {
-      free(Inquiry);
-      return NULL;  /* sorry! */
-    }
-  return Inquiry;
+Inquiry_T *RequestInquiry(DEVICE_TYPE fd, RequestSense_T *RequestSense)
+{
+       Inquiry_T *Inquiry;
+       CDB_T CDB;
+
+       Inquiry = (Inquiry_T *) xmalloc(sizeof(Inquiry_T));  
+
+       CDB[0] = 0x12;          /* INQUIRY */
+       CDB[1] = 0;                     /* EVPD = 0 */
+       CDB[2] = 0;                     /* Page Code */
+       CDB[3] = 0;                     /* Reserved */
+       CDB[4] = sizeof(Inquiry_T);     /* Allocation Length */
+       CDB[5] = 0;                     /* Control */
+
+       /* set us a very short timeout, sigh... */
+       SCSI_Set_Timeout(30); /* 30 seconds, sigh! */
+
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 6,
+               Inquiry, sizeof(Inquiry_T), RequestSense) != 0)
+       {
+#ifdef DEBUG
+               fprintf(stderr, "SCSI Inquiry Command failed\n");
+#endif
+               free(Inquiry);
+               return NULL;  /* sorry! */
+       }
+       return Inquiry;
 }
 
 
-int BigEndian16(unsigned char *BigEndianData)
+#if defined(DEBUG_NSM) || defined(DEBUG_EXCHANGE)
+/* DEBUG */
+static void dump_cdb(unsigned char *CDB, int len)
 {
-  return (BigEndianData[0] << 8) + BigEndianData[1];
+       fprintf(stderr,"CDB:");
+       PrintHex(1, CDB, len);
 }
+#endif
 
 
-int BigEndian24(unsigned char *BigEndianData)
+#if defined(DEBUG_NSM) || defined(DEBUG_ADIC)
+/* DEBUG */
+static void dump_data(unsigned char *data, int len)
 {
-  return (BigEndianData[0] << 16) + (BigEndianData[1] << 8) + BigEndianData[2];
+       if (!len)
+       {
+               fprintf(stderr,"**NO DATA**\n");
+               return;
+       }
+
+       fprintf(stderr,"DATA:");
+       PrintHex(1, data, len);
 }
+#endif
 
 
+int BigEndian16(unsigned char *BigEndianData)
+{
+       return (BigEndianData[0] << 8) + BigEndianData[1];
+}
 
 
+int BigEndian24(unsigned char *BigEndianData)
+{
+       return (BigEndianData[0] << 16) + (BigEndianData[1] << 8) + BigEndianData[2];
+}
+
 
 void FatalError(char *ErrorMessage, ...)
 {
 #define FORMAT_BUF_LEN 1024
-  char FormatBuffer[FORMAT_BUF_LEN];
-  char *SourcePointer;
-  char *TargetPointer = FormatBuffer;
-  int Character, LastCharacter = '\0';
-  int numchars = 0;
-
-  va_list ArgumentPointer;
-  va_start(ArgumentPointer, ErrorMessage);
-  /*  SourcePointer = "mtx: "; */
-  sprintf(TargetPointer,"%s: ",argv0);
-  numchars=strlen(TargetPointer);
-  
-  /* while ((Character = *SourcePointer++) != '\0') { */
-  /*  *TargetPointer++ = Character;                   */
-  /*  numchars++;                                     */
-  /*   }                                              */
-  
-  while ((Character = *ErrorMessage++) != '\0')
-    if (LastCharacter == '%')
-      {
-       if (Character == 'm')
-         {
-           SourcePointer = strerror(errno);
-           while ((Character = *SourcePointer++) != '\0') {
-             *TargetPointer++ = Character;
-             numchars++;
-             if (numchars==FORMAT_BUF_LEN-1) break;  
-           }
-           if (numchars==FORMAT_BUF_LEN-1) break;  /* break outer loop... */
-         }
-       else
-         {
-           *TargetPointer++ = '%';
-           *TargetPointer++ = Character;
-           numchars++;
-           if (numchars==FORMAT_BUF_LEN-1) break;
-         }
-       LastCharacter = '\0';
-      }
-    else
-      {
-       if (Character != '%') {
-         *TargetPointer++ = Character;
-         numchars++;
-         if (numchars==FORMAT_BUF_LEN-1) break;
+
+       char    FormatBuffer[FORMAT_BUF_LEN];
+       char    *SourcePointer;
+       char    *TargetPointer = FormatBuffer;
+       char    Character, LastCharacter = '\0';
+       int             numchars = 0;
+
+       va_list ArgumentPointer;
+       va_start(ArgumentPointer, ErrorMessage);
+       /*  SourcePointer = "mtx: "; */
+       sprintf(TargetPointer,"%s: ",argv0);
+       numchars=strlen(TargetPointer);
+
+       while ((Character = *ErrorMessage++) != '\0')
+       {
+               if (LastCharacter == '%')
+               {
+                       if (Character == 'm')
+                       {
+                               SourcePointer = strerror(errno);
+                               while ((Character = *SourcePointer++) != '\0')
+                               {
+                                       *TargetPointer++ = Character;
+                                       numchars++;
+                                       if (numchars == FORMAT_BUF_LEN - 1)
+                                       {
+                                               break;
+                                       }
+                               }
+                               if (numchars == FORMAT_BUF_LEN - 1)
+                               {
+                                       break;  /* break outer loop... */
+                               }
+                       }
+                       else
+                       {
+                               *TargetPointer++ = '%';
+                               *TargetPointer++ = Character;
+                               numchars++;
+                               if (numchars == FORMAT_BUF_LEN - 1)
+                               {
+                                       break;
+                               }
+                       }
+                       LastCharacter = '\0';
+               }
+               else
+               {
+                       if (Character != '%')
+                       {
+                               *TargetPointer++ = Character;
+                               numchars++;
+                               if (numchars == FORMAT_BUF_LEN-1)
+                               {
+                                       break;
+                               }
+                       }
+                       LastCharacter = Character;
+               }
        }
-       LastCharacter = Character;
-      }
-  *TargetPointer = '\0';  /* works even if we had to break from above... */
-  vfprintf(stderr, FormatBuffer, ArgumentPointer);
-  va_end(ArgumentPointer);
+
+       *TargetPointer = '\0';  /* works even if we had to break from above... */
+       vfprintf(stderr, FormatBuffer, ArgumentPointer);
+       va_end(ArgumentPointer);
+
 #ifndef VMS
-  exit(1);
+       exit(1);
 #else
-  sys$exit(VMS_ExitCode);
+       sys$exit(VMS_ExitCode);
 #endif
 }
 
 /* This is a really slow and stupid 'bzero' implementation'... */
-void slow_bzero(char *buffer, int numchars) {
-  while (numchars--) *buffer++ = 0;
+void slow_bzero(char *buffer, int numchars)
+{
+       while (numchars--)
+       {
+               *buffer++ = 0;
+       }
 }
 
-
 /* malloc some memory while checking for out-of-memory conditions. */
 void *xmalloc(size_t Size)
 {
-  void *Result = (void *) malloc(Size);
-  if (Result == NULL)
-    FatalError("cannot allocate %d bytes of memory\n", Size);
-  return Result;
+       void *Result = (void *) malloc(Size);
+       if (Result == NULL)
+       {
+               FatalError("cannot allocate %d bytes of memory\n", Size);
+       }
+       return Result;
 }
 
 /* malloc some memory, zeroing it too: */
 void *xzmalloc(size_t Size)
 {
-  void *Result=(void *)xmalloc(Size);
-  
-  slow_bzero(Result,Size);
-  return Result;
+       void *Result = (void *)xmalloc(Size);
+
+       slow_bzero(Result, Size);
+       return Result;
 }
 
 
 int min(int x, int y)
 {
-  return (x < y ? x : y);
+       return (x < y ? x : y);
 }
 
 
 int max(int x, int y)
 {
-  return (x > y ? x : y);
+       return (x > y ? x : y);
+}
+
+
+/* Okay, this is a hack for the NSM modular jukebox series, which
+ * uses the "SEND DIAGNOSTIC" command to do shit. 
+ */
+
+int SendNSMHack(DEVICE_TYPE MediumChangerFD, NSM_Param_T *nsm_command, 
+               int param_len, int timeout)
+{
+       CDB_T CDB;
+       int list_len = param_len + sizeof(NSM_Param_T) - 2048;
+
+       /* Okay, now for the command: */
+       CDB[0] = 0x1D;
+       CDB[1] = 0x10;
+       CDB[2] = 0;
+       CDB[3] = (unsigned char)(list_len >> 8);
+       CDB[4] = (unsigned char)list_len;
+       CDB[5] = 0;
+
+#ifdef DEBUG_NSM
+       dump_cdb(&CDB,6);
+       dump_data(nsm_command,list_len);
+#endif
+       fflush(stderr);
+       /* Don't set us any timeout unless timeout is > 0 */
+       if (timeout > 0)
+       {
+               SCSI_Set_Timeout(timeout); /* 30 minutes, sigh! */
+       }
+
+       /* Now send the command: */
+       if (SCSI_ExecuteCommand(MediumChangerFD, Output, &CDB, 6, nsm_command, list_len, &scsi_error_sense))
+       {
+               return -1; /* we failed */
+       }
+       return 0; /* Did it! */
 }
 
+NSM_Result_T *RecNSMHack(      DEVICE_TYPE MediumChangerFD,
+                                                       int param_len, int timeout)
+{
+       CDB_T CDB;
+
+       NSM_Result_T *retval = (NSM_Result_T *)xzmalloc(sizeof(NSM_Result_T));
+
+       int list_len = param_len + sizeof(NSM_Result_T) - 0xffff;
+
+       /* Okay, now for the command: */
+       CDB[0] = 0x1C;
+       CDB[1] = 0x00;
+       CDB[2] = 0;
+       CDB[3] = (unsigned char)(list_len >> 8);
+       CDB[4] = (unsigned char)list_len;
+       CDB[5] = 0;
+
+#ifdef DEBUG_NSM
+       dump_cdb(&CDB,6);
+#endif
+
+       /* Don't set us any timeout unless timeout is > 0 */
+       if (timeout > 0)
+       {
+               SCSI_Set_Timeout(timeout);
+       }
+
+       /* Now send the command: */
+       if (SCSI_ExecuteCommand(MediumChangerFD, Input, &CDB, 6, retval, list_len, &scsi_error_sense))
+       {
+               return NULL; /* we failed */
+       }
+
+#ifdef DEBUG_NSM
+       fprintf(stderr,
+                       "page_code=%02x page_len=%d command_code=%s\n",
+                       retval->page_code,
+                       (int) ((retval->page_len_msb << 8) + retval->page_len_lsb),
+       retval->command_code);
+#endif
+
+       return retval; /* Did it! (maybe!)*/
+}
 
 /* Routine to inventory the library. Needed by, e.g., some Breece Hill
  * loaders. Sends an INITIALIZE_ELEMENT_STATUS command. This command
  * has no parameters, such as a range to scan :-(. 
  */
 
-int Inventory(DEVICE_TYPE MediumChangerFD) {
-  CDB_T CDB;
-  RequestSense_T RequestSense;
-  /* okay, now for the command: */
-  CDB[0]=0x07; 
-  CDB[1]=CDB[2]=CDB[3]=CDB[4]=CDB[5]=0;
-
-  /* set us a very long timeout, sigh... */
-  SCSI_Set_Timeout(30*60); /* 30 minutes, sigh! */
-  
-  if (SCSI_ExecuteCommand(MediumChangerFD,Input,&CDB,6,NULL,0,&RequestSense) != 0) {
-    return -1;  /* could not do! */
-  }
-  return 0; /* did do! */
-}
+int Inventory(DEVICE_TYPE MediumChangerFD)
+{
+       CDB_T   CDB;
 
-/* Routine to send an UNLOAD from the SSC spec to a device. This can be
- * used either to eject a tape (when sent to a tape drive), or to eject
- * a magzine (on some Seagate changers, when sent to LUN 1 ). 
- */
+       /* okay, now for the command: */
+       CDB[0] = 0x07; 
+       CDB[1] = CDB[2] = CDB[3] = CDB[4] = CDB[5] = 0;
 
-int Eject(DEVICE_TYPE fd) {
-  CDB_T CDB;
-  RequestSense_T RequestSense;
-  /* okay, now for the command: */
-  
-  CDB[0]=0x1b;
-  CDB[1]=CDB[2]=CDB[3]=CDB[4]=CDB[5]=0;
-  
-  if (SCSI_ExecuteCommand(fd,Input,&CDB,6,NULL,0,&RequestSense) != 0) {
-    return -1;  /* could not do! */
-  }
-  return 0; /* did do! */
-}  
+       /* set us a very long timeout, sigh... */
+       SCSI_Set_Timeout(30 * 60); /* 30 minutes, sigh! */
+
+       if (SCSI_ExecuteCommand(MediumChangerFD,Input,&CDB,6,NULL,0,&scsi_error_sense) != 0)
+       {
+#ifdef DEBUG
+               PrintRequestSense(&scsi_error_sense);
+               fprintf(stderr, "Initialize Element Status (0x07) failed\n");
+#endif
+               return -1;  /* could not do! */
+       }
+       return 0; /* did do! */
+}
 
 /* Routine to read the Mode Sense Element Address Assignment Page */
 /* We try to read the page. If we can't read the page, we return NULL.
  * Our caller really isn't too worried about why we could not read the
  * page, it will simply default to some kind of default values. 
  */ 
-ElementModeSense_T *ReadAssignmentPage(DEVICE_TYPE MediumChangerFD) {
-  CDB_T CDB;
-  ElementModeSense_T *retval;  /* processed SCSI. */
-  unsigned char input_buffer[136];
-  ElementModeSensePage_T *sense_page; /* raw SCSI. */
-  RequestSense_T RequestSense;       /* see what retval of raw SCSI was... */
-  
-  /* okay, now for the command: */
-  CDB[0]=0x1a; /* Mode Sense(6) */
-  CDB[1]=0; 
-  CDB[2]=0x1d; /* Mode Sense Element Address Assignment Page */
-  CDB[3]=0;
-  CDB[4]=136; /* allocation_length... */
-  CDB[5]=0;
-
-  /* clear the data buffer: */
-  slow_bzero((char *)&RequestSense,sizeof(RequestSense_T));
-  slow_bzero((char *)input_buffer,sizeof(input_buffer));
-
-  if (SCSI_ExecuteCommand(MediumChangerFD,Input,&CDB,6,
-                         &input_buffer,sizeof(input_buffer),&RequestSense) != 0) {
+ElementModeSense_T *ReadAssignmentPage(DEVICE_TYPE MediumChangerFD)
+{
+       CDB_T CDB;
+       ElementModeSense_T *retval;  /* processed SCSI. */
+       unsigned char input_buffer[136];
+       ElementModeSensePage_T *sense_page; /* raw SCSI. */
+
+       /* okay, now for the command: */
+       CDB[0] = 0x1A; /* Mode Sense(6) */
+       CDB[1] = 0x08; 
+       CDB[2] = 0x1D; /* Mode Sense Element Address Assignment Page */
+       CDB[3] = 0;
+       CDB[4] = 136; /* allocation_length... */
+       CDB[5] = 0;
+
+       /* clear the data buffer: */
+       slow_bzero((char *)&scsi_error_sense, sizeof(RequestSense_T));
+       slow_bzero((char *)input_buffer, sizeof(input_buffer));
+
+       if (SCSI_ExecuteCommand(MediumChangerFD, Input, &CDB, 6,
+                                                       &input_buffer, sizeof(input_buffer), &scsi_error_sense) != 0)
+       {
+               PrintRequestSense(&scsi_error_sense);
+               fprintf(stderr,"Mode sense (0x1A) for Page 0x1D failed\n");
+               fflush(stderr);
+               return NULL; /* sorry, couldn't do it. */
+       }
+
+       /* Could do it, now build return value: */
+
 #ifdef DEBUG_MODE_SENSE
-    fprintf(stderr,"Could not execute mode sense...\n");
-    fflush(stderr);
+       PrintHex(0, input_buffer, 30);
 #endif
-    return NULL; /* sorry, couldn't do it. */
-  }
 
-  /* Could do it, now build return value: */
+       /* first, skip past: mode data header, and block descriptor header if any */
+       sense_page=(ElementModeSensePage_T *)(input_buffer+4+input_buffer[3]);
 
 #ifdef DEBUG_MODE_SENSE
-  {
-    int i;
-    for (i=0;i<30;i+=3) {
-      fprintf(stderr,"ib[%d]=%d ib[%d]=%d ib[%d]=%d\n",
-             i,input_buffer[i],i+1,input_buffer[i+1],
-             i+2,input_buffer[i+2]);
-      /*  fprintf(stderr,"input_buffer[0]=%d input_buffer[3]=%d\n",
-       *         input_buffer[0], input_buffer[3]);
-       */
-    }
-    fflush(stderr);
-  }
-#endif
-  /* first, skip past: mode data header, and block descriptor header if any */
-  sense_page=(ElementModeSensePage_T *)(input_buffer+4+input_buffer[3]);
+       fprintf(stderr,"*sense_page=%x  %x\n",*((unsigned char *)sense_page),sense_page->PageCode);
+       fflush(stderr);
+#endif
 
-#ifdef DEBUG_MODE_SENSE
-  fprintf(stderr,"*sense_page=%x  %x\n",*((unsigned char *)sense_page),sense_page->PageCode);
-  fflush(stderr);
-#endif  
+       retval = (ElementModeSense_T *)xzmalloc(sizeof(ElementModeSense_T));
 
-  retval=(ElementModeSense_T *) xzmalloc(sizeof(ElementModeSense_T));
+       /* Remember that all SCSI values are big-endian: */
+       retval->MediumTransportStart =
+               (((int)sense_page->MediumTransportStartHi) << 8) +
+               sense_page->MediumTransportStartLo;
 
-  /* Remember that all SCSI values are big-endian: */
-  retval->MediumTransportStart=(((int)sense_page->MediumTransportStartHi)<<8) +
-    sense_page->MediumTransportStartLo;
-  retval->NumMediumTransport=(((int)(sense_page->NumMediumTransportHi))<<8) +
-    sense_page->NumMediumTransportLo;
+       retval->NumMediumTransport =
+               (((int)(sense_page->NumMediumTransportHi))<<8) +
+               sense_page->NumMediumTransportLo;
 
-  /* HACK! Some HP autochangers don't report NumMediumTransport right! */
-  /* ARG! TAKE OUT THE %#@!# HACK! */
+       /* HACK! Some HP autochangers don't report NumMediumTransport right! */
+       /* ARG! TAKE OUT THE %#@!# HACK! */
 #ifdef STUPID_DUMB_IDIOTIC_HP_LOADER_HACK
-  if (!retval->NumMediumTransport) {
-    retval->NumMediumTransport=1;
-  }
+       if (!retval->NumMediumTransport)
+       {
+               retval->NumMediumTransport = 1;
+       }
 #endif
 
 #ifdef DEBUG_MODE_SENSE
-  fprintf(stderr,"rawNumStorage= %d %d    rawNumImportExport= %d %d\n",
-         sense_page->NumStorageHi,sense_page->NumStorageLo,
-         sense_page->NumImportExportHi, sense_page->NumImportExportLo);
-  fprintf(stderr,"rawNumTransport=%d %d  rawNumDataTransfer=%d %d\n",
-         sense_page->NumMediumTransportHi,sense_page->NumMediumTransportLo,
-         sense_page->NumDataTransferHi,sense_page->NumDataTransferLo);
-  fflush(stderr);
-#endif
-
-  retval->StorageStart=(((int)(sense_page->StorageStartHi))<<8) +
-    sense_page->StorageStartLo;
-  retval->NumStorage=(((int)(sense_page->NumStorageHi))<<8) + 
-    sense_page->NumStorageLo;
-  retval->ImportExportStart=(((int)(sense_page->ImportExportStartHi))<<8)+
-    sense_page->ImportExportStartLo; 
-  retval->NumImportExport=(((int)(sense_page->NumImportExportHi))<<8)+
-    sense_page->NumImportExportLo;
-  retval->DataTransferStart=(((int)(sense_page->DataTransferStartHi))<<8)+
-    sense_page->DataTransferStartLo;
-  retval->NumDataTransfer=(((int)(sense_page->NumDataTransferHi))<<8)+
-    sense_page->NumDataTransferLo;
-
-  /* allocate a couple spares 'cause some HP autochangers and maybe others
-   * don't properly report the robotics arm(s) count here... 
-   */
-  retval->NumElements=retval->NumStorage+retval->NumImportExport+
-    retval->NumDataTransfer+retval->NumMediumTransport;
-
-  retval->MaxReadElementStatusData=(sizeof(ElementStatusDataHeader_T) +
-                                   4 * sizeof(ElementStatusPage_T) +
-                                   (retval->NumElements) *
-                                     sizeof(TransportElementDescriptor_T));
+       fprintf(stderr, "rawNumStorage= %d %d    rawNumImportExport= %d %d\n",
+                       sense_page->NumStorageHi, sense_page->NumStorageLo,
+                       sense_page->NumImportExportHi, sense_page->NumImportExportLo);
+       fprintf(stderr, "rawNumTransport=%d %d  rawNumDataTransfer=%d %d\n",
+                       sense_page->NumMediumTransportHi, sense_page->NumMediumTransportLo,
+                       sense_page->NumDataTransferHi, sense_page->NumDataTransferLo);
+       fflush(stderr);
+#endif
+
+       retval->StorageStart =
+               ((int)sense_page->StorageStartHi << 8) + sense_page->StorageStartLo;
+
+       retval->NumStorage =
+               ((int)sense_page->NumStorageHi << 8) + sense_page->NumStorageLo;
+
+       retval->ImportExportStart =
+               ((int)sense_page->ImportExportStartHi << 8) + sense_page->ImportExportStartLo; 
+
+       retval->NumImportExport =
+               ((int)sense_page->NumImportExportHi << 8) + sense_page->NumImportExportLo;
 
+       retval->DataTransferStart =
+               ((int)sense_page->DataTransferStartHi << 8) + sense_page->DataTransferStartLo;
+
+       retval->NumDataTransfer =
+               ((int)sense_page->NumDataTransferHi << 8) + sense_page->NumDataTransferLo;
+
+       /* allocate a couple spares 'cause some HP autochangers and maybe others
+       * don't properly report the robotics arm(s) count here... 
+       */
+       retval->NumElements =
+               retval->NumStorage+retval->NumImportExport +
+               retval->NumDataTransfer+retval->NumMediumTransport;
+
+       retval->MaxReadElementStatusData =
+               (sizeof(ElementStatusDataHeader_T) +
+               4 * sizeof(ElementStatusPage_T) +
+               retval->NumElements * sizeof(TransportElementDescriptor_T));
 
 #ifdef IMPORT_EXPORT_HACK
-  retval->NumStorage=retval->NumStorage+retval->NumImportExport;
+       retval->NumStorage = retval->NumStorage+retval->NumImportExport;
 #endif
 
 #ifdef DEBUG_MODE_SENSE
-  fprintf(stderr,"NumMediumTransport=%d\n",retval->NumMediumTransport);
-  fprintf(stderr,"NumStorage=%d\n",retval->NumStorage);
-  fprintf(stderr,"NumImportExport=%d\n",retval->NumImportExport);
-  fprintf(stderr,"NumDataTransfer=%d\n",retval->NumDataTransfer);
-  fprintf(stderr,"MaxReadElementStatusData=%d\n",retval->MaxReadElementStatusData);
-  fprintf(stderr,"NumElements=%d\n",retval->NumElements);
-  fflush(stderr);
-#endif
-  
-  return retval;
+       fprintf(stderr, "NumMediumTransport=%d\n", retval->NumMediumTransport);
+       fprintf(stderr, "NumStorage=%d\n", retval->NumStorage);
+       fprintf(stderr, "NumImportExport=%d\n", retval->NumImportExport);
+       fprintf(stderr, "NumDataTransfer=%d\n", retval->NumDataTransfer);
+       fprintf(stderr, "MaxReadElementStatusData=%d\n", retval->MaxReadElementStatusData);
+       fprintf(stderr, "NumElements=%d\n", retval->NumElements);
+       fflush(stderr);
+#endif
+
+       return retval;
 }
 
 static void FreeElementData(ElementStatus_T *data)
 {
-  free(data->DataTransferElementAddress);
-  free(data->DataTransferElementSourceStorageElementNumber);
-  free(data->DataTransferPrimaryVolumeTag);
-  free(data->DataTransferAlternateVolumeTag);
-  free(data->PrimaryVolumeTag);
-  free(data->AlternateVolumeTag);
-  free(data->StorageElementAddress);
-  free(data->StorageElementIsImportExport);
-  free(data->StorageElementFull);
-  free(data->DataTransferElementFull);
+       free(data->DataTransferElementAddress);
+       free(data->DataTransferElementSourceStorageElementNumber);
+       free(data->DataTransferPrimaryVolumeTag);
+       free(data->DataTransferAlternateVolumeTag);
+       free(data->PrimaryVolumeTag);
+       free(data->AlternateVolumeTag);
+       free(data->StorageElementAddress);
+       free(data->StorageElementIsImportExport);
+       free(data->StorageElementFull);
+       free(data->DataTransferElementFull);
 }
-  
-       
+
 
 /* allocate data  */
 
-static ElementStatus_T *AllocateElementData(ElementModeSense_T *mode_sense) {
-  ElementStatus_T *retval;
-
-  retval=(ElementStatus_T *) xzmalloc(sizeof(ElementStatus_T));
-
-  /* now for the invidual component arrays.... */
-
-  retval->DataTransferElementAddress = (int *) xzmalloc(sizeof(int)*
-                                    (mode_sense->NumDataTransfer + 1));
-  retval->DataTransferElementSourceStorageElementNumber = 
-    (int *) xzmalloc(sizeof(int)*(mode_sense->NumDataTransfer+1));
-  retval->DataTransferPrimaryVolumeTag=
-    (barcode *)xzmalloc(sizeof(barcode)*(mode_sense->NumDataTransfer+1));
-  retval->DataTransferAlternateVolumeTag=
-    (barcode *)xzmalloc(sizeof(barcode)*(mode_sense->NumDataTransfer+1));
-  retval->PrimaryVolumeTag=
-    (barcode *)xzmalloc(sizeof(barcode)*(mode_sense->NumStorage+1));
-  retval->AlternateVolumeTag=
-    (barcode *)xzmalloc(sizeof(barcode)*(mode_sense->NumStorage+1));
-  retval->StorageElementAddress=
-    (int *)xzmalloc(sizeof(int)*(mode_sense->NumStorage+1));
-  retval->StorageElementIsImportExport=
-    (boolean *)xzmalloc(sizeof(boolean)*(mode_sense->NumStorage+1));    
-  retval->StorageElementFull=
-    (boolean *)xzmalloc(sizeof(boolean)*(mode_sense->NumStorage+1));    
-  retval->DataTransferElementFull=
-    (boolean *)xzmalloc(sizeof(boolean)*(mode_sense->NumDataTransfer+1));
-  
-  return retval; /* sigh! */
+static ElementStatus_T *AllocateElementData(ElementModeSense_T *mode_sense)
+{
+       ElementStatus_T *retval;
+
+       retval = (ElementStatus_T *)xzmalloc(sizeof(ElementStatus_T));
+
+       /* now for the invidual component arrays.... */
+
+       retval->DataTransferElementAddress =
+               (int *)xzmalloc(sizeof(int) * (mode_sense->NumDataTransfer + 1));
+       retval->DataTransferElementSourceStorageElementNumber = 
+               (int *)xzmalloc(sizeof(int) * (mode_sense->NumDataTransfer + 1));
+       retval->DataTransferPrimaryVolumeTag =
+               (barcode *)xzmalloc(sizeof(barcode) * (mode_sense->NumDataTransfer + 1));
+       retval->DataTransferAlternateVolumeTag =
+               (barcode *)xzmalloc(sizeof(barcode) * (mode_sense->NumDataTransfer + 1));
+       retval->PrimaryVolumeTag =
+               (barcode *)xzmalloc(sizeof(barcode) * (mode_sense->NumStorage + 1));
+       retval->AlternateVolumeTag =
+               (barcode *)xzmalloc(sizeof(barcode) * (mode_sense->NumStorage + 1));
+       retval->StorageElementAddress =
+               (int *)xzmalloc(sizeof(int) * (mode_sense->NumStorage + 1));
+       retval->StorageElementIsImportExport =
+               (boolean *)xzmalloc(sizeof(boolean) * (mode_sense->NumStorage + 1));
+       retval->StorageElementFull =
+               (boolean *)xzmalloc(sizeof(boolean) * (mode_sense->NumStorage + 1));
+       retval->DataTransferElementFull =
+               (boolean *)xzmalloc(sizeof(boolean) * (mode_sense->NumDataTransfer + 1));
+
+       return retval; /* sigh! */
 }
 
 
-void copy_barcode(unsigned char *src, unsigned char *dest) {
-  int i;
-  
-  for (i=0; i < 36; i++) {
-    *dest=*src++;
-#ifdef __WEIRD_CHAR_SUPPRESS
-    if ((*dest < 32) || (*dest > 127))
-       *dest = '\0';
-#endif
-     dest++;
-  }
-  dest=0; /* null-terminate, sigh. */ 
-}
+void copy_barcode(unsigned char *src, unsigned char *dest)
+{
+       int i;
+
+       for (i=0; i < 36; i++)
+       {
+               *dest = *src++;
 
+               if ((*dest < 32) || (*dest > 127))
+               {
+                       *dest = '\0';
+               }
+
+               dest++;
+       }
+       *dest = 0; /* null-terminate */ 
+}
 
 /* This #%!@# routine has more parameters than I can count! */
-unsigned char *SendElementStatusRequest(DEVICE_TYPE MediumChangerFD,
+static unsigned char *SendElementStatusRequestActual(
+                                       DEVICE_TYPE MediumChangerFD,
                                        RequestSense_T *RequestSense,
                                        Inquiry_T *inquiry_info, 
                                        SCSI_Flags_T *flags,
                                        int ElementStart,
                                        int NumElements,
                                        int NumBytes
-                                       ) {
-
-  CDB_T CDB;
-  boolean is_attached = false;
+                                       )
+{
+       CDB_T CDB;
+       boolean is_attached = false;
 
-  unsigned char *DataBuffer; /* size of data... */
+       unsigned char *DataBuffer; /* size of data... */
 
 #ifdef HAVE_GET_ID_LUN
-  scsi_id_t *scsi_id;
+       scsi_id_t *scsi_id;
 #endif
-  if ((inquiry_info->MChngr) && (inquiry_info->PeripheralDeviceType != MEDIUM_CHANGER_TYPE)) {
-    is_attached=true;
-  }
-  if (flags->no_attached) { /* override, sigh */ 
-    is_attached=false;
-  }
+       if (inquiry_info->MChngr && 
+               inquiry_info->PeripheralDeviceType != MEDIUM_CHANGER_TYPE)
+       {
+               is_attached = true;
+       }
+
+       if (flags->no_attached)
+       {
+               /* override, sigh */ 
+               is_attached = false;
+       }
+
+       DataBuffer = (unsigned char *)xzmalloc(NumBytes + 1);
 
-  DataBuffer=(unsigned char *) xmalloc(NumBytes+1);
+       slow_bzero((char *)RequestSense, sizeof(RequestSense_T));
 
-  slow_bzero((char *)RequestSense,sizeof(RequestSense_T));
 #ifdef HAVE_GET_ID_LUN
-  scsi_id = SCSI_GetIDLun(MediumChangerFD);
+       scsi_id = SCSI_GetIDLun(MediumChangerFD);
 #endif
 
+       CDB[0] = 0xB8;          /* READ ELEMENT STATUS */
+
+       if (is_attached)
+       {
+               CDB[0] = 0xB4;  /* whoops, READ_ELEMENT_STATUS_ATTACHED! */ 
+       }
 
-  CDB[0] = 0xB8;               /* READ ELEMENT STATUS */
-  if (is_attached) {
-    CDB[0] = 0xB4;  /* whoops, READ_ELEMENT_STATUS_ATTACHED! */ 
-  }
 #ifdef HAVE_GET_ID_LUN
-  CDB[1] = (scsi_id->lun << 5) | ((flags->no_barcodes) ? 0 : 0x10) | flags->elementtype;  /* Lun + VolTag + Type code */
-  free(scsi_id);
+       CDB[1] = (scsi_id->lun << 5) | ((flags->no_barcodes) ? 
+               0 : 0x10) | flags->elementtype;  /* Lun + VolTag + Type code */
+       free(scsi_id);
 #else
-  CDB[1] = ((flags->no_barcodes) ? 0 : 0x10) | flags->elementtype;             /* Element Type Code = 0, VolTag = 1 */
+       /* Element Type Code = 0, VolTag = 1 */
+       CDB[1] = (unsigned char)((flags->no_barcodes ? 0 : 0x10) | flags->elementtype);
 #endif
-  CDB[2] = (ElementStart >> 8) & 0xff; /* Starting Element Address MSB */
-  CDB[3] = ElementStart & 0xff;                /* Starting Element Address LSB */
+       /* Starting Element Address */
+       CDB[2] = (unsigned char)(ElementStart >> 8);
+       CDB[3] = (unsigned char)ElementStart;
+
+       /* Number Of Elements */
+       CDB[4]= (unsigned char)(NumElements >> 8);
+       CDB[5]= (unsigned char)NumElements;
+
+       CDB[6] = 0;                     /* Reserved */
+
+       /* allocation length */
+       CDB[7]= (unsigned char)(NumBytes >> 16);
+       CDB[8]= (unsigned char)(NumBytes >> 8);
+       CDB[9]= (unsigned char)NumBytes;
+
+       CDB[10] = 0;                    /* Reserved */
+       CDB[11] = 0;                    /* Control */
 
+#ifdef DEBUG_BARCODE
+       fprintf(stderr,"CDB:\n");
+       PrintHex(2, CDB, 12);
+#endif
 
-  CDB[4]= (NumElements >> 8) & 0xff;     /* Number Of Elements MSB */
-  CDB[5]= NumElements & 0xff ;        /* Number of elements LSB */
+       if (SCSI_ExecuteCommand(MediumChangerFD, Input, &CDB, 12,
+               DataBuffer,NumBytes, RequestSense) != 0)
+       {
 
-  /*  CDB[5]=127; */ /* test */
 #ifdef DEBUG
-  fprintf(stderr,"CDB[5]=%d\n" , CDB[5]);
+               fprintf(stderr, "Read Element Status (0x%02X) failed\n", CDB[0]);
 #endif
-  CDB[6] = 0;                  /* Reserved */
 
-  CDB[7]= (NumBytes >> 16) & 0xff; /* allocation length MSB */
-  CDB[8]= (NumBytes >> 8) & 0xff;
-  CDB[9]= NumBytes & 0xff;   /* allocation length LSB */
+               /*
+                       First see if we have sense key of 'illegal request',
+                       additional sense code of '24', additional sense qualfier of 
+                       '0', and field in error of '4'. This means that we issued a request
+                       w/bar code reader and did not have one, thus must re-issue the request
+                       w/out barcode :-(.
+               */
+
+               /*
+                       Most autochangers and tape libraries set a sense key here if
+                       they do not have a bar code reader. For some reason, the ADIC DAT
+                       uses a different sense key? Let's retry w/o bar codes for *ALL*
+                       sense keys.
+               */
+
+               if (RequestSense->SenseKey > 1)
+               {
+                       /* we issued a code requesting bar codes, there is no bar code reader? */
+                       /* clear out our sense buffer first... */
+                       slow_bzero((char *)RequestSense, sizeof(RequestSense_T));
 
-  CDB[10] = 0;                 /* Reserved */
-  CDB[11] = 0;                 /* Control */
+                       CDB[1] &= ~0x10; /* clear bar code flag! */
 
 #ifdef DEBUG_BARCODE
-  {
-    int i;
-    fprintf(stderr,"CDB= ");
-    for (i=0;i<12;i++) {
-      fprintf(stderr,"%x ",CDB[i]);
-    }
-    fprintf(stderr,"\n");
-    fflush(stderr);
-  }
-#endif
-
-  if (SCSI_ExecuteCommand(MediumChangerFD, Input, &CDB, 12,
-                         DataBuffer,NumBytes, RequestSense) != 0){
-    /* okay, first see if we have sense key of 'illegal request',
-       additional sense code of '24', additional sense qualfier of 
-       '0', and field in error of '4'. This means that we issued a request
-       w/bar code reader and did not have one, thus must re-issue the request
-       w/out barcode :-(.
-    */
-    
-    /* Okay, most autochangers and tape libraries set a sense key here if
-     * they do not have a bar code reader. For some reason, the ADIC DAT
-     * uses a different sense key? Let's retry w/o bar codes for *ALL*
-     * sense keys, sigh sigh sigh. 
-     */
-    
-    if ( RequestSense->SenseKey > 1 ) {
-      /* we issued a code requesting bar codes, there is no bar code reader? */
-      /* clear out our sense buffer first... */
-      slow_bzero((char *)RequestSense,sizeof(RequestSense_T));
-
-      CDB[1] &= ~0x10; /* clear bar code flag! */
+                       fprintf(stderr,"CDB:\n");
+                       PrintHex(2, CDB, 12);
+#endif
 
-#ifdef DEBUG_BARCODE
-      {
-       int i;
-       fprintf(stderr,"CDB= ");
-       for (i=0;i<12;i++) {
-         fprintf(stderr,"%x ",CDB[i]);
+                       if (SCSI_ExecuteCommand(MediumChangerFD, Input, &CDB, 12,
+                                                                       DataBuffer, NumBytes, RequestSense) != 0)
+                       {
+                               free(DataBuffer);
+                               return NULL;
+                       }
+               }
+               else
+               {
+                       free(DataBuffer);
+                       return NULL;
+               }
        }
-       fprintf(stderr,"\n");
-       fflush(stderr);
-      }
-#endif
-      
-      if (SCSI_ExecuteCommand(MediumChangerFD, Input, &CDB, 12,
-                             DataBuffer, NumBytes, RequestSense) != 0){
-       free(DataBuffer);
-       return NULL;
-      }
-    } else {
-      free(DataBuffer);
-      return NULL;
-    }
-  }
 
 #ifdef DEBUG_BARCODE
-  /* print a bunch of extra debug data :-(.  */
-  PrintRequestSense(RequestSense); /* see what it sez :-(. */
-  {
-    int i;
-    fprintf(stderr,"Data:");
-    for (i=0;i<40;i++) {
-      fprint(stderr,"%02x ",DataBuffer[i]);
-    }
-    fprintf(stderr,"\n");
-  }
+       /* print a bunch of extra debug data :-(.  */
+       PrintRequestSense(RequestSense); /* see what it sez :-(. */
+       fprintf(stderr,"Data:\n");
+       PrintHex(2, DataBuffer, 40);
 #endif  
-  return DataBuffer; /* we succeeded! */
+       return DataBuffer; /* we succeeded! */
+}
+
+
+unsigned char *SendElementStatusRequest(DEVICE_TYPE MediumChangerFD,
+                                                                               RequestSense_T *RequestSense,
+                                                                               Inquiry_T *inquiry_info, 
+                                                                               SCSI_Flags_T *flags,
+                                                                               int ElementStart,
+                                                                               int NumElements,
+                                                                               int NumBytes
+                                                                               )
+{
+       unsigned char *DataBuffer; /* size of data... */
+       int real_numbytes;
+
+       DataBuffer = SendElementStatusRequestActual(MediumChangerFD,
+                                                                                               RequestSense,
+                                                                                               inquiry_info,
+                                                                                               flags,
+                                                                                               ElementStart,
+                                                                                               NumElements,
+                                                                                               NumBytes
+                                                                                               );
+       /*
+               One weird loader wants either 8 or BYTE_COUNT_OF_REPORT
+               values for the ALLOCATION_LENGTH. Give it what it wants
+               if we get an Sense Key of 05 Illegal Request with a 
+               CDB position of 7 as the field in error.
+       */
+
+       if (DataBuffer == NULL &&
+               RequestSense->SenseKey == 5 &&
+               RequestSense->CommandData &&
+               RequestSense->BitPointer == 7)
+       {
+               NumBytes=8; /* send an 8 byte request */
+               DataBuffer=SendElementStatusRequestActual(      MediumChangerFD,
+                                                                                                       RequestSense,
+                                                                                                       inquiry_info,
+                                                                                                       flags,
+                                                                                                       ElementStart,
+                                                                                                       NumElements,
+                                                                                                       NumBytes
+                                                                                                       );
+       }
+
+       /* the above code falls thru into this: */
+       if (DataBuffer != NULL)
+       {
+               /* see if we need to retry with a bigger NumBytes: */
+               real_numbytes = ((int)DataBuffer[5] << 16) +
+                                               ((int)DataBuffer[6] << 8) +
+                                                (int)DataBuffer[7] + 8;
+
+               if (real_numbytes > NumBytes)
+               {
+                       /* uh-oh, retry! */
+                       free(DataBuffer); /* solve memory leak */
+                       DataBuffer = SendElementStatusRequestActual(MediumChangerFD,
+                                                                                                               RequestSense,
+                                                                                                               inquiry_info,
+                                                                                                               flags,
+                                                                                                               ElementStart,
+                                                                                                               NumElements,
+                                                                                                               real_numbytes
+                                                                                                               );
+               }
+       }
+
+       return DataBuffer;
 }
 
+
+
 /******************* ParseElementStatus ***********************************/
 /* This does the actual grunt work of parsing element status data. It fills
  * in appropriate pieces of its input data. It may be called multiple times
  * while we are gathering element status.
  */
 
-static void ParseElementStatus(int *EmptyStorageElementAddress,
-                              int *EmptyStorageElementCount,
-                              unsigned char *DataBuffer,
-                              ElementStatus_T *ElementStatus,
-                              ElementModeSense_T *mode_sense
-
-                              )   {
-    
-    unsigned char *DataPointer=DataBuffer;
-    TransportElementDescriptor_T TEBuf;
-    TransportElementDescriptor_T *TransportElementDescriptor;
-    ElementStatusDataHeader_T *ElementStatusDataHeader;
-    Element2StatusPage_T *ElementStatusPage;
-    Element2StatusPage_T ESBuf;
-    int ElementCount;
-    int TransportElementDescriptorLength;
-    int BytesAvailable; 
-    
-    ElementStatusDataHeader = (ElementStatusDataHeader_T *) DataBuffer;
-
-    
-
-  ElementStatusDataHeader = (ElementStatusDataHeader_T *) DataPointer;
-  DataPointer += sizeof(ElementStatusDataHeader_T);
-  ElementCount =
-    BigEndian16(ElementStatusDataHeader->NumberOfElementsAvailable);
+static void ParseElementStatus(        int *EmptyStorageElementAddress,
+                                                               int *EmptyStorageElementCount,
+                                                               unsigned char *DataBuffer,
+                                                               ElementStatus_T *ElementStatus,
+                                                               ElementModeSense_T *mode_sense,
+                                                               int *pNextElement
+                                                               )
+{
+       unsigned char *DataPointer = DataBuffer;
+       TransportElementDescriptor_T TEBuf;
+       TransportElementDescriptor_T *TransportElementDescriptor;
+       ElementStatusDataHeader_T *ElementStatusDataHeader;
+       Element2StatusPage_T *ElementStatusPage;
+       Element2StatusPage_T ESBuf;
+       int ElementCount;
+       int TransportElementDescriptorLength;
+       int BytesAvailable;
+       int ImportExportIndex;
+
+       ElementStatusDataHeader = (ElementStatusDataHeader_T *) DataPointer;
+       DataPointer += sizeof(ElementStatusDataHeader_T);
+       ElementCount =
+               BigEndian16(ElementStatusDataHeader->NumberOfElementsAvailable);
+
 #ifdef DEBUG
-      fprintf(stderr,"ElementCount=%d\n",ElementCount);
-      fflush(stderr);
+       fprintf(stderr,"ElementCount=%d\n",ElementCount);
+       fflush(stderr);
+#endif
+
+       while (ElementCount > 0)
+       {
+#ifdef DEBUG
+               int got_element_num=0;
+
+               fprintf(stderr,"Working on element # %d Element Count %d\n",got_element_num,ElementCount);
+               got_element_num++;
 #endif
-  while (ElementCount > 0)
-    {
+
+               memcpy(&ESBuf, DataPointer, sizeof(ElementStatusPage_T));
+               ElementStatusPage = &ESBuf;
+               DataPointer += sizeof(ElementStatusPage_T);
+
+               TransportElementDescriptorLength =
+                       BigEndian16(ElementStatusPage->ElementDescriptorLength);
+
+               if (TransportElementDescriptorLength <
+                       sizeof(TransportElementDescriptorShort_T))
+               {
+                       /* Foo, Storage Element Descriptors can be 4 bytes?! */
+                       if ((ElementStatusPage->ElementTypeCode != MediumTransportElement &&
+                               ElementStatusPage->ElementTypeCode != StorageElement &&
+                               ElementStatusPage->ElementTypeCode != ImportExportElement ) ||
+                               TransportElementDescriptorLength < 4)
+                       {
 #ifdef DEBUG
-      int got_element_num=0;
-      
-      fprintf(stderr,"Working on element # %d Element Count %d\n",got_element_num,ElementCount);
-      got_element_num++;
-#endif
-
-      memcpy(&ESBuf, DataPointer, sizeof(ElementStatusPage_T));
-      ElementStatusPage = &ESBuf;
-      DataPointer += sizeof(ElementStatusPage_T);
-      TransportElementDescriptorLength =
-       BigEndian16(ElementStatusPage->ElementDescriptorLength);
-      if (TransportElementDescriptorLength <
-         sizeof(TransportElementDescriptorShort_T)) {
-
-       /* Foo, Storage Element Descriptors can be 4 bytes?! */
-       if ( (ElementStatusPage->ElementTypeCode != MediumTransportElement &&
-             ElementStatusPage->ElementTypeCode != StorageElement &&
-             ElementStatusPage->ElementTypeCode != ImportExportElement ) ||
-            TransportElementDescriptorLength < 4) {
+                               fprintf(stderr,"boom! ElementTypeCode=%d\n",ElementStatusPage->ElementTypeCode);
+#endif
+                               FatalError("Transport Element Descriptor Length too short: %d\n", TransportElementDescriptorLength);
+                       }
+               }
 #ifdef DEBUG
-         fprintf(stderr,"boom! ElementTypeCode=%d\n",ElementStatusPage->ElementTypeCode);
+               fprintf(stderr,"Transport Element Descriptor Length=%d\n",TransportElementDescriptorLength);
 #endif
-         FatalError("Transport Element Descriptor Length too short: %d\n",TransportElementDescriptorLength);
-       } 
-       
-      }
+               BytesAvailable =
+                       BigEndian24(ElementStatusPage->ByteCountOfDescriptorDataAvailable);
 #ifdef DEBUG
-      fprintf(stderr,"Transport Element Descriptor Length=%d\n",TransportElementDescriptorLength);
-#endif
-      BytesAvailable =
-       BigEndian24(ElementStatusPage->ByteCountOfDescriptorDataAvailable);
-      if (BytesAvailable <= 0) {
-             ElementCount--;
-      }
-      while (BytesAvailable > 0)
-       {
-         /* TransportElementDescriptor =
-            (TransportElementDescriptor_T *) DataPointer; */
-          memcpy(&TEBuf, DataPointer, 
-                       (TransportElementDescriptorLength <= sizeof(TEBuf)) ?
-                               TransportElementDescriptorLength  :
-                               sizeof(TEBuf));
-          TransportElementDescriptor = &TEBuf;
-
-         DataPointer += TransportElementDescriptorLength;
-         BytesAvailable -= TransportElementDescriptorLength;
-         ElementCount--;
-         switch (ElementStatusPage->ElementTypeCode)
-           {
-           case MediumTransportElement:
-             ElementStatus->TransportElementAddress = BigEndian16(TransportElementDescriptor->ElementAddress);
+               fprintf(stderr,"%d bytes of descriptor data available in descriptor\n",
+                               BytesAvailable);
+#endif
+               /* work around a bug in ADIC DAT loaders */
+               if (BytesAvailable <= 0)
+               {
+                       ElementCount--; /* sorry :-( */
+               }
+               while (BytesAvailable > 0)
+               {
+                       /* TransportElementDescriptor =
+                       (TransportElementDescriptor_T *) DataPointer; */
+                       memcpy(&TEBuf, DataPointer, 
+                               (TransportElementDescriptorLength <= sizeof(TEBuf)) ?
+                                       TransportElementDescriptorLength  :
+                                       sizeof(TEBuf));
+                       TransportElementDescriptor = &TEBuf;
+
+                       if (pNextElement != NULL)
+                       {
+                               if (BigEndian16(TransportElementDescriptor->ElementAddress) != 0 || *pNextElement == 0)
+                               {
+                                       (*pNextElement) = BigEndian16(TransportElementDescriptor->ElementAddress) + 1;
+                               }
+                               else
+                               {
+                                       return;
+                               }
+                       }
+
+                       DataPointer += TransportElementDescriptorLength;
+                       BytesAvailable -= TransportElementDescriptorLength;
+                       ElementCount--;
+
+                       switch (ElementStatusPage->ElementTypeCode)
+                       {
+                       case MediumTransportElement:
+                               ElementStatus->TransportElementAddress = BigEndian16(TransportElementDescriptor->ElementAddress);
 #ifdef DEBUG
-             fprintf(stderr,"TransportElementAddress=%d\n",ElementStatus->TransportElementAddress); 
-#endif
-             break;
-             /* we treat ImportExport elements as if they were normal
-              * storage elements now, sigh...
-              */
-           case ImportExportElement:
-             ElementStatus->ImportExportCount++;
+                               fprintf(stderr,"TransportElementAddress=%d\n",ElementStatus->TransportElementAddress); 
+#endif
+                               break;
+
+                       /* we treat ImportExport elements as if they were normal
+                       * storage elements now, sigh...
+                       */
+                       case ImportExportElement:
 #ifdef DEBUG
-             fprintf(stderr,"ImportExportElement=%d\n",ElementStatus->StorageElementCount);
+                               fprintf(stderr,"ImportExportElement=%d\n",ElementStatus->StorageElementCount);
 #endif
-             ElementStatus->StorageElementIsImportExport[ElementStatus->StorageElementCount] = 1;
-             /* WARNING: DO *NOT* PUT A 'break' STATEMENT HERE, it is supposed
-              * to run on into the case for a Storage Element! 
-              */
-           case StorageElement:
+                               if (ElementStatus->ImportExportCount >= mode_sense->NumImportExport)
+                               {
+                                       fprintf(stderr,"Warning:Too Many Import/Export Elements Reported (expected %d, now have %d\n",
+                                       mode_sense->NumImportExport,
+                                       ElementStatus->ImportExportCount + 1);
+                                       fflush(stderr);
+                                       return; /* we're done :-(. */
+                               }
+
+                               ImportExportIndex = mode_sense->NumStorage - mode_sense->NumImportExport + ElementStatus->ImportExportCount;
+
+                               ElementStatus->StorageElementAddress[ImportExportIndex] =
+                                       BigEndian16(TransportElementDescriptor->ElementAddress);
+                               ElementStatus->StorageElementFull[ImportExportIndex] =
+                                       TransportElementDescriptor->Full;
+
+                               if ( (TransportElementDescriptorLength > 11) && 
+                                       (ElementStatusPage->VolBits & E2_AVOLTAG))
+                               {
+                                       copy_barcode(TransportElementDescriptor->AlternateVolumeTag,
+                                               ElementStatus->AlternateVolumeTag[ImportExportIndex]);
+                               }
+                               else
+                               {
+                                       ElementStatus->AlternateVolumeTag[ImportExportIndex][0] = 0;  /* null string. */;
+                               } 
+                               if ((TransportElementDescriptorLength > 11) && 
+                                       (ElementStatusPage->VolBits & E2_PVOLTAG))
+                               {
+                                       copy_barcode(TransportElementDescriptor->PrimaryVolumeTag,
+                                               ElementStatus->PrimaryVolumeTag[ImportExportIndex]);
+                               }
+                               else
+                               {
+                                       ElementStatus->PrimaryVolumeTag[ImportExportIndex][0]=0; /* null string. */
+                               }
+
+                               ElementStatus->StorageElementIsImportExport[ImportExportIndex] = 1;
+
+                               ElementStatus->ImportExportCount++;
+                               break;
+
+                       case StorageElement:
 #ifdef DEBUG
-             fprintf(stderr,"StorageElementCount=%d  ElementAddress = %d ",ElementStatus->StorageElementCount,BigEndian16(TransportElementDescriptor->ElementAddress));
+                               fprintf(stderr,"StorageElementCount=%d  ElementAddress = %d ",ElementStatus->StorageElementCount,BigEndian16(TransportElementDescriptor->ElementAddress));
 #endif
-             ElementStatus->StorageElementAddress[ElementStatus->StorageElementCount] =
-               BigEndian16(TransportElementDescriptor->ElementAddress);
-             ElementStatus->StorageElementFull[ElementStatus->StorageElementCount] =
-               TransportElementDescriptor->Full;
+                               /* ATL/Exabyte kludge -- skip slots that aren't installed :-( */
+                               if (TransportElementDescriptor->AdditionalSenseCode==0x83 && 
+                                       TransportElementDescriptor->AdditionalSenseCodeQualifier==0x02) 
+                                       continue;
+
+                               ElementStatus->StorageElementAddress[ElementStatus->StorageElementCount] =
+                                       BigEndian16(TransportElementDescriptor->ElementAddress);
+                               ElementStatus->StorageElementFull[ElementStatus->StorageElementCount] =
+                                       TransportElementDescriptor->Full;
 #ifdef DEBUG
-             fprintf(stderr,"TransportElement->Full = %d\n",TransportElementDescriptor->Full);
+                               if (TransportElementDescriptor->Except)
+                                       fprintf(stderr,"ASC,ASCQ = 0x%x,0x%x ",TransportElementDescriptor->AdditionalSenseCode,TransportElementDescriptor->AdditionalSenseCodeQualifier);
+                               fprintf(stderr,"TransportElement->Full = %d\n",TransportElementDescriptor->Full);
 #endif
-             if (!TransportElementDescriptor->Full)
-               {
-                 EmptyStorageElementAddress[(*EmptyStorageElementCount)++] =
-                   ElementStatus->StorageElementCount; /* slot idx. */
-                   /*   ElementStatus->StorageElementAddress[ElementStatus->StorageElementCount]; */
+                               if (!TransportElementDescriptor->Full)
+                               {
+                                       EmptyStorageElementAddress[(*EmptyStorageElementCount)++] =
+                                               ElementStatus->StorageElementCount; /* slot idx. */
+                                       /*   ElementStatus->StorageElementAddress[ElementStatus->StorageElementCount]; */
+                               }
+                               if ((TransportElementDescriptorLength >  11) && 
+                                       (ElementStatusPage->VolBits & E2_AVOLTAG))
+                               {
+                                       copy_barcode(TransportElementDescriptor->AlternateVolumeTag,
+                                               ElementStatus->AlternateVolumeTag[ElementStatus->StorageElementCount]);
+                               }
+                               else
+                               {
+                                       ElementStatus->AlternateVolumeTag[ElementStatus->StorageElementCount][0]=0;  /* null string. */;
+                               } 
+                               if ((TransportElementDescriptorLength > 11) && 
+                                       (ElementStatusPage->VolBits & E2_PVOLTAG))
+                               {
+                                       copy_barcode(TransportElementDescriptor->PrimaryVolumeTag,
+                                               ElementStatus->PrimaryVolumeTag[ElementStatus->StorageElementCount]);
+                               }
+                               else
+                               {
+                                       ElementStatus->PrimaryVolumeTag[ElementStatus->StorageElementCount][0]=0; /* null string. */
+                               }
+
+                               ElementStatus->StorageElementCount++;
+                               /*
+                                       Note that the original mtx had no check here for 
+                                       buffer overflow, though some drives might mistakingly
+                                       do one... 
+                               */
+
+                               if (ElementStatus->StorageElementCount > mode_sense->NumStorage)
+                               {
+                                       fprintf(stderr,"Warning:Too Many Storage Elements Reported (expected %d, now have %d\n",
+                                                       mode_sense->NumStorage,
+                                                       ElementStatus->StorageElementCount);
+                                       fflush(stderr);
+                                       return; /* we're done :-(. */
+                               }
+                               break;
+
+                       case DataTransferElement:
+                               /* tape drive not installed, go back to top of loop */
+
+                               /* if (TransportElementDescriptor->Except) continue ; */
+
+                               /* Note: This is for Exabyte tape libraries that improperly
+                               report that they have a 2nd tape drive when they don't. We
+                               could generalize this in an ideal world, but my attempt to
+                               do so failed with dual-drive Exabyte tape libraries that
+                               *DID* have the second drive. Sigh. 
+                               */
+                               if (TransportElementDescriptor->AdditionalSenseCode==0x83 && 
+                                       TransportElementDescriptor->AdditionalSenseCodeQualifier==0x04)
+                               {
+                                       continue;
+                               }
+
+                               /*      generalize it. Does it work? Let's try it! */
+                               /*      
+                                       No, dammit, following does not work on dual-drive Exabyte
+                                       'cause if a tape is in the drive, it sets the AdditionalSense
+                                       code to something (sigh).
+                               */
+                               /* if (TransportElementDescriptor->AdditionalSenseCode!=0)
+                                       continue;
+                               */ 
+
+                               ElementStatus->DataTransferElementAddress[ElementStatus->DataTransferElementCount] =
+                                       BigEndian16(TransportElementDescriptor->ElementAddress);
+                               ElementStatus->DataTransferElementFull[ElementStatus->DataTransferElementCount] = 
+                                       TransportElementDescriptor->Full;
+                               ElementStatus->DataTransferElementSourceStorageElementNumber[ElementStatus->DataTransferElementCount] =
+                                       BigEndian16(TransportElementDescriptor->SourceStorageElementAddress);
+
+#if DEBUG
+                               fprintf(stderr, "%d: ElementAddress = %d, Full = %d, SourceElement = %d\n", 
+                                               ElementStatus->DataTransferElementCount,
+                                               ElementStatus->DataTransferElementAddress[ElementStatus->DataTransferElementCount],
+                                               ElementStatus->DataTransferElementFull[ElementStatus->DataTransferElementCount],
+                                               ElementStatus->DataTransferElementSourceStorageElementNumber[ElementStatus->DataTransferElementCount]);
+#endif
+                               if (ElementStatus->DataTransferElementCount >= mode_sense->NumDataTransfer)
+                               {
+                                       FatalError("Too many Data Transfer Elements Reported\n");
+                               }
+
+                               if (ElementStatusPage->VolBits & E2_PVOLTAG)
+                               {
+                                       copy_barcode(TransportElementDescriptor->PrimaryVolumeTag,
+                                       ElementStatus->DataTransferPrimaryVolumeTag[ElementStatus->DataTransferElementCount]);
+                               }
+                               else
+                               {
+                                       ElementStatus->DataTransferPrimaryVolumeTag[ElementStatus->DataTransferElementCount][0]=0; /* null string */
+                               }
+
+                               if (ElementStatusPage->VolBits & E2_AVOLTAG)
+                               {
+                                       copy_barcode(TransportElementDescriptor->AlternateVolumeTag,
+                                       ElementStatus->DataTransferAlternateVolumeTag[ElementStatus->DataTransferElementCount]);
+                               }
+                               else
+                               {
+                                       ElementStatus->DataTransferAlternateVolumeTag[ElementStatus->DataTransferElementCount][0]=0; /* null string */
+                               }
+
+                               ElementStatus->DataTransferElementCount++;
+
+                               /* 0 actually is a usable element address */
+                               /* if (DataTransferElementAddress == 0) */
+                               /*      FatalError( */
+                               /*  "illegal Data Transfer Element Address %d reported\n", */
+                               /* DataTransferElementAddress); */
+                               break;
+
+                       default:
+                               FatalError("illegal Element Type Code %d reported\n",
+                                                       ElementStatusPage->ElementTypeCode);
+                       }
                }
-             if ( (TransportElementDescriptorLength >  11) && 
-                  (ElementStatusPage->VolBits & E2_AVOLTAG)) {
-               copy_barcode(TransportElementDescriptor->AlternateVolumeTag,
-                            ElementStatus->AlternateVolumeTag[ElementStatus->StorageElementCount]);
-             } else {
-               ElementStatus->AlternateVolumeTag[ElementStatus->StorageElementCount][0]=0;  /* null string. */;
-             } 
-             if ( (TransportElementDescriptorLength > 11) && 
-                  (ElementStatusPage->VolBits & E2_PVOLTAG)) {
-               copy_barcode(TransportElementDescriptor->PrimaryVolumeTag,
-                            ElementStatus->PrimaryVolumeTag[ElementStatus->StorageElementCount]);
-             } else {
-               ElementStatus->PrimaryVolumeTag[ElementStatus->StorageElementCount][0]=0; /* null string. */
-             }
-             
-             ElementStatus->StorageElementCount++;
-             /* Note that the original mtx had no check here for 
-                buffer overflow, though some drives might mistakingly
-                do one... 
-             */ 
-             if (ElementStatus->StorageElementCount > mode_sense->NumStorage) {
-               fprintf(stderr,"Warning:Too Many Storage Elements Reported (expected %d, now have %d\n",
-                       mode_sense->NumStorage,
-                       ElementStatus->StorageElementCount);
-               fflush(stderr);
-               return; /* we're done :-(. */
-             }
-
-
-             break;
-
-
-           case DataTransferElement:
-             /* tape drive not installed, go back to top of loop */
-
-             /* if (TransportElementDescriptor->Except) continue ; */
-
-             /* Note: This is for Exabyte tape libraries that improperly
-                report that they have a 2nd tape drive when they don't. We
-                could generalize this in an ideal world, but my attempt to
-                do so failed with dual-drive Exabyte tape libraries that
-                *DID* have the second drive. Sigh. 
-             */
-             /* No longer need this test due to code restructuring? */
-             /* if (TransportElementDescriptor->AdditionalSenseCode==0x83 && 
-                 TransportElementDescriptor->AdditionalSenseCodeQualifier==0x04) 
-               continue;
-             */ 
-             /* generalize it. Does it work? Let's try it! */
-             /* No, dammit, following does not work on dual-drive Exabyte
-                'cause if a tape is in the drive, it sets the AdditionalSense
-                 code to something (sigh).
-             */
-             /* if (TransportElementDescriptor->AdditionalSenseCode!=0)
-               continue;
-             */ 
-             
-
-                 
-             ElementStatus->DataTransferElementAddress[ElementStatus->DataTransferElementCount] =
-               BigEndian16(TransportElementDescriptor->ElementAddress);
-             ElementStatus->DataTransferElementFull[ElementStatus->DataTransferElementCount] = 
-               TransportElementDescriptor->Full;
-             ElementStatus->DataTransferElementSourceStorageElementNumber[ElementStatus->DataTransferElementCount] =
-               BigEndian16(TransportElementDescriptor
-                           ->SourceStorageElementAddress);
-
-             if (ElementStatus->DataTransferElementCount >= mode_sense->NumDataTransfer) {
-               FatalError("Too many Data Transfer Elements Reported\n");
-             }
-             if (ElementStatusPage->VolBits & E2_PVOLTAG) {
-               copy_barcode(TransportElementDescriptor->PrimaryVolumeTag,
-                            ElementStatus->DataTransferPrimaryVolumeTag[ElementStatus->DataTransferElementCount]);
-             } else {
-               ElementStatus->DataTransferPrimaryVolumeTag[ElementStatus->DataTransferElementCount][0]=0; /* null string */
-             }
-             if (ElementStatusPage->VolBits & E2_AVOLTAG) {
-               copy_barcode(TransportElementDescriptor->AlternateVolumeTag,
-                            ElementStatus->DataTransferAlternateVolumeTag[ElementStatus->DataTransferElementCount]);
-             } else {
-               ElementStatus->DataTransferAlternateVolumeTag[ElementStatus->DataTransferElementCount][0]=0; /* null string */
-             }
-             ElementStatus->DataTransferElementCount++;
-             /* 0 actually is a usable element address */
-             /* if (DataTransferElementAddress == 0) */
-             /*        FatalError( */
-             /*  "illegal Data Transfer Element Address %d reported\n", */
-             /* DataTransferElementAddress); */
-             break;
-           default:
-             FatalError("illegal Element Type Code %d reported\n",
-                        ElementStatusPage->ElementTypeCode);
-           }
        }
-    }
+
+#ifdef DEBUG
+       if (pNextElement)
+               fprintf(stderr,"Next start element will be %d\n",*pNextElement);
+#endif
 }
 
+
 /********************* Real ReadElementStatus ********************* */
 
 /*
@@ -824,510 +1119,744 @@ static void ParseElementStatus(int *EmptyStorageElementAddress,
 
 */
 
-ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *RequestSense, Inquiry_T *inquiry_info, SCSI_Flags_T *flags) {
-  ElementStatus_T *ElementStatus;
-  
-  unsigned char *DataBuffer; /* size of data... */
-  
-  int EmptyStorageElementCount=0;
-  int *EmptyStorageElementAddress; /* [MAX_STORAGE_ELEMENTS]; */
-  
-  int empty_idx=0;
-  int invalid_sources=0;
-  boolean is_attached = false;
-  int i,j;
-  
-  ElementModeSense_T *mode_sense = NULL;
-  
-  if ((inquiry_info->MChngr) && (inquiry_info->PeripheralDeviceType != MEDIUM_CHANGER_TYPE)) {
-    is_attached=true;
-  }
-  if (flags->no_attached) { /* override, sigh */ 
-    is_attached=false;
-  }
-  if (!is_attached) {
-    mode_sense=ReadAssignmentPage(MediumChangerFD);
-  }
-  if (!mode_sense) {
-    mode_sense=(ElementModeSense_T *) xmalloc(sizeof(ElementModeSense_T));
-    mode_sense->NumMediumTransport=MAX_TRANSPORT_ELEMENTS;
-    mode_sense->NumStorage=MAX_STORAGE_ELEMENTS;
-    mode_sense->NumDataTransfer=MAX_TRANSFER_ELEMENTS;
-    mode_sense->MaxReadElementStatusData=  (sizeof(ElementStatusDataHeader_T)
-                                           + 3 * sizeof(ElementStatusPage_T)
-                                           + (MAX_STORAGE_ELEMENTS+MAX_TRANSFER_ELEMENTS+MAX_TRANSPORT_ELEMENTS)
-                                           * sizeof(TransportElementDescriptor_T));
-    
-    /* don't care about the others anyhow at the moment... */
-  }
-  
-  ElementStatus=AllocateElementData(mode_sense);
-
-  /* Now to initialize it (sigh).  */
-  ElementStatus->StorageElementCount = 0;
-  ElementStatus->DataTransferElementCount=0;
-    
-  
-  /* first, allocate some empty storage stuff: Note that we pass this
-   * down to ParseElementStatus (sigh!) 
-   */
-  
-  EmptyStorageElementAddress=(int *)xzmalloc((mode_sense->NumStorage+1)*sizeof(int));
-  for (i=0;i<mode_sense->NumStorage;i++) {
-    EmptyStorageElementAddress[i]=-1;
-  }
-  
-  /* Okay, now to send some requests for the various types of stuff: */
-
-  /* -----------STORAGE ELEMENTS---------------- */
-  /* Let's start with storage elements: */
-
-  for (i=0;i<mode_sense->NumDataTransfer;i++) {
-    /* initialize them to an illegal # so that we can fix later... */
-    ElementStatus->DataTransferElementSourceStorageElementNumber[i] = -1; 
-  }
-  
-
-  flags->elementtype=StorageElement; /* sigh! */
-  DataBuffer=SendElementStatusRequest(MediumChangerFD,RequestSense,
-                                     inquiry_info,flags,
-                                     mode_sense->StorageStart,
-                                     /* adjust for import/export. */
-                                     mode_sense->NumStorage-mode_sense->NumImportExport,
-                                     mode_sense->MaxReadElementStatusData);
-  if (!DataBuffer) {
-    /* darn. Free up stuff and return. */
-    /****FIXME**** do a free on element data! */
-    FreeElementData(ElementStatus);
-    return NULL; 
-  } 
-
-  ParseElementStatus(EmptyStorageElementAddress,&EmptyStorageElementCount,
-                    DataBuffer,ElementStatus,mode_sense);
-
-  free(DataBuffer); /* sigh! */
-
-  /* --------------IMPORT/EXPORT--------------- */
-  /* Next let's see if we need to do Import/Export: */
-  if (mode_sense->NumImportExport > 0) {
-    flags->elementtype=ImportExportElement;
-    DataBuffer=SendElementStatusRequest(MediumChangerFD,RequestSense,
-                                       inquiry_info,flags,
-                                       mode_sense->ImportExportStart,
-                                       mode_sense->NumImportExport,
-                                       mode_sense->MaxReadElementStatusData);
-    
-    if (!DataBuffer) {
-      /* darn. Free up stuff and return. */
-      /****FIXME**** do a free on element data! */
-      FreeElementData(ElementStatus);
-      return NULL; 
-    } 
-    ParseElementStatus(EmptyStorageElementAddress,&EmptyStorageElementCount,
-                    DataBuffer,ElementStatus,mode_sense);
-
-  }
-  
-
-
-  /* ----------------- DRIVES ---------------------- */
-
-
-  flags->elementtype=DataTransferElement; /* sigh! */
-  DataBuffer=SendElementStatusRequest(MediumChangerFD,RequestSense,
-                                     inquiry_info,flags,
-                                     mode_sense->DataTransferStart,
-                                     mode_sense->NumDataTransfer,
-                                     mode_sense->MaxReadElementStatusData);
-  if (!DataBuffer) {
-    /* darn. Free up stuff and return. */
-    /****FIXME**** do a free on element data! */
-    FreeElementData(ElementStatus);
-    return NULL; 
-  } 
-
-  ParseElementStatus(EmptyStorageElementAddress,&EmptyStorageElementCount,
-                    DataBuffer,ElementStatus,mode_sense);
-
-  free(DataBuffer); /* sigh! */
-
-
-  /* ----------------- Robot Arm(s) -------------------------- */
-
-    /* grr, damned brain dead HP doesn't report that it has any! */
-  if (!mode_sense->NumMediumTransport) { 
-    ElementStatus->TransportElementAddress=0; /* default it sensibly :-(. */
-  } else {
-     flags->elementtype=MediumTransportElement; /* sigh! */
-     DataBuffer=SendElementStatusRequest(MediumChangerFD,RequestSense,
-                                     inquiry_info,flags,
-                                     mode_sense->MediumTransportStart,
-                                     1, /* only get 1, sigh. */
-                                     mode_sense->MaxReadElementStatusData);
-     if (!DataBuffer) {
-       /* darn. Free up stuff and return. */
-       /****FIXME**** do a free on element data! */
-       FreeElementData(ElementStatus);
-       return NULL; 
-     } 
-   
-     ParseElementStatus(EmptyStorageElementAddress,&EmptyStorageElementCount,
-                    DataBuffer,ElementStatus,mode_sense);
-
-     free(DataBuffer); /* sigh! */
-  }
-
-  /*---------------------- Sanity Checking ------------------- */
-
-  if (!ElementStatus->DataTransferElementCount)
-    FatalError("no Data Transfer Element reported\n");
-  if (ElementStatus->StorageElementCount == 0)
-    FatalError("no Storage Elements reported\n");
-
-
-  /* ---------------------- Reset SourceStorageElementNumbers ------- */
-
-  /* okay, re-write the SourceStorageElementNumber code  *AGAIN*.
-   * Pass1:
-   *   Translate from raw element # to our translated # (if possible).
-   * First, check the SourceStorageElementNumbers against the list of 
-   * filled slots. If the slots indicated are empty, we accept that list as
-   * valid. Otherwise decide the SourceStorageElementNumbers are invalid.
-   *
-   * Pass2:
-   *
-   * If we had some invalid (or unknown) SourceStorageElementNumbers
-   * then we must search for free slots, and assign SourceStorageElementNumbers
-   * to those free slots. We happen to already built a list of free
-   * slots as part of the process of reading the storage element numbers
-   * from the tape. So that's easy enough to do! 
-   */
+ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *RequestSense, Inquiry_T *inquiry_info, SCSI_Flags_T *flags)
+{
+       ElementStatus_T *ElementStatus;
 
-#ifdef DEBUG_TAPELIST
-  fprintf(stderr,"empty slots: %d\n",EmptyStorageElementCount);
-  if (EmptyStorageElementCount) {
-     for (i=0; i<EmptyStorageElementCount; i++) {
-         fprintf(stderr,"empty: %d\n",EmptyStorageElementAddress[i]);
-     }
-  }
-#endif
-
-  /* Okay, now we re-assign origin slots if the "real" origin slot
-   * is obviously defective: 
-   */
-  /* pass one: */
-  invalid_sources=0; /* no invalid sources yet! */
-  for (i=0;i<ElementStatus->DataTransferElementCount;i++) {
-    int elnum;
-    int translated_elnum = -1;
-    /* if we have an element, then ... */
-    if (ElementStatus->DataTransferElementFull[i]) {
-      elnum=ElementStatus->DataTransferElementSourceStorageElementNumber[i];
-      /* if we have an element number, then ... */
-      if (elnum >= 0) {
-         /* Now to translate the elnum: */
-        for (j=0; j<ElementStatus->StorageElementCount; j++) {
-            if (elnum == ElementStatus->StorageElementAddress[j]) {
-                translated_elnum=j; 
-            }
-        }
-      /* now see if the element # is already occupied: */
-       if (ElementStatus->StorageElementFull[translated_elnum]) {
-         invalid_sources=1;
-         break; /* break out of the loop! */
-       } else {
-          /* properly set the source... */
-       ElementStatus->DataTransferElementSourceStorageElementNumber[i]=
-               translated_elnum;
+       unsigned char *DataBuffer; /* size of data... */
+
+       int EmptyStorageElementCount=0;
+       int *EmptyStorageElementAddress; /* [MAX_STORAGE_ELEMENTS]; */
+
+       int empty_idx = 0;
+       boolean is_attached = false;
+       int i,j;
+
+       ElementModeSense_T *mode_sense = NULL;
+
+       if (inquiry_info->MChngr && inquiry_info->PeripheralDeviceType != MEDIUM_CHANGER_TYPE)
+       {
+               is_attached = true;
+       }
+
+       if (flags->no_attached)
+       {
+               /* override, sigh */ 
+               is_attached = false;
+       }
+
+       if (!is_attached)
+       {
+               mode_sense = ReadAssignmentPage(MediumChangerFD);
+       }
+
+       if (!mode_sense)
+       {
+               mode_sense = (ElementModeSense_T *)xmalloc(sizeof(ElementModeSense_T));
+               mode_sense->NumMediumTransport = MAX_TRANSPORT_ELEMENTS;
+               mode_sense->NumStorage = MAX_STORAGE_ELEMENTS;
+               mode_sense->NumDataTransfer = MAX_TRANSFER_ELEMENTS;
+               mode_sense->MaxReadElementStatusData =
+                       (sizeof(ElementStatusDataHeader_T) + 3 * sizeof(ElementStatusPage_T) +
+                       (MAX_STORAGE_ELEMENTS+MAX_TRANSFER_ELEMENTS+MAX_TRANSPORT_ELEMENTS) *
+                               sizeof(TransportElementDescriptor_T));
+
+               /* don't care about the others anyhow at the moment... */
+       }
+
+       ElementStatus = AllocateElementData(mode_sense);
+
+       /* Now to initialize it (sigh).  */
+       ElementStatus->StorageElementCount = 0;
+       ElementStatus->DataTransferElementCount = 0;
+
+       /* first, allocate some empty storage stuff: Note that we pass this
+       * down to ParseElementStatus (sigh!) 
+       */
+
+       EmptyStorageElementAddress = (int *)xzmalloc((mode_sense->NumStorage+1)*sizeof(int));
+       for (i = 0; i < mode_sense->NumStorage; i++)
+       {
+               EmptyStorageElementAddress[i] = -1;
+       }
+
+       /* Okay, now to send some requests for the various types of stuff: */
+
+       /* -----------STORAGE ELEMENTS---------------- */
+       /* Let's start with storage elements: */
+
+       for (i = 0; i < mode_sense->NumDataTransfer; i++)
+       {
+               /* initialize them to an illegal # so that we can fix later... */
+               ElementStatus->DataTransferElementSourceStorageElementNumber[i] = -1; 
        }
-                
-      } else {
-       /* if element # was not >=0, then we had an invalid source anyhow! */
-       invalid_sources=1;
-      }
-    }
-  }
+
+       if (flags->querytype == MTX_ELEMENTSTATUS_ORIGINAL)
+       {
+#ifdef DEBUG
+               fprintf(stderr,"Using original element status polling method (storage, import/export, drivers etc independantly)\n");
+#endif
+               flags->elementtype = StorageElement; /* sigh! */
+               DataBuffer = SendElementStatusRequest(  MediumChangerFD, RequestSense,
+                                                                                               inquiry_info, flags,
+                                                                                               mode_sense->StorageStart,
+                                                                                               /* adjust for import/export. */
+                                                                                               mode_sense->NumStorage - mode_sense->NumImportExport,
+                                                                                               mode_sense->MaxReadElementStatusData);
+
+               if (!DataBuffer)
+               {
+#ifdef DEBUG
+                       fprintf(stderr,"Had no elements!\n");
+#endif
+                       /* darn. Free up stuff and return. */
+#ifdef DEBUG_MODE_SENSE
+                       PrintRequestSense(RequestSense);
+#endif
+                       FreeElementData(ElementStatus);
+                       return NULL; 
+               }
+
+#ifdef DEBUG
+               fprintf(stderr, "Parsing storage elements\n");
+#endif
+               ParseElementStatus(EmptyStorageElementAddress, &EmptyStorageElementCount,
+                       DataBuffer,ElementStatus,mode_sense,NULL);
+
+               free(DataBuffer); /* sigh! */
+
+               /* --------------IMPORT/EXPORT--------------- */
+               /* Next let's see if we need to do Import/Export: */
+               if (mode_sense->NumImportExport > 0)
+               {
+#ifdef DEBUG
+                       fprintf(stderr,"Sending request for Import/Export status\n");
+#endif
+                       flags->elementtype = ImportExportElement;
+                       DataBuffer = SendElementStatusRequest(  MediumChangerFD,RequestSense,
+                                                                                                       inquiry_info, flags,
+                                                                                                       mode_sense->ImportExportStart,
+                                                                                                       mode_sense->NumImportExport,
+                                                                                                       mode_sense->MaxReadElementStatusData);
+
+                       if (!DataBuffer)
+                       {
+#ifdef DEBUG
+                               fprintf(stderr,"Had no input/export element!\n");
+#endif
+                               /* darn. Free up stuff and return. */
+#ifdef DEBUG_MODE_SENSE
+                               PrintRequestSense(RequestSense);
+#endif
+                               FreeElementData(ElementStatus);
+                               return NULL;
+                       }
+#ifdef DEBUG
+                       fprintf(stderr,"Parsing inport/export element status\n");
+#endif
+#ifdef DEBUG_ADIC
+                       dump_data(DataBuffer, 100);             /* dump some data :-(. */
+#endif
+                       ParseElementStatus(     EmptyStorageElementAddress, &EmptyStorageElementCount,
+                                                               DataBuffer, ElementStatus, mode_sense, NULL);
+
+                       ElementStatus->StorageElementCount += ElementStatus->ImportExportCount;
+               }
+
+               /* ----------------- DRIVES ---------------------- */
+
+#ifdef DEBUG
+               fprintf(stderr,"Sending request for data transfer element (drive) status\n");
+#endif
+               flags->elementtype = DataTransferElement; /* sigh! */
+               DataBuffer = SendElementStatusRequest(  MediumChangerFD, RequestSense,
+                                                                                               inquiry_info, flags,
+                                                                                               mode_sense->DataTransferStart,
+                                                                                               mode_sense->NumDataTransfer,
+                                                                                               mode_sense->MaxReadElementStatusData);
+               if (!DataBuffer)
+               {
+#ifdef DEBUG
+                       fprintf(stderr,"No data transfer element status.");
+#endif
+                       /* darn. Free up stuff and return. */
+#ifdef DEBUG_MODE_SENSE
+                       PrintRequestSense(RequestSense);
+#endif
+                       FreeElementData(ElementStatus);
+                       return NULL; 
+               }
+
+#ifdef DEBUG
+               fprintf(stderr,"Parsing data for data transfer element (drive) status\n");
+#endif
+               ParseElementStatus(     EmptyStorageElementAddress, &EmptyStorageElementCount,
+                                                       DataBuffer,ElementStatus, mode_sense, NULL);
+
+               free(DataBuffer); /* sigh! */
+
+               /* ----------------- Robot Arm(s) -------------------------- */
+
+               /* grr, damned brain dead HP doesn't report that it has any! */
+               if (!mode_sense->NumMediumTransport)
+               { 
+                       ElementStatus->TransportElementAddress = 0; /* default it sensibly :-(. */
+               }
+               else
+               {
+#ifdef DEBUG
+                       fprintf(stderr,"Sending request for robot arm status\n");
+#endif
+                       flags->elementtype = MediumTransportElement; /* sigh! */
+                       DataBuffer = SendElementStatusRequest(  MediumChangerFD, RequestSense,
+                                                                                                       inquiry_info, flags,
+                                                                                                       mode_sense->MediumTransportStart,
+                                                                                                       1, /* only get 1, sigh. */
+                                                                                                       mode_sense->MaxReadElementStatusData);
+                       if (!DataBuffer)
+                       {
+#ifdef DEBUG
+                               fprintf(stderr,"Loader reports no robot arm!\n");
+#endif
+                               /* darn. Free up stuff and return. */
+#ifdef DEBUG_MODE_SENSE
+                               PrintRequestSense(RequestSense);
+#endif
+                               FreeElementData(ElementStatus);
+                               return NULL; 
+                       } 
+#ifdef DEBUG
+                       fprintf(stderr,"Parsing robot arm data\n");
+#endif
+                       ParseElementStatus(     EmptyStorageElementAddress, &EmptyStorageElementCount,
+                                                               DataBuffer, ElementStatus, mode_sense, NULL);
+
+                       free(DataBuffer);
+               }
+       }
+       else
+       {
+               int nLastEl=-1, nNextEl=0;
+
+#ifdef DEBUG
+               fprintf(stderr,"Using alternative element status polling method (all elements)\n");
+#endif
+               /* ----------------- ALL Elements ---------------------- */
+               /*      Just keep asking for elements till no more are returned 
+                       - increment our starting address as we go acording to the 
+                       number of elements returned from the last call
+               */
+
+               while(nLastEl!=nNextEl)
+               {
+                       flags->elementtype = AllElementTypes;//StorageElement; /* sigh! */ /*XL1B2 firewire changer does not seem to respond to specific types so just use all elements*/
+                       DataBuffer = SendElementStatusRequest(  MediumChangerFD,
+                                                                                                       RequestSense,
+                                                                                                       inquiry_info,
+                                                                                                       flags,
+                                                                                                       nNextEl,//mode_sense->StorageStart,
+                                                                                                       /* adjust for import/export. */
+                                                                                                       mode_sense->NumStorage - mode_sense->NumImportExport,//FIX ME:this should be a more sensible value
+                                                                                                       mode_sense->MaxReadElementStatusData);
+                       if (!DataBuffer)
+                       {
+                               if (RequestSense->AdditionalSenseCode == 0x21 && 
+                               RequestSense->AdditionalSenseCodeQualifier == 0x01)
+                               {
+                                       /* Error is invalid element address, we've probably just hit the end */
+                                       break;
+                               }
+
+                               /* darn. Free up stuff and return. */
+                               FreeElementData(ElementStatus);
+                               return NULL; 
+                       } 
+
+                       nLastEl = nNextEl;
+
+                       ParseElementStatus(     EmptyStorageElementAddress, &EmptyStorageElementCount,
+                                                               DataBuffer, ElementStatus, mode_sense, &nNextEl);
+
+                       free(DataBuffer); /* sigh! */
+               }
+
+               ElementStatus->StorageElementCount += ElementStatus->ImportExportCount;
+       }
+
+       /*---------------------- Sanity Checking ------------------- */
+
+       if (ElementStatus->DataTransferElementCount == 0)
+               FatalError("no Data Transfer Element reported\n");
+
+       if (ElementStatus->StorageElementCount == 0)
+               FatalError("no Storage Elements reported\n");
+
+
+       /* ---------------------- Reset SourceStorageElementNumbers ------- */
+
+       /*
+        * Re-write the SourceStorageElementNumber code  *AGAIN*.
+        *
+        * Pass1:
+        *      Translate from raw element # to our translated # (if possible).
+        *      First, check the SourceStorageElementNumbers against the list of 
+        *      filled slots. If the slots indicated are empty, we accept that list as
+        *      valid. Otherwise decide the SourceStorageElementNumbers are invalid.
+        *
+        * Pass2:
+        *      If we had some invalid (or unknown) SourceStorageElementNumbers
+        *      then we must search for free slots, and assign SourceStorageElementNumbers
+        *      to those free slots. We happen to already built a list of free
+        *      slots as part of the process of reading the storage element numbers
+        *      from the tape. So that's easy enough to do! 
+        */
 
 #ifdef DEBUG_TAPELIST
-   fprintf(stderr,"invalid_sources=%d\n",invalid_sources);
-#endif
-
-  /* Pass2: */
-  /* okay, we have invalid sources, so let's see what they should be: */
-  /* Note: If EmptyStorageElementCount is < # of drives, the leftover
-   * drives will be assigned a -1 (see the initialization loop for
-   * EmptyStorageElementAddress above), which will be reported as "slot 0"
-   * by the user interface. This is an invalid value, but more useful for us
-   * to have than just crapping out here :-(. 
-   */ 
-  if (invalid_sources) {
-    empty_idx=0;
-    for (i=0;i<ElementStatus->DataTransferElementCount;i++) {
-      if (ElementStatus->DataTransferElementFull[i]) {
+       fprintf(stderr, "empty slots: %d\n", EmptyStorageElementCount);
+       if (EmptyStorageElementCount)
+       {
+               for (i = 0; i < EmptyStorageElementCount; i++)
+               {
+                       fprintf(stderr, "empty: %d\n", EmptyStorageElementAddress[i]);
+               }
+       }
+#endif
+
+       /*
+        *      Now we re-assign origin slots if the "real" origin slot
+        *      is obviously defective: 
+        */
+       /* pass one: */
+       for (i = 0; i < ElementStatus->DataTransferElementCount; i++)
+       {
+               int elnum;
+
+               /* if we have an element, then ... */
+               if (ElementStatus->DataTransferElementFull[i])
+               {
+                       elnum = ElementStatus->DataTransferElementSourceStorageElementNumber[i];
+                       /* if we have an element number, then ... */
+                       if (elnum >= 0)
+                       {
+                               /* Now to translate the elnum: */
+                               ElementStatus->DataTransferElementSourceStorageElementNumber[i] = -1;
+                               for (j = 0; j < ElementStatus->StorageElementCount; j++)
+                               {
+                                       if (elnum == ElementStatus->StorageElementAddress[j])
+                                       {
+                                               /* now see if the element # is already occupied:*/
+                                               if (!ElementStatus->StorageElementFull[j])
+                                               {
+                                                       /* properly set the source... */
+                                                       ElementStatus->DataTransferElementSourceStorageElementNumber[i] = j;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /* Pass2: */
+       /*      We have invalid sources, so let's see what they should be: */
+       /*      Note: If EmptyStorageElementCount is < # of drives, the leftover
+        *      drives will be assigned a -1 (see the initialization loop for
+        *      EmptyStorageElementAddress above), which will be reported as "slot 0"
+        *      by the user interface. This is an invalid value, but more useful for us
+        *      to have than just crapping out here :-(. 
+       */
+       empty_idx=0;
+       for (i = 0; i < ElementStatus->DataTransferElementCount; i++)
+       {
+               if (ElementStatus->DataTransferElementFull[i] && 
+                       ElementStatus->DataTransferElementSourceStorageElementNumber[i] < 0)
+               {
 #ifdef DEBUG_TAPELIST
-        fprintf(stderr,"for drive %d, changing source %d to %d (empty slot #%d)\n",
-            i,
-            ElementStatus->DataTransferElementSourceStorageElementNumber[i],
-             EmptyStorageElementAddress[empty_idx],
-             empty_idx);
-#endif
-              
-       ElementStatus->DataTransferElementSourceStorageElementNumber[i]=
-         EmptyStorageElementAddress[empty_idx++];
-      }
-    }
-  }
-
-  /* and done! */      
-  free(mode_sense);
-  free(EmptyStorageElementAddress);
-  return ElementStatus;
-  
+                       fprintf(stderr,"for drive %d, changing to %d (empty slot #%d)\n",
+                                       i,
+                                       EmptyStorageElementAddress[empty_idx],
+                                       empty_idx);
+#endif
+                       ElementStatus->DataTransferElementSourceStorageElementNumber[i] =
+                               EmptyStorageElementAddress[empty_idx++];
+               }
+       }
+
+       /* and done! */
+       free(mode_sense);
+       free(EmptyStorageElementAddress);
+       return ElementStatus;
 }
 
 /*************************************************************************/
 
+RequestSense_T *PositionElement(DEVICE_TYPE MediumChangerFD,
+               int DestinationAddress,
+               ElementStatus_T *ElementStatus)
+{
+       RequestSense_T *RequestSense = xmalloc(sizeof(RequestSense_T));
+       CDB_T CDB;
+
+       CDB[0] = 0x2b;
+       CDB[1] = 0;
+       CDB[2] = (unsigned char)(ElementStatus->TransportElementAddress >> 8);
+       CDB[3] = (unsigned char)ElementStatus->TransportElementAddress;
+       CDB[4] = (unsigned char)(DestinationAddress >> 8);
+       CDB[5] = (unsigned char)DestinationAddress;
+       CDB[6] = 0;
+       CDB[7] = 0;
+       CDB[8] = 0;
+       CDB[9] = 0;
+
+       if(SCSI_ExecuteCommand( MediumChangerFD, Output, &CDB, 10,
+                                                       NULL, 0, RequestSense) != 0)
+       {
+               return RequestSense;
+       }
+       free(RequestSense);
+       return NULL; /* success */
+}
 
 
 /* Now the actual media movement routine! */
-RequestSense_T *MoveMedium(DEVICE_TYPE MediumChangerFD, int SourceAddress,
-                      int DestinationAddress, 
-                      ElementStatus_T *ElementStatus,
-                      Inquiry_T *inquiry_info, SCSI_Flags_T *flags)
+RequestSense_T *MoveMedium(    DEVICE_TYPE MediumChangerFD, int SourceAddress,
+                                                       int DestinationAddress, 
+                                                       ElementStatus_T *ElementStatus,
+                                                       Inquiry_T *inquiry_info, SCSI_Flags_T *flags)
+{
+       RequestSense_T *RequestSense = xmalloc(sizeof(RequestSense_T));
+       CDB_T CDB;
+
+       if (inquiry_info->MChngr && inquiry_info->PeripheralDeviceType != MEDIUM_CHANGER_TYPE)
+       {
+               /* if using the ATTACHED API */
+               CDB[0] = 0xA7;          /* MOVE_MEDIUM_ATTACHED */
+       }
+       else
+       {
+               CDB[0] = 0xA5;          /* MOVE MEDIUM */
+       }
+
+       CDB[1] = 0;                     /* Reserved */
+
+       /* Transport Element Address */
+       CDB[2] = (unsigned char)(ElementStatus->TransportElementAddress >> 8);
+       CDB[3] = (unsigned char)ElementStatus->TransportElementAddress;
+
+       /* Source Address */
+       CDB[4] = (unsigned char)(SourceAddress >> 8);
+       CDB[5] = (unsigned char)SourceAddress;
+
+       /* Destination Address */
+       CDB[6] = (unsigned char)(DestinationAddress >> 8);
+       CDB[7] = (unsigned char)DestinationAddress;
+
+       CDB[8] = 0;                     /* Reserved */
+       CDB[9] = 0;                     /* Reserved */
+
+       if (flags->invert)
+       {
+               CDB[10] = 1;                    /* Reserved */
+       }
+       else
+       {
+               CDB[10] = 0;
+       }
+       /* eepos controls the tray for import/export elements, sometimes. */
+       CDB[11] = flags->eepos << 6;                    /* Control */
+
+       if (SCSI_ExecuteCommand(MediumChangerFD, Output, &CDB, 12,
+                                                       NULL, 0, RequestSense) != 0)
+       {
+#ifdef DEBUG
+               fprintf(stderr, "Move Medium (0x%02X) failed\n", CDB[0]);
+#endif
+               return RequestSense;
+       }
+
+       free(RequestSense);
+       return NULL; /* success! */
+}
+
+
+/* Now the actual Exchange Medium routine! */
+RequestSense_T *ExchangeMedium(        DEVICE_TYPE MediumChangerFD, int SourceAddress,
+                                                               int DestinationAddress, int Dest2Address,
+                                                               ElementStatus_T *ElementStatus,
+                                                               SCSI_Flags_T *flags)
 {
-  RequestSense_T *RequestSense = xmalloc(sizeof(RequestSense_T));
-  CDB_T CDB;
-  if ((inquiry_info->MChngr) && (inquiry_info->PeripheralDeviceType != MEDIUM_CHANGER_TYPE)) {  /* if using the ATTACHED API */
-    CDB[0]=0xA7;   /* MOVE_MEDIUM_ATTACHED */
-  } else {
-    CDB[0] = 0xA5;             /* MOVE MEDIUM */
-  }
-  CDB[1] = 0;                  /* Reserved */
-  CDB[2] = (ElementStatus->TransportElementAddress >> 8) & 0xFF;  /* Transport Element Address MSB */
-  CDB[3] = (ElementStatus->TransportElementAddress) & 0xff;   /* Transport Element Address LSB */
-  CDB[4] = (SourceAddress >> 8) & 0xFF;        /* Source Address MSB */
-  CDB[5] = SourceAddress & 0xFF; /* Source Address MSB */
-  CDB[6] = (DestinationAddress >> 8) & 0xFF; /* Destination Address MSB */
-  CDB[7] = DestinationAddress & 0xFF; /* Destination Address MSB */
-  CDB[8] = 0;                  /* Reserved */
-  CDB[9] = 0;                  /* Reserved */
-  if (flags->invert) {
-    CDB[10] = 1;                       /* Reserved */
-  } else {
-    CDB[10] = 0;
-  }
-  /* eepos controls the tray for import/export elements, sometimes. */
-  CDB[11] = 0 | (flags->eepos <<6);                    /* Control */
-  
-  if (SCSI_ExecuteCommand(MediumChangerFD, Output, &CDB, 12,
-                         NULL, 0, RequestSense) != 0) {
-    return RequestSense;
-  }
-  free(RequestSense);
-  return NULL; /* success! */
+       RequestSense_T *RequestSense = xmalloc(sizeof(RequestSense_T));
+       CDB_T CDB;
+
+       CDB[0] = 0xA6;          /* EXCHANGE MEDIUM */
+       CDB[1] = 0;                     /* Reserved */
+
+       /* Transport Element Address */
+       CDB[2] = (unsigned char)(ElementStatus->TransportElementAddress >> 8);
+       CDB[3] = (unsigned char)ElementStatus->TransportElementAddress;
+
+       /* Source Address */
+       CDB[4] = (unsigned char)(SourceAddress >> 8);
+       CDB[5] = (unsigned char)SourceAddress;
+
+       /* Destination Address */
+       CDB[6] = (unsigned char)(DestinationAddress >> 8);
+       CDB[7] = (unsigned char)DestinationAddress;
+
+       /* move destination back to source? */
+       CDB[8] = (unsigned char)(Dest2Address >> 8);
+       CDB[9] = (unsigned char)Dest2Address;
+       CDB[10] = 0;
+
+       if (flags->invert)
+       {
+               CDB[10] |= 2;                   /* INV2 */
+       }
+
+       if (flags->invert2)
+       {
+               CDB[1] |= 1;                    /* INV1 */
+       }
+
+       /* eepos controls the tray for import/export elements, sometimes. */
+       CDB[11] = flags->eepos << 6;                    /* Control */
+
+#ifdef DEBUG_EXCHANGE
+       dump_cdb(&CDB,12);
+#endif  
+
+       if (SCSI_ExecuteCommand(MediumChangerFD, Output, &CDB, 12,
+                                                       NULL, 0, RequestSense) != 0)
+       {
+               return RequestSense;
+       }
+       free(RequestSense);
+       return NULL; /* success! */
 }
 
-/* for Linux, this creates a way to do a short erase... the @#$%@ st.c
+
+/*
+ * for Linux, this creates a way to do a short erase... the @#$%@ st.c
  * driver defaults to doing a long erase!
  */
 
-RequestSense_T *Erase(DEVICE_TYPE MediumChangerFD) {
-  RequestSense_T *RequestSense = xmalloc(sizeof(RequestSense_T));
-  CDB_T CDB;
-
-  CDB[0]=0x19;
-  CDB[1]=0;  /* Short! */
-  CDB[2]=CDB[3]=CDB[4]=CDB[5]=0;
-
-  if (SCSI_ExecuteCommand(MediumChangerFD, Output, &CDB, 6,
-                         NULL, 0, RequestSense) != 0) {
-    return RequestSense;
-  }
-  free(RequestSense);
-  return NULL;  /* Success! */
-}  
-
-
-#ifdef LONG_PRINT_REQUEST_SENSE
-
-static char *sense_keys[] = {
-  "No Sense",  /* 00 */
-  "Recovered Error", /* 01 */
-  "Not Ready",  /* 02 */
-  "Medium Error",  /* 03 */
-  "Hardware Error",  /* 04 */
-  "Illegal Request",  /* 05 */
-  "Unit Attention", /* 06 */
-  "Data Protect",   /* 07 */
-  "Blank Check", /* 08 */
-  "0x09",   /* 09 */
-  "0x0a",   /* 0a */
-  "Aborted Command", /* 0b */
-  "0x0c",  /* 0c */
-  "Volume Overflow", /* 0d */
-  "Miscompare",   /* 0e */
-  "0x0f"  /* 0f */
-};
+RequestSense_T *Erase(DEVICE_TYPE MediumChangerFD)
+{
+       RequestSense_T *RequestSense = xmalloc(sizeof(RequestSense_T));
+       CDB_T CDB;
 
-static char Yes[]="yes";
-static char No[]="no";
+       CDB[0] = 0x19;
+       CDB[1] = 0;  /* Short! */
+       CDB[2] = CDB[3] = CDB[4] = CDB[5] = 0;
 
-void PrintRequestSense(RequestSense_T *RequestSense)
-{
-  char *msg;
-
-  fprintf(stderr, "mtx: Request Sense: Long Report=yes\n");
-  fprintf(stderr, "mtx: Request Sense: Valid Residual=%s\n", RequestSense->Valid ? Yes : No);
-  if (RequestSense->ErrorCode==0x70) { 
-    msg = "Current" ;
-  } else if (RequestSense->ErrorCode==0x71) { 
-    msg = "Deferred" ;
-  } else {
-    msg = "Unknown?!" ;
-  }
-  fprintf(stderr, "mtx: Request Sense: Error Code=%0x (%s)\n",RequestSense->ErrorCode,msg);
-  fprintf(stderr, "mtx: Request Sense: Sense Key=%s\n",sense_keys[RequestSense->SenseKey]);
-  fprintf(stderr, "mtx: Request Sense: FileMark=%s\n", RequestSense->Filemark ? Yes : No);
-  fprintf(stderr, "mtx: Request Sense: EOM=%s\n", RequestSense->EOM ? Yes : No);
-  fprintf(stderr, "mtx: Request Sense: ILI=%s\n", RequestSense->ILI ? Yes : No);
-  if (RequestSense->Valid) {
-    fprintf(stderr, "mtx: Request Sense: Residual = %02X %02X %02X %02X\n",RequestSense->Information[0],RequestSense->Information[1],RequestSense->Information[2],RequestSense->Information[3]);
-  } 
-  fprintf(stderr,"mtx: Request Sense: Additional Sense Code = %02X\n", RequestSense->AdditionalSenseCode);
-  fprintf(stderr,"mtx: Request Sense: Additional Sense Qualifier = %02X\n", RequestSense->AdditionalSenseCodeQualifier);
-  if (RequestSense->SKSV) {
-    fprintf(stderr,"mtx: Request Sense: Field in Error = %02X\n",RequestSense->BitPointer);
-  }
-  fprintf(stderr,"mtx: Request Sense: BPV=%s\n",RequestSense->BPV ? Yes : No);
-  fprintf(stderr,"mtx: Request Sense: Error in CDB=%s\n",RequestSense->CommandData ? Yes : No);
-  fprintf(stderr,"mtx: Request Sense: SKSV=%s\n",RequestSense->SKSV ? Yes : No);
-  fflush(stderr);
-  if (RequestSense->BPV || RequestSense -> SKSV) {
-    fprintf(stderr,"mtx: Request Sense: Field Pointer = %02X %02X\n",RequestSense->FieldData[0],RequestSense->FieldData[1]);
-  }
+       if (SCSI_ExecuteCommand(MediumChangerFD, Output, &CDB, 6,
+                                                       NULL, 0, RequestSense) != 0)
+       {
+#ifdef DEBUG
+               fprintf(stderr, "Erase (0x19) failed\n");
+#endif
+               return RequestSense;
+       }
+
+       free(RequestSense);
+       return NULL;            /* Success! */
 }
 
+/* Routine to send an LOAD/UNLOAD from the MMC/SSC spec to a device. 
+ * For tapes and changers this can be used either to eject a tape 
+ * or to eject a magazine (on some Seagate changers, when sent to LUN 1 ).
+ * For CD/DVDs this is used to Load or Unload a disc which is required by
+ * some media changers.
+ */
 
-#else
-void PrintRequestSense(RequestSense_T *RequestSense)
+int LoadUnload(DEVICE_TYPE fd, int bLoad)
 {
-  int i;
-  fprintf(stderr, "mtx: Request Sense: %02X",
-         ((unsigned char *) RequestSense)[0]);
-  for (i = 1; i < sizeof(RequestSense_T); i++)
-    fprintf(stderr, " %02X", ((unsigned char *) RequestSense)[i]);
-  fprintf(stderr, "\n");
+       CDB_T CDB;
+       /* okay, now for the command: */
+
+       CDB[0] = 0x1B;
+       CDB[4] = bLoad ? 3 : 2;
+       CDB[1] = CDB[2] = CDB[3] = CDB[5] = 0;
+
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 6, NULL, 0, &scsi_error_sense) != 0)
+       {
+#ifdef DEBUG_MODE_SENSE
+               PrintRequestSense(&scsi_error_sense);
+               fprintf(stderr, "Eject (0x1B) failed\n");
+#endif
+               return -1;  /* could not do! */
+       }
+       return 0; /* did do! */
 }
 
+/* Routine to send an START/STOP from the MMC/SSC spec to a device. 
+ * For tape drives this may be required prior to using the changer 
+ * Load or Unload commands.
+ * For CD/DVD drives this is used to Load or Unload a disc which may be
+ * required by some media changers.
+ */
+
+int StartStop(DEVICE_TYPE fd, int bStart)
+{
+       CDB_T CDB;
+       /* okay, now for the command: */
+
+       CDB[0] = 0x1B;
+       CDB[4] = bStart ? 1 : 0;
+       CDB[1] = CDB[2] = CDB[3] = CDB[5] = 0;
+
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 6,NULL, 0, &scsi_error_sense) != 0)
+       {
+#ifdef DEBUG_MODE_SENSE
+               PrintRequestSense(&scsi_error_sense);
+               fprintf(stderr, "Eject (0x1B) failed\n");
 #endif
+               return -1;  /* could not do! */
+       }
+       return 0; /* did do! */
+}
 
-/* $Date: 2002/09/27 17:23:28 $
- * $Log: mtxl.c,v $
- * Revision 1.8.2.7  2002/09/27 17:23:28  elgreen
- * Don't dereference pointer in barcode stuff
- *
- * Revision 1.8.2.6  2002/09/27 17:20:18  elgreen
- * doh, get rid of the + from the patch process!
- *
- * Revision 1.8.2.5  2002/09/27 17:17:13  elgreen
- * fix copy_barcode
- *
- * Revision 1.8.2.4  2002/09/27 16:49:43  elgreen
- * copy_barcode was off by one (sigh!)
- *
- * Revision 1.8.2.3  2002/02/05 16:51:11  elgreen
- * mtx 1.2.16pre3
- *
- * Revision 1.8.2.2  2002/01/22 16:27:47  elgreen
- * Handle too-big transport element descriptor lengths
- *
- * Revision 1.8.2.1  2002/01/17 22:24:35  elgreen
- * Handle ADIC silliness of saying that it has 1 import/export element whose
- * descriptor is 0 bytes in length
- *
- * Revision 1.8  2001/06/25 23:06:22  elgreen
- * Readying this for 1.2.13 release
- *
- * Revision 1.7  2001/06/25 04:56:35  elgreen
- * Kai to the rescue *again* :-)
- *
- * Revision 1.6  2001/06/24 07:02:01  elgreen
- * Kai's fix was better than mine.
- *
- * Revision 1.5  2001/06/24 06:59:19  elgreen
- * Kai found bug in the barcode backoff.
- *
- * Revision 1.4  2001/06/15 18:56:54  elgreen
- * Arg, it doesn't help to check for 0 robot arms if you force it to 1!
- *
- * Revision 1.3  2001/06/15 14:26:09  elgreen
- * Fixed brain-dead case of HP loaders that report they have no robot arms.
- *
- * Revision 1.2  2001/06/09 17:26:26  elgreen
- * Added 'nobarcode' command to mtx (to skip the initial request asking for
- * barcodes for mtx status purposes).
- *
- * Revision 1.1.1.1  2001/06/05 17:10:25  elgreen
- * Initial import into SourceForge
- *
- * Revision 1.29  2001/05/01 01:39:23  eric
- * Remove the Exabyte special case code, which seemed to be barfing me :-(.
- *
- * Revision 1.28  2001/04/28 00:03:10  eric
- * update for 1.2.12.
- *
- * Revision 1.27  2001/04/18 19:27:39  eric
- * whoops, move ImportExport parser into the $#%!@ ImportExport test :-(.
- *
- * Revision 1.26  2001/04/18 18:55:44  eric
- * turn too many storage elements into a warning rather than a fatal error (sigh!)
- *
- * Revision 1.25  2001/04/18 18:46:54  eric
- * $%!@# "C" precedence rules.
- *
- * Revision 1.24  2001/04/18 17:58:04  eric
- * initialize EmptyStorageElementCount (sigh)
- *
- * Revision 1.23  2001/04/18 16:55:03  eric
- * hopefully get the initialization for element status straigtened out.
- *
- * Revision 1.22  2001/04/18 16:32:59  eric
- * Cleaned up all -Wall messages.
- *
- * Revision 1.21  2001/04/18 16:08:08  eric
- * after re-arranging & fixing bugs
- *
- * Revision 1.20  2001/04/17 21:28:43  eric
- * mtx 1.2.11
- *
- * Revision 1.19  2001/04/02 20:12:48  eric
- * checkin, mtx 1.2.11pre6
- *
- * Revision 1.18  2001/03/06 01:37:05  eric
- * Solaris changes
- *
- * Revision 1.17  2001/02/26 20:56:12  eric
- * added debugging, removed Makefile
- *
- * Revision 1.16  2001/02/19 23:22:28  eric
- * Add E2 bits
- *
- * Revision 1.15  2001/02/19 23:02:04  eric
- * Apply SPARC patch.
- *
- * Revision 1.14  2001/01/26 15:58:10  eric
- * Make work on solaris?
- *
- * Revision 1.13  2001/01/17 19:39:01  eric
- * Changed mtx.h and mtxl.c to use autoconf stuff to figure out which SCSI
- * routines to use (this way, if we ever port to an OS that has an identical
- * SCSI interface to one of the supported OS's, we don't have to do anything
- * special!).
- *
- * Revision 1.12  2001/01/17 16:36:26  eric
- * added date & revision strings as needed
- *
- * Revision 1.11  2000/11/30 20:35:18  eric
- * Added Erase command.
- *
+/* Routine to send a LOCK/UNLOCK from the SSC/MMC spec to a device. 
+ * This can be used to prevent or allow the Tape or CD/DVD from being
+ * removed. 
  */
+
+int LockUnlock(DEVICE_TYPE fd, int bLock)
+{
+       CDB_T CDB;
+       /* okay, now for the command: */
+
+       CDB[0] = 0x1E;
+       CDB[1] = CDB[2] = CDB[3] = CDB[5] = 0;
+       CDB[4] = (char)bLock;
+
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 6, NULL, 0, &scsi_error_sense) != 0)
+       {
+#ifdef DEBUG_MODE_SENSE
+               PrintRequestSense(&scsi_error_sense);
+               fprintf(stderr, "Eject (0x1B) failed\n");
+#endif
+               return -1;  /* could not do! */
+       }
+       return 0; /* did do! */
+}
+
+static char Spaces[] = "                                                            ";
+
+void PrintHex(int Indent, unsigned char *Buffer, int Length)
+{
+       int             idxBuffer;
+       int             idxAscii;
+       int             PadLength;
+       char    cAscii;
+
+       for (idxBuffer = 0; idxBuffer < Length; idxBuffer++)
+       {
+               if ((idxBuffer % 16) == 0)
+               {
+                       if (idxBuffer > 0)
+                       {
+                               fputc('\'', stderr);
+
+                               for (idxAscii = idxBuffer - 16; idxAscii < idxBuffer; idxAscii++)
+                               {
+                                       cAscii = Buffer[idxAscii] >= 0x20 && Buffer[idxAscii] < 0x7F ? Buffer[idxAscii] : '.';
+                                       fputc(cAscii, stderr);
+                               }
+                               fputs("'\n", stderr);
+                       }
+                       fprintf(stderr, "%.*s%04X: ", Indent, Spaces, idxBuffer);
+               }
+               fprintf(stderr, "%02X ", (unsigned char)Buffer[idxBuffer]);
+       }
+
+       PadLength = 16 - (Length % 16);
+
+       if (PadLength > 0)
+       {
+               fprintf(stderr, "%.*s'", 3 * PadLength, Spaces);
+
+               for (idxAscii = idxBuffer - (16 - PadLength); idxAscii < idxBuffer; idxAscii++)
+               {
+                       cAscii = Buffer[idxAscii] >= 0x20 && Buffer[idxAscii] < 0x80 ? Buffer[idxAscii] : '.';
+                       fputc(cAscii, stderr);
+               }
+               fputs("'\n", stderr);
+       }
+
+       fflush(stderr);
+}
+
+static char *sense_keys[] =
+{
+       "No Sense",                     /* 00 */
+       "Recovered Error",      /* 01 */
+       "Not Ready",            /* 02 */
+       "Medium Error",         /* 03 */
+       "Hardware Error",       /* 04 */
+       "Illegal Request",      /* 05 */
+       "Unit Attention",       /* 06 */
+       "Data Protect",         /* 07 */
+       "Blank Check",          /* 08 */
+       "0x09",                         /* 09 */
+       "0x0a",                         /* 0a */
+       "Aborted Command",      /* 0b */
+       "0x0c",                         /* 0c */
+       "Volume Overflow",      /* 0d */
+       "Miscompare",           /* 0e */
+       "0x0f"                          /* 0f */
+};
+
+static char Yes[] = "yes";
+static char No[] = "no";
+
+void PrintRequestSense(RequestSense_T *RequestSense)
+{
+       char *msg;
+
+       fprintf(stderr, "mtx: Request Sense: Long Report=yes\n");
+       fprintf(stderr, "mtx: Request Sense: Valid Residual=%s\n", RequestSense->Valid ? Yes : No);
+
+       if (RequestSense->ErrorCode == 0x70)
+       { 
+               msg = "Current" ;
+       }
+       else if (RequestSense->ErrorCode == 0x71)
+       {
+               msg = "Deferred" ;
+       }
+       else
+       {
+               msg = "Unknown?!" ;
+       }
+
+       fprintf(stderr, "mtx: Request Sense: Error Code=%0x (%s)\n", RequestSense->ErrorCode, msg);
+       fprintf(stderr, "mtx: Request Sense: Sense Key=%s\n", sense_keys[RequestSense->SenseKey]);
+       fprintf(stderr, "mtx: Request Sense: FileMark=%s\n", RequestSense->Filemark ? Yes : No);
+       fprintf(stderr, "mtx: Request Sense: EOM=%s\n", RequestSense->EOM ? Yes : No);
+       fprintf(stderr, "mtx: Request Sense: ILI=%s\n", RequestSense->ILI ? Yes : No);
+
+       if (RequestSense->Valid)
+       {
+               fprintf(stderr, "mtx: Request Sense: Residual = %02X %02X %02X %02X\n",RequestSense->Information[0],RequestSense->Information[1],RequestSense->Information[2],RequestSense->Information[3]);
+       }
+
+       fprintf(stderr,"mtx: Request Sense: Additional Sense Code = %02X\n", RequestSense->AdditionalSenseCode);
+       fprintf(stderr,"mtx: Request Sense: Additional Sense Qualifier = %02X\n", RequestSense->AdditionalSenseCodeQualifier);
+
+       if (RequestSense->SKSV)
+       {
+               fprintf(stderr,"mtx: Request Sense: Field in Error = %02X\n", RequestSense->BitPointer);
+       }
+
+       fprintf(stderr, "mtx: Request Sense: BPV=%s\n", RequestSense->BPV ? Yes : No);
+       fprintf(stderr, "mtx: Request Sense: Error in CDB=%s\n", RequestSense->CommandData ? Yes : No);
+       fprintf(stderr, "mtx: Request Sense: SKSV=%s\n", RequestSense->SKSV ? Yes : No);
+
+       if (RequestSense->BPV || RequestSense -> SKSV)
+       {
+               fprintf(stderr, "mtx: Request Sense: Field Pointer = %02X %02X\n",
+                               RequestSense->FieldData[0], RequestSense->FieldData[1]);
+       }
+
+       fflush(stderr);
+}
diff --git a/mtxl.h b/mtxl.h
index 560c96f9bae75dffa781fa75034b80c63c9a223b..a4ee8880bd571d3faae251a250ff5758df14ecd9 100644 (file)
--- a/mtxl.h
+++ b/mtxl.h
@@ -2,7 +2,7 @@
   MTX -- SCSI Tape Attached Medium Changer Control Program
 
   Copyright 1997-1998 Leonard N. Zubkoff <lnz@dandelion.com>
-  This file created by Eric Lee Green <eric@estinc.com>
+  This file created by Eric Lee Green <eric@badtux.org>
   
   This program is free software; you may redistribute and/or modify it under
   the terms of the GNU General Public License Version 2 as published by the
@@ -13,8 +13,8 @@
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   for complete details.
 
-  $Date: 2001/06/19 21:51:32 $
-  $Revision: 1.2 $
+  $Date: 2007-03-24 18:14:01 -0700 (Sat, 24 Mar 2007) $
+  $Revision: 166 $
 */
 
 /* Much of the guts of mtx.c has been extracted to mtxl.c, a library file
@@ -27,6 +27,9 @@
 
 #include "mtx.h"
 
+#undef min
+#undef max
+
 void FatalError(char *ErrorMessage, ...);
 void *xmalloc(size_t Size);
 void *xzmalloc(size_t Size);
@@ -49,17 +52,38 @@ int BigEndian24(unsigned char *BigEndianData);
 int min(int x, int y);
 int max(int x, int y);
 
-ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *RequestSense, Inquiry_T *inquiry_info, SCSI_Flags_T *flags);
+void PrintHex(int Indent, unsigned char *Buffer, int Length);
+
+ElementStatus_T *ReadElementStatus(    DEVICE_TYPE MediumChangerFD,
+                                                                       RequestSense_T *RequestSense,
+                                                                       Inquiry_T *inquiry_info,
+                                                                       SCSI_Flags_T *flags);
+
+Inquiry_T *RequestInquiry(     DEVICE_TYPE fd,
+                                                       RequestSense_T *RequestSense);
+
+RequestSense_T *MoveMedium(    DEVICE_TYPE MediumChangerFD,
+                                                       int SourceAddress,
+                                                       int DestinationAddress, 
+                                                       ElementStatus_T *ElementStatus, 
+                                                       Inquiry_T *inquiry_info,
+                                                       SCSI_Flags_T *flags);
 
-Inquiry_T *RequestInquiry(DEVICE_TYPE fd, RequestSense_T *RequestSense);
+RequestSense_T *ExchangeMedium(        DEVICE_TYPE MediumChangerFD,
+                                                               int SourceAddress,
+                                                               int DestinationAddress,
+                                                               int Dest2Address,
+                                                               ElementStatus_T *ElementStatus, 
+                                                               SCSI_Flags_T *flags);
 
-RequestSense_T *MoveMedium(DEVICE_TYPE MediumChangerFD, int SourceAddress,
-                      int DestinationAddress, 
-                      ElementStatus_T *ElementStatus, 
-                          Inquiry_T *inquiry_info, SCSI_Flags_T *flags);
+RequestSense_T *PositionElement(DEVICE_TYPE MediumChangerFD,
+                                                               int DestinationAddress,
+                                                               ElementStatus_T *ElementStatus);
 
 int Inventory(DEVICE_TYPE MediumChangerFD);  /* inventory library */
-int Eject(DEVICE_TYPE fd);                  /* unload tape or magazine */
+int LoadUnload(DEVICE_TYPE fd, int bLoad); /* load/unload tape, magazine or disc */
+int StartStop(DEVICE_TYPE fd, int bStart); /* start/stop device */
+int LockUnlock(DEVICE_TYPE fd, int bLock); /* lock/unlock medium in device */
 RequestSense_T *Erase(DEVICE_TYPE fd);        /* send SHORT erase to drive */
 
 void SCSI_Set_Timeout(int secs); /* set the SCSI timeout */
@@ -70,4 +94,14 @@ void SCSI_Default_Timeout(void);  /* go back to default timeout */
    scsi_id_t *SCSI_GetIDLun(DEVICE_TYPE fd);
 #endif
 
+/* These two hacks are so that I can stick the tongue out on an
+ * NSM optical jukebox. 
+ */ 
+NSM_Result_T *RecNSMHack(DEVICE_TYPE MediumChangerFD, 
+                        int param_len, int timeout);
+
+int SendNSMHack(DEVICE_TYPE MediumChangerFD, NSM_Param_T *nsm_command, 
+               int param_len, int timeout);
+
 #endif
+
diff --git a/nsmhack.c b/nsmhack.c
new file mode 100644 (file)
index 0000000..d7b03ab
--- /dev/null
+++ b/nsmhack.c
@@ -0,0 +1,341 @@
+/* Copyright 2001 DISC Inc. 
+ * Released under terms of the GNU General Public License as required
+ * by the license on the file "mtxl.c". See file "LICENSE" for details.
+ */
+
+#define DEBUG_NSM 1
+
+/* This is a hack to make the NSM modular series jukeboxes stick out
+ * their tongue, then retract tongue, so we can import media. They
+ * automatically stick out their tongue when exporting media, but
+ * importing media is not working, you try to do a MOVE_MEDIUM and
+ * it says "What medium?" before even sticking out its tongue. 
+ * My manager has turned in a change request to NSM engineering to direct 
+ * their firmware guys to add EEPOS support to the NSM modular jukeboxes so 
+ * that we have tongue firmware that's compatible with Exabyte, Sony, Breece
+ *  Hill, etc., but until that new firmware is here, this hack will work.
+ */
+
+/* Note: Perhaps "hack" is an overstatement, since this will also
+ * eventually add pack management and other things of that nature
+ * that are extremely loader dependent.
+ */
+
+/* Commands:
+   -f <devicenode>
+   tongue_out <sourceslot>
+   tongue_in
+   tongue_button_wait
+   tongue_button_enable
+   tongue_button_disable
+*/
+   
+
+#include "mtxl.h"  /* get the SCSI routines out of the main file */
+
+/****************************************************************/
+/* Variables:  */
+/****************************************************************/   
+
+/* the device handle we're operating upon, sigh. */
+static char *device;  /* the text of the device thingy. */
+static DEVICE_TYPE MediumChangerFD = (DEVICE_TYPE) -1;
+char *argv0;
+int arg[4]; /* arguments for the command. */
+#define arg1 (arg[0])  /* for backward compatibility, sigh */
+static SCSI_Flags_T SCSI_Flags = { 0, 0, 0,0 };
+
+static ElementStatus_T *ElementStatus = NULL;
+
+/* Okay, now let's do the main routine: */
+
+void Usage(void) {
+  FatalError("Usage: nsmhack -f <generic-device> <command> where <command> is:\n [tongue_out] | [tongue_in] | [tongue_button_wait] | [tongue_button_enable]\n    | tongue_button_disable. \n");
+}
+
+static int S_tongue_out(void);
+static int S_tongue_in(void);
+static int S_slotinfo(void);
+static int S_jukeinfo(void);
+
+struct command_table_struct {
+  int num_args;
+  char *name;
+  int (*command)(void);
+} command_table[] = {
+  { 1, "tongue_out", S_tongue_out },
+  { 0, "tongue_in", S_tongue_in },
+  { 0, "slotinfo", S_slotinfo },
+  { 0, "jukeinfo", S_jukeinfo },
+  { 0, NULL, NULL }
+};
+
+
+/* open_device() -- set the 'fh' variable.... */
+void open_device(void) {
+
+  if (MediumChangerFD != -1) {
+    SCSI_CloseDevice("Unknown",MediumChangerFD);  /* close it, sigh...  new device now! */
+  }
+
+  MediumChangerFD = SCSI_OpenDevice(device);
+
+}
+
+static int get_arg(char *arg) {
+  int retval=-1;
+
+  if (*arg < '0' || *arg > '9') {
+    return -1;  /* sorry! */
+  }
+
+  retval=atoi(arg);
+  return retval;
+}
+
+/* we see if we've got a file open. If not, we open one :-(. Then
+ * we execute the actual command. Or not :-(. 
+ */ 
+int execute_command(struct command_table_struct *command) {
+
+  /* if the device is not already open, then open it from the 
+   * environment.
+   */
+  if (MediumChangerFD == -1) {
+    /* try to get it from STAPE or TAPE environment variable... */
+    device=getenv("STAPE");
+    if (device==NULL) {
+      device=getenv("TAPE");
+      if (device==NULL) {
+       Usage();
+      }
+    }
+    open_device();
+  }
+
+
+  /* okay, now to execute the command... */
+  return command->command();
+}
+
+/* parse_args():
+ *   Basically, we are parsing argv/argc. We can have multiple commands
+ * on a line now, such as "unload 3 0 load 4 0" to unload one tape and
+ * load in another tape into drive 0, and we execute these commands one
+ * at a time as we come to them. If we don't have a -f at the start, we
+ * barf. If we leave out a drive #, we default to drive 0 (the first drive
+ * in the cabinet). 
+ */ 
+
+int parse_args(int argc,char **argv) {
+  int i,cmd_tbl_idx,retval,arg_idx;
+  struct command_table_struct *command;
+
+  i=1;
+  arg_idx=0;
+  while (i<argc) {
+    if (strcmp(argv[i],"-f") == 0) {
+      i++;
+      if (i>=argc) {
+       Usage();
+      }
+      device=argv[i++];
+      open_device(); /* open the device and do a status scan on it... */
+    } else {
+      cmd_tbl_idx=0;
+      command=&command_table[0]; /* default to the first command... */
+      command=&command_table[cmd_tbl_idx];
+      while (command->name) {
+       if (!strcmp(command->name,argv[i])) {
+         /* we have a match... */
+         break;
+       }
+       /* otherwise we don't have a match... */
+       cmd_tbl_idx++;
+       command=&command_table[cmd_tbl_idx];
+      }
+      /* if it's not a command, exit.... */
+      if (!command->name) {
+       Usage();
+      }
+      i++;  /* go to the next argument, if possible... */
+      /* see if we need to gather arguments, though! */
+      arg1=-1; /* default it to something */
+      for (arg_idx=0;arg_idx < command->num_args ; arg_idx++) {
+       if (i < argc) {
+         arg[arg_idx]=get_arg(argv[i]);
+         if (arg[arg_idx] !=  -1) {
+           i++; /* increment i over the next cmd. */
+         }
+       } else {
+         arg[arg_idx]=0; /* default to 0 setmarks or whatever */
+       } 
+      }
+      retval=execute_command(command);  /* execute_command handles 'stuff' */
+      exit(retval);
+    }
+  }
+  return 0; /* should never get here */
+}
+
+static void init_param(NSM_Param_T *param, char *command, int paramlen, int resultlen) {
+  int i;
+
+  /* zero it out first: */
+  memset((char *)param,0,sizeof(NSM_Param_T));
+
+  resultlen=resultlen+sizeof(NSM_Result_T)-0xffff;
+
+  
+  param->page_code=0x80;
+  param->reserved=0;
+  param->page_len_msb=((paramlen+8)>>8) & 0xff;
+  param->page_len_lsb=(paramlen+8) & 0xff;
+  param->allocation_msb=((resultlen + 10) >> 8) & 0xff;
+  param->allocation_lsb= (resultlen+10) & 0xff;
+  param->reserved2[0]=0;
+  param->reserved2[1]=0;
+
+  for (i=0;i<4;i++) {
+    param->command_code[i]=command[i];
+  }
+
+}
+
+static NSM_Result_T *SendRecHack(NSM_Param_T *param,int param_len, 
+                                int read_len) {
+  NSM_Result_T *result;
+  /* send the command: */
+  if (SendNSMHack(MediumChangerFD,param,param_len,0)) {
+    PrintRequestSense(&scsi_error_sense);                   
+    FatalError("SendNSMHack failed.\n");    
+  }
+
+  /* Now read the result: */
+  result=RecNSMHack(MediumChangerFD,read_len,0);
+  if (!result) {
+    PrintRequestSense(&scsi_error_sense);                   
+    FatalError("RecNSMHack failed.\n");    
+  }  
+
+  return result;
+}
+
+
+/* Print some info about the NSM jukebox. */
+static int S_jukeinfo(void) {
+  NSM_Result_T *result;
+  NSM_Param_T param;
+
+  if (!device)
+    Usage();
+
+  /* okay, we have a device: Let's get vendor ID: */
+  init_param(&param,"1010",0,8);
+  result=SendRecHack(&param,0,8);
+  /* Okay, we got our result, print out the vendor ID: */
+  result->return_data[8]=0;
+  printf("Vendor ID: %s\n",result->return_data);
+  free(result);
+  
+  /* Get our product ID: */
+  init_param(&param,"1011",0,16);
+  result=SendRecHack(&param,0,16);
+  result->return_data[16]=0;
+  printf("Product ID: %s\n",result->return_data);
+  free(result);
+
+  init_param(&param,"1012",0,4);
+  result=SendRecHack(&param,0,4);
+  result->return_data[4]=0;
+  printf("Product Revision: %s\n",result->return_data);
+  free(result);
+
+  init_param(&param,"1013",0,8);
+  result=SendRecHack(&param,0,8);
+  result->return_data[8]=0;
+  printf("Production Date: %s\n",result->return_data);
+  free(result);
+
+  init_param(&param,"1014",0,8);
+  result=SendRecHack(&param,0,8);
+  result->return_data[8]=0;
+  printf("Part Number: %s\n",result->return_data);
+  free(result);
+
+  init_param(&param,"1015",0,12);
+  result=SendRecHack(&param,0,12);
+  result->return_data[12]=0;
+  printf("Serial Number: %s\n",result->return_data);
+  free(result);
+
+  init_param(&param,"1016",0,4);
+  result=SendRecHack(&param,0,4);
+  result->return_data[4]=0;
+  printf("Firmware Release: %s\n",result->return_data);
+  free(result);
+
+  init_param(&param,"1017",0,8);
+  result=SendRecHack(&param,0,8);
+  result->return_data[8]=0;
+  printf("Firmware Date: %s\n",result->return_data);
+  free(result);
+
+  return 0;
+}
+
+static int S_slotinfo(void) {
+  NSM_Result_T *result;
+  NSM_Param_T param;
+
+  if (!device)
+    Usage();
+
+  /* Okay, let's see what I can get from slotinfo: */
+  init_param(&param,"1020",0,6);
+  result=SendRecHack(&param,0,6);
+  result->return_data[6]=0;
+  printf("Layout: %s\n",result->return_data);
+  free(result);
+  
+  return 0;
+}
+
+static int S_tongue_in(void) {
+  return 0;
+}
+
+/* okay, stick our tongue out. We need a slot ID to grab a caddy from. */
+static int S_tongue_out(void) {
+  int slotnum=arg1;
+  Inquiry_T *inquiry_info;  /* needed by MoveMedium etc... */
+  RequestSense_T RequestSense;
+
+  /* see if we have element status: */
+  if (ElementStatus==NULL) {
+    inquiry_info=RequestInquiry(MediumChangerFD,&RequestSense);
+    if (!inquiry_info) {
+      PrintRequestSense(&RequestSense);                   
+      FatalError("INQUIRY Command Failed\n"); 
+    }
+    ElementStatus = ReadElementStatus(MediumChangerFD,&RequestSense,inquiry_info,&SCSI_Flags);
+    if (!ElementStatus) {
+      PrintRequestSense(&RequestSense);                   
+      FatalError("READ ELEMENT STATUS Command Failed\n"); 
+    }
+  }
+  
+  /* Okay, we have element status, so now let's assume that */
+  return 0;
+}
+
+/* See parse_args for the scoop. parse_args does all. */
+int main(int argc, char **argv) {
+  argv0=argv[0];
+  parse_args(argc,argv);
+
+  if (device) 
+    SCSI_CloseDevice(device,MediumChangerFD);
+
+  exit(0);
+}
index 1c65b6acb15553e5e2f2b81ff8f1c4b428664242..41ced9341d509d26906e0ba06de1c07823b34632 100644 (file)
@@ -1,8 +1,7 @@
-/* Copyright 2001 Enhanced Software Technologies Inc.
- *   Written by Eric Lee Green <eric@estinc.com>
- *
- *$Date: 2001/06/05 17:10:25 $
- *$Revision: 1.1.1.1 $
+/* Changes 2003 Steve Heck <steve.heck@am.sony.com>
+
+$Date: 2007-03-04 15:27:11 -0800 (Sun, 04 Mar 2007) $
+$Revision: 164 $
 
   This program is free software; you may redistribute and/or modify it under
   the terms of the GNU General Public License Version 2 as published by the
 
 */
 
-/* These are the SCSI commands for AIX. The syntax for AIX is:
- *
- *  /dev/scsi<n>/<id>.<lun>
- *
- * where <n> is the number of the scsi adapter (0..n) and
- * <id> and <lun> are the SCSI ID and LUN of the device you wish to
- * talk to. 
- *
- * AIX has a very flexible SCSI subsystem, but it is somewhat
- * clumsy to use. 
- */
-
-/* we do very nasty thing here -- we operate upon device name! */
-DEVICE_TYPE SCSI_OpenDevice(char *DeviceName) {
-  /* okay, we must first parse out the ID and LUN: */
-  char *rptr;
-  struct tm_device_type *retval = (struct tm_device_type *) malloc(sizeof(struct tm_device_type));
-  int id,lun,filenum,idlun;
-
-  if (retval==NULL) {
-    fprintf(stderr,"%s: Allocation error in SCSI_OpenDevice for %s. Exiting.\n",argv0,DeviceName);
-    fflush(stderr);
-    exit(1);
-  }
-
-  rptr=strrchr(DeviceName,'/');
-  
-  if (!rptr) {
-    fprintf(stderr,"%s: Illegal device name '%s'. Exiting.\n",argv0,DeviceName);
-    fflush(stderr);
-    exit(1);
-  }
-  
-  *rptr++=0;
-
-  if (sscanf(rptr,"%d.%d",&id,&lun) < 2) {
-    /* whoops, we did not get 2 items:  */ 
-    fprintf(stderr,"%s: Illegal device name '%s/%s'. Exiting.\n",argv0,DeviceName,rptr);
-    fflush(stderr);
-    exit(1);
-  }
-
-  /* Okay, now to try to open the DeviceName */
-  if ((filenum=open(DeviceName,0))<0) {
-    fprintf(stderr,"%s: Illegal device name '%s/%s'. Exiting.\n",argv0,DeviceName,rptr);
-    perror(argv0);
-    fflush(stderr);
-    exit(1);
-  }
-
-  retval->filenum=filenum;
-  retval->id=id;
-  retval->lun=lun;
-  retval->DeviceName=DeviceName;
-  return (DEVICE_TYPE) retval;
+
+/* This is the SCSI commands for AIX using GSC Generic SCSI Interface. */
+
+#define LONG_PRINT_REQUEST_SENSE  /* sigh! */
+
+DEVICE_TYPE SCSI_OpenDevice(char *DeviceName)
+{
+       int DeviceFD = open(DeviceName, 0); 
+
+       if (DeviceFD < 0)
+               FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
+       return (DEVICE_TYPE) DeviceFD;
+}
+
+
+void SCSI_CloseDevice(char *DeviceName, DEVICE_TYPE DeviceFD)
+{
+       if (close(DeviceFD) < 0)
+               FatalError("cannot close SCSI device '%s' - %m\n", DeviceName);
 }
 
-#define MTX_HZ 1000 
-#define MTX_DEFAULT_SCSI_TIMEOUT 60*5*MTX_HZ /* 5 minutes! */
-static int mtx_default_timeout = MTX_DEFAULT_SCSI_TIMEOUT ;
-void SCSI_Set_Timeout(int sec) {
-  mtx_default_timeout=sec*MTX_HZ;
+
+#define HAS_SCSI_TIMEOUT
+
+static int timeout = 9 * 60;
+
+void SCSI_Set_Timeout(int to)
+{
+       timeout = to;
+}
+
+void SCSI_Default_Timeout(void)
+{
+       timeout = 9 * 60; /* the default */
 }
 
-void SCSI_Default_Timeout() {
-  mtx_default_timeout=MTX_DEFAULT_SCSI_TIMEOUT;
+#ifdef DEBUG
+int SCSI_DumpBuffer(int DataBufferLength, unsigned char *DataBuffer)
+{
+       int i, j;
+       j = 0;
+
+       for (i = 0; i < DataBufferLength; i++)
+       {
+               if (j == 25)
+               {
+                       fprintf(stderr, "\n");
+                       j = 0;
+               }
+
+               if (j == 0)
+               {
+                       fprintf(stderr, "%04x:", i);
+               }
+
+               if (j > 0)
+               {
+                       fprintf(stderr, " ");
+               }
+
+               fprintf(stderr, "%02x", (int)DataBuffer[i]);
+               j++;
+       }
+       fprintf(stderr, "\n");
 }
+#endif
+
+
 
-/* Okay , now *DO IT!* */
 int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
-                       Direction_T Direction,
-                       CDB_T *CDB,
-                       int CDB_Length,
-                       void *DataBuffer,
-                       int DataBufferLength,
-                       RequestSense_T *RequestSense) {
-
-  int id,lun;
-  struct tm_device_type *fd=(struct tm_device_type *) DeviceFD;
-  struct devinfo info;
-  struct sc_buf sb; /* the sc_buf struct needed to commicate w/adapter. */
-
-
-  id=fd->id;
-  lun=fd->lun;
-
-  /* okay, first of all, make sure we're not asking for a bigger
-   * operation than we are allowed to ask for, by going to the driver
-   * with IOCINFO. 
-   */
-  if (ioctl(filenum,IOCINFO,&info)) {
-    fprintf(stderr,"%s: Could not get info for %s. Exiting.\n",argv0,fd->DeviceName);
-    exit(1);
-  }
-    
-  /* Now check the max_transfer: */
-  if ((int)info.scsi.max_transfer < DataBufferLength) {
-    fprintf(stderr,"%s: SCSI transfer too large. %d requested, %d allowed.\n",argv0,DataBufferLength,(int)info.scsi.max_transfer);
-    fflush(stderr);
-    exit(1);
-  }
-  
-  /* okay, we have our open file, we have the other stuff: Now initialize
-     a transaction with that ID/LUN:
-  */
-
-  if (ioctl(filenum, SCIOSTART,IDLUN(id,lun))) {
-    fprintf(stderr,"%s: Could not start SCSI transaction with %s/%d.%d. Exiting.\n",argv0,fd->DeviceName,id,lun);
-    fflush(stderr);
-    exit(1);
-  }
-  
-  /* okay, now to decide command: */
-  
-  
-
-
-  /*... have finished command...*/
-  
-  /* when done w/command, get rid of the connection: */  
-  if (ioctl(filenum,SCIOSTOP,IDLUN(id,lun))) {
-    fprintf(stderr,"%s: Could not stop SCSI transaction with %s/%d.%d. Exiting.\n",argv0,fd->DeviceName,id,lun);
-    fflush(stderr);
-    exit(1);
-  }
-     
-  
+                                               Direction_T Direction,
+                                               CDB_T *CDB,
+                                               int CDB_Length,
+                                               void *DataBuffer,
+                                               int DataBufferLength,
+                                               RequestSense_T *RequestSense)
+{
+       int ioctl_result;
+       char sbyte;
+       scmd_t scmd;
+
+#ifdef DEBUG_SCSI
+       fprintf(stderr,"------CDB--------\n");
+       SCSI_DumpBuffer(CDB_Length,(char *)CDB);
+#endif
+
+       /* memset(&scmd, 0, sizeof(struct scmd_t)); */
+       /* memset(RequestSense, 0, sizeof(RequestSense_T)); */
+       switch (Direction)
+       {
+       case Input:
+               scmd.rw = 1;
+               if (DataBufferLength > 0)
+               {
+                       memset(DataBuffer, 0, DataBufferLength);
+               }
+               break;
+
+       case Output:
+               scmd.rw = 2;
+               break;
+       }
+       /* Set timeout to 5 minutes. */
+#ifdef DEBUG_TIMEOUT
+       fprintf(stderr,"timeout=%d\n",timeout);
+       fflush(stderr);
+#endif
+
+       scmd.timeval = timeout;
+
+       scmd.cdb = (caddr_t) CDB;
+       scmd.cdblen = CDB_Length;
+       scmd.data_buf = DataBuffer;
+       scmd.datalen = DataBufferLength;
+       scmd.sense_buf = (caddr_t) RequestSense;
+       scmd.senselen = sizeof(RequestSense_T);
+       scmd.statusp = &sbyte;
+       ioctl_result = ioctl(DeviceFD, GSC_CMD, (caddr_t) &scmd);
+
+       SCSI_Default_Timeout(); /* set it back to default, sigh. */
+
+       if (ioctl_result < 0)
+       {
+#ifdef DEBUG
+               perror("mtx");
+#endif
+               return ioctl_result;
+       }
+
+       if (sbyte != 0)
+       {
+               return -1;
+       }
+#ifdef DEBUG_SCSI
+       if (Direction==Input)
+       {
+               fprintf(stderr,"--------input data-----------\n");
+               SCSI_DumpBuffer(DataBufferLength,DataBuffer);
+       }
+#endif
+       return 0;
+}
index 8c88d82e1c37f70872f32a96526bede7aa8f1dd2..fe1cf660389be1dbb1d68471e8a74dcc582608ae 100644 (file)
@@ -1,8 +1,8 @@
 /* Copyright 2000 Enhanced Software Technologies Inc. (http://www.estinc.com)
-   Written by Eric Lee Green <eric@estinc.com>
+   Written by Eric Lee Green <eric@badtux.org>
 
-$Date: 2001/06/05 17:10:25 $
-$Revision: 1.1.1.1 $
+$Date: 2007-03-04 15:27:11 -0800 (Sun, 04 Mar 2007) $
+$Revision: 164 $
 
   This program is free software; you may redistribute and/or modify it under
   the terms of the GNU General Public License Version 2 as published by the
@@ -18,98 +18,98 @@ $Revision: 1.1.1.1 $
 /* This is the SCSI commands for FreeBSD */
 DEVICE_TYPE SCSI_OpenDevice(char *DeviceName)
 {
-  struct cam_device *DeviceFD = cam_open_pass(DeviceName, O_RDWR | O_EXCL,
-                                             NULL);
-  if (DeviceFD == 0)
-    FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
-  return (DEVICE_TYPE) DeviceFD;
+       struct cam_device *DeviceFD = cam_open_pass(DeviceName, O_RDWR | O_EXCL, NULL);
+       if (DeviceFD == 0)
+               FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
+       return (DEVICE_TYPE) DeviceFD;
 }
 
 
-void SCSI_CloseDevice(char *DeviceName,
-                            DEVICE_TYPE DeviceFD)
+void SCSI_CloseDevice(char *DeviceName, DEVICE_TYPE DeviceFD)
 {
-  cam_close_device((struct cam_device *) DeviceFD);
+       cam_close_device((struct cam_device *) DeviceFD);
 }
 
 #define PASS_HZ 1000*60
 #define PASS_DEFAULT_TIMEOUT 5*PASS_HZ
 static int pass_timeout = PASS_DEFAULT_TIMEOUT;
 
-void SCSI_Set_Timeout(int secs) {
-  pass_timeout=secs*PASS_HZ;
+void SCSI_Set_Timeout(int secs)
+{
+       pass_timeout=secs*PASS_HZ;
 }
 
 void SCSI_Default_Timeout(void) {
-  pass_timeout=5*PASS_HZ;
+       pass_timeout=5*PASS_HZ;
 }
 
 int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
-                              Direction_T Direction,
-                              CDB_T *CDB,
-                              int CDB_Length,
-                              void *DataBuffer,
-                              int DataBufferLength,
-                              RequestSense_T *RequestSense)
+                                               Direction_T Direction,
+                                               CDB_T *CDB,
+                                               int CDB_Length,
+                                               void *DataBuffer,
+                                               int DataBufferLength,
+                                               RequestSense_T *RequestSense)
 {
-  struct cam_device *dsp = (struct cam_device *) DeviceFD;
-  int retval;
-  union ccb *ccb;
-  CDB_T *cdb;
-  int Result;
-
-  ccb=cam_getccb(dsp);
-  cdb = (CDB_T *) &ccb->csio.cdb_io.cdb_bytes; /* pointer to actual cdb. */
-
-  /* cam_getccb() zeros the CCB header only. So now clear the
-   * payload portion of the ccb.
-   */
-  bzero(&(&ccb->ccb_h)[1],
-       sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr));
-
-  /* copy the CDB... */
-  memcpy(cdb,CDB,CDB_Length);
-  /* set the command control block stuff.... the rather involved
-  * conditional expression sets the direction to NONE if there is no
-  * data to go in or out, and IN or OUT if we want data. Movement
-  * commands will have no data buffer, just a CDB, while INQUIRY and
-  * READ_ELEMENT_STATUS will have input data, and we don't have any 
-  * stuff that outputs data -- yet -- but we may eventually. 
-  */
-  cam_fill_csio(&ccb->csio,
-               /* retries */ 1,
-               /* cbfcnp*/ NULL,
-               /* flags */((DataBufferLength) ?
-                           ((Direction == Input) ? CAM_DIR_IN : CAM_DIR_OUT) :
-                           CAM_DIR_NONE),  
-               /* tag action */ MSG_SIMPLE_Q_TAG,
-               /* data ptr */ DataBuffer,
-               /* xfer_len */ DataBufferLength,
-               /* sense_len */ SSD_FULL_SIZE,
-               /* cdb_len */ CDB_Length,
-               /* timeout */ pass_timeout /* should be 5 minutes or more?! */
-               ); 
-
-  pass_timeout=PASS_DEFAULT_TIMEOUT; /* make sure it gets reset. */
-  memset(RequestSense, 0, sizeof(RequestSense_T)); /* clear sense buffer... */
-
-  if (Direction == Input)
-  {
-     memset(DataBuffer, 0, DataBufferLength);
-  }
-
-  Result = cam_send_ccb(DeviceFD,ccb);
-  if ( (Result < 0) || 
-       (ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
-    /* copy our sense data, sigh... */
-    memcpy(RequestSense,(void *) &ccb->csio.sense_data,
-          min(sizeof(RequestSense_T), sizeof(struct scsi_sense_data)));
-    
-    cam_freeccb(ccb);
-    return -1; /* sorry!  */
-  }
-  
-  /* okay, we did good, maybe? */
-  cam_freeccb(ccb);
-  return 0; /* and done? */
+       struct cam_device *dsp = (struct cam_device *) DeviceFD;
+       int retval;
+       union ccb *ccb;
+       CDB_T *cdb;
+       int Result;
+
+       ccb = cam_getccb(dsp);
+       cdb = (CDB_T *) &ccb->csio.cdb_io.cdb_bytes; /* pointer to actual cdb. */
+
+       /* cam_getccb() zeros the CCB header only. So now clear the
+       * payload portion of the ccb.
+       */
+       bzero(&(&ccb->ccb_h)[1], sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr));
+
+       /* copy the CDB... */
+       memcpy(cdb,CDB,CDB_Length);
+
+       /* set the command control block stuff.... the rather involved
+       * conditional expression sets the direction to NONE if there is no
+       * data to go in or out, and IN or OUT if we want data. Movement
+       * commands will have no data buffer, just a CDB, while INQUIRY and
+       * READ_ELEMENT_STATUS will have input data, and we don't have any 
+       * stuff that outputs data -- yet -- but we may eventually. 
+       */
+       cam_fill_csio(  &ccb->csio,
+                                       1,                                                      /* retries */
+                                       NULL,                                           /* cbfcnp*/
+                                       (DataBufferLength ? 
+                                               (Direction == Input ? CAM_DIR_IN : CAM_DIR_OUT) : 
+                                               CAM_DIR_NONE),                  /* flags */
+                                       MSG_SIMPLE_Q_TAG,                       /* tag action */
+                                       DataBuffer,                                     /* data ptr */
+                                       DataBufferLength,                       /* xfer_len */
+                                       SSD_FULL_SIZE,                          /* sense_len */
+                                       CDB_Length,                                     /* cdb_len */
+                                       pass_timeout                            /* timeout */ /* should be 5 minutes or more?! */
+                                       ); 
+
+       pass_timeout = PASS_DEFAULT_TIMEOUT; /* make sure it gets reset. */
+       memset(RequestSense, 0, sizeof(RequestSense_T)); /* clear sense buffer... */
+
+       if (Direction == Input)
+       {
+               memset(DataBuffer, 0, DataBufferLength);
+       }
+
+       Result = cam_send_ccb(DeviceFD,ccb);
+       if (Result < 0 || 
+               (ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
+       {
+               /* copy our sense data, sigh... */
+               memcpy(RequestSense,(void *) &ccb->csio.sense_data,
+               min(sizeof(RequestSense_T), sizeof(struct scsi_sense_data)));
+
+               cam_freeccb(ccb);
+               return -1; /* sorry!  */
+       }
+
+       /* okay, we did good, maybe? */
+       cam_freeccb(ccb);
+       return 0; /* and done? */
 }
index 66a07b949eb7fa0392203141cdd2d8ffdf504323..cc46a0392745f7d601180264206ed010f721ea4a 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright 1997, 1998 Leonard Zubkoff <lnz@dandelion.com>
-   Changes copyright 2000 Eric Green <eric@estinc.com>
+   Changes copyright 2000 Eric Green <eric@badtux.org>
 
   This program is free software; you may redistribute and/or modify it under
   the terms of the GNU General Public License Version 2 as published by the
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   for complete details.
 
-struct sctl_io {
-        unsigned flags;                 // IN: SCTL_READ
-        unsigned cdb_length;            // IN
-        unsigned char cdb[16];          // IN 
-        void *data;                     // IN 
-        unsigned data_length;           // IN 
-        unsigned max_msecs;             // IN: milli-seconds before abort 
-        unsigned data_xfer;             // OUT 
-        unsigned cdb_status;            // OUT: SCSI status 
-        unsigned char sense[256];       // OUT 
-        unsigned sense_status;          // OUT: SCSI status 
-        unsigned sense_xfer;            // OUT: bytes of sense data received 
-        unsigned reserved[16];          // IN: Must be zero; OUT: undefined 
+struct sctl_io
+{
+       unsigned flags;                 // IN: SCTL_READ
+       unsigned cdb_length;            // IN
+       unsigned char cdb[16];          // IN 
+       void *data;                     // IN 
+       unsigned data_length;           // IN 
+       unsigned max_msecs;             // IN: milli-seconds before abort 
+       unsigned data_xfer;             // OUT 
+       unsigned cdb_status;            // OUT: SCSI status 
+       unsigned char sense[256];       // OUT 
+       unsigned sense_status;          // OUT: SCSI status 
+       unsigned sense_xfer;            // OUT: bytes of sense data received 
+       unsigned reserved[16];          // IN: Must be zero; OUT: undefined 
 };
 
 */
@@ -43,81 +44,90 @@ struct sctl_io {
 
 DEVICE_TYPE SCSI_OpenDevice(char *DeviceName)
 {
-  int DeviceFD = open(DeviceName, O_RDWR | O_NDELAY);
-  if (DeviceFD < 0)
-    FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
-  return (DEVICE_TYPE) DeviceFD;
+       int DeviceFD = open(DeviceName, O_RDWR | O_NDELAY);
+
+       if (DeviceFD < 0)
+               FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
+
+       return (DEVICE_TYPE) DeviceFD;
 }
 
 
-void SCSI_CloseDevice(char *DeviceName,
-                            DEVICE_TYPE DeviceFD)
+void SCSI_CloseDevice(char *DeviceName, DEVICE_TYPE DeviceFD)
 {
-  if (close(DeviceFD) < 0)
-    FatalError("cannot close SCSI device '%s' - %m\n", DeviceName);
+       if (close(DeviceFD) < 0)
+               FatalError("cannot close SCSI device '%s' - %m\n", DeviceName);
 }
 
 #define MTX_HZ 1000
 #define DEFAULT_HZ (5*60*MTX_HZ)
 
-static int sctl_io_timeout=DEFAULT_HZ;  /* default timeout is 5 minutes. */
+static int sctl_io_timeout=DEFAULT_HZ;         /* default timeout is 5 minutes. */
 
 
-void SCSI_Set_Timeout(int to) {
-  sctl_io_timeout=to*60*MTX_HZ;
+void SCSI_Set_Timeout(int to)
+{
+       sctl_io_timeout=to*60*MTX_HZ;
 }
 
-void SCSI_Default_Timeout(void) {
-  sctl_io_timeout=DEFAULT_HZ;
+void SCSI_Default_Timeout(void)
+{
+       sctl_io_timeout=DEFAULT_HZ;
 }
 
 
 int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
-                              Direction_T Direction,
-                              CDB_T *CDB,
-                              int CDB_Length,
-                              void *DataBuffer,
-                              int DataBufferLength,
-                              RequestSense_T *RequestSense)
+                                               Direction_T Direction,
+                                               CDB_T *CDB,
+                                               int CDB_Length,
+                                               void *DataBuffer,
+                                               int DataBufferLength,
+                                               RequestSense_T *RequestSense)
 {
-    int ioctl_result;
-    struct sctl_io Command;
-
-    int i;
-
-    memset(&Command, 0, sizeof(struct sctl_io));
-    memset(RequestSense, 0, sizeof(RequestSense_T));
-
-    switch (Direction) {
-         case Input:
-              if (DataBufferLength > 0)
-                  memset(DataBuffer, 0, DataBufferLength);
-              Command.flags =  SCTL_READ | SCTL_INIT_SDTR;
-              break;
-         case Output:
-              Command.flags = SCTL_INIT_WDTR | SCTL_INIT_SDTR;
-              break;
-         }
-
-    Command.max_msecs = sctl_io_timeout;    /* Set timeout to <n> minutes. */
-    memcpy(Command.cdb, CDB, CDB_Length);
-    Command.cdb_length = CDB_Length;
-    Command.data = DataBuffer;
-    Command.data_length = DataBufferLength;
-    ioctl_result=ioctl(DeviceFD, SIOC_IO, &Command);
-    SCSI_Default_Timeout();  /* change the default back to 5 minutes */
-    if (ioctl_result < 0) {
-         perror("mtx");
-         return ioctl_result;
-         }
-
-    if (Command.sense_xfer > sizeof(RequestSense_T)) {
-      Command.sense_xfer=sizeof(RequestSense_T);
-    }
-
-    if (Command.sense_xfer) {
-      memcpy(RequestSense, Command.sense, Command.sense_xfer);
-    }
-
-    return Command.sense_status;
+       int ioctl_result;
+       struct sctl_io Command;
+
+       int i;
+
+       memset(&Command, 0, sizeof(struct sctl_io));
+       memset(RequestSense, 0, sizeof(RequestSense_T));
+
+       switch (Direction)
+       {
+       case Input:
+               if (DataBufferLength > 0)
+                       memset(DataBuffer, 0, DataBufferLength);
+               Command.flags =  SCTL_READ | SCTL_INIT_SDTR;
+               break;
+
+       case Output:
+               Command.flags = SCTL_INIT_WDTR | SCTL_INIT_SDTR;
+               break;
+       }
+
+       Command.max_msecs = sctl_io_timeout;    /* Set timeout to <n> minutes. */
+       memcpy(Command.cdb, CDB, CDB_Length);
+       Command.cdb_length = CDB_Length;
+       Command.data = DataBuffer;
+       Command.data_length = DataBufferLength;
+       ioctl_result=ioctl(DeviceFD, SIOC_IO, &Command);
+       SCSI_Default_Timeout();                 /* change the default back to 5 minutes */
+
+       if (ioctl_result < 0)
+       {
+               perror("mtx");
+               return ioctl_result;
+       }
+
+       if (Command.sense_xfer > sizeof(RequestSense_T))
+       {
+               Command.sense_xfer=sizeof(RequestSense_T);
+       }
+
+       if (Command.sense_xfer)
+       {
+               memcpy(RequestSense, Command.sense, Command.sense_xfer);
+       }
+
+       return Command.sense_status;
 }
index c5a350852b662448cb2ed2ad6b8e033f4e42ec62..06cdd7e31bf31599cddad1872d940502e981fa1e 100644 (file)
@@ -1,8 +1,8 @@
 /* Copyright 1997, 1998 Leonard Zubkoff <lnz@dandelion.com>
-   Changes in Feb 2000 Eric Green <eric@estinc.com>
+   Changes in Feb 2000 Eric Green <eric@badtux.org>
 
-$Date: 2001/06/19 21:51:32 $
-$Revision: 1.2 $
+$Date: 2007-03-24 21:17:10 -0700 (Sat, 24 Mar 2007) $
+$Revision: 171 $
 
   This program is free software; you may redistribute and/or modify it under
   the terms of the GNU General Public License Version 2 as published by the
@@ -24,7 +24,7 @@ $Revision: 1.2 $
 
 #ifndef HZ
 #warning "HZ is not defined, mtx might not work correctly!"
-#define HZ 100
+#define HZ 100   /* Jiffys for SG_SET_TIMEOUT */
 #endif
 
 /* These are copied out of BRU 16.1, with all the boolean masks changed
@@ -55,38 +55,53 @@ $Revision: 1.2 $
 
 #define STILL_A_VALID_READ(s) (HIT_FILEMARK(s) || SHORT_READ(s) || HIT_EOD(s) || HIT_EOP(s) || HIT_EOM(s))
 
+#define SG_SCSI_DEFAULT_TIMEOUT (HZ*60*5)  /* 5 minutes? */
 
-#define SG_SCSI_DEFAULT_TIMEOUT HZ*60*5                        /* 5 minutes */
+static int pack_id;
+static int sg_timeout;
 
 DEVICE_TYPE SCSI_OpenDevice(char *DeviceName)
 {
-  int timeout=SG_SCSI_DEFAULT_TIMEOUT;
-  int DeviceFD = open(DeviceName, O_RDWR);
-  if (DeviceFD < 0)
-    FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
+       int timeout = SG_SCSI_DEFAULT_TIMEOUT;
+#ifdef SG_IO
+       int k; /* version */
+#endif
+       int DeviceFD = open(DeviceName, O_RDWR);
 
-  if(ioctl(DeviceFD, SG_SET_TIMEOUT, &timeout)) {
-    FatalError("failed to set sg timeout - %m\n");
-  }
+       if (DeviceFD < 0)
+               FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
 
-  return (DEVICE_TYPE) DeviceFD;
-}
 
-static int sg_timeout = SG_SCSI_DEFAULT_TIMEOUT ;
+#ifdef SG_IO
+       /* It is prudent to check we have a sg device by trying an ioctl */
+       if ((ioctl(DeviceFD, SG_GET_VERSION_NUM, &k) < 0) || (k < 30000))
+       {
+               FatalError("%s is not an sg device, or old sg driver\n", DeviceName);
+       }
+#endif
 
-void SCSI_Set_Timeout(int secs) {
-  sg_timeout=secs*HZ;
+       if (ioctl(DeviceFD, SG_SET_TIMEOUT, &timeout))
+       {
+               FatalError("failed to set sg timeout - %m\n");
+       }
+       pack_id = 1;    /* used for SG v3 interface if possible. */
+       return (DEVICE_TYPE) DeviceFD;
+}
+
+void SCSI_Set_Timeout(int secs)
+{
+       sg_timeout = secs * HZ;
 }
  
-void SCSI_Default_Timeout(void) {
-  sg_timeout=SG_SCSI_DEFAULT_TIMEOUT;
+void SCSI_Default_Timeout(void)
+{
+       sg_timeout = SG_SCSI_DEFAULT_TIMEOUT;
 }
 
-void SCSI_CloseDevice(char *DeviceName,
-                            DEVICE_TYPE DeviceFD)
+void SCSI_CloseDevice(char *DeviceName, DEVICE_TYPE DeviceFD)
 {
-  if (close(DeviceFD) < 0)
-    FatalError("cannot close SCSI device '%s' - %m\n", DeviceName);
+       if (close(DeviceFD) < 0)
+               FatalError("cannot close SCSI device '%s' - %m\n", DeviceName);
 }
 
 
@@ -94,29 +109,113 @@ void SCSI_CloseDevice(char *DeviceName,
  * Seagate autoloader (hopefully!). 
  */
 /* Get the SCSI ID and LUN... */
-scsi_id_t *SCSI_GetIDLun(DEVICE_TYPE fd) {
-  int status;
-  scsi_id_t *retval;
-  
-  struct my_scsi_idlun {
-    int word1;
-    int word2;
-  } idlun;
-
-  status=ioctl(fd,SCSI_IOCTL_GET_IDLUN,&idlun);
-  if (status) {
-    return NULL; /* sorry! */
-  }
-  
-  retval=(scsi_id_t *)xmalloc(sizeof(scsi_id_t));
-  retval->id=idlun.word1 & 0xff;
-  retval->lun=idlun.word1 >> 8 & 0xff;
+scsi_id_t *SCSI_GetIDLun(DEVICE_TYPE fd)
+{
+       int status;
+       scsi_id_t *retval;
+
+       struct my_scsi_idlun
+       {
+               int word1;
+               int word2;
+       } idlun;
+
+       status = ioctl(fd, SCSI_IOCTL_GET_IDLUN, &idlun);
+       if (status)
+       {
+               return NULL; /* sorry! */
+       }
+
+       retval = (scsi_id_t *)xmalloc(sizeof(scsi_id_t));
+       retval->id = idlun.word1 & 0xff;
+       retval->lun = idlun.word1 >> 8 & 0xff;
+
 #ifdef DEBUG
-  fprintf(stderr,"SCSI:ID=%d LUN=%d\n",retval->id,retval->lun);
+       fprintf(stderr, "SCSI:ID=%d LUN=%d\n", retval->id, retval->lun);
 #endif
-  return retval;
+
+       return retval;
 }
-  
+
+
+/* Changed January 2001 by Eric Green <eric@badtux.org> to 
+ * use the Linux version 2.4 SCSI Generic facility if available.
+ * Liberally cribbed code from Doug Gilbert's sg3 utils. 
+ */
+
+#ifdef SG_IO
+#include "sg_err.h"  /* error stuff. */
+#include "sg_err.c"  /* some of Doug Gilbert's routines */
+
+/* Use the new SG_IO structure */
+int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
+                                               Direction_T Direction,
+                                               CDB_T *CDB,
+                                               int CDB_Length,
+                                               void *DataBuffer,
+                                               int DataBufferLength,
+                                               RequestSense_T *RequestSense)
+{
+       unsigned int status;
+       sg_io_hdr_t io_hdr;
+
+       memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
+       memset(RequestSense, 0, sizeof(RequestSense_T));
+
+       /* Fill in the common stuff... */
+       io_hdr.interface_id = 'S';
+       io_hdr.cmd_len = CDB_Length;
+       io_hdr.mx_sb_len = sizeof(RequestSense_T);
+       io_hdr.dxfer_len = DataBufferLength;
+       io_hdr.cmdp = (unsigned char *) CDB;
+       io_hdr.sbp = (unsigned char *) RequestSense;
+       io_hdr.dxferp = DataBuffer;
+       io_hdr.timeout = sg_timeout * 10; /* Convert from Jiffys to milliseconds */
+
+       if (Direction==Input)
+       {
+               /* fprintf(stderr,"direction=input\n"); */
+               io_hdr.dxfer_direction=SG_DXFER_FROM_DEV;
+       }
+       else
+       {
+               /* fprintf(stderr,"direction=output\n"); */
+               io_hdr.dxfer_direction=SG_DXFER_TO_DEV;
+       }
+
+       /* Now do it:  */
+       if ((status = ioctl(DeviceFD, SG_IO , &io_hdr)) || io_hdr.masked_status)
+       {
+               /* fprintf(stderr, "smt_scsi_cmd: Rval=%d Status=%d, errno=%d [%s]\n",status, io_hdr.masked_status,
+               errno, 
+               strerror(errno)); */
+
+               switch (sg_err_category3(&io_hdr))
+               {
+               case SG_ERR_CAT_CLEAN:
+               case SG_ERR_CAT_RECOVERED:
+                       break;
+
+               case SG_ERR_CAT_MEDIA_CHANGED:
+                       return 2;
+
+               default:
+                       return -1;
+               }
+
+               /*  fprintf(stderr,"host_status=%d driver_status=%d residual=%d writelen=%d\n",io_hdr.host_status,io_hdr.driver_status,io_hdr.resid,io_hdr.sb_len_wr ); */
+
+               return -errno;
+       }
+
+       /* Now check the returned statuses: */
+       /* fprintf(stderr,"host_status=%d driver_status=%d residual=%d writelen=%d\n",io_hdr.host_status,io_hdr.driver_status,io_hdr.resid,io_hdr.sb_len_wr ); */
+
+       SCSI_Default_Timeout();  /* reset back to default timeout, sigh. */
+       return 0;
+}
+
+#else
 
 /* Changed February 2000 by Eric Green <eric@estinc.com> to 
  * use the SCSI generic interface rather than SCSI_IOCTL_SEND_COMMAND
@@ -131,271 +230,264 @@ scsi_id_t *SCSI_GetIDLun(DEVICE_TYPE fd) {
  * manner. This sucks. But sucks less than SCSI_IOCTL_SEND_COMMAND, sigh.
  */
 
+
 #ifndef OLD_EXECUTE_COMMAND_STUFF
 
 static void slow_memcopy(unsigned char *src, unsigned char *dest, int numbytes)
 {
-  while (numbytes--) {
-    *dest++ = *src++;
-  }
+       while (numbytes--)
+       {
+               *dest++ = *src++;
+       }
 }
 
 
 int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
-                              Direction_T Direction,
-                              CDB_T *CDB,
-                              int CDB_Length,
-                              void *DataBuffer,
-                              int DataBufferLength,
-                              RequestSense_T *RequestSense)
+                                               Direction_T Direction,
+                                               CDB_T *CDB,
+                                               int CDB_Length,
+                                               void *DataBuffer,
+                                               int DataBufferLength,
+                                               RequestSense_T *RequestSense)
 {
+       unsigned char *Command=NULL;   /* the command data struct sent to them... */
+       unsigned char *ResultBuf=NULL; /* the data we read in return...         */
 
-  unsigned char *Command=NULL;   /* the command data struct sent to them... */
-  unsigned char *ResultBuf=NULL; /* the data we read in return...         */
+       unsigned char *src;       /* for copying stuff, sigh. */
+       unsigned char *dest;      /* for copy stuff, again, sigh. */
 
-  unsigned char *src;       /* for copying stuff, sigh. */
-  unsigned char *dest;      /* for copy stuff, again, sigh. */
+       int write_length = sizeof(struct sg_header)+CDB_Length;
+       int i;                  /* a random index...          */
+       int result;             /* the result of the write... */ 
 
-  int write_length = sizeof(struct sg_header)+CDB_Length;
-  int i;                  /* a random index...          */
-  int result;             /* the result of the write... */ 
-  
-  
-  struct sg_header *Header; /* we actually point this into Command... */
-  struct sg_header *ResultHeader; /* we point this into ResultBuf... */
+       struct sg_header *Header; /* we actually point this into Command... */
+       struct sg_header *ResultHeader; /* we point this into ResultBuf... */
 
-
-  /* First, see if we need to set our SCSI timeout to something different */
-  if (sg_timeout != SG_SCSI_DEFAULT_TIMEOUT) {
-    /* if not default, set it: */
+       /* First, see if we need to set our SCSI timeout to something different */
+       if (sg_timeout != SG_SCSI_DEFAULT_TIMEOUT)
+       {
+               /* if not default, set it: */
 #ifdef DEBUG_TIMEOUT
-    fprintf(stderr,"Setting timeout to %d\n", sg_timeout);
-    fflush(stderr);
+               fprintf(stderr,"Setting timeout to %d\n", sg_timeout);
+               fflush(stderr);
 #endif
-    if(ioctl(DeviceFD, SG_SET_TIMEOUT, &sg_timeout)) {
-      FatalError("failed to set sg timeout - %m\n");
-    }
-  }
-
-  if (Direction == Output) {  /* if we're writing, our length is longer... */
-    write_length += DataBufferLength; 
-  }
-  
-  /* allocate some memory... enough for the command plus the header +
-   *  any other data that we may need here...
-   */
-  
-  Command=(unsigned char *)xmalloc(write_length);
-  Header = (struct sg_header *) Command;  /* make it point to start of buf */
-
-  dest=Command; /* now to copy the CDB... from start of buffer,*/
-  dest+= sizeof(struct sg_header); /* increment it past the header. */
-
-  slow_memcopy((char *)CDB,dest,CDB_Length);
-
-  /* if we are writing additional data, tack it on here! */
-  if (Direction == Output) {
-    dest += CDB_Length;
-    slow_memcopy(DataBuffer,dest,DataBufferLength); /* copy to end of command */
-  }
-  /* Now to fill in the Header struct: */
-  Header->reply_len=DataBufferLength+sizeof(struct sg_header);
+               if(ioctl(DeviceFD, SG_SET_TIMEOUT, &sg_timeout))
+               {
+                       FatalError("failed to set sg timeout - %m\n");
+               }
+       }
+
+       if (Direction == Output)
+       {
+               /* if we're writing, our length is longer... */
+               write_length += DataBufferLength; 
+       }
+
+       /* allocate some memory... enough for the command plus the header +
+        *  any other data that we may need here...
+        */
+
+       Command = (unsigned char *)xmalloc(write_length);
+       Header = (struct sg_header *) Command;  /* make it point to start of buf */
+
+       dest = Command; /* now to copy the CDB... from start of buffer,*/
+       dest += sizeof(struct sg_header); /* increment it past the header. */
+
+       slow_memcopy((char *)CDB, dest, CDB_Length);
+
+       /* if we are writing additional data, tack it on here! */
+       if (Direction == Output)
+       {
+               dest += CDB_Length;
+               slow_memcopy(DataBuffer, dest, DataBufferLength); /* copy to end of command */
+       }
+
+       /* Now to fill in the Header struct: */
+       Header->reply_len=DataBufferLength+sizeof(struct sg_header);
 #ifdef DEBUG
-  fprintf(stderr,"sg:reply_len(sent)=%d\n",Header->reply_len);
+       fprintf(stderr,"sg:reply_len(sent)=%d\n",Header->reply_len);
 #endif
-  Header->twelve_byte = CDB_Length == 12; 
-  Header->result = 0;
-  Header->pack_len = write_length; /* # of bytes written... */
-  Header->pack_id = 0;             /* not used              */
-  Header->other_flags = 0;         /* not used.             */
-  Header->sense_buffer[0]=0;      /* used? */
-
-  /* Now to do the write... */
-  result=write(DeviceFD,Command,write_length);
-  
-  /* Now to check the result :-(. */
-  /* Note that we don't have any request sense here. So we have no
-   * idea what's going on. 
-   */ 
-  if ( (result < 0) || (result != write_length) || Header->result ||
-       Header->sense_buffer[0] ) {
+       Header->twelve_byte = CDB_Length == 12; 
+       Header->result = 0;
+       Header->pack_len = write_length; /* # of bytes written... */
+       Header->pack_id = 0;             /* not used              */
+       Header->other_flags = 0;         /* not used.             */
+       Header->sense_buffer[0]=0;      /* used? */
+
+       /* Now to do the write... */
+       result = write(DeviceFD,Command,write_length);
+
+       /* Now to check the result :-(. */
+       /* Note that we don't have any request sense here. So we have no
+       * idea what's going on. 
+       */ 
+       if (result < 0 || result != write_length || Header->result || Header->sense_buffer[0])
+       {
 #ifdef DEBUG_SCSI
-    fprintf(stderr,"scsi:result=%d Header->result=%d Header->sense_buffer[0]=%d\n",
-           result,Header->result,Header->sense_buffer[0]);
+               fprintf(stderr,"scsi:result=%d Header->result=%d Header->sense_buffer[0]=%d\n",
+               result,Header->result,Header->sense_buffer[0]);
 #endif  
-    /* we don't have any real sense data, sigh :-(. */
-    if (Header->sense_buffer[0]) {
-      /* well, I guess we DID have some! eep! copy the sense data! */
-      slow_memcopy((char *)Header->sense_buffer,(char *)RequestSense,
-                  sizeof(Header->sense_buffer));
-    } else {
-      dest=(unsigned char *)RequestSense;
-      *dest=(unsigned char)Header->result; /* may chop, sigh... */
-    }
-
-    /* okay, now, we may or may not need to find a non-zero value to return.
-     * For tape drives, we may get a BLANK_CHECK or MEDIUM_ERROR and find
-     * that it's *STILL* a good read! Use the STILL_A_VALID_READ macro
-     * that calls all those macros I cribbed from Richard. 
-     */
-    
-    if (!STILL_A_VALID_READ(RequestSense)) {
-      free(Command); /* zap memory leak, sigh */
-      /* okay, find us a non-zero value to return :-(. */
-      if (result) {
-       return result;
-      } else if (Header->result) {
-       return Header->result;
-      } else {
-       return -1;  /* sigh */
-      }
-    } else {
-      result=-1;
-    }
-  } else {
-    result=0; /* we're okay! */
-  }
-    
-  
-  /* now to allocate the new block.... */
-  ResultBuf=(unsigned char *)xmalloc(Header->reply_len);
-  /* now to clear ResultBuf... */
-  slow_bzero(ResultBuf,Header->reply_len); 
-
-  ResultHeader=(struct sg_header *)ResultBuf;
-  
-  /* copy the original Header... */
-  ResultHeader->result=0;
-  ResultHeader->pack_id=0;
-  ResultHeader->other_flags=0;
-  ResultHeader->reply_len=Header->reply_len;
-  ResultHeader->twelve_byte = CDB_Length == 12; 
-  ResultHeader->pack_len = write_length; /* # of bytes written... */
-  ResultHeader->sense_buffer[0]=0; /* whoops! Zero that! */
+               /* we don't have any real sense data, sigh :-(. */
+               if (Header->sense_buffer[0])
+               {
+                       /* well, I guess we DID have some! eep! copy the sense data! */
+                       slow_memcopy((char *)Header->sense_buffer,(char *)RequestSense,
+                                                sizeof(Header->sense_buffer));
+               }
+               else
+               {
+                       dest=(unsigned char *)RequestSense;
+                       *dest=(unsigned char)Header->result; /* may chop, sigh... */
+               }
+
+               /* okay, now, we may or may not need to find a non-zero value to return.
+               * For tape drives, we may get a BLANK_CHECK or MEDIUM_ERROR and find
+               * that it's *STILL* a good read! Use the STILL_A_VALID_READ macro
+               * that calls all those macros I cribbed from Richard. 
+               */
+
+               if (!STILL_A_VALID_READ(RequestSense))
+               {
+                       free(Command); /* zap memory leak, sigh */
+                       /* okay, find us a non-zero value to return :-(. */
+                       if (result)
+                       {
+                               return result;
+                       }
+                       else if (Header->result)
+                       {
+                               return Header->result;
+                       }
+                       else
+                       {
+                               return -1;  /* sigh */
+                       }
+               }
+               else
+               {
+                       result=-1;
+               }
+       }
+       else
+       {
+               result=0; /* we're okay! */
+       }
+
+       /* now to allocate the new block.... */
+       ResultBuf=(unsigned char *)xmalloc(Header->reply_len);
+       /* now to clear ResultBuf... */
+       slow_bzero(ResultBuf,Header->reply_len); 
+
+       ResultHeader=(struct sg_header *)ResultBuf;
+
+       /* copy the original Header... */
+       ResultHeader->result=0;
+       ResultHeader->pack_id=0;
+       ResultHeader->other_flags=0;
+       ResultHeader->reply_len=Header->reply_len;
+       ResultHeader->twelve_byte = CDB_Length == 12; 
+       ResultHeader->pack_len = write_length; /* # of bytes written... */
+       ResultHeader->sense_buffer[0]=0; /* whoops! Zero that! */
 #ifdef DEBUG
-  fprintf(stderr,"sg:Reading %d bytes from DeviceFD\n",Header->reply_len);
-  fflush(stderr);
+       fprintf(stderr,"sg:Reading %d bytes from DeviceFD\n",Header->reply_len);
+       fflush(stderr);
 #endif
-  result=read(DeviceFD,ResultBuf,Header->reply_len);
+       result=read(DeviceFD,ResultBuf,Header->reply_len);
 #ifdef DEBUG
-  fprintf(stderr,"sg:result=%d ResultHeader->result=%d\n",
-         result,ResultHeader->result);
-  fflush(stderr);
+       fprintf(stderr,"sg:result=%d ResultHeader->result=%d\n",
+       result,ResultHeader->result);
+       fflush(stderr);
 #endif
-  /* New: added check to see if the result block is still all zeros! */
-  if ( (result < 0) || (result != Header->reply_len) || ResultHeader->result ||
-       ResultHeader->sense_buffer[0] ) {
+       /* New: added check to see if the result block is still all zeros! */
+       if (result < 0 ||
+               result != Header->reply_len ||
+               ResultHeader->result ||
+               ResultHeader->sense_buffer[0])
+       {
 #ifdef DEBUG
-    fprintf(stderr,
-           "scsi: result=%d Header->reply_len=%d ResultHeader->result=%d ResultHeader->sense_buffer[0]=%d\n",
-           result,
-           Header->reply_len,
-           ResultHeader->result,
-           ResultHeader->sense_buffer[0]);
+               fprintf(stderr,
+               "scsi: result=%d Header->reply_len=%d ResultHeader->result=%d ResultHeader->sense_buffer[0]=%d\n",
+               result,
+               Header->reply_len,
+               ResultHeader->result,
+               ResultHeader->sense_buffer[0]);
 #endif
-    /* eep! copy the sense data! */
-    slow_memcopy((char *)ResultHeader->sense_buffer,(char *)RequestSense,
-                sizeof(ResultHeader->sense_buffer));
-    /* sense data copied, now find us a non-zero value to return :-(. */
-    /* NOTE: Some commands return sense data even though they validly
-     * executed! We catch a few of those with the macro STILL_A_VALID_READ.
-     */
-
-    if (!STILL_A_VALID_READ(RequestSense)) {
-      free(Command);
-      if (result) {
-       free(ResultBuf);
-       return result;
-      } else if (ResultHeader->result) {
-       free(ResultBuf);
-       return ResultHeader->result;
-      } else {
-       free(ResultBuf);
-       return -1; /* sigh! */
-      } 
-    } else {
-      result=-1; /* if it was a valid read, still have -1 result. */
-    }
-  } else {
-    result=0;
-  }
-  
-  /* See if we need to reset our SCSI timeout */
-  if (sg_timeout != SG_SCSI_DEFAULT_TIMEOUT) {
-    sg_timeout = SG_SCSI_DEFAULT_TIMEOUT; /* reset it back to default */
+               /* eep! copy the sense data! */
+               slow_memcopy((char *)ResultHeader->sense_buffer,(char *)RequestSense,
+               sizeof(ResultHeader->sense_buffer));
+               /* sense data copied, now find us a non-zero value to return :-(. */
+               /* NOTE: Some commands return sense data even though they validly
+               * executed! We catch a few of those with the macro STILL_A_VALID_READ.
+               */
+
+               if (!STILL_A_VALID_READ(RequestSense))
+               {
+                       free(Command);
+                       if (result)
+                       {
+                               free(ResultBuf);
+                               return result;
+                       }
+                       else if (ResultHeader->result)
+                       {
+                               free(ResultBuf);
+                               return ResultHeader->result;
+                       }
+                       else
+                       {
+                               free(ResultBuf);
+                               return -1; /* sigh! */
+                       } 
+               }
+               else
+               {
+                       result=-1; /* if it was a valid read, still have -1 result. */
+               }
+       }
+       else
+       {
+               result=0;
+       }
+
+       /* See if we need to reset our SCSI timeout */
+       if (sg_timeout != SG_SCSI_DEFAULT_TIMEOUT)
+       {
+               sg_timeout = SG_SCSI_DEFAULT_TIMEOUT; /* reset it back to default */
+
 #ifdef DEBUG_TIMEOUT
-    fprintf(stderr,"Setting timeout to %d\n", sg_timeout);
-    fflush(stderr);
+               fprintf(stderr,"Setting timeout to %d\n", sg_timeout);
+               fflush(stderr);
 #endif
-    /* if not default, set it: */
-    if(ioctl(DeviceFD, SG_SET_TIMEOUT, &sg_timeout)) {
-      FatalError("failed to set sg timeout - %m\n");
-    }
-  }
-  
-  
-  /* now for the crowning moment: copying any result into the DataBuffer! */
-  /* (but only if it were an input command and not an output command :-}  */
-  if (Direction == Input) {
+               /* if not default, set it: */
+               if (ioctl(DeviceFD, SG_SET_TIMEOUT, &sg_timeout))
+               {
+                       FatalError("failed to set sg timeout - %m\n");
+               }
+       }
+
+       /* now for the crowning moment: copying any result into the DataBuffer! */
+       /* (but only if it were an input command and not an output command :-}  */
+       if (Direction == Input)
+       {
 #ifdef DEBUG
-    fprintf(stderr,"Header->reply_len=%d,ResultHeader->reply_len=%d\n",
-           Header->reply_len,ResultHeader->reply_len);
+               fprintf(stderr,"Header->reply_len=%d,ResultHeader->reply_len=%d\n",
+               Header->reply_len,ResultHeader->reply_len);
 #endif
-    src=ResultBuf+sizeof(struct sg_header);
-    dest=DataBuffer;
-    for (i=0;i< (ResultHeader->reply_len);i++) {
-      if (i>=DataBufferLength) break;  /* eep! */
-      *dest++=*src++;
-    }
-  }
-  
-  /* and return! */
-  free(Command);    /* clean up memory leak... */
-  free(ResultBuf);
-  return result; /* good stuff ! */
+               src=ResultBuf+sizeof(struct sg_header);
+               dest=DataBuffer;
+               for (i = 0; i < ResultHeader->reply_len; i++)
+               {
+                       if (i >= DataBufferLength)
+                               break;  /* eep! */
+                       *dest++ = *src++;
+               }
+       }
+
+       /* and return! */
+       free(Command);    /* clean up memory leak... */
+       free(ResultBuf);
+       return result; /* good stuff ! */
 }
 
 #endif  
-  
-
-#ifdef OLD_EXECUTE_COMMAND_STUFF
-
-int SCSI_ExecuteCommand(int DeviceFD,
-                              Direction_T Direction,
-                              CDB_T CDB,
-                              int CDB_Length,
-                              void *DataBuffer,
-                              int DataBufferLength,
-                              RequestSense_T *RequestSense)
-{
-  unsigned char *Command;
-  int Zero = 0, Result;
-  memset(RequestSense, 0, sizeof(RequestSense_T));
-  switch (Direction)
-    {
-    case Input:
-      Command = (unsigned char *)
-       xmalloc(8 + max(DataBufferLength, sizeof(RequestSense_T)));
-      memcpy(&Command[0], &Zero, 4);
-      memcpy(&Command[4], &DataBufferLength, 4);
-      memcpy(&Command[8], CDB, CDB_Length);
-      break;
-    case Output:
-      Command = (unsigned char *)
-       xmalloc(8 + max(CDB_Length + DataBufferLength, sizeof(RequestSense_T)));
-      memcpy(&Command[0], &DataBufferLength, 4);
-      memcpy(&Command[4], &Zero, 4);
-      memcpy(&Command[8], CDB, CDB_Length);
-      memcpy(&Command[8 + CDB_Length], DataBuffer, DataBufferLength);
-      break;
-    }
-  Result = ioctl(DeviceFD, SCSI_IOCTL_SEND_COMMAND, Command);
-  if (Result != 0)
-    memcpy(RequestSense, &Command[8], sizeof(RequestSense_T));
-  else if (Direction == Input)
-    memcpy(DataBuffer, &Command[8], DataBufferLength);
-  free(Command);
-  return Result;
-}
-
-#endif
+#endif   /* #ifdef  SG_IO    */
index c215de912c42cf5c6bbd6ae6b4d5002c522adacc..855aabbede4bae9a85defaa800e7f1acde071ed9 100644 (file)
@@ -1,8 +1,8 @@
 /* Copyright 1997, 1998 Leonard Zubkoff <lnz@dandelion.com>
-   Changes copyright 2000 Eric Green <eric@estinc.com>
+   Changes copyright 2000 Eric Green <eric@badtux.org>
 
-$Date: 2001/06/05 17:10:26 $
-$Revision: 1.1.1.1 $
+$Date: 2007-03-04 15:27:11 -0800 (Sun, 04 Mar 2007) $
+$Revision: 164 $
 
   This program is free software; you may redistribute and/or modify it under
   the terms of the GNU General Public License Version 2 as published by the
@@ -18,58 +18,63 @@ $Revision: 1.1.1.1 $
 /* This is the SCSI commands for SGI Iris */
 DEVICE_TYPE SCSI_OpenDevice(char *DeviceName)
 {
-  dsreq_t *DeviceFD = dsopen(DeviceName, O_RDWR | O_EXCL);
-  if (DeviceFD == 0)
-    FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
-  return (DEVICE_TYPE) DeviceFD;
+       dsreq_t *DeviceFD = dsopen(DeviceName, O_RDWR | O_EXCL);
+       if (DeviceFD == 0)
+               FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
+       return (DEVICE_TYPE) DeviceFD;
 }
 
 
-void SCSI_CloseDevice(char *DeviceName,
-                            DEVICE_TYPE DeviceFD)
+void SCSI_CloseDevice(char *DeviceName, DEVICE_TYPE DeviceFD)
 {
-  dsclose((dsreq_t *) DeviceFD);
+       dsclose((dsreq_t *) DeviceFD);
 }
 
 #define MTX_HZ 1000 
 #define MTX_DEFAULT_SCSI_TIMEOUT 60*5*MTX_HZ /* 5 minutes! */
 
 static int mtx_default_timeout = MTX_DEFAULT_SCSI_TIMEOUT ;
-void SCSI_Set_Timeout(int sec) {
-  mtx_default_timeout=sec*MTX_HZ;
+void SCSI_Set_Timeout(int sec)
+{
+       mtx_default_timeout=sec*MTX_HZ;
 }
 
-void SCSI_Default_Timeout() {
-  mtx_default_timeout=MTX_DEFAULT_SCSI_TIMEOUT;
+void SCSI_Default_Timeout()
+{
+       mtx_default_timeout=MTX_DEFAULT_SCSI_TIMEOUT;
 }
 
 int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
-                              Direction_T Direction,
-                              CDB_T *CDB,
-                              int CDB_Length,
-                              void *DataBuffer,
-                              int DataBufferLength,
-                              RequestSense_T *RequestSense)
+                                               Direction_T Direction,
+                                               CDB_T *CDB,
+                                               int CDB_Length,
+                                               void *DataBuffer,
+                                               int DataBufferLength,
+                                               RequestSense_T *RequestSense)
 {
-  dsreq_t *dsp = (dsreq_t *) DeviceFD;
-  int Result;
-  memset(RequestSense, 0, sizeof(RequestSense_T));
-  memcpy(CMDBUF(dsp), CDB, CDB_Length);
-  if (Direction == Input)
-  {
-     memset(DataBuffer, 0, DataBufferLength);
-     filldsreq(dsp, (unsigned char *) DataBuffer, DataBufferLength,
-              DSRQ_READ | DSRQ_SENSE);
-  }
-  else filldsreq(dsp, (unsigned char *) DataBuffer, DataBufferLength,
-                DSRQ_WRITE | DSRQ_SENSE);
-  /* Set 5 minute timeout. */
-  /* TIME(dsp) = 300 * 1000; */
-  TIME(dsp) = mtx_default_timeout;
-  Result = doscsireq(getfd((dsp)), dsp);
-  if (SENSESENT(dsp) > 0)
-    memcpy(RequestSense, SENSEBUF(dsp),
-          min(sizeof(RequestSense_T), SENSESENT(dsp)));
-  SCSI_Default_Timeout(); /* reset the mtx default timeout */
-  return Result;
+       dsreq_t *dsp = (dsreq_t *) DeviceFD;
+       int Result;
+       memset(RequestSense, 0, sizeof(RequestSense_T));
+       memcpy(CMDBUF(dsp), CDB, CDB_Length);
+
+       if (Direction == Input)
+       {
+               memset(DataBuffer, 0, DataBufferLength);
+               filldsreq(dsp, (unsigned char *) DataBuffer, DataBufferLength, DSRQ_READ | DSRQ_SENSE);
+       }
+       else
+               filldsreq(dsp, (unsigned char *) DataBuffer, DataBufferLength, DSRQ_WRITE | DSRQ_SENSE);
+
+       /* Set 5 minute timeout. */
+       /* TIME(dsp) = 300 * 1000; */
+       TIME(dsp) = mtx_default_timeout;
+       Result = doscsireq(getfd((dsp)), dsp);
+       
+       if (SENSESENT(dsp) > 0)
+       {
+               memcpy(RequestSense, SENSEBUF(dsp), min(sizeof(RequestSense_T), SENSESENT(dsp)));
+       }
+
+       SCSI_Default_Timeout(); /* reset the mtx default timeout */
+       return Result;
 }
index ca37a3bb30bf64b60fba6300351b9d09ba9f90e4..2ef66d21e66a806fddadca368121809705e866c1 100644 (file)
@@ -1,8 +1,8 @@
 /* Copyright 1997, 1998 Leonard Zubkoff <lnz@dandelion.com>
-   Changes copyright 2000 Eric Green <eric@estinc.com>
+   Changes copyright 2000 Eric Green <eric@badtux.org>
 
-$Date: 2001/12/13 16:30:11 $
-$Revision: 1.1.1.1.2.2 $
+$Date: 2007-03-04 15:27:11 -0800 (Sun, 04 Mar 2007) $
+$Revision: 164 $
 
   This program is free software; you may redistribute and/or modify it under
   the terms of the GNU General Public License Version 2 as published by the
@@ -21,18 +21,17 @@ $Revision: 1.1.1.1.2.2 $
 
 DEVICE_TYPE SCSI_OpenDevice(char *DeviceName)
 {
-  int DeviceFD = open(DeviceName, O_RDWR | O_NDELAY);
-  if (DeviceFD < 0)
-    FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
-  return (DEVICE_TYPE) DeviceFD;
+       int DeviceFD = open(DeviceName, O_RDWR | O_NDELAY);
+       if (DeviceFD < 0)
+               FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
+       return (DEVICE_TYPE) DeviceFD;
 }
 
 
-void SCSI_CloseDevice(char *DeviceName,
-                            DEVICE_TYPE DeviceFD)
+void SCSI_CloseDevice(char *DeviceName, DEVICE_TYPE DeviceFD)
 {
-  if (close(DeviceFD) < 0)
-    FatalError("cannot close SCSI device '%s' - %m\n", DeviceName);
+       if (close(DeviceFD) < 0)
+               FatalError("cannot close SCSI device '%s' - %m\n", DeviceName);
 }
 
 
@@ -40,102 +39,117 @@ void SCSI_CloseDevice(char *DeviceName,
 
 static int uscsi_timeout=5*60; 
 
-void SCSI_Set_Timeout(int to) {
-  uscsi_timeout=to;
+void SCSI_Set_Timeout(int to)
+{
+       uscsi_timeout = to;
 }
 
-void SCSI_Default_Timeout(void) {
-  uscsi_timeout=5*60; /* the default */
+void SCSI_Default_Timeout(void)
+{
+       uscsi_timeout=5*60; /* the default */
 }
 
 #ifdef DEBUG
-int SCSI_DumpBuffer(int DataBufferLength, unsigned char *DataBuffer) {
-  int i,j;
-  j=0;
-  for (i=0; i < DataBufferLength; i++) {
-    if (j==25) {
-      fprintf(stderr,"\n");
-      j=0;
-    }
-    if (j==0) {
-      fprintf(stderr,"%04x:",i);
-    }
-    if (j>0) {
-      fprintf(stderr," ");
-    }
-    fprintf(stderr,"%02x",(int)DataBuffer[i]);
-    j++;
-  }
-  fprintf(stderr,"\n");
+int SCSI_DumpBuffer(int DataBufferLength, unsigned char *DataBuffer)
+{
+       int i,j;
+       j = 0;
+
+       for (i = 0; i < DataBufferLength; i++)
+       {
+               if (j == 25)
+               {
+                       fprintf(stderr,"\n");
+                       j = 0;
+               }
+
+               if (j == 0)
+               {
+                       fprintf(stderr, "%04x:", i);
+               }
+
+               if (j > 0)
+               {
+                       fprintf(stderr," ");
+               }
+
+               fprintf(stderr, "%02x", (int)DataBuffer[i]);
+               j++;
+       }
+       fprintf(stderr, "\n");
 }
 #endif
 
 
 int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
-                              Direction_T Direction,
-                              CDB_T *CDB,
-                              int CDB_Length,
-                              void *DataBuffer,
-                              int DataBufferLength,
-                              RequestSense_T *RequestSense)
+                                               Direction_T Direction,
+                                               CDB_T *CDB,
+                                               int CDB_Length,
+                                               void *DataBuffer,
+                                               int DataBufferLength,
+                                               RequestSense_T *RequestSense)
 {
-  int ioctl_result;
-  struct uscsi_cmd Command;
+       int ioctl_result;
+       struct uscsi_cmd Command;
 
 #ifdef DEBUG_SCSI
-  fprintf(stderr,"------CDB--------\n");
-  SCSI_DumpBuffer(CDB_Length,(char *)CDB);
+       fprintf(stderr,"------CDB--------\n");
+       SCSI_DumpBuffer(CDB_Length,(char *)CDB);
 #endif
 
-  memset(&Command, 0, sizeof(struct uscsi_cmd));
-  memset(RequestSense, 0, sizeof(RequestSense_T));
-  switch (Direction)
-    {
-    case Input:
-      Command.uscsi_flags = USCSI_DIAGNOSE | USCSI_ISOLATE | USCSI_RQENABLE;
-      if (DataBufferLength > 0) {
-          memset(DataBuffer, 0, DataBufferLength);
-          Command.uscsi_flags |= USCSI_READ;
-      }
-      break;
-    case Output:
-      Command.uscsi_flags = USCSI_DIAGNOSE | USCSI_ISOLATE
-                           | USCSI_WRITE | USCSI_RQENABLE;
-      break;
-    }
+       memset(&Command, 0, sizeof(struct uscsi_cmd));
+       memset(RequestSense, 0, sizeof(RequestSense_T));
+       switch (Direction)
+       {
+       case Input:
+               Command.uscsi_flags = USCSI_DIAGNOSE | USCSI_ISOLATE | USCSI_RQENABLE;
+               if (DataBufferLength > 0)
+               {
+                       memset(DataBuffer, 0, DataBufferLength);
+                       Command.uscsi_flags |= USCSI_READ;
+               }
+               break;
+       case Output:
+               Command.uscsi_flags = USCSI_DIAGNOSE | USCSI_ISOLATE |
+                                                               USCSI_WRITE | USCSI_RQENABLE;
+               break;
+       }
   /* Set timeout to 5 minutes. */
 #ifdef DEBUG_TIMEOUT
-  fprintf(stderr,"uscsi_timeout=%d\n",uscsi_timeout);
-  fflush(stderr);
+       fprintf(stderr,"uscsi_timeout=%d\n",uscsi_timeout);
+       fflush(stderr);
 #endif
-  Command.uscsi_timeout = uscsi_timeout;
-  
-  Command.uscsi_cdb = (caddr_t) CDB;
-  Command.uscsi_cdblen = CDB_Length;
-  Command.uscsi_bufaddr = DataBuffer;
-  Command.uscsi_buflen = DataBufferLength;
-  Command.uscsi_rqbuf = (caddr_t) RequestSense;
-  Command.uscsi_rqlen = sizeof(RequestSense_T);
-  ioctl_result=ioctl(DeviceFD, USCSICMD, &Command);
+       Command.uscsi_timeout = uscsi_timeout;
 
-  SCSI_Default_Timeout(); /* set it back to default, sigh. */
+       Command.uscsi_cdb = (caddr_t) CDB;
+       Command.uscsi_cdblen = CDB_Length;
+       Command.uscsi_bufaddr = DataBuffer;
+       Command.uscsi_buflen = DataBufferLength;
+       Command.uscsi_rqbuf = (caddr_t) RequestSense;
+       Command.uscsi_rqlen = sizeof(RequestSense_T);
+       ioctl_result = ioctl(DeviceFD, USCSICMD, &Command);
 
+       SCSI_Default_Timeout(); /* set it back to default, sigh. */
 
-  if (ioctl_result < 0) {
+       if (ioctl_result < 0)
+       {
 #ifdef DEBUG
-    perror("mtx");
+               perror("mtx");
 #endif
-    return ioctl_result;
-  }
+               return ioctl_result;
+       }
+
+       if (RequestSense->ErrorCode > 1)
+       {
+               return -1;
+       }
 
-  if (RequestSense -> ErrorCode > 1) {
-    return -1;
-  }
 #ifdef DEBUG_SCSI
-  if (Direction==Input) {
-    fprintf(stderr,"--------input data-----------\n");
-    SCSI_DumpBuffer(DataBufferLength,DataBuffer);
-  }
+       if (Direction==Input)
+       {
+               fprintf(stderr,"--------input data-----------\n");
+               SCSI_DumpBuffer(DataBufferLength, DataBuffer);
+       }
 #endif
-  return 0;
+       return 0;
 }
diff --git a/scsi_win32.c b/scsi_win32.c
new file mode 100644 (file)
index 0000000..dc60ec8
--- /dev/null
@@ -0,0 +1,354 @@
+/* Copyright 2006 Robert Nelson <robertn@the-nelsons.org>
+
+$Date: 2007-03-24 18:14:01 -0700 (Sat, 24 Mar 2007) $
+$Revision: 166 $
+
+  This program is free software; you may redistribute and/or modify it under
+  the terms of the GNU General Public License Version 2 as published by the
+  Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
+  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+  for complete details.
+
+*/
+
+/*
+ * This is the SCSI commands for Windows.
+ */
+
+#include <stdio.h>
+#include <windows.h>
+
+#ifdef _MSC_VER
+#include <ntddscsi.h>
+#else
+#include <ddk/ntddscsi.h>
+#endif
+
+#define SCSI_DEFAULT_TIMEOUT   300             /* 1 minutes */
+#define SCSI_MAX_TIMEOUT               108000  /* 30 hours */
+
+typedef        struct  _HANDLE_ENTRY
+{
+       HANDLE  hDevice;
+       UCHAR   PortId;
+       UCHAR   PathId;
+       UCHAR   TargetId;
+       UCHAR   Lun;
+} HANDLE_ENTRY, *PHANDLE_ENTRY;
+
+PHANDLE_ENTRY  HandleTable = NULL;
+int                            nEntries = 0;
+
+DEVICE_TYPE SCSI_OpenDevice(char *DeviceName)
+{
+       int             DeviceIndex;
+       TCHAR   szDevicePath[256];
+
+       int             nColons = 0;
+       int             index;
+
+       int             port, path, target, lun;
+
+       for (DeviceIndex = 0; DeviceIndex < nEntries; DeviceIndex++)
+       {
+               if (HandleTable[DeviceIndex].hDevice == INVALID_HANDLE_VALUE)
+                       break;
+       }
+
+       if (DeviceIndex >= nEntries)
+       {
+               PHANDLE_ENTRY pNewTable;
+
+               nEntries += 4;
+
+               if (HandleTable == NULL)
+               {
+                       pNewTable = (PHANDLE_ENTRY)malloc(nEntries * sizeof(HANDLE_ENTRY));
+               }
+               else
+               {
+                       pNewTable = (PHANDLE_ENTRY)realloc(HandleTable, nEntries * sizeof(HANDLE_ENTRY));
+               }
+
+               if (pNewTable == NULL)
+               {
+                       FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
+               }
+
+               HandleTable = pNewTable;
+       }
+
+       for (index = 0; DeviceName[index] != '\0'; index++)
+       {
+               if (DeviceName[index] == ':')
+                       nColons++;
+               else if (DeviceName[index] < '0' || DeviceName[index] > '9')
+                       break;
+       }
+
+       if (DeviceName[index] == '\0' && nColons == 3 && 
+               sscanf(DeviceName, "%d:%d:%d:%d", &port, &path, &target, &lun) == 4)
+       {
+               HandleTable[DeviceIndex].PortId = (UCHAR)port;
+               HandleTable[DeviceIndex].PathId = (UCHAR)path;
+               HandleTable[DeviceIndex].TargetId = (UCHAR)target;
+               HandleTable[DeviceIndex].Lun = (UCHAR)lun;
+
+               sprintf(szDevicePath, "\\\\.\\scsi%d:", port);
+       }
+       else 
+       {
+               int nPrefixLength = 0;
+
+               if (DeviceName[0] != '\\') {
+                       memcpy(szDevicePath, "\\\\.\\", 4 * sizeof(TCHAR));
+                       nPrefixLength = 4;
+               }
+
+               HandleTable[DeviceIndex].PortId = 0;
+               HandleTable[DeviceIndex].PathId = 0;
+               HandleTable[DeviceIndex].TargetId = 0;
+               HandleTable[DeviceIndex].Lun = 0;
+
+               strncpy(&szDevicePath[nPrefixLength], 
+                               DeviceName, 
+                               sizeof(szDevicePath) / sizeof(TCHAR) - nPrefixLength - 1);
+
+               szDevicePath[sizeof(szDevicePath) / sizeof(TCHAR) - 1] = '\0';
+       }
+
+       HandleTable[DeviceIndex].hDevice = CreateFile(szDevicePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+
+       if (HandleTable[DeviceIndex].hDevice == INVALID_HANDLE_VALUE)
+       {
+               DWORD dwError = GetLastError();
+
+#if DEBUG
+               LPSTR lpszMessage;
+
+               FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, 0, (LPSTR)&lpszMessage, 0, NULL);
+               fputs(lpszMessage, stderr);
+#endif
+
+               switch (dwError)
+               {
+               case ERROR_FILE_NOT_FOUND:
+               case ERROR_PATH_NOT_FOUND:
+                       errno = ENOENT;
+                       break;
+
+               case ERROR_TOO_MANY_OPEN_FILES:
+                       errno =  EMFILE;
+                       break;
+
+               default:
+               case ERROR_ACCESS_DENIED:
+               case ERROR_SHARING_VIOLATION:
+               case ERROR_LOCK_VIOLATION:
+               case ERROR_INVALID_NAME:
+                       errno = EACCES;
+                       break;
+
+               case ERROR_FILE_EXISTS:
+                       errno = EEXIST;
+                       break;
+
+               case ERROR_INVALID_PARAMETER:
+                       errno = EINVAL;
+                       break;
+               }
+
+               FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
+       }
+
+       return DeviceIndex;
+}
+
+static int scsi_timeout = SCSI_DEFAULT_TIMEOUT;
+
+void SCSI_Set_Timeout(int secs)
+{
+       if (secs > SCSI_MAX_TIMEOUT)
+       {
+               secs = SCSI_MAX_TIMEOUT;
+       }
+
+       scsi_timeout = secs;
+}
+void SCSI_Default_Timeout(void)
+{
+       scsi_timeout = SCSI_DEFAULT_TIMEOUT;
+}
+
+void SCSI_CloseDevice(char *DeviceName, DEVICE_TYPE DeviceFD)
+{
+       if (DeviceFD < nEntries)
+       {
+               CloseHandle(HandleTable[DeviceFD].hDevice);
+               HandleTable[DeviceFD].hDevice = INVALID_HANDLE_VALUE;
+       }
+       else
+       {
+               errno = EBADF;
+               FatalError("cannot close SCSI device '%s' - %m\n", DeviceName);
+       }
+}
+
+
+/* Get the SCSI ID and LUN... */
+scsi_id_t *SCSI_GetIDLun(DEVICE_TYPE fd)
+{
+       scsi_id_t *             retval;
+
+       SCSI_ADDRESS    ScsiAddress;
+       BOOL                    bResult;
+       DWORD                   dwBytesReturned;
+
+       if (fd < nEntries)
+       {
+               retval = (scsi_id_t *)xmalloc(sizeof(scsi_id_t));
+               retval->id = HandleTable[fd].TargetId;
+               retval->lun = HandleTable[fd].Lun;
+
+#ifdef DEBUG
+               fprintf(stderr,"SCSI:ID=%d LUN=%d\n", retval->id, retval->lun);
+#endif
+               return retval;
+       }
+       else
+       {
+               errno = EBADF;
+               FatalError("cannot close SCSI device - %m\n");
+       }
+
+       memset(&ScsiAddress, 0, sizeof(ScsiAddress));
+
+       ScsiAddress.Length = sizeof(ScsiAddress);
+
+       bResult = DeviceIoControl(      HandleTable[fd].hDevice, 
+                                                               IOCTL_SCSI_GET_ADDRESS, 
+                                                               &ScsiAddress, sizeof(ScsiAddress), 
+                                                               &ScsiAddress, sizeof(ScsiAddress), 
+                                                               &dwBytesReturned, 
+                                                               NULL);
+
+       if (!bResult)
+       {
+               return NULL;
+       }
+
+       retval = (scsi_id_t *)xmalloc(sizeof(scsi_id_t));
+       retval->id = ScsiAddress.TargetId;
+       retval->lun = ScsiAddress.Lun;
+
+#ifdef DEBUG
+       fprintf(stderr,"SCSI:ID=%d LUN=%d\n",retval->id,retval->lun);
+#endif
+       return retval;
+}
+
+int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
+                                               Direction_T Direction,
+                                               CDB_T *CDB,
+                                               int CDB_Length,
+                                               void *DataBuffer,
+                                               int DataBufferLength,
+                                               RequestSense_T *RequestSense)
+{
+       PSCSI_PASS_THROUGH ScsiPassThrough;
+
+       const DWORD     dwDataBufferOffset = sizeof(SCSI_PASS_THROUGH) + (sizeof(RequestSense_T) + 3) / 4 * 4;
+       const DWORD     dwBufferSize = dwDataBufferOffset + DataBufferLength;
+
+       BOOL            bResult;
+       DWORD           dwBytesReturned;
+       DWORD           dwInputLength;
+       DWORD           dwOutputLength;
+
+       if (DeviceFD >= nEntries || HandleTable[DeviceFD].hDevice == INVALID_HANDLE_VALUE)
+       {
+               errno = EBADF;
+               return -1;
+       }
+
+       ScsiPassThrough = (PSCSI_PASS_THROUGH)malloc(dwBufferSize);
+
+       memset(ScsiPassThrough, 0, dwDataBufferOffset);
+
+       ScsiPassThrough->Length = sizeof(SCSI_PASS_THROUGH);
+
+       ScsiPassThrough->PathId = HandleTable[DeviceFD].PathId;
+       ScsiPassThrough->TargetId = HandleTable[DeviceFD].TargetId;
+       ScsiPassThrough->Lun = HandleTable[DeviceFD].Lun;
+       ScsiPassThrough->CdbLength = (UCHAR)CDB_Length;
+       ScsiPassThrough->DataIn = Direction == Input;
+       ScsiPassThrough->DataBufferOffset = dwDataBufferOffset;
+       ScsiPassThrough->DataTransferLength = DataBufferLength;
+       ScsiPassThrough->SenseInfoOffset = sizeof(SCSI_PASS_THROUGH);
+       ScsiPassThrough->SenseInfoLength = sizeof(RequestSense_T);
+       ScsiPassThrough->TimeOutValue = scsi_timeout;
+
+       memcpy(ScsiPassThrough->Cdb, CDB, CDB_Length);
+       dwBytesReturned = 0;
+
+       if (Direction == Output)
+       {
+               memcpy((void *)(((char *)ScsiPassThrough) + dwDataBufferOffset), DataBuffer, DataBufferLength);
+               dwInputLength = dwBufferSize;
+               dwOutputLength = dwDataBufferOffset;
+       }
+       else
+       {
+               dwInputLength = sizeof(SCSI_PASS_THROUGH);
+               dwOutputLength = dwBufferSize;
+       }
+
+       bResult = DeviceIoControl(      HandleTable[DeviceFD].hDevice, 
+                                                               IOCTL_SCSI_PASS_THROUGH, 
+                                                               ScsiPassThrough, dwInputLength, 
+                                                               ScsiPassThrough, dwOutputLength, 
+                                                               &dwBytesReturned, 
+                                                               NULL);
+       if (bResult)
+       {
+               if (ScsiPassThrough->ScsiStatus != 0)
+               {
+                       memcpy(RequestSense, &ScsiPassThrough[1], sizeof(RequestSense_T));
+#if DEBUG
+                       fprintf(stderr, "Command failed - ScsiStatus = %d\n", ScsiPassThrough->ScsiStatus);
+                       PrintRequestSense(RequestSense);
+#endif
+                       bResult = false;
+               }
+               else
+               {
+                       if (Direction == Input)
+                       {
+                               memcpy( DataBuffer, 
+                                               (void *)(((char *)ScsiPassThrough) + dwDataBufferOffset),
+                                               DataBufferLength);
+                       }
+               }
+       }
+       else
+       {
+#if DEBUG
+               DWORD   dwError = GetLastError();
+               LPSTR   lpszMessage;
+
+               FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, 0, (LPSTR)&lpszMessage, 0, NULL);
+               fputs(lpszMessage, stderr);
+               LocalFree(lpszMessage);
+#endif
+
+               memset(RequestSense, 0, sizeof(RequestSense_T));
+       }
+
+       free(ScsiPassThrough);
+
+       return bResult ? 0 : -1;
+}
diff --git a/scsieject.1 b/scsieject.1
new file mode 100644 (file)
index 0000000..fb6e117
--- /dev/null
@@ -0,0 +1,116 @@
+.\" scsieject.1  Document Copyright 2007 Robert Nelson
+.\"
+.\" This is free documentation; you can redistribute it and/or
+.\" modify it under the terms of the GNU General Public License as
+.\" published by the Free Software Foundation; either version 2 of
+.\" the License, or (at your option) any later version.
+.\"
+.\" The GNU General Public License's references to "object code"
+.\" and "executables" are to be interpreted as the output of any
+.\" document formatting or typesetting system, including
+.\" intermediate and printed output.
+.\"
+.\" This manual is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public
+.\" License along with this manual; if not, write to the Free
+.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+.\" USA.
+.\"
+.TH scsieject 1 scsieject1.0
+.SH NAME
+scsieject \- control SCSI tape devices 
+.SH SYNOPSIS
+scsieject [-f <scsi-generic-device>] commands
+.SH DESCRIPTION
+The 
+.B scsieject
+command controls SCSI devices in a platform-independent
+manner. As long as 'mtx' works on the platform, so does 'scsieject'. 
+.SH OPTIONS
+The first argument, given following
+.B -f
+, is the SCSI generic device corresponding to your tape drive.
+Consult your operating system's documentation for more information (for
+example, under Linux these are generally /dev/sg0 through /dev/sg15, 
+under FreeBSD these are /dev/pass0 through /dev/passX. Under Solaris
+this is usually the same as your tape drive (Solaris has a SCSI passthrough
+ioctl). You can set the STAPE or TAPE environment variable rather
+than use -f.
+.P
+.SH COMMANDS
+.TP 10
+.B load
+Load the medium into the drive.  When this command is issued to a CD/DVD drive 
+and the tray is extended the tray will be retracted if the drive is capable of it.
+
+.TP 10
+.B unload
+Unload the medium from the drive (also known as eject).  When this command is issued 
+to a CD/DVD drive or a tape drive the media will be ejected if the device supports it.
+
+.TP 10
+.B start
+Start the device.  Some devices require a start command after a media changer has 
+loaded new media into the device.
+
+.TP 10
+.B stop
+Stop the device.  Some devices require a stop command prior to unloading the medium 
+from the device when using a media changer.
+
+.TP 10
+.B lock
+Lock the device.  Locks the device so that the medium cannot be removed manually.
+
+.TP 10
+.B unlock
+Unlock the device.  Unlocks the device so that the medium can be removed manually.
+
+.SH AUTHORS
+This program was written by Robert Nelson <robertnelson@users.sourceforge.net> 
+based on the scsitape program written by Eric Lee Green <eric@badtux.org>. 
+Major portions of the 'mtxl.c' library used herein were written by
+Leonard Zubkoff. 
+.P
+
+.SH HINTS
+Under Linux, 
+.B cat /proc/scsi/scsi
+will tell you what SCSI devices you have.
+You can then refer to them as 
+.B /dev/sga,
+.B /dev/sgb, 
+etc. by the order they
+are reported.
+.P
+Under FreeBSD, 
+.B camcontrol devlist
+will tell you what SCSI devices you
+have, along with which 
+.B pass
+device controls them.
+.P
+Under Solaris 7 and 8,
+.B /usr/sbin/devfsadm -C
+will clean up your /devices directory. Then
+.B find /devices -name 'st@*' -print 
+will return a list of all tape drives. /dev on Solaris is apparently only
+of historical interest. 
+
+.SH BUGS AND LIMITATIONS
+There are no known bugs or limitations.
+
+.SH AVAILABILITY
+This version of 
+.B scsieject
+is currently being maintained by Robert Nelson <robertnelson@users.sourceforge.net> 
+as part of the 'mtx' suite of programs. The 'mtx' home page is 
+http://mtx.sourceforge.net and the actual code is currently available there and via 
+SVN from http://sourceforge.net/projects/mtx. 
+
+.SH SEE ALSO
+.BR loaderinfo (1), tapeinfo (1), mtx (1)
diff --git a/scsieject.c b/scsieject.c
new file mode 100644 (file)
index 0000000..7943035
--- /dev/null
@@ -0,0 +1,255 @@
+/* Copyright 2007, Robert Nelson\r
+ *   Released under terms of the GNU General Public License as\r
+ * required by the license on 'mtxl.c'.\r
+ * $Date: 2007-01-28 19:23:33 -0800 (Sun, 28 Jan 2007) $\r
+ * $Revision: 125 $\r
+ */\r
+\r
+/* This is a generic SCSI device control program. It operates by\r
+ * directly sending commands to the device.\r
+ */\r
+\r
+/* \r
+ *     Commands:\r
+ *             load -- Load medium\r
+ *             unload -- Unload medium\r
+ *             start -- Start device\r
+ *             stop -- Stop device\r
+ *             lock -- Lock medium\r
+ *             unlock -- Unlock medium\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+\r
+#include "mtx.h"\r
+#include "mtxl.h"\r
+\r
+#if HAVE_UNISTD_H\r
+#include <unistd.h>\r
+#endif\r
+\r
+#if HAVE_SYS_TYPES_H\r
+#include <sys/types.h>\r
+#endif\r
+\r
+#ifdef _MSC_VER\r
+#include <io.h>\r
+#endif\r
+\r
+char *argv0;\r
+\r
+/* the device handle we're operating upon. */\r
+static char *device;  /* the device name. */\r
+static DEVICE_TYPE DeviceFD = (DEVICE_TYPE) -1;\r
+\r
+static int S_load(void);\r
+static int S_unload(void);\r
+static int S_start(void);\r
+static int S_stop(void);\r
+static int S_lock(void);\r
+static int S_unlock(void);\r
+\r
+struct command_table_struct\r
+{\r
+       char *name;\r
+       int (*command)(void);\r
+}\r
+       command_table[] =\r
+{\r
+       { "load", S_load },\r
+       { "unload", S_unload },\r
+       { "start", S_start },\r
+       { "stop", S_stop },\r
+       { "lock", S_lock },\r
+       { "unlock", S_unlock },\r
+       { NULL, NULL } /* terminate list */\r
+};\r
+\r
+void Usage(void)\r
+{\r
+       FatalError("Usage: scsieject -f <generic-device> <command> where <command> is:\n load | unload | start | stop | lock | unlock\n");\r
+}\r
+\r
+/* open_device() -- set the 'DeviceFD' variable.... */\r
+void open_device(void)\r
+{\r
+       if (DeviceFD != -1)\r
+       {\r
+               SCSI_CloseDevice("Unknown", DeviceFD);\r
+       }\r
+\r
+       DeviceFD = SCSI_OpenDevice(device);\r
+}\r
+\r
+/* we see if we've got a file open. If not, we open one :-(. Then\r
+ * we execute the actual command. Or not :-(. \r
+ */ \r
+int execute_command(struct command_table_struct *command)\r
+{\r
+       /*\r
+        * If the device is not already open, then open it from the \r
+        * environment.\r
+        */\r
+       if (DeviceFD == -1)\r
+       {\r
+               /* try to get it from STAPE or TAPE environment variable... */\r
+               if ((device = getenv("STAPE")) == NULL &&\r
+                       (device = getenv("TAPE")) == NULL)\r
+               {\r
+                       Usage();        /* Doesn't return */\r
+               }\r
+\r
+               open_device();\r
+       }\r
+\r
+       /* okay, now to execute the command... */\r
+       return command->command();\r
+}\r
+\r
+\r
+/* parse_args():\r
+ * Basically, we are parsing argv/argc. We can have multiple commands\r
+ * on a line, such as "load start" to load a tape and start the device.\r
+ * We execute these commands one at a time as we come to them. If we don't \r
+ * have a -f at the start and the default device isn't defined in a TAPE or \r
+ * STAPE environment variable, we exit.\r
+ */ \r
+\r
+int parse_args(int argc, char **argv)\r
+{\r
+       int index, retval;\r
+       struct command_table_struct *command;\r
+\r
+       argv0 = argv[0];\r
+\r
+       for (index = 1; index < argc; index++)\r
+       {\r
+               if (strcmp(argv[index], "-f") == 0)\r
+               {\r
+                       index++;\r
+                       if (index >= argc)\r
+                       {\r
+                               Usage();        /* Doesn't return */\r
+                       }\r
+                       device = argv[index];\r
+                       open_device();\r
+               }\r
+               else\r
+               {\r
+                       for (command = &command_table[0]; command->name != NULL; command++)\r
+                       {\r
+                               if (strcmp(command->name, argv[index]) == 0)\r
+                               {\r
+                                       break;\r
+                               }\r
+                       }\r
+\r
+                       if (command->name == NULL)\r
+                       {\r
+                               Usage();        /* Doesn't return */\r
+                       }\r
+\r
+                       retval = execute_command(command);\r
+\r
+                       if (retval < 0)\r
+                       {\r
+                               /* Command failed, we probably shouldn't continue */\r
+                               return retval;\r
+                       }\r
+               }\r
+       }\r
+\r
+       return 0;\r
+}\r
+\r
+int S_load(void)\r
+{\r
+       int result = LoadUnload(DeviceFD, 1);\r
+\r
+       if (result < 0)\r
+       {\r
+               fputs("scsieject: load failed\n", stderr);\r
+               fflush(stderr);\r
+       }\r
+\r
+       return result;\r
+}\r
+\r
+int S_unload(void)\r
+{\r
+       int result = LoadUnload(DeviceFD, 0);\r
+\r
+       if (result < 0)\r
+       {\r
+               fputs("scsieject: unload failed\n", stderr);\r
+               fflush(stderr);\r
+       }\r
+\r
+       return result;\r
+}\r
+\r
+int S_start(void)\r
+{\r
+       int result = StartStop(DeviceFD, 1);\r
+\r
+       if (result < 0)\r
+       {\r
+               fputs("scsieject: start failed\n", stderr);\r
+               fflush(stderr);\r
+       }\r
+\r
+       return result;\r
+}\r
+\r
+int S_stop(void)\r
+{\r
+       int result = StartStop(DeviceFD, 0);\r
+\r
+       if (result < 0)\r
+       {\r
+               fputs("scsieject: stop failed\n", stderr);\r
+               fflush(stderr);\r
+       }\r
+\r
+       return result;\r
+}\r
+\r
+int S_lock(void)\r
+{\r
+       int result = LockUnlock(DeviceFD, 1);\r
+\r
+       if (result < 0)\r
+       {\r
+               fputs("scsieject: lock failed\n", stderr);\r
+               fflush(stderr);\r
+       }\r
+\r
+       return result;\r
+}\r
+\r
+int S_unlock(void)\r
+{\r
+       int result = LockUnlock(DeviceFD, 0);\r
+\r
+       if (result < 0)\r
+       {\r
+               fputs("scsieject: unlock failed\n", stderr);\r
+               fflush(stderr);\r
+       }\r
+\r
+       return result;\r
+}\r
+\r
+/* See parse_args for the scoop. parse_args does all. */\r
+int main(int argc, char **argv)\r
+{\r
+       parse_args(argc, argv);\r
+\r
+       if (device)\r
+       {\r
+               SCSI_CloseDevice(device, DeviceFD);\r
+       }\r
+\r
+       exit(0);\r
+}\r
index 2f9d7e9716e784f3a73a7bef6097ed4f0192b8f8..b9425abac48ff30bc30580aef3ac054d92994aa3 100644 (file)
@@ -102,7 +102,7 @@ partition or end of tape.
 
 
 .SH AUTHORS
-This program was written by Eric Lee Green <eric@estinc.com>. 
+This program was written by Eric Lee Green <eric@badtux.org>. 
 Major portions of the 'mtxl.c' library used herein were written by
 Leonard Zubkoff. 
 .P
@@ -118,7 +118,6 @@ names considerably shorter than the rather sesquipedalian 'mtx'
 identifiers). As required by 'mtxl.c', these routines are licensed
 under the GNU General Public License.
 
-
 .SH HINTS
 Under Linux, 
 .B cat /proc/scsi/scsi
@@ -163,18 +162,17 @@ attempt to intermingle scsitape commands with native tape driver
 operations. Note that BRU 16.1 for Solaris (and possibly others, but
 Solaris I know about) will have a 'scsi' keyword to bypass the 
 native tape driver and write via direct uscsi commands, so if you use
-'scsitape' to bypass the flaws of the native Solaris driver, you can use
+\'scsitape\' to bypass the flaws of the native Solaris driver, you can use
 BRU 16.1 to write your actual tape archives. (Assuming that BRU 16.1
 has been released at the time that you read this). 
 
 .SH AVAILABILITY
 This version of 
 .B scsitape
-is currently being maintained by Eric Lee Green <eric@badtux.org> formerly of
-Enhanced Software Technologies Inc. as part of the 'mtx' suite of
-programs. The 'mtx' home page is http://mtx.sourceforge.net and the
-actual code is currently available there and via CVS from
-http://sourceforge.net/projects/mtx . 
+is currently being maintained by Robert Nelson <robertnelson@users.sourceforge.net> 
+as part of the 'mtx' suite of programs. The 'mtx' home page is 
+http://mtx.sourceforge.net and the actual code is currently available there and via 
+SVN from http://sourceforge.net/projects/mtx. 
 
 .SH SEE ALSO
-.BR tapeinfo (1), mtx (1)
+.BR loaderinfo (1), tapeinfo (1), mtx (1)
index 1ff389295eea1d7100917a41aa9a363d28e3b623..8a7b2ca85f33475b6f599f93047e3503472ed819 100644 (file)
@@ -1,8 +1,8 @@
 /* Copyright 2001 Enhanced Software Technologies Inc.
  *   Released under terms of the GNU General Public License as
  * required by the license on 'mtxl.c'.
- * $Date: 2001/06/05 17:10:27 $
- * $Revision: 1.1.1.1 $
+ * $Date: 2007-03-24 18:14:01 -0700 (Sat, 24 Mar 2007) $
+ * $Revision: 166 $
  */
 
 /* This is a generic SCSI tape control program. It operates by
 /*#define DEBUG 1 */
 
 /* 
-   Commands:
-         setblk <n> -- set the block size to <n>
-         fsf <n> -- go forward by <n> filemarks
-         bsf <n> -- go backward by <n> filemarks
-         eod  -- go to end of data
-         rewind -- rewind back to start of data
-         eject  -- rewind, then eject the tape. 
-        erase  -- (short) erase the tape (we have no long erase)
-         mark <n> -- write <n> filemarks.
-         seek <n> -- seek to position <n>.
-
-        write <blksize> <-- write blocks from stdin to the tape 
-         read  [<blksize>] [<#blocks/#bytes>] -- read blocks from tape, write to stdout. 
-
-   See the 'tapeinfo' program for status info about the tape drive.
+       Commands:
+               setblk <n> -- set the block size to <n>
+               fsf <n> -- go forward by <n> filemarks
+               bsf <n> -- go backward by <n> filemarks
+               eod  -- go to end of data
+               rewind -- rewind back to start of data
+               eject  -- rewind, then eject the tape. 
+               erase  -- (short) erase the tape (we have no long erase)
+               mark <n> -- write <n> filemarks.
+               seek <n> -- seek to position <n>.
+
+               write <blksize> <-- write blocks from stdin to the tape 
+               read  [<blksize>] [<#blocks/#bytes>] -- read blocks from tape, write to stdout. 
+
+       See the 'tapeinfo' program for status info about the tape drive.
 
  */
 
 #include "mtx.h"
 #include "mtxl.h"
 
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
+
+#if HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif
+
+#if HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
+#endif
+
+#if HAVE_SYS_MTIO_H
 #include <sys/mtio.h> /* will try issuing some ioctls for Solaris, sigh. */
+#endif
+
+#ifdef _MSC_VER
+#include <io.h>
+#endif
 
 void Usage(void) {
   FatalError("Usage: scsitape -f <generic-device> <command> where <command> is:\n setblk <n> | fsf <n> | bsf <n> | eod | rewind | eject | mark <n> |\n  seek <n> | read [<blksize> [<numblocks]] | write [<blocksize>] \n");
@@ -54,8 +69,8 @@ void Usage(void) {
 static int arg[4];  /* the argument for the command, sigh. */
 
 /* the device handle we're operating upon, sigh. */
-static unsigned char *device;  /* the text of the device thingy. */
-static DEVICE_TYPE MediumChangerFD = (DEVICE_TYPE) 0;
+static char *device;  /* the text of the device thingy. */
+static DEVICE_TYPE MediumChangerFD = (DEVICE_TYPE) -1;
 
 
 
@@ -75,109 +90,78 @@ static int S_write(void);
 
 
 struct command_table_struct {
-  int num_args;
-  char *name;
-  int (*command)(void);
+       int num_args;
+       char *name;
+       int (*command)(void);
 } command_table[] = {
-  { 1, "setblk", S_setblk },
-  { 1, "fsf", S_fsf },
-  { 1, "bsf", S_bsf },
-  { 0, "eod", S_eod },
-  { 0, "rewind", S_rewind },
-  { 0, "eject", S_eject },
-  { 0, "reten", S_reten },
-  { 0, "erase", S_erase },
-  { 1, "mark", S_mark },
-  { 1, "seek", S_seek },
-  { 2, "read", S_read },
-  { 2, "write",S_write }
+       { 1, "setblk", S_setblk },
+       { 1, "fsf", S_fsf },
+       { 1, "bsf", S_bsf },
+       { 0, "eod", S_eod },
+       { 0, "rewind", S_rewind },
+       { 0, "eject", S_eject },
+       { 0, "reten", S_reten },
+       { 0, "erase", S_erase },
+       { 1, "mark", S_mark },
+       { 1, "seek", S_seek },
+       { 2, "read", S_read },
+       { 2, "write",S_write },
+       { 0, NULL, NULL } /* terminate list */
 };
 
 char *argv0;
 
-/* A table for printing out the peripheral device type as ASCII. */ 
-static char *PeripheralDeviceType[32] = {
-  "Disk Drive",
-  "Tape Drive",
-  "Printer",
-  "Processor",
-  "Write-once",
-  "CD-ROM",
-  "Scanner",
-  "Optical",
-  "Medium Changer",
-  "Communications",
-  "ASC IT8",
-  "ASC IT8",
-  "RAID Array",
-  "Enclosure Services",
-  "OCR/W",
-  "Bridging Expander", /* 0x10 */
-  "Reserved",  /* 0x11 */
-  "Reserved", /* 0x12 */
-  "Reserved",  /* 0x13 */
-  "Reserved",  /* 0x14 */
-  "Reserved",  /* 0x15 */
-  "Reserved",  /* 0x16 */
-  "Reserved",  /* 0x17 */
-  "Reserved",  /* 0x18 */
-  "Reserved",  /* 0x19 */
-  "Reserved",  /* 0x1a */
-  "Reserved",  /* 0x1b */
-  "Reserved",  /* 0x1c */
-  "Reserved",  /* 0x1d */
-  "Reserved",  /* 0x1e */
-  "Unknown"    /* 0x1f */
-};
-
-
 
 /* open_device() -- set the 'fh' variable.... */
-void open_device(void) {
-
-  if (MediumChangerFD) {
-    SCSI_CloseDevice("Unknown",MediumChangerFD);  /* close it, sigh...  new device now! */
-  }
-
-  MediumChangerFD = SCSI_OpenDevice(device);
+void open_device(void)
+{
+       if (MediumChangerFD != -1)
+       {
+               SCSI_CloseDevice("Unknown",MediumChangerFD);  /* close it, sigh...  new device now! */
+       }
 
+       MediumChangerFD = SCSI_OpenDevice(device);
 }
 
-static int get_arg(char *arg) {
-  int retval=-1;
+static int get_arg(char *arg)
+{
+       int retval=-1;
 
-  if (*arg < '0' || *arg > '9') {
-    return -1;  /* sorry! */
-  }
+       if (*arg < '0' || *arg > '9')
+       {
+               return -1;  /* sorry! */
+       }
 
-  retval=atoi(arg);
-  return retval;
+       retval=atoi(arg);
+       return retval;
 }
 
 
 /* we see if we've got a file open. If not, we open one :-(. Then
  * we execute the actual command. Or not :-(. 
  */ 
-int execute_command(struct command_table_struct *command) {
-
-  /* if the device is not already open, then open it from the 
-   * environment.
-   */
-  if (!MediumChangerFD) {
-    /* try to get it from STAPE or TAPE environment variable... */
-    device=getenv("STAPE");
-    if (device==NULL) {
-      device=getenv("TAPE");
-      if (device==NULL) {
-       Usage();
-      }
-    }
-    open_device();
-  }
-
-
-  /* okay, now to execute the command... */
-  return command->command();
+int execute_command(struct command_table_struct *command)
+{
+       /* if the device is not already open, then open it from the 
+       * environment.
+       */
+       if (!MediumChangerFD == -1)
+       {
+               /* try to get it from STAPE or TAPE environment variable... */
+               device = getenv("STAPE");
+               if (device == NULL)
+               {
+                       device = getenv("TAPE");
+                       if (device == NULL)
+                       {
+                               Usage();
+                       }
+               }
+               open_device();
+       }
+
+       /* okay, now to execute the command... */
+       return command->command();
 }
 
 
@@ -190,55 +174,69 @@ int execute_command(struct command_table_struct *command) {
  * in the cabinet). 
  */ 
 
-int parse_args(int argc,char **argv) {
-  int i,cmd_tbl_idx,retval,arg_idx;
-  struct command_table_struct *command;
-
-  i=1;
-  arg_idx=0;
-  while (i<argc) {
-    if (strcmp(argv[i],"-f") == 0) {
-      i++;
-      if (i>=argc) {
-       Usage();
-      }
-      device=argv[i++];
-      open_device(); /* open the device and do a status scan on it... */
-    } else {
-      cmd_tbl_idx=0;
-      command=&command_table[0]; /* default to the first command... */
-      command=&command_table[cmd_tbl_idx];
-      while (command->name) {
-       if (!strcmp(command->name,argv[i])) {
-         /* we have a match... */
-         break;
+int parse_args(int argc, char **argv)
+{
+       int i, cmd_tbl_idx,retval,arg_idx;
+       struct command_table_struct *command;
+
+       i=1;
+       arg_idx = 0;
+       while (i < argc)
+       {
+               if (strcmp(argv[i],"-f") == 0)
+               {
+                       i++;
+                       if (i >= argc)
+                       {
+                               Usage();
+                       }
+                       device = argv[i++];
+                       open_device(); /* open the device and do a status scan on it... */
+               }
+               else
+               {
+                       cmd_tbl_idx=0;
+                       command = &command_table[0]; /* default to the first command... */
+                       command = &command_table[cmd_tbl_idx];
+                       while (command->name)
+                       {
+                               if (strcmp(command->name,argv[i]) == 0)
+                               {
+                                       /* we have a match... */
+                                       break;
+                               }
+                               /* otherwise we don't have a match... */
+                               cmd_tbl_idx++;
+                               command = &command_table[cmd_tbl_idx];
+                       }
+                       /* if it's not a command, exit.... */
+                       if (command->name == NULL)
+                       {
+                               Usage();
+                       }
+                       i++;  /* go to the next argument, if possible... */
+                       /* see if we need to gather arguments, though! */
+                       arg1 = -1; /* default it to something */
+                       for (arg_idx=0;arg_idx < command->num_args ; arg_idx++)
+                       {
+                               if (i < argc)
+                               {
+                                       arg[arg_idx] = get_arg(argv[i]);
+                                       if (arg[arg_idx] !=  -1)
+                                       {
+                                               i++; /* increment i over the next cmd. */
+                                       }
+                               }
+                               else
+                               {
+                                       arg[arg_idx] = 0; /* default to 0 setmarks or whatever */
+                               }
+                       }
+                       retval=execute_command(command);  /* execute_command handles 'stuff' */
+                       exit(retval);
+               }
        }
-       /* otherwise we don't have a match... */
-       cmd_tbl_idx++;
-       command=&command_table[cmd_tbl_idx];
-      }
-      /* if it's not a command, exit.... */
-      if (!command->name) {
-       Usage();
-      }
-      i++;  /* go to the next argument, if possible... */
-      /* see if we need to gather arguments, though! */
-      arg1=-1; /* default it to something */
-      for (arg_idx=0;arg_idx < command->num_args ; arg_idx++) {
-       if (i < argc) {
-         arg[arg_idx]=get_arg(argv[i]);
-         if (arg[arg_idx] !=  -1) {
-           i++; /* increment i over the next cmd. */
-         }
-       } else {
-         arg[arg_idx]=0; /* default to 0 setmarks or whatever */
-       } 
-      }
-      retval=execute_command(command);  /* execute_command handles 'stuff' */
-      exit(retval);
-    }
-  }
-  return 0; /* should never get here */
+       return 0; /* should never get here */
 }
 
 /* For Linux, this allows us to do a short erase on a tape (sigh!).
@@ -248,21 +246,24 @@ int parse_args(int argc,char **argv) {
  * driver. Note that to do an erase, you must first rewind!
 
  */
-static int S_erase(void) {
-  int retval;
-  RequestSense_T *RequestSense;
-
-  retval=S_rewind();
-  if (retval) {
-    return retval;  /* we have an exit status :-(. */
-  } 
-
-  RequestSense=Erase(MediumChangerFD);
-  if (RequestSense) {
-    PrintRequestSense(RequestSense);
-    exit(1);  /* exit with an error status. */
-  }
-  return 0;
+static int S_erase(void)
+{
+       int retval;
+       RequestSense_T *RequestSense;
+
+       retval=S_rewind();
+       if (retval)
+       {
+               return retval;  /* we have an exit status :-(. */
+       } 
+
+       RequestSense=Erase(MediumChangerFD);
+       if (RequestSense)
+       {
+               PrintRequestSense(RequestSense);
+               exit(1);  /* exit with an error status. */
+       }
+       return 0;
 }
 
 /* This should eject a tape or magazine, depending upon the device sent
@@ -270,91 +271,97 @@ static int S_erase(void) {
  */
 static int S_eject(void)
 {
-int i;
-  i=Eject(MediumChangerFD);
-  if (i<0) {
-    fprintf(stderr,"scsitape:eject failed\n");
-    fflush(stderr);
-  }
-  return i;  /* if it failed, well, sigh.... */
+       int i;
+       i = LoadUnload(MediumChangerFD, 0);
+       if ( i < 0)
+       {
+               fprintf(stderr,"scsitape:eject failed\n");
+               fflush(stderr);
+       }
+       return i;
 }
 
 
 
-
 /* We write a filemarks of 0 before going to grab position, in order
  * to insure that data in the buffer is not a problem. 
  */
 
-static int S_mark(void) {
-  RequestSense_T RequestSense; /* for result of ReadElementStatus */
-  CDB_T CDB;
-  unsigned char buffer[6];
-  int count=arg1; /* voila! */
-
-  CDB[0]=0x10;  /* SET_MARK */
-  CDB[1]=0;
-  CDB[2]=(count >> 16) & 0xff;
-  CDB[3]=(count >>8) & 0xff;
-  CDB[4]=count & 0xff;
-  CDB[5]=0; 
-
-  /* we really don't care if this command works or not, sigh.  */
-  slow_bzero((unsigned char *)&RequestSense,sizeof(RequestSense_T));
-  if (SCSI_ExecuteCommand(MediumChangerFD,Input,&CDB,6,buffer,0,&RequestSense)!=0){
-    PrintRequestSense(&RequestSense);
-    return 1;
-  }
-  return 0;
+static int S_mark(void)
+{
+       RequestSense_T RequestSense; /* for result of ReadElementStatus */
+       CDB_T CDB;
+       unsigned char buffer[6];
+       int count = arg1; /* voila! */
+
+       CDB[0] = 0x10;  /* SET_MARK */
+       CDB[1] = 0;
+       CDB[2] = (unsigned char)(count >> 16);
+       CDB[3] = (unsigned char)(count >> 8);
+       CDB[4] = (unsigned char)count;
+       CDB[5] = 0; 
+
+       /* we really don't care if this command works or not, sigh.  */
+       slow_bzero((char *)&RequestSense, sizeof(RequestSense_T));
+
+       if (SCSI_ExecuteCommand(MediumChangerFD, Input, &CDB, 6, buffer, 0, &RequestSense)!= 0)
+       {
+               PrintRequestSense(&RequestSense);
+               return 1;
+       }
+       return 0;
 }
 /* let's rewind to bod! 
  */
 
-static int S_rewind(void) {
-  RequestSense_T sense;
-  CDB_T CDB;
-  unsigned char buffer[6];
-
-  CDB[0]=0x01;  /* REWIND */
-  CDB[1]=0;
-  CDB[2]=0;
-  CDB[3]=0;
-  CDB[4]=0;
-  CDB[5]=0; 
-
-  /* we really don't care if this command works or not, sigh.  */
-  slow_bzero((unsigned char *)&sense,sizeof(RequestSense_T));
-  if (SCSI_ExecuteCommand(MediumChangerFD,Input,&CDB,6,buffer,0,&sense)!=0){
-    PrintRequestSense(&sense);
-    return 1;
-  }
-  return 0;
+static int S_rewind(void)
+{
+       RequestSense_T sense;
+       CDB_T CDB;
+       unsigned char buffer[6];
+
+       CDB[0] = 0x01;  /* REWIND */
+       CDB[1] = 0;
+       CDB[2] = 0;
+       CDB[3] = 0;
+       CDB[4] = 0;
+       CDB[5] = 0; 
+
+       /* we really don't care if this command works or not, sigh.  */
+       slow_bzero((char *)&sense,sizeof(RequestSense_T));
+       if (SCSI_ExecuteCommand(MediumChangerFD,Input,&CDB,6,buffer,0,&sense)!=0)
+       {
+               PrintRequestSense(&sense);
+               return 1;
+       }
+       return 0;
 }
 
 
 
 
 /* This is used for fsf and bsf. */
-static int Space(int count,int code){
-  RequestSense_T sense;
-  CDB_T CDB;
-  unsigned char buffer[6];
-
-  CDB[0]=0x11;  /* SET_MARK */
-  CDB[1]=code;
-  CDB[2]=(count >> 16) & 0xff;
-  CDB[3]=(count >>8) & 0xff;
-  CDB[4]=count & 0xff;
-  CDB[5]=0; 
-
-  /* we really don't care if this command works or not, sigh.  */
-  slow_bzero((unsigned char *)&sense,sizeof(RequestSense_T));
-  if (SCSI_ExecuteCommand(MediumChangerFD,Input,&CDB,6,buffer,0,&sense)!=0){
-    PrintRequestSense(&sense);
-    return 1;
-  }
-  return 0;
-  
+static int Space(int count, char code)
+{
+       RequestSense_T sense;
+       CDB_T CDB;
+       unsigned char buffer[6];
+
+       CDB[0] = 0x11;  /* SET_MARK */
+       CDB[1] = code;
+       CDB[2] = (unsigned char)(count >> 16);
+       CDB[3] = (unsigned char)(count >> 8);
+       CDB[4] = (unsigned char)count;
+       CDB[5] = 0; 
+
+       /* we really don't care if this command works or not, sigh.  */
+       slow_bzero((char *)&sense,sizeof(RequestSense_T));
+       if (SCSI_ExecuteCommand(MediumChangerFD, Input, &CDB, 6, buffer, 0, &sense) != 0)
+       {
+               PrintRequestSense(&sense);
+               return 1;
+       }
+       return 0;
 }
 
 
@@ -363,141 +370,150 @@ static int Space(int count,int code){
  * to insure that data in the buffer is not a problem. 
  */
 
-static int S_fsf(void) {
-  return Space(arg1,1); /* go forward! */
+static int S_fsf(void)
+{
+       return Space(arg1,1); /* go forward! */
 }
 
-static int S_bsf(void) {
-  return Space(-arg1,1); /* go backward! */
+static int S_bsf(void)
+{
+       return Space(-arg1,1); /* go backward! */
 }
 
-static int S_eod(void) {
-  return Space(0,3); /* go to eod! */
+static int S_eod(void)
+{
+       return Space(0,3); /* go to eod! */
 }
 
 /* sigh, abuse of the LOAD command...
 
  */
-static int S_reten(void) {
-  RequestSense_T sense;
-  CDB_T CDB;
-  unsigned char buffer[6];
-
-  CDB[0]=0x1b;  /* START_STOP */
-  CDB[1]=0; /* wait */
-  CDB[2]=0;
-  CDB[3]=0;
-  CDB[4]=3; /* reten. */ 
-  CDB[5]=0; 
-
-  /* we really don't care if this command works or not, sigh.  */
-  slow_bzero((unsigned char *)&sense,sizeof(RequestSense_T));
-  if (SCSI_ExecuteCommand(MediumChangerFD,Input,&CDB,6,buffer,0,&sense)!=0){
-    PrintRequestSense(&sense);
-    return 1;
-  }
-  return 0;
-
+static int S_reten(void)
+{
+       RequestSense_T sense;
+       CDB_T CDB;
+       unsigned char buffer[6];
+
+       CDB[0] = 0x1B;  /* START_STOP */
+       CDB[1] = 0; /* wait */
+       CDB[2] = 0;
+       CDB[3] = 0;
+       CDB[4] = 3; /* reten. */ 
+       CDB[5] = 0; 
+
+       /* we really don't care if this command works or not, sigh.  */
+       slow_bzero((char *)&sense, sizeof(RequestSense_T));
+       if (SCSI_ExecuteCommand(MediumChangerFD, Input, &CDB, 6, buffer, 0, &sense) != 0)
+       {
+               PrintRequestSense(&sense);
+               return 1;
+       }
+       return 0;
 }
 
 /* seek a position on the tape (sigh!) */
-static int S_seek(void){
-  RequestSense_T sense;
-  CDB_T CDB;
-  unsigned char buffer[6];
-  int count =  arg1;
-
-  /* printf("count=%d\n",arg1); */
-
-  CDB[0]=0x2b;  /* LOCATE */
-  CDB[1]=0;  /* Logical */
-  CDB[2]=0; /* padding */
-  CDB[3]=(count >> 24) & 0xff;
-  CDB[4]=(count >> 16) & 0xff;
-  CDB[5]=(count >>8) & 0xff;
-  CDB[6]=count & 0xff;
-  CDB[7]=0; 
-  CDB[8]=0; 
-  CDB[9]=0; 
-
-  /* we really don't care if this command works or not, sigh.  */
-  slow_bzero((unsigned char *)&sense,sizeof(RequestSense_T));
-  if (SCSI_ExecuteCommand(MediumChangerFD,Input,&CDB,10,buffer,0,&sense)!=0){
-    PrintRequestSense(&sense);
-    return 1;
-  }
-  return 0;
+static int S_seek(void)
+{
+       RequestSense_T sense;
+       CDB_T CDB;
+       unsigned char buffer[6];
+       int count =  arg1;
+
+       /* printf("count=%d\n",arg1); */
+
+       CDB[0] = 0x2B;  /* LOCATE */
+       CDB[1] = 0;  /* Logical */
+       CDB[2] = 0; /* padding */
+       CDB[3] = (unsigned char)(count >> 24);
+       CDB[4] = (unsigned char)(count >> 16);
+       CDB[5] = (unsigned char)(count >> 8);
+       CDB[6] = (unsigned char)count;
+       CDB[7] = 0; 
+       CDB[8] = 0; 
+       CDB[9] = 0; 
+
+       /* we really don't care if this command works or not, sigh.  */
+       slow_bzero((char *)&sense,sizeof(RequestSense_T));
+       if (SCSI_ExecuteCommand(MediumChangerFD, Input, &CDB, 10, buffer, 0, &sense) != 0)
+       {
+               PrintRequestSense(&sense);
+               return 1;
+       }
+       return 0;
 }
 
 #ifdef MTSRSZ
-static int Solaris_setblk(int fh,int count) {
-  /* we get here only if we have a MTSRSZ, which means Solaris. */
-  struct mtop mt_com;  /* the struct used for the MTIOCTOP ioctl */
-  int result;
-
-  /* okay, we have fh and count.... */
-  
-  /* Now to try the ioctl: */
-  mt_com.mt_op=MTSRSZ;
-  mt_com.mt_count=count;
-
-  /* surround the actual ioctl to enable threading, since fsf/etc. can be
-   * big time consumers and we want other threads to be able to run too. 
-   */
-  result=ioctl(fh, MTIOCTOP, (char *)&mt_com);
-
-  if (result < 0) {
-    return errno;
-  }
-
-  /* okay, we did okay. Return a value of None... */
-  return 0;
+static int Solaris_setblk(int fh,int count)
+{
+       /* we get here only if we have a MTSRSZ, which means Solaris. */
+       struct mtop mt_com;  /* the struct used for the MTIOCTOP ioctl */
+       int result;
+
+       /* okay, we have fh and count.... */
+
+       /* Now to try the ioctl: */
+       mt_com.mt_op=MTSRSZ;
+       mt_com.mt_count=count;
+
+       /* surround the actual ioctl to enable threading, since fsf/etc. can be
+        * big time consumers and we want other threads to be able to run too. 
+        */
+
+       result=ioctl(fh, MTIOCTOP, (char *)&mt_com);
+
+       if (result < 0)
+       {
+               return errno;
+       }
+
+       /* okay, we did okay. Return a value of None... */
+       return 0;
 }
-#endif  
+#endif
 
 
 /* okay, this is a write: we need to set the block size to something: */
-static int S_setblk(void) {
-  RequestSense_T sense;
-  CDB_T CDB;
-  unsigned char buffer[12];
-  unsigned int count = (unsigned int) arg1;
-
-  
-  CDB[0]=0x15;  /* MODE SELECT */
-  CDB[1]=0x10;  /* scsi2 */
-  CDB[2]=0; 
-  CDB[3]=0;
-  CDB[4]=12; /* length of data */
-  CDB[5]=0;
-
-  slow_bzero((unsigned char *)&sense,sizeof(RequestSense_T));
-  slow_bzero(buffer,12);
-
-  /* Now to set the mode page header: */
-  buffer[0]=0;
-  buffer[1]=0;
-  buffer[2]=0x10; /* we are in buffered mode now, people! */
-  buffer[3]=8; /* block descriptor length. */ 
-  buffer[4]=0; /* reset to default density, sigh. */ /* 0 */
-  buffer[5]=0; /* 1 */
-  buffer[6]=0; /* 2 */
-  buffer[7]=0; /* 3 */
-  buffer[8]=0; /* 4 */
-  buffer[9]=(count >> 16) & 0xff; /* 5 */
-  buffer[10]=(count >> 8) & 0xff; /* 6 */
-  buffer[11]= count & 0xff;  /* 7 */
-     
-  if (SCSI_ExecuteCommand(MediumChangerFD,Output,&CDB,6,buffer,12,&sense)!=0){
-    PrintRequestSense(&sense);
-    return 1;
-  }
+static int S_setblk(void)
+{
+       RequestSense_T sense;
+       CDB_T CDB;
+       char buffer[12];
+       unsigned int count = (unsigned int) arg1;
+
+       CDB[0] = 0x15;  /* MODE SELECT */
+       CDB[1] = 0x10;  /* scsi2 */
+       CDB[2] = 0; 
+       CDB[3] = 0;
+       CDB[4] = 12; /* length of data */
+       CDB[5] = 0;
+
+       slow_bzero((char *)&sense, sizeof(RequestSense_T));
+       slow_bzero(buffer, 12);
+
+       /* Now to set the mode page header: */
+       buffer[0] = 0;
+       buffer[1] = 0;
+       buffer[2] = 0x10; /* we are in buffered mode now, people! */
+       buffer[3] = 8; /* block descriptor length. */ 
+       buffer[4] = 0; /* reset to default density, sigh. */ /* 0 */
+       buffer[5] = 0; /* 1 */
+       buffer[6] = 0; /* 2 */
+       buffer[7] = 0; /* 3 */
+       buffer[8] = 0; /* 4 */
+       buffer[9] = (unsigned char)(count >> 16); /* 5 */
+       buffer[10] = (unsigned char)(count >> 8); /* 6 */
+       buffer[11] = (unsigned char)count;  /* 7 */
+
+       if (SCSI_ExecuteCommand(MediumChangerFD,Output,&CDB,6,buffer,12,&sense)!=0)
+       {
+               PrintRequestSense(&sense);
+               return 1;
+       }
 #ifdef MTSRSZ
-  /*   Solaris_setblk(MediumChangerFD,count);   */
+       /*   Solaris_setblk(MediumChangerFD,count);   */
 #endif
 
-  return 0;
+       return 0;
 }
 
 /*************************************************************************/
@@ -541,7 +557,7 @@ static int S_setblk(void) {
  * detect a short read while in variable block mode. We'll see.
  */
 #define SHORT_READ(s) (S_NO_SENSE((s)) && (s).ILI && (s).Valid &&  (s).AdditionalSenseCode==0  && (s).AdditionalSenseCodeQualifier==0)
-                      
+
 #define HIT_EOD(s) (S_BLANK_CHECK((s)) && (s).Valid)
 #define HIT_EOP(s) (S_MEDIUM_ERROR((s)) && (s).EOM && (s).Valid)
 #define HIT_EOM(s) ((s).EOM && (s).Valid)
@@ -553,196 +569,247 @@ static int S_setblk(void) {
  * we are in trouble anyhow. 
  */
 int SCSI_readt(DEVICE_TYPE fd, char * buf, unsigned int bufsize, unsigned int *len, unsigned int timeout) {
-  int rtnval;
-  CDB_T cmd;
-
-  int blockCount;
-  int info;
-  
-  RequestSense_T RequestSense;
-  
-  if (bufsize==0) { /* we are in variable block mode */
-    blockCount=MAX_READ_SIZE; /* variable block size. */
-  } else {
-    blockCount= *len / bufsize ;
-    if ((*len % bufsize) != 0) {
-      fprintf(stderr,"Error: Data (%d bytes) not even multiple of block size (%d bytes).\n",*len,bufsize);
-      exit(1); /* we're finished, sigh. */
-    }
-  }
-  
-  if (timeout == 0) {
-    timeout = 1 * 60; /* 1 minutes */
-  }
-  
-  memset(&cmd, 0, sizeof(CDB_T));
-  cmd[0] = 0x08; /* READ */
-  cmd[1] = (bufsize) ? 1 : 0; /* fixed length or var length blocks */
-  cmd[2] = (blockCount >> 16) & 0xff; /* MSB */
-  cmd[3] = (blockCount >> 8) & 0xff;
-  cmd[4] = blockCount & 0xff; /* LSB */
-  
-  /* okay, let's read, look @ the result code: */
-  rtnval=READ_OK;
-  if (SCSI_ExecuteCommand(fd,Input,&cmd,6,buf,(bufsize) ? *len : MAX_READ_SIZE,&RequestSense)) {
-    
-    rtnval=READ_ERROR;
-    if (HIT_EOP(RequestSense)) {
-      cmd[0]=0x08;
-      rtnval=READ_EOP;
-    }
-
-    if (HIT_FILEMARK(RequestSense)) {
-      rtnval=READ_FILEMARK;
-    }
-    if (HIT_EOD(RequestSense)) {
-      rtnval=READ_EOD;
-    }
-    if ( (bufsize==0) && SHORT_READ(RequestSense)) {
-      rtnval=READ_SHORT; /* we only do short reads for variable block mode */
-    }
-    if (rtnval != READ_ERROR) {
-      /* info contains number of blocks or bytes *not* read. May be 
-       negative if the block we were trying to read was too big. So
-       we will have to account for that and set it to zero if so, so that
-       we return the proper # of blocks read. 
-      */
-      info=((RequestSense.Information[0]<<24) +
-           (RequestSense.Information[1]<<16) +
-           (RequestSense.Information[2]<<8) +
-           RequestSense.Information[3]);
-      /* on 64-bit platforms, we may need to turn 'info' into a negative # */
-      if (info > 0x7fffffff) info = 0;
-      if (info < 0) info=0;  /* make sure  we don't return too big len read. */
-      /* Now set *len to # of bytes read. */
-      *len= bufsize ? (blockCount-info) * bufsize : MAX_READ_SIZE-info ;
-    } else {
-      PrintRequestSense(&RequestSense);
-      exit(1);  /* foo. */
-    }
-  }
-  
-  return(rtnval);
+       int rtnval;
+       CDB_T cmd;
+
+       int blockCount;
+       int info;
+
+       RequestSense_T RequestSense;
+
+       if (bufsize==0)
+       {
+               /* we are in variable block mode */
+               blockCount=MAX_READ_SIZE; /* variable block size. */
+       }
+       else
+       {
+               blockCount= *len / bufsize;
+               if ((*len % bufsize) != 0)
+               {
+                       fprintf(stderr,"Error: Data (%d bytes) not even multiple of block size (%d bytes).\n",*len,bufsize);
+                       exit(1); /* we're finished, sigh. */
+               }
+       }
+
+       if (timeout == 0)
+       {
+               timeout = 1 * 60; /* 1 minutes */
+       }
+
+       memset(&cmd, 0, sizeof(CDB_T));
+       cmd[0] = 0x08; /* READ */
+       cmd[1] = (bufsize) ? 1 : 0; /* fixed length or var length blocks */
+       cmd[2] = (unsigned char)(blockCount >> 16); /* MSB */
+       cmd[3] = (unsigned char)(blockCount >> 8);
+       cmd[4] = (unsigned char)blockCount; /* LSB */
+
+       /* okay, let's read, look @ the result code: */
+       rtnval=READ_OK;
+       if (SCSI_ExecuteCommand(fd,Input,&cmd,6,buf,(bufsize) ? *len : MAX_READ_SIZE,&RequestSense))
+       {
+               rtnval=READ_ERROR;
+               if (HIT_EOP(RequestSense))
+               {
+                       cmd[0]=0x08;
+                       rtnval=READ_EOP;
+               }
+
+               if (HIT_FILEMARK(RequestSense))
+               {
+                       rtnval=READ_FILEMARK;
+               }
+
+               if (HIT_EOD(RequestSense))
+               {
+                       rtnval=READ_EOD;
+               }
+
+               if ( (bufsize==0) && SHORT_READ(RequestSense))
+               {
+                       rtnval=READ_SHORT; /* we only do short reads for variable block mode */
+               }
+
+               if (rtnval != READ_ERROR)
+               {
+                       /* info contains number of blocks or bytes *not* read. May be 
+                       negative if the block we were trying to read was too big. So
+                       we will have to account for that and set it to zero if so, so that
+                       we return the proper # of blocks read. 
+                       */
+                       info = ((RequestSense.Information[0] << 24) +
+                                       (RequestSense.Information[1] << 16) +
+                                       (RequestSense.Information[2] << 8) +
+                                        RequestSense.Information[3]);
+
+                       /* on 64-bit platforms, we may need to turn 'info' into a negative # */
+                       if (info > 0x7fffffff)
+                               info = 0;
+
+                       if (info < 0)
+                               info=0;  /* make sure  we don't return too big len read. */
+
+                       /* Now set *len to # of bytes read. */
+                       *len= bufsize ? (blockCount-info) * bufsize : MAX_READ_SIZE-info ;
+               }
+               else
+               {
+                       PrintRequestSense(&RequestSense);
+                       exit(1);  /* foo. */
+               }
+       }
+
+       return rtnval;
 }
 
 /* Low level SCSI write. Modified from BRU 16.1,  with much BRU smarts
  * taken out and with the various types changed to mtx types rather than
  * BRU types.
  */ 
-int SCSI_writet(DEVICE_TYPE fd, char * buf, unsigned int blocksize,
-                unsigned int *len, 
-               unsigned int timeout) {
-  CDB_T cmd;
-
-  int blockCount;
-  int rtnval=0;
-  RequestSense_T RequestSense;
-
-  if (blocksize==0) { /* we are in variable block mode */
-    blockCount=*len; /* variable block size. */
-  } else {
-    blockCount= *len / blocksize ;
-    if ((*len % blocksize) != 0) {
-      fprintf(stderr,"Error: Data (%d bytes) not even multiple of block size (%d bytes).\n",*len,blocksize);
-      exit(1); /* we're finished, sigh. */
-    }
-  }
-
-  fprintf(stderr,"Writing %d blocks\n",blockCount);
-  
-  memset(&cmd, 0, sizeof(CDB_T));
-  cmd[0] = 0x0a; /* WRITE */
-  cmd[1] = (blocksize) ? 1 : 0; /* fixed length or var length blocks */
-  cmd[2] = (blockCount >> 16) & 0xff; /* MSB */
-  cmd[3] = (blockCount >> 8) & 0xff;
-  cmd[4] = blockCount & 0xff; /* LSB */
-  
-  
-  if (SCSI_ExecuteCommand(fd,Output,&cmd,6,buf, *len, &RequestSense)) {
-    if (HIT_EOM(RequestSense)) {
-      /* we hit end of media. Return -1. */
-      if (S_VOLUME_OVERFLOW(RequestSense)) {
-       exit(WRITE_EOV);
-      }
-      exit(WRITE_EOM); /* end of media! */
-    }
-    else { /* it was plain old write error: */
-      PrintRequestSense(&RequestSense);
-      exit(WRITE_ERROR);
-    }
-  } else {
-    rtnval = *len; /* worked! */
-  }
-  return(rtnval);
+int SCSI_write(DEVICE_TYPE fd, char * buf, unsigned int blocksize,
+                               unsigned int *len)
+{
+       CDB_T cmd;
+
+       int blockCount;
+       int rtnval=0;
+       RequestSense_T RequestSense;
+
+       if (blocksize == 0)
+       {
+               /* we are in variable block mode */
+               blockCount = *len; /* variable block size. */
+       }
+       else
+       {
+               blockCount= *len / blocksize ;
+               if ((*len % blocksize) != 0)
+               {
+                       fprintf(stderr,"Error: Data (%d bytes) not even multiple of block size (%d bytes).\n",*len,blocksize);
+                       exit(1); /* we're finished, sigh. */
+               }
+       }
+
+       fprintf(stderr,"Writing %d blocks\n",blockCount);
+
+       memset(&cmd, 0, sizeof(CDB_T));
+       cmd[0] = 0x0a; /* WRITE */
+       cmd[1] = (blocksize) ? 1 : 0; /* fixed length or var length blocks */
+       cmd[2] = (unsigned char)(blockCount >> 16); /* MSB */
+       cmd[3] = (unsigned char)(blockCount >> 8);
+       cmd[4] = (unsigned char)blockCount; /* LSB */
+
+
+       if (SCSI_ExecuteCommand(fd,Output,&cmd,6,buf, *len, &RequestSense))
+       {
+               if (HIT_EOM(RequestSense))
+               {
+                       /* we hit end of media. Return -1. */
+                       if (S_VOLUME_OVERFLOW(RequestSense))
+                       {
+                               exit(WRITE_EOV);
+                       }
+                       exit(WRITE_EOM); /* end of media! */
+               }
+               else
+               {
+                       /* it was plain old write error: */
+                       PrintRequestSense(&RequestSense);
+                       exit(WRITE_ERROR);
+               }
+       }
+       else
+       {
+               rtnval = *len; /* worked! */
+       }
+       return rtnval;
 }
 
 /* S_write is not implemented yet! */
-static int S_write(void) {
-  unsigned char *buffer; /* the buffer we're gonna read/write out of. */
-  int buffersize;
-  int len; /* the length of the data in the buffer */
-  int blocksize=arg[0];
-  int numblocks=arg[1];
-  int varsize=0; /* variable size block flag */
-  int result;
-  int eof_input;
-  int infile=fileno(stdin); /* sigh */
-
-  if (blocksize==0) {
-    varsize=1;
-    buffersize=MAX_READ_SIZE;
-    len=MAX_READ_SIZE;
-  }  else {
-    varsize=0; /* fixed block mode */
-    buffersize=blocksize;
-    len=blocksize;
-  }
-  /* sigh, make it oversized just to have some */  
-  buffer=malloc(buffersize+8); 
-
-  eof_input=0;
-  while (!eof_input) {
-    /* size_t could be 64 bit on a 32 bit platform, so do casts. */
-    len=0;
-    /* If it is a pipe, we could read 4096 bytes rather than the full
-     * 128K bytes or whatever, so we must gather multiple reads into
-     * the buffer.
-     */
-    while (len < buffersize) {
-      result=(int)read(infile,buffer+len,(size_t)(buffersize-len));
-      if (!result) {
-       eof_input=1;
-       if (!len) { /* if we have no deata in our buffer, exit */
-         return 0; /* we're at end of file! */
+static int S_write(void)
+{
+       char *buffer; /* the buffer we're gonna read/write out of. */
+       int buffersize;
+       int len; /* the length of the data in the buffer */
+       int blocksize = arg[0];
+       int numblocks = arg[1];
+       int varsize=0; /* variable size block flag */
+       int result;
+       int eof_input;
+       int infile=fileno(stdin); /* sigh */
+
+       if (blocksize == 0)
+       {
+               varsize = 1;
+               buffersize = MAX_READ_SIZE;
+               len = MAX_READ_SIZE;
        }
-       break; /* otherwise, break and write the data */
-      }
-      len+=result;  /* add the result input to our length. */
-    }
-    
-
-    result=SCSI_writet(MediumChangerFD,buffer,blocksize,&len,DEFAULT_TIMEOUT);
-    if (!result) {
-      return 1; /* at end of tape! */
-    }
-    /* Now see if we have numbytes or numblocks. If so, we may wish to exit
-       this loop.
-    */
-    if (arg[1]) {
-      if (varsize) {
-       /***BUG***/
-       return 0; /* we will only write one block in variable size mode :-( */
-      } else {
-       if (numblocks) {
-         numblocks--;
-       } else {
-         return 0; /* we're done. */
+       else
+       {
+               varsize = 0; /* fixed block mode */
+               buffersize = blocksize;
+               len = blocksize;
        }
-      }
-    }
-  }
-  /* and done! */
-  return 0;
+
+       /* sigh, make it oversized just to have some */  
+       buffer = malloc(buffersize+8); 
+
+       eof_input = 0;
+       while (!eof_input)
+       {
+               /* size_t could be 64 bit on a 32 bit platform, so do casts. */
+               len=0;
+               /* If it is a pipe, we could read 4096 bytes rather than the full
+               * 128K bytes or whatever, so we must gather multiple reads into
+               * the buffer.
+               */
+               while (len < buffersize)
+               {
+                       result=(int)read(infile, buffer + len, (size_t)(buffersize - len));
+                       if (!result)
+                       {
+                               eof_input = 1;
+                               if (!len)
+                               {
+                                       /* if we have no deata in our buffer, exit */
+                                       return 0; /* we're at end of file! */
+                               }
+                               break;          /* otherwise, break and write the data */
+                       }
+                       len += result;  /* add the result input to our length. */
+               }
+
+               result = SCSI_write(MediumChangerFD, buffer, blocksize, (unsigned int *)&len);
+               if (!result)
+               {
+                       return 1; /* at end of tape! */
+               }
+
+               /* Now see if we have numbytes or numblocks. If so, we may wish to exit
+               this loop.
+               */
+               if (arg[1])
+               {
+                       if (varsize)
+                       {
+                               /***BUG***/
+                               return 0; /* we will only write one block in variable size mode :-( */
+                       }
+                       else
+                       {
+                               if (numblocks)
+                               {
+                                       numblocks--;
+                               }
+                               else
+                               {
+                                       return 0; /* we're done. */
+                               }
+                       }
+               }
+       }
+       /* and done! */
+       return 0;
 }
 
 /* Okay, the read thingy: */
@@ -753,99 +820,121 @@ static int S_write(void) {
  */ 
 
 
-static int S_read(void) {
-  unsigned char *buffer; /* the buffer we're going to be reading out of */
-  int buffersize;
-  int len; /* the length of the data in the buffer */
-  int blocksize=arg[0];
-  int numblocks=arg[1];
-  int varsize=0; /* variable size block flag. */
-
-  int result;
-
-  int outfile=fileno(stdout); /* sigh. */
-  
-
-  if (blocksize==0) {
-    varsize=1;
-    buffersize=MAX_READ_SIZE;
-    len=MAX_READ_SIZE;
-  }  else {
-    varsize=0; /* fixed block mode */
-    buffersize=blocksize;
-    len=blocksize;
-  }
-  /* sigh, make it oversized just to have some */  
-  buffer=malloc(buffersize+8); 
-  
-
-  while (1) {
-    if (varsize) {
-      /* it could have gotten reset by prior short read... */
-      len=MAX_READ_SIZE; 
-    }
-    result=SCSI_readt(MediumChangerFD,buffer,blocksize, &len, DEFAULT_TIMEOUT);
-    if (result==READ_FILEMARK || result==READ_EOD || result==READ_EOP) {
-      /* okay, normal end of file? */
-      if (len > 0) {
-       write(outfile,buffer,len);
-      }
-#ifdef NEED_TO_GO_PAST_FILEMARK
-      /* Now, let's try to go past the filemark if that's what we hit: */
-      if (result==READ_FILEMARK) {
-       arg1=1; /* arg for S_fsf. */
-       S_fsf(); /* and go forward 1 filemark, we hope! */
-      }
-#endif   
-      return 0; /* hit normal end of file. */
-    } else if (result==READ_SHORT) {
-      /* short reads are only valid in variable block mode. */
-      if (varsize) {
-       if (len > 0) {
-         write(outfile,buffer,len);
+static int S_read(void)
+{
+       char *buffer; /* the buffer we're going to be reading out of */
+       int buffersize;
+       unsigned int len; /* the length of the data in the buffer */
+       int blocksize = arg[0];
+       int numblocks = arg[1];
+       int varsize = 0; /* variable size block flag. */
+
+       int result;
+
+       int outfile=fileno(stdout); /* sigh. */
+
+       if (blocksize == 0)
+       {
+               varsize=1;
+               buffersize=MAX_READ_SIZE;
+               len=MAX_READ_SIZE;
        }
-      } else {
-       fprintf(stderr,"scsitape:Short Read encountered on input. Aborting.\n");
-       fflush(stderr);
-       exit(1); /* error exit! */
-      }
-    } else if (result==READ_OK) {
-      write(outfile,buffer,len);
-    } else {
-
-      fprintf(stderr,"scsitape:Read Error\n");
-      fflush(stderr);
-      exit(1);
-    }
-    /* Now see if we have numbytes or numblocks: if so, we may wish to
-     * exit this loop.
-     */
-    if (arg[1]) {
-      if (varsize) {
-       /****BUG****/ 
-       return 0; /* we're only reading one block in var size mode! */
-      } else {
-       if (numblocks) {
-         numblocks--;
-       } else {
-         return 0; /* we're done. */
+       else
+       {
+               varsize=0; /* fixed block mode */
+               buffersize=blocksize;
+               len=blocksize;
+       }
+
+       /* sigh, make it oversized just to have some */  
+       buffer = malloc(buffersize + 8); 
+
+       for ( ; ; )
+       {
+               if (varsize)
+               {
+                       /* it could have gotten reset by prior short read... */
+                       len=MAX_READ_SIZE; 
+               }
+               result=SCSI_readt(MediumChangerFD,buffer,blocksize, &len, DEFAULT_TIMEOUT);
+
+               if (result==READ_FILEMARK || result==READ_EOD || result==READ_EOP)
+               {
+                       /* okay, normal end of file? */
+                       if (len > 0)
+                       {
+                               write(outfile,buffer,len);
+                       }
+
+#ifdef NEED_TO_GO_PAST_FILEMARK
+                       /* Now, let's try to go past the filemark if that's what we hit: */
+                       if (result==READ_FILEMARK)
+                       {
+                               arg1 = 1;       /* arg for S_fsf. */
+                               S_fsf();        /* and go forward 1 filemark, we hope! */
+                       }
+#endif
+                       return 0; /* hit normal end of file. */
+               }
+               else if (result == READ_SHORT)
+               {
+                       /* short reads are only valid in variable block mode. */
+                       if (varsize)
+                       {
+                               if (len > 0)
+                               {
+                                       write(outfile,buffer,len);
+                               }
+                       }
+                       else
+                       {
+                               fprintf(stderr,"scsitape:Short Read encountered on input. Aborting.\n");
+                               fflush(stderr);
+                               exit(1); /* error exit! */
+                       }
+               }
+               else if (result == READ_OK)
+               {
+                       write(outfile,buffer,len);
+               }
+               else
+               {
+                       fprintf(stderr,"scsitape:Read Error\n");
+                       fflush(stderr);
+                       exit(1);
+               }
+
+               /* Now see if we have numbytes or numblocks: if so, we may wish to
+                * exit this loop.
+                */
+               if (arg[1])
+               {
+                       if (varsize)
+                       {
+                               /****BUG****/ 
+                               return 0; /* we're only reading one block in var size mode! */
+                       }
+                       else if (numblocks)
+                       {
+                               numblocks--;
+                       }
+                       else
+                       {
+                               return 0; /* we're done. */
+                       }
+               }
        }
-      }
-    }
-  }
-} /* got the goddam cancer of the curly braces. You can tell I used to 
-   * do Lisp.
-   */
+}
 
 
 /* See parse_args for the scoop. parse_args does all. */
-int main(int argc, char **argv) {
-  argv0=argv[0];
-  parse_args(argc,argv);
+int main(int argc, char **argv)
+{
+       argv0 = argv[0];
+       parse_args(argc, argv);
 
-  if (device) 
-    SCSI_CloseDevice(device,MediumChangerFD);
+       if (device)
+               SCSI_CloseDevice(device,MediumChangerFD);
 
-  exit(0);
+       exit(0);
 }
-      
diff --git a/sg_err.c b/sg_err.c
new file mode 100644 (file)
index 0000000..2c98c31
--- /dev/null
+++ b/sg_err.c
@@ -0,0 +1,644 @@
+
+/* This file is a huge cut, paste and hack from linux/drivers/scsi/constant.c
+*  which I guess was written by:
+*         Copyright (C) 1993, 1994, 1995 Eric Youngdale
+
+* The rest of this is:
+*  Copyright (C) 1999 - 2001 D. Gilbert
+*
+*  This program is free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2, or (at your option)
+*  any later version.
+*
+*  ASCII values for a number of symbolic constants, printing functions, etc.
+*
+*  Some of the tables have been updated for SCSI 2.
+*
+*  Version 0.84 (20010115)
+*      Change output from stdout to stderr
+*/
+
+#define OUTP stderr
+
+static const unsigned char scsi_command_size[8] = { 6, 10, 10, 12,
+                                                   12, 12, 10, 10 };
+
+#define COMMAND_SIZE(opcode) scsi_command_size[((opcode) >> 5) & 7]
+
+static const char unknown[] = "UNKNOWN";
+
+static const char * group_0_commands[] = {
+/* 00-03 */ "Test Unit Ready", "Rezero Unit", unknown, "Request Sense",
+/* 04-07 */ "Format Unit", "Read Block Limits", unknown, "Reasssign Blocks",
+/* 08-0d */ "Read (6)", unknown, "Write (6)", "Seek (6)", unknown, unknown,
+/* 0e-12 */ unknown, "Read Reverse", "Write Filemarks", "Space", "Inquiry",
+/* 13-16 */ "Verify", "Recover Buffered Data", "Mode Select", "Reserve",
+/* 17-1b */ "Release", "Copy", "Erase", "Mode Sense", "Start/Stop Unit",
+/* 1c-1d */ "Receive Diagnostic", "Send Diagnostic",
+/* 1e-1f */ "Prevent/Allow Medium Removal", unknown,
+};
+
+
+static const char *group_1_commands[] = {
+/* 20-22 */  unknown, unknown, unknown,
+/* 23-28 */ unknown, "Define window parameters", "Read Capacity",
+            unknown, unknown, "Read (10)",
+/* 29-2d */ "Read Generation", "Write (10)", "Seek (10)", "Erase",
+            "Read updated block",
+/* 2e-31 */ "Write Verify","Verify", "Search High", "Search Equal",
+/* 32-34 */ "Search Low", "Set Limits", "Prefetch or Read Position",
+/* 35-37 */ "Synchronize Cache","Lock/Unlock Cache", "Read Defect Data",
+/* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer",
+            "Read Buffer",
+/* 3d-3f */ "Update Block", "Read Long",  "Write Long",
+};
+
+static const char *group_2_commands[] = {
+/* 40-41 */ "Change Definition", "Write Same",
+/* 42-48 */ "Read sub-channel", "Read TOC", "Read header",
+            "Play audio (10)", unknown, "Play audio msf",
+            "Play audio track/index",
+/* 49-4f */ "Play track relative (10)", unknown, "Pause/resume",
+            "Log Select", "Log Sense", unknown, unknown,
+/* 50-55 */ unknown, unknown, unknown, unknown, unknown, "Mode Select (10)",
+/* 56-5b */ unknown, unknown, unknown, unknown, "Mode Sense (10)", unknown,
+/* 5c-5f */ unknown, unknown, unknown,
+};
+
+
+/* The following are 12 byte commands in group 5 */
+static const char *group_5_commands[] = {
+/* a0-a5 */ unknown, unknown, unknown, unknown, unknown,
+            "Move medium/play audio(12)",
+/* a6-a9 */ "Exchange medium", unknown, "Read(12)", "Play track relative(12)",
+/* aa-ae */ "Write(12)", unknown, "Erase(12)", unknown,
+            "Write and verify(12)",
+/* af-b1 */ "Verify(12)", "Search data high(12)", "Search data equal(12)",
+/* b2-b4 */ "Search data low(12)", "Set limits(12)", unknown,
+/* b5-b6 */ "Request volume element address", "Send volume tag",
+/* b7-b9 */ "Read defect data(12)", "Read element status", unknown,
+/* ba-bf */ unknown, unknown, unknown, unknown, unknown, unknown,
+};
+
+
+
+
+#define group(opcode) (((opcode) >> 5) & 7)
+
+#define RESERVED_GROUP  0
+#define VENDOR_GROUP    1
+
+static const char **commands[] = {
+    group_0_commands, group_1_commands, group_2_commands,
+    (const char **) RESERVED_GROUP, (const char **) RESERVED_GROUP,
+    group_5_commands, (const char **) VENDOR_GROUP,
+    (const char **) VENDOR_GROUP
+};
+
+static const char reserved[] = "RESERVED";
+static const char vendor[] = "VENDOR SPECIFIC";
+
+static void print_opcode(int opcode) {
+    const char **table = commands[ group(opcode) ];
+    switch ((unsigned long) table) {
+    case RESERVED_GROUP:
+        fprintf(OUTP, "%s(0x%02x) ", reserved, opcode);
+        break;
+    case VENDOR_GROUP:
+        fprintf(OUTP, "%s(0x%02x) ", vendor, opcode);
+        break;
+    default:
+        if (table[opcode & 0x1f] != unknown)
+            fprintf(OUTP, "%s ",table[opcode & 0x1f]);
+        else
+            fprintf(OUTP, "%s(0x%02x) ", unknown, opcode);
+        break;
+    }
+}
+
+void sg_print_command (const unsigned char * command) {
+    int i,s;
+    print_opcode(command[0]);
+    for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
+        fprintf(OUTP, "%02x ", command[i]);
+    fprintf(OUTP, "\n");
+}
+
+static const char * statuses[] = {
+/* 0-4 */ "Good", "Check Condition", "Condition Met", unknown, "Busy",
+/* 5-9 */ unknown, unknown, unknown, "Intermediate", unknown,
+/* a-c */ "Intermediate-Condition Met", unknown, "Reservation Conflict",
+/* d-10 */ unknown, unknown, unknown, unknown,
+/* 11-14 */ "Command Terminated", unknown, unknown, "Queue Full",
+/* 15-1a */ unknown, unknown, unknown,  unknown, unknown, unknown,
+/* 1b-1f */ unknown, unknown, unknown,  unknown, unknown,
+};
+
+void sg_print_status (int masked_status) {
+    /* status = (status >> 1) & 0xf; */ /* already done */
+    fprintf(OUTP, "%s ",statuses[masked_status]);
+}
+
+#define D 0x001  /* DIRECT ACCESS DEVICE (disk) */
+#define T 0x002  /* SEQUENTIAL ACCESS DEVICE (tape) */
+#define L 0x004  /* PRINTER DEVICE */
+#define P 0x008  /* PROCESSOR DEVICE */
+#define W 0x010  /* WRITE ONCE READ MULTIPLE DEVICE */
+#define R 0x020  /* READ ONLY (CD-ROM) DEVICE */
+#define S 0x040  /* SCANNER DEVICE */
+#define O 0x080  /* OPTICAL MEMORY DEVICE */
+#define M 0x100  /* MEDIA CHANGER DEVICE */
+#define C 0x200  /* COMMUNICATION DEVICE */
+
+struct error_info{
+    unsigned char code1, code2;
+    unsigned short int devices;
+    const char * text;
+};
+
+struct error_info2{
+    unsigned char code1, code2_min, code2_max;
+    unsigned short int devices;
+    const char * text;
+};
+
+static struct error_info2 additional2[] =
+{
+  {0x40,0x00,0x7f,D,"Ram failure (%x)"},
+  {0x40,0x80,0xff,D|T|L|P|W|R|S|O|M|C,"Diagnostic failure on component (%x)"},
+  {0x41,0x00,0xff,D,"Data path failure (%x)"},
+  {0x42,0x00,0xff,D,"Power-on or self-test failure (%x)"},
+  {0, 0, 0, 0, NULL}
+};
+
+static struct error_info additional[] =
+{
+  {0x00,0x01,T,"Filemark detected"},
+  {0x00,0x02,T|S,"End-of-partition/medium detected"},
+  {0x00,0x03,T,"Setmark detected"},
+  {0x00,0x04,T|S,"Beginning-of-partition/medium detected"},
+  {0x00,0x05,T|S,"End-of-data detected"},
+  {0x00,0x06,D|T|L|P|W|R|S|O|M|C,"I/O process terminated"},
+  {0x00,0x11,R,"Audio play operation in progress"},
+  {0x00,0x12,R,"Audio play operation paused"},
+  {0x00,0x13,R,"Audio play operation successfully completed"},
+  {0x00,0x14,R,"Audio play operation stopped due to error"},
+  {0x00,0x15,R,"No current audio status to return"},
+  {0x01,0x00,D|W|O,"No index/sector signal"},
+  {0x02,0x00,D|W|R|O|M,"No seek complete"},
+  {0x03,0x00,D|T|L|W|S|O,"Peripheral device write fault"},
+  {0x03,0x01,T,"No write current"},
+  {0x03,0x02,T,"Excessive write errors"},
+  {0x04,0x00,D|T|L|P|W|R|S|O|M|C,
+     "Logical unit not ready, cause not reportable"},
+  {0x04,0x01,D|T|L|P|W|R|S|O|M|C,
+     "Logical unit is in process of becoming ready"},
+  {0x04,0x02,D|T|L|P|W|R|S|O|M|C,
+     "Logical unit not ready, initializing command required"},
+  {0x04,0x03,D|T|L|P|W|R|S|O|M|C,
+     "Logical unit not ready, manual intervention required"},
+  {0x04,0x04,D|T|L|O,"Logical unit not ready, format in progress"},
+  {0x05,0x00,D|T|L|W|R|S|O|M|C,"Logical unit does not respond to selection"},
+  {0x06,0x00,D|W|R|O|M,"No reference position found"},
+  {0x07,0x00,D|T|L|W|R|S|O|M,"Multiple peripheral devices selected"},
+  {0x08,0x00,D|T|L|W|R|S|O|M|C,"Logical unit communication failure"},
+  {0x08,0x01,D|T|L|W|R|S|O|M|C,"Logical unit communication time-out"},
+  {0x08,0x02,D|T|L|W|R|S|O|M|C,"Logical unit communication parity error"},
+  {0x09,0x00,D|T|W|R|O,"Track following error"},
+  {0x09,0x01,W|R|O,"Tracking servo failure"},
+  {0x09,0x02,W|R|O,"Focus servo failure"},
+  {0x09,0x03,W|R|O,"Spindle servo failure"},
+  {0x0A,0x00,D|T|L|P|W|R|S|O|M|C,"Error log overflow"},
+  {0x0C,0x00,T|S,"Write error"},
+  {0x0C,0x01,D|W|O,"Write error recovered with auto reallocation"},
+  {0x0C,0x02,D|W|O,"Write error - auto reallocation failed"},
+  {0x10,0x00,D|W|O,"Id crc or ecc error"},
+  {0x11,0x00,D|T|W|R|S|O,"Unrecovered read error"},
+  {0x11,0x01,D|T|W|S|O,"Read retries exhausted"},
+  {0x11,0x02,D|T|W|S|O,"Error too long to correct"},
+  {0x11,0x03,D|T|W|S|O,"Multiple read errors"},
+  {0x11,0x04,D|W|O,"Unrecovered read error - auto reallocate failed"},
+  {0x11,0x05,W|R|O,"L-ec uncorrectable error"},
+  {0x11,0x06,W|R|O,"Circ unrecovered error"},
+  {0x11,0x07,W|O,"Data resynchronization error"},
+  {0x11,0x08,T,"Incomplete block read"},
+  {0x11,0x09,T,"No gap found"},
+  {0x11,0x0A,D|T|O,"Miscorrected error"},
+  {0x11,0x0B,D|W|O,"Unrecovered read error - recommend reassignment"},
+  {0x11,0x0C,D|W|O,"Unrecovered read error - recommend rewrite the data"},
+  {0x12,0x00,D|W|O,"Address mark not found for id field"},
+  {0x13,0x00,D|W|O,"Address mark not found for data field"},
+  {0x14,0x00,D|T|L|W|R|S|O,"Recorded entity not found"},
+  {0x14,0x01,D|T|W|R|O,"Record not found"},
+  {0x14,0x02,T,"Filemark or setmark not found"},
+  {0x14,0x03,T,"End-of-data not found"},
+  {0x14,0x04,T,"Block sequence error"},
+  {0x15,0x00,D|T|L|W|R|S|O|M,"Random positioning error"},
+  {0x15,0x01,D|T|L|W|R|S|O|M,"Mechanical positioning error"},
+  {0x15,0x02,D|T|W|R|O,"Positioning error detected by read of medium"},
+  {0x16,0x00,D|W|O,"Data synchronization mark error"},
+  {0x17,0x00,D|T|W|R|S|O,"Recovered data with no error correction applied"},
+  {0x17,0x01,D|T|W|R|S|O,"Recovered data with retries"},
+  {0x17,0x02,D|T|W|R|O,"Recovered data with positive head offset"},
+  {0x17,0x03,D|T|W|R|O,"Recovered data with negative head offset"},
+  {0x17,0x04,W|R|O,"Recovered data with retries and/or circ applied"},
+  {0x17,0x05,D|W|R|O,"Recovered data using previous sector id"},
+  {0x17,0x06,D|W|O,"Recovered data without ecc - data auto-reallocated"},
+  {0x17,0x07,D|W|O,"Recovered data without ecc - recommend reassignment"},
+  {0x18,0x00,D|T|W|R|O,"Recovered data with error correction applied"},
+  {0x18,0x01,D|W|R|O,"Recovered data with error correction and retries applied"},
+  {0x18,0x02,D|W|R|O,"Recovered data - data auto-reallocated"},
+  {0x18,0x03,R,"Recovered data with circ"},
+  {0x18,0x04,R,"Recovered data with lec"},
+  {0x18,0x05,D|W|R|O,"Recovered data - recommend reassignment"},
+  {0x19,0x00,D|O,"Defect list error"},
+  {0x19,0x01,D|O,"Defect list not available"},
+  {0x19,0x02,D|O,"Defect list error in primary list"},
+  {0x19,0x03,D|O,"Defect list error in grown list"},
+  {0x1A,0x00,D|T|L|P|W|R|S|O|M|C,"Parameter list length error"},
+  {0x1B,0x00,D|T|L|P|W|R|S|O|M|C,"Synchronous data transfer error"},
+  {0x1C,0x00,D|O,"Defect list not found"},
+  {0x1C,0x01,D|O,"Primary defect list not found"},
+  {0x1C,0x02,D|O,"Grown defect list not found"},
+  {0x1D,0x00,D|W|O,"Miscompare during verify operation"},
+  {0x1E,0x00,D|W|O,"Recovered id with ecc correction"},
+  {0x20,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid command operation code"},
+  {0x21,0x00,D|T|W|R|O|M,"Logical block address out of range"},
+  {0x21,0x01,M,"Invalid element address"},
+  {0x22,0x00,D,"Illegal function (should use 20 00, 24 00, or 26 00)"},
+  {0x24,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid field in cdb"},
+  {0x25,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit not supported"},
+  {0x26,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid field in parameter list"},
+  {0x26,0x01,D|T|L|P|W|R|S|O|M|C,"Parameter not supported"},
+  {0x26,0x02,D|T|L|P|W|R|S|O|M|C,"Parameter value invalid"},
+  {0x26,0x03,D|T|L|P|W|R|S|O|M|C,"Threshold parameters not supported"},
+  {0x27,0x00,D|T|W|O,"Write protected"},
+  {0x28,0x00,D|T|L|P|W|R|S|O|M|C,"Not ready to ready transition (medium may have changed)"},
+  {0x28,0x01,M,"Import or export element accessed"},
+  {0x29,0x00,D|T|L|P|W|R|S|O|M|C,"Power on, reset, or bus device reset occurred"},
+  {0x2A,0x00,D|T|L|W|R|S|O|M|C,"Parameters changed"},
+  {0x2A,0x01,D|T|L|W|R|S|O|M|C,"Mode parameters changed"},
+  {0x2A,0x02,D|T|L|W|R|S|O|M|C,"Log parameters changed"},
+  {0x2B,0x00,D|T|L|P|W|R|S|O|C,"Copy cannot execute since host cannot disconnect"},
+  {0x2C,0x00,D|T|L|P|W|R|S|O|M|C,"Command sequence error"},
+  {0x2C,0x01,S,"Too many windows specified"},
+  {0x2C,0x02,S,"Invalid combination of windows specified"},
+  {0x2D,0x00,T,"Overwrite error on update in place"},
+  {0x2F,0x00,D|T|L|P|W|R|S|O|M|C,"Commands cleared by another initiator"},
+  {0x30,0x00,D|T|W|R|O|M,"Incompatible medium installed"},
+  {0x30,0x01,D|T|W|R|O,"Cannot read medium - unknown format"},
+  {0x30,0x02,D|T|W|R|O,"Cannot read medium - incompatible format"},
+  {0x30,0x03,D|T,"Cleaning cartridge installed"},
+  {0x31,0x00,D|T|W|O,"Medium format corrupted"},
+  {0x31,0x01,D|L|O,"Format command failed"},
+  {0x32,0x00,D|W|O,"No defect spare location available"},
+  {0x32,0x01,D|W|O,"Defect list update failure"},
+  {0x33,0x00,T,"Tape length error"},
+  {0x36,0x00,L,"Ribbon, ink, or toner failure"},
+  {0x37,0x00,D|T|L|W|R|S|O|M|C,"Rounded parameter"},
+  {0x39,0x00,D|T|L|W|R|S|O|M|C,"Saving parameters not supported"},
+  {0x3A,0x00,D|T|L|W|R|S|O|M,"Medium not present"},
+  {0x3B,0x00,T|L,"Sequential positioning error"},
+  {0x3B,0x01,T,"Tape position error at beginning-of-medium"},
+  {0x3B,0x02,T,"Tape position error at end-of-medium"},
+  {0x3B,0x03,L,"Tape or electronic vertical forms unit not ready"},
+  {0x3B,0x04,L,"Slew failure"},
+  {0x3B,0x05,L,"Paper jam"},
+  {0x3B,0x06,L,"Failed to sense top-of-form"},
+  {0x3B,0x07,L,"Failed to sense bottom-of-form"},
+  {0x3B,0x08,T,"Reposition error"},
+  {0x3B,0x09,S,"Read past end of medium"},
+  {0x3B,0x0A,S,"Read past beginning of medium"},
+  {0x3B,0x0B,S,"Position past end of medium"},
+  {0x3B,0x0C,S,"Position past beginning of medium"},
+  {0x3B,0x0D,M,"Medium destination element full"},
+  {0x3B,0x0E,M,"Medium source element empty"},
+  {0x3D,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid bits in identify message"},
+  {0x3E,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit has not self-configured yet"},
+  {0x3F,0x00,D|T|L|P|W|R|S|O|M|C,"Target operating conditions have changed"},
+  {0x3F,0x01,D|T|L|P|W|R|S|O|M|C,"Microcode has been changed"},
+  {0x3F,0x02,D|T|L|P|W|R|S|O|M|C,"Changed operating definition"},
+  {0x3F,0x03,D|T|L|P|W|R|S|O|M|C,"Inquiry data has changed"},
+  {0x43,0x00,D|T|L|P|W|R|S|O|M|C,"Message error"},
+  {0x44,0x00,D|T|L|P|W|R|S|O|M|C,"Internal target failure"},
+  {0x45,0x00,D|T|L|P|W|R|S|O|M|C,"Select or reselect failure"},
+  {0x46,0x00,D|T|L|P|W|R|S|O|M|C,"Unsuccessful soft reset"},
+  {0x47,0x00,D|T|L|P|W|R|S|O|M|C,"Scsi parity error"},
+  {0x48,0x00,D|T|L|P|W|R|S|O|M|C,"Initiator detected error message received"},
+  {0x49,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid message error"},
+  {0x4A,0x00,D|T|L|P|W|R|S|O|M|C,"Command phase error"},
+  {0x4B,0x00,D|T|L|P|W|R|S|O|M|C,"Data phase error"},
+  {0x4C,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit failed self-configuration"},
+  {0x4E,0x00,D|T|L|P|W|R|S|O|M|C,"Overlapped commands attempted"},
+  {0x50,0x00,T,"Write append error"},
+  {0x50,0x01,T,"Write append position error"},
+  {0x50,0x02,T,"Position error related to timing"},
+  {0x51,0x00,T|O,"Erase failure"},
+  {0x52,0x00,T,"Cartridge fault"},
+  {0x53,0x00,D|T|L|W|R|S|O|M,"Media load or eject failed"},
+  {0x53,0x01,T,"Unload tape failure"},
+  {0x53,0x02,D|T|W|R|O|M,"Medium removal prevented"},
+  {0x54,0x00,P,"Scsi to host system interface failure"},
+  {0x55,0x00,P,"System resource failure"},
+  {0x57,0x00,R,"Unable to recover table-of-contents"},
+  {0x58,0x00,O,"Generation does not exist"},
+  {0x59,0x00,O,"Updated block read"},
+  {0x5A,0x00,D|T|L|P|W|R|S|O|M,"Operator request or state change input (unspecified)"},
+  {0x5A,0x01,D|T|W|R|O|M,"Operator medium removal request"},
+  {0x5A,0x02,D|T|W|O,"Operator selected write protect"},
+  {0x5A,0x03,D|T|W|O,"Operator selected write permit"},
+  {0x5B,0x00,D|T|L|P|W|R|S|O|M,"Log exception"},
+  {0x5B,0x01,D|T|L|P|W|R|S|O|M,"Threshold condition met"},
+  {0x5B,0x02,D|T|L|P|W|R|S|O|M,"Log counter at maximum"},
+  {0x5B,0x03,D|T|L|P|W|R|S|O|M,"Log list codes exhausted"},
+  {0x5C,0x00,D|O,"Rpl status change"},
+  {0x5C,0x01,D|O,"Spindles synchronized"},
+  {0x5C,0x02,D|O,"Spindles not synchronized"},
+  {0x60,0x00,S,"Lamp failure"},
+  {0x61,0x00,S,"Video acquisition error"},
+  {0x61,0x01,S,"Unable to acquire video"},
+  {0x61,0x02,S,"Out of focus"},
+  {0x62,0x00,S,"Scan head positioning error"},
+  {0x63,0x00,R,"End of user area encountered on this track"},
+  {0x64,0x00,R,"Illegal mode for this track"},
+  {0, 0, 0, NULL}
+};
+
+static const char *snstext[] = {
+    "None",                     /* There is no sense information */
+    "Recovered Error",          /* The last command completed successfully
+                                   but used error correction */
+    "Not Ready",                /* The addressed target is not ready */
+    "Medium Error",             /* Data error detected on the medium */
+    "Hardware Error",           /* Controller or device failure */
+    "Illegal Request",
+    "Unit Attention",           /* Removable medium was changed, or
+                                   the target has been reset */
+    "Data Protect",             /* Access to the data is blocked */
+    "Blank Check",              /* Reached unexpected written or unwritten
+                                   region of the medium */
+    "Key=9",                    /* Vendor specific */
+    "Copy Aborted",             /* COPY or COMPARE was aborted */
+    "Aborted Command",          /* The target aborted the command */
+    "Equal",                    /* A SEARCH DATA command found data equal */
+    "Volume Overflow",          /* Medium full with still data to be written */
+    "Miscompare",               /* Source data and data on the medium
+                                   do not agree */
+    "Key=15"                    /* Reserved */
+};
+
+/* Print sense information */
+void sg_print_sense(const char * leadin, const unsigned char * sense_buffer,
+                    int sb_len)
+{
+    int i, s;
+    int sense_class, valid, code;
+    const char * error = NULL;
+
+    sense_class = (sense_buffer[0] >> 4) & 0x07;
+    code = sense_buffer[0] & 0xf;
+    valid = sense_buffer[0] & 0x80;
+
+    if (sense_class == 7) {     /* extended sense data */
+        s = sense_buffer[7] + 8;
+        if(s > sb_len)
+           s = sb_len;
+
+        if (!valid)
+            fprintf(OUTP, "[valid=0] ");
+        fprintf(OUTP, "Info fld=0x%x, ", (int)((sense_buffer[3] << 24) |
+                (sense_buffer[4] << 16) | (sense_buffer[5] << 8) |
+                sense_buffer[6]));
+
+        if (sense_buffer[2] & 0x80)
+           fprintf(OUTP, "FMK ");     /* current command has read a filemark */
+        if (sense_buffer[2] & 0x40)
+           fprintf(OUTP, "EOM ");     /* end-of-medium condition exists */
+        if (sense_buffer[2] & 0x20)
+           fprintf(OUTP, "ILI ");     /* incorrect block length requested */
+
+        switch (code) {
+        case 0x0:
+            error = "Current";  /* error concerns current command */
+            break;
+        case 0x1:
+            error = "Deferred"; /* error concerns some earlier command */
+                /* e.g., an earlier write to disk cache succeeded, but
+                   now the disk discovers that it cannot write the data */
+            break;
+        default:
+            error = "Invalid";
+        }
+
+        fprintf(OUTP, "%s ", error);
+
+        if (leadin)
+            fprintf(OUTP, "%s: ", leadin);
+        fprintf(OUTP, "sense key: %s\n", snstext[sense_buffer[2] & 0x0f]);
+
+        /* Check to see if additional sense information is available */
+        if(sense_buffer[7] + 7 < 13 ||
+           (sense_buffer[12] == 0  && sense_buffer[13] ==  0)) goto done;
+
+        for(i=0; additional[i].text; i++)
+            if(additional[i].code1 == sense_buffer[12] &&
+               additional[i].code2 == sense_buffer[13])
+                fprintf(OUTP, "Additional sense indicates: %s\n",
+                        additional[i].text);
+
+        for(i=0; additional2[i].text; i++)
+            if(additional2[i].code1 == sense_buffer[12] &&
+               additional2[i].code2_min >= sense_buffer[13]  &&
+               additional2[i].code2_max <= sense_buffer[13]) {
+                fprintf(OUTP, "Additional sense indicates: ");
+                fprintf(OUTP, additional2[i].text, sense_buffer[13]);
+                fprintf(OUTP, "\n");
+            };
+    } else {    /* non-extended sense data */
+
+         /*
+          * Standard says:
+          *    sense_buffer[0] & 0200 : address valid
+          *    sense_buffer[0] & 0177 : vendor-specific error code
+          *    sense_buffer[1] & 0340 : vendor-specific
+          *    sense_buffer[1..3] : 21-bit logical block address
+          */
+
+        if (leadin)
+            fprintf(OUTP, "%s: ", leadin);
+        if (sense_buffer[0] < 15)
+            fprintf(OUTP, 
+                   "old sense: key %s\n", snstext[sense_buffer[0] & 0x0f]);
+        else
+            fprintf(OUTP, "sns = %2x %2x\n", sense_buffer[0], sense_buffer[2]);
+
+        fprintf(OUTP, "Non-extended sense class %d code 0x%0x ", 
+               sense_class, code);
+        s = 4;
+    }
+
+ done:
+    fprintf(OUTP, "Raw sense data (in hex):\n  ");
+    for (i = 0; i < s; ++i) {
+        if ((i > 0) && (0 == (i % 24)))
+            fprintf(OUTP, "\n  ");
+        fprintf(OUTP, "%02x ", sense_buffer[i]);
+    }
+    fprintf(OUTP, "\n");
+    return;
+}
+
+static const char * hostbyte_table[]={
+"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
+"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
+"DID_PASSTHROUGH", "DID_SOFT_ERROR", NULL};
+
+void sg_print_host_status(int host_status)
+{   static int maxcode=0;
+    int i;
+
+    if(! maxcode) {
+        for(i = 0; hostbyte_table[i]; i++) ;
+        maxcode = i-1;
+    }
+    fprintf(OUTP, "Host_status=0x%02x", host_status);
+    if(host_status > maxcode) {
+        fprintf(OUTP, "is invalid ");
+        return;
+    }
+    fprintf(OUTP, "(%s) ",hostbyte_table[host_status]);
+}
+
+static const char * driverbyte_table[]={
+"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT",  "DRIVER_MEDIA", "DRIVER_ERROR",
+"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE", NULL};
+
+static const char * driversuggest_table[]={"SUGGEST_OK",
+"SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE",
+unknown,unknown,unknown, "SUGGEST_SENSE",NULL};
+
+
+void sg_print_driver_status(int driver_status)
+{
+    static int driver_max =0 , suggest_max=0;
+    int i;
+    int dr = driver_status & SG_ERR_DRIVER_MASK;
+    int su = (driver_status & SG_ERR_SUGGEST_MASK) >> 4;
+
+    if(! driver_max) {
+        for(i = 0; driverbyte_table[i]; i++) ;
+        driver_max = i;
+        for(i = 0; driversuggest_table[i]; i++) ;
+        suggest_max = i;
+    }
+    fprintf(OUTP, "Driver_status=0x%02x",driver_status);
+    fprintf(OUTP, " (%s,%s) ",
+            dr < driver_max  ? driverbyte_table[dr]:"invalid",
+            su < suggest_max ? driversuggest_table[su]:"invalid");
+}
+
+#ifdef SG_IO
+int sg_chk_n_print3(const char * leadin, struct sg_io_hdr * hp)
+{
+    return sg_chk_n_print(leadin, hp->masked_status, hp->host_status,
+                          hp->driver_status, hp->sbp, hp->sb_len_wr);
+}
+#endif
+
+int sg_chk_n_print(const char * leadin, int masked_status,
+                   int host_status, int driver_status,
+                   const unsigned char * sense_buffer, int sb_len)
+{
+    int done_leadin = 0;
+    int done_sense = 0;
+
+    if ((0 == masked_status) && (0 == host_status) &&
+        (0 == driver_status))
+        return 1;       /* No problems */
+    if (0 != masked_status) {
+        if (leadin)
+            fprintf(OUTP, "%s: ", leadin);
+        done_leadin = 1;
+        sg_print_status(masked_status);
+        fprintf(OUTP, "\n");
+        if (sense_buffer && ((masked_status == CHECK_CONDITION) ||
+                             (masked_status == COMMAND_TERMINATED))) {
+            sg_print_sense(0, sense_buffer, sb_len);
+            done_sense = 1;
+        }
+    }
+    if (0 != host_status) {
+        if (leadin && (! done_leadin))
+            fprintf(OUTP, "%s: ", leadin);
+        if (done_leadin)
+            fprintf(OUTP, "plus...: ");
+        else
+            done_leadin = 1;
+        sg_print_host_status(host_status);
+        fprintf(OUTP, "\n");
+    }
+    if (0 != driver_status) {
+        if (leadin && (! done_leadin))
+            fprintf(OUTP, "%s: ", leadin);
+        if (done_leadin)
+            fprintf(OUTP, "plus...: ");
+        else
+            done_leadin = 1;
+        sg_print_driver_status(driver_status);
+        fprintf(OUTP, "\n");
+        if (sense_buffer && (! done_sense) &&
+            (SG_ERR_DRIVER_SENSE & driver_status))
+            sg_print_sense(0, sense_buffer, sb_len);
+    }
+    return 0;
+}
+
+#ifdef SG_IO
+int sg_err_category3(struct sg_io_hdr * hp)
+{
+    return sg_err_category(hp->masked_status, hp->host_status,
+                           hp->driver_status, hp->sbp, hp->sb_len_wr);
+}
+#endif
+
+int sg_err_category(int masked_status, int host_status,
+                    int driver_status, const unsigned char * sense_buffer,
+                    int sb_len)
+{
+    if ((0 == masked_status) && (0 == host_status) &&
+        (0 == driver_status))
+        return SG_ERR_CAT_CLEAN;
+    if ((CHECK_CONDITION == masked_status) ||
+        (COMMAND_TERMINATED == masked_status) ||
+        (SG_ERR_DRIVER_SENSE & driver_status)) {
+        if (sense_buffer && (sb_len > 2)) {
+            if(RECOVERED_ERROR == sense_buffer[2])
+                return SG_ERR_CAT_RECOVERED;
+            else if ((UNIT_ATTENTION == (0x0f & sense_buffer[2])) &&
+                     (sb_len > 12)) {
+                if (0x28 == sense_buffer[12])
+                    return SG_ERR_CAT_MEDIA_CHANGED;
+                if (0x29 == sense_buffer[12])
+                    return SG_ERR_CAT_RESET;
+            }
+        }
+        return SG_ERR_CAT_SENSE;
+    }
+    if (0 != host_status) {
+        if ((SG_ERR_DID_NO_CONNECT == host_status) ||
+            (SG_ERR_DID_BUS_BUSY == host_status) ||
+            (SG_ERR_DID_TIME_OUT == host_status))
+            return SG_ERR_CAT_TIMEOUT;
+    }
+    if (0 != driver_status) {
+        if (SG_ERR_DRIVER_TIMEOUT == driver_status)
+            return SG_ERR_CAT_TIMEOUT;
+    }
+    return SG_ERR_CAT_OTHER;
+}
+
+int sg_get_command_size(unsigned char opcode)
+{
+    return COMMAND_SIZE(opcode);
+}
diff --git a/sg_err.h b/sg_err.h
new file mode 100644 (file)
index 0000000..fd59e3b
--- /dev/null
+++ b/sg_err.h
@@ -0,0 +1,140 @@
+#ifndef SG_ERR_H
+#define SG_ERR_H
+
+/* Feel free to copy and modify this GPL-ed code into your applications. */
+
+/* Version 0.84 (20010115) 
+       - all output now sent to stderr rather thatn stdout
+       - remove header files included in this file
+*/
+
+
+/* Some of the following error/status codes are exchanged between the
+   various layers of the SCSI sub-system in Linux and should never
+   reach the user. They are placed here for completeness. What appears
+   here is copied from drivers/scsi/scsi.h which is not visible in
+   the user space. */
+
+/* The following are 'host_status' codes */
+#ifndef DID_OK
+#define DID_OK 0x00
+#endif
+#ifndef DID_NO_CONNECT
+#define DID_NO_CONNECT 0x01     /* Unable to connect before timeout */
+#define DID_BUS_BUSY 0x02       /* Bus remain busy until timeout */
+#define DID_TIME_OUT 0x03       /* Timed out for some other reason */
+#define DID_BAD_TARGET 0x04     /* Bad target (id?) */
+#define DID_ABORT 0x05          /* Told to abort for some other reason */
+#define DID_PARITY 0x06         /* Parity error (on SCSI bus) */
+#define DID_ERROR 0x07          /* Internal error */
+#define DID_RESET 0x08          /* Reset by somebody */
+#define DID_BAD_INTR 0x09       /* Received an unexpected interrupt */
+#define DID_PASSTHROUGH 0x0a    /* Force command past mid-level */
+#define DID_SOFT_ERROR 0x0b     /* The low-level driver wants a retry */
+#endif
+
+/* These defines are to isolate applictaions from kernel define changes */
+#define SG_ERR_DID_OK           DID_OK
+#define SG_ERR_DID_NO_CONNECT   DID_NO_CONNECT
+#define SG_ERR_DID_BUS_BUSY     DID_BUS_BUSY
+#define SG_ERR_DID_TIME_OUT     DID_TIME_OUT
+#define SG_ERR_DID_BAD_TARGET   DID_BAD_TARGET
+#define SG_ERR_DID_ABORT        DID_ABORT
+#define SG_ERR_DID_PARITY       DID_PARITY
+#define SG_ERR_DID_ERROR        DID_ERROR
+#define SG_ERR_DID_RESET        DID_RESET
+#define SG_ERR_DID_BAD_INTR     DID_BAD_INTR
+#define SG_ERR_DID_PASSTHROUGH  DID_PASSTHROUGH
+#define SG_ERR_DID_SOFT_ERROR   DID_SOFT_ERROR
+
+/* The following are 'driver_status' codes */
+#ifndef DRIVER_OK
+#define DRIVER_OK 0x00
+#endif
+#ifndef DRIVER_BUSY
+#define DRIVER_BUSY 0x01
+#define DRIVER_SOFT 0x02
+#define DRIVER_MEDIA 0x03
+#define DRIVER_ERROR 0x04
+#define DRIVER_INVALID 0x05
+#define DRIVER_TIMEOUT 0x06
+#define DRIVER_HARD 0x07
+#define DRIVER_SENSE 0x08       /* Sense_buffer has been set */
+
+/* Following "suggests" are "or-ed" with one of previous 8 entries */
+#define SUGGEST_RETRY 0x10
+#define SUGGEST_ABORT 0x20
+#define SUGGEST_REMAP 0x30
+#define SUGGEST_DIE 0x40
+#define SUGGEST_SENSE 0x80
+#define SUGGEST_IS_OK 0xff
+#endif
+#ifndef DRIVER_MASK
+#define DRIVER_MASK 0x0f
+#endif
+#ifndef SUGGEST_MASK
+#define SUGGEST_MASK 0xf0
+#endif
+
+/* These defines are to isolate applictaions from kernel define changes */
+#define SG_ERR_DRIVER_OK        DRIVER_OK
+#define SG_ERR_DRIVER_BUSY      DRIVER_BUSY
+#define SG_ERR_DRIVER_SOFT      DRIVER_SOFT
+#define SG_ERR_DRIVER_MEDIA     DRIVER_MEDIA
+#define SG_ERR_DRIVER_ERROR     DRIVER_ERROR
+#define SG_ERR_DRIVER_INVALID   DRIVER_INVALID
+#define SG_ERR_DRIVER_TIMEOUT   DRIVER_TIMEOUT
+#define SG_ERR_DRIVER_HARD      DRIVER_HARD
+#define SG_ERR_DRIVER_SENSE     DRIVER_SENSE
+#define SG_ERR_SUGGEST_RETRY    SUGGEST_RETRY
+#define SG_ERR_SUGGEST_ABORT    SUGGEST_ABORT
+#define SG_ERR_SUGGEST_REMAP    SUGGEST_REMAP
+#define SG_ERR_SUGGEST_DIE      SUGGEST_DIE
+#define SG_ERR_SUGGEST_SENSE    SUGGEST_SENSE
+#define SG_ERR_SUGGEST_IS_OK    SUGGEST_IS_OK
+#define SG_ERR_DRIVER_MASK      DRIVER_MASK
+#define SG_ERR_SUGGEST_MASK     SUGGEST_MASK
+
+
+
+/* The following "print" functions send ACSII to stdout */
+extern void sg_print_command(const unsigned char * command);
+extern void sg_print_sense(const char * leadin,
+                           const unsigned char * sense_buffer, int sb_len);
+extern void sg_print_status(int masked_status);
+extern void sg_print_host_status(int host_status);
+extern void sg_print_driver_status(int driver_status);
+
+/* sg_chk_n_print() returns 1 quietly if there are no errors/warnings
+   else it prints to standard output and returns 0. */
+extern int sg_chk_n_print(const char * leadin, int masked_status,
+                          int host_status, int driver_status,
+                          const unsigned char * sense_buffer, int sb_len);
+
+/* The following function declaration is for the sg version 3 driver. 
+   Only version 3 sg_err.c defines it. */
+struct sg_io_hdr;
+extern int sg_chk_n_print3(const char * leadin, struct sg_io_hdr * hp);
+
+
+/* The following "category" function returns one of the following */
+#define SG_ERR_CAT_CLEAN 0      /* No errors or other information */
+#define SG_ERR_CAT_MEDIA_CHANGED 1 /* interpreted from sense buffer */
+#define SG_ERR_CAT_RESET 2      /* interpreted from sense buffer */
+#define SG_ERR_CAT_TIMEOUT 3
+#define SG_ERR_CAT_RECOVERED 4  /* Successful command after recovered err */
+#define SG_ERR_CAT_SENSE 98     /* Something else is in the sense buffer */
+#define SG_ERR_CAT_OTHER 99     /* Some other error/warning has occurred */
+
+extern int sg_err_category(int masked_status, int host_status,
+               int driver_status, const unsigned char * sense_buffer,
+               int sb_len);
+
+/* The following function declaration is for the sg version 3 driver. 
+   Only version 3 sg_err.c defines it. */
+extern int sg_err_category3(struct sg_io_hdr * hp);
+
+/* Returns length of SCSI command given the opcode (first byte) */
+int sg_get_command_size(unsigned char opcode);
+
+#endif
diff --git a/sparc-patch1 b/sparc-patch1
deleted file mode 100644 (file)
index 3b62195..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-diff -ux Makefile mtx-1.2.9/mtxl.c mtx-1.2.9.works/mtxl.c
---- mtx-1.2.9/mtxl.c    Mon Jul 31 12:33:53 2000
-+++ mtx-1.2.9.works/mtxl.c      Sat Nov 25 16:47:45 2000
-@@ -431,8 +431,10 @@
- ElementStatus_T *ReadElementStatus(DEVICE_TYPE MediumChangerFD, RequestSense_T *RequestSense, Inquiry_T *inquiry_info, SCSI_Flags_T *flags) {
-   ElementStatusDataHeader_T *ElementStatusDataHeader;
-   ElementStatusPage_T *ElementStatusPage;
-+  ElementStatusPage_T ESBuf;
-   ElementStatus_T *ElementStatus;
-   TransportElementDescriptor_T *TransportElementDescriptor;
-+  TransportElementDescriptor_T TEBuf;
-   unsigned char *DataBuffer; /* size of data... */
-   unsigned char *DataPointer; /* point into the databuffer; */
-@@ -648,7 +651,8 @@
-       got_element_num++;
- #endif
--      ElementStatusPage = (ElementStatusPage_T *) DataPointer;
-+      memcpy(&ESBuf, DataPointer, sizeof(ElementStatusPage_T));
-+      ElementStatusPage = &ESBuf;
-       DataPointer += sizeof(ElementStatusPage_T);
-       TransportElementDescriptorLength =
-        BigEndian16(ElementStatusPage->ElementDescriptorLength);
-@@ -671,8 +675,8 @@
-        BigEndian24(ElementStatusPage->ByteCountOfDescriptorDataAvailable);
-       while (BytesAvailable > 0)
-        {
--         TransportElementDescriptor =
--           (TransportElementDescriptor_T *) DataPointer;
-+         memcpy(&TEBuf, DataPointer, TransportElementDescriptorLength);
-+         TransportElementDescriptor = &TEBuf;
-          DataPointer += TransportElementDescriptorLength;
-          BytesAvailable -= TransportElementDescriptorLength;
-          ElementCount--;                                                       
index b53a86c8d295b1f2e2ec895a7577a1d953116ab9..09d66857974c30ce02978f1e1636c1f90bbe0f1f 100644 (file)
@@ -1,5 +1,5 @@
 .\" tapeinfo.1  Document copyright 2000 Eric Lee Green
-.\"  Program Copyright 2000 Eric Lee Green <eric@estinc.com>
+.\"  Program Copyright 2000 Eric Lee Green <eric@badtux.org>
 .\"
 .\" This is free documentation; you can redistribute it and/or
 .\" modify it under the terms of the GNU General Public License as
@@ -62,11 +62,10 @@ tape drives (HP DDS4, Seagate AIT).
 .P
 .SH AVAILABILITY
 .B tapeinfo
-is currently being maintained by Eric Lee Green <eric@badtux.org> formerly of
-Enhanced Software Technologies Inc. The 'mtx' home page is
-http://mtx.sourceforge.net and the actual code
-is currently available there and via CVS from 
-http://sourceforge.net/projects/mtx/ . 
+is currently being maintained by Robert Nelson <robertnelson@users.sourceforge.net> 
+as part of the 'mtx' suite of programs. The 'mtx' home page is 
+http://mtx.sourceforge.net and the actual code is currently available there and via 
+SVN from http://sourceforge.net/projects/mtx. 
 
 .SH SEE ALSO
-.BR mt (1), mtx (1), scsitape (1)
+.BR mt (1), mtx (1), scsitape (1), scsieject (1), loaderinfo (1)
index 820004ed66a84aab1ce35b80a49d04452f32eea1..bd80b3b78490e77a6edef3db1c9903e1cb0812ed 100644 (file)
@@ -1,8 +1,8 @@
 /* Copyright 2000 Enhanced Software Technologies Inc.
  *   Released under terms of the GNU General Public License as
  * required by the license on 'mtxl.c'.
- * $Date: 2001/06/19 21:51:32 $
- * $Revision: 1.2 $
+ * $Date: 2007-03-24 18:14:01 -0700 (Sat, 24 Mar 2007) $
+ * $Revision: 166 $
  */
 
 /*#define DEBUG_PARTITION */
 #include "mtx.h"
 #include "mtxl.h"
 
-char  *argv0;
+char   *argv0;
 
-void usage(void) {
-  FatalError("Usage: tapeinfo -f <generic-device>\n");
+void usage(void)
+{
+       FatalError("Usage: tapeinfo -f <generic-device>\n");
 }
 
 /* A table for printing out the peripheral device type as ASCII. */ 
-static char *PeripheralDeviceType[32] = {
-  "Disk Drive",
-  "Tape Drive",
-  "Printer",
-  "Processor",
-  "Write-once",
-  "CD-ROM",
-  "Scanner",
-  "Optical",
-  "Medium Changer",
-  "Communications",
-  "ASC IT8",
-  "ASC IT8",
-  "RAID Array",
-  "Enclosure Services",
-  "OCR/W",
-  "Bridging Expander", /* 0x10 */
-  "Reserved",  /* 0x11 */
-  "Reserved", /* 0x12 */
-  "Reserved",  /* 0x13 */
-  "Reserved",  /* 0x14 */
-  "Reserved",  /* 0x15 */
-  "Reserved",  /* 0x16 */
-  "Reserved",  /* 0x17 */
-  "Reserved",  /* 0x18 */
-  "Reserved",  /* 0x19 */
-  "Reserved",  /* 0x1a */
-  "Reserved",  /* 0x1b */
-  "Reserved",  /* 0x1c */
-  "Reserved",  /* 0x1d */
-  "Reserved",  /* 0x1e */
-  "Unknown"    /* 0x1f */
+static char *PeripheralDeviceType[32] =
+{
+       "Disk Drive",
+       "Tape Drive",
+       "Printer",
+       "Processor",
+       "Write-once",
+       "CD-ROM",
+       "Scanner",
+       "Optical",
+       "Medium Changer",
+       "Communications",
+       "ASC IT8",
+       "ASC IT8",
+       "RAID Array",
+       "Enclosure Services",
+       "OCR/W",
+       "Bridging Expander",    /* 0x10 */
+       "Reserved",                             /* 0x11 */
+       "Reserved",                             /* 0x12 */
+       "Reserved",                             /* 0x13 */
+       "Reserved",                             /* 0x14 */
+       "Reserved",                             /* 0x15 */
+       "Reserved",                             /* 0x16 */
+       "Reserved",                             /* 0x17 */
+       "Reserved",                             /* 0x18 */
+       "Reserved",                             /* 0x19 */
+       "Reserved",                             /* 0x1a */
+       "Reserved",                             /* 0x1b */
+       "Reserved",                             /* 0x1c */
+       "Reserved",                             /* 0x1d */
+       "Reserved",                             /* 0x1e */
+       "Unknown"                               /* 0x1f */
 };
 
 
@@ -99,34 +101,43 @@ static char *PeripheralDeviceType[32] = {
 
 static void ReportInquiry(DEVICE_TYPE MediumChangerFD)
 {
-  RequestSense_T RequestSense;
-  Inquiry_T *Inquiry;
-  int i;
-
-  Inquiry = RequestInquiry(MediumChangerFD,&RequestSense);
-  if (Inquiry == NULL) 
-    {
-      PrintRequestSense(&RequestSense);
-      FatalError("INQUIRY Command Failed\n");
-    }
-  
-  printf("Product Type: %s\n",PeripheralDeviceType[Inquiry->PeripheralDeviceType]);
-  printf("Vendor ID: '");
-  for (i = 0; i < sizeof(Inquiry->VendorIdentification); i++)
-    printf("%c", Inquiry->VendorIdentification[i]);
-  printf("'\nProduct ID: '");
-  for (i = 0; i < sizeof(Inquiry->ProductIdentification); i++)
-    printf("%c", Inquiry->ProductIdentification[i]);
-  printf("'\nRevision: '");
-  for (i = 0; i < sizeof(Inquiry->ProductRevisionLevel); i++)
-    printf("%c", Inquiry->ProductRevisionLevel[i]);
-  printf("'\n");\
-  if (Inquiry->MChngr) {  /* check the attached-media-changer bit... */
-    printf("Attached Changer: Yes\n");
-  } else {
-    printf("Attached Changer: No\n");
-  }
-  free(Inquiry);  /* well, we're about to exit, but ... */
+       RequestSense_T RequestSense;
+       Inquiry_T *Inquiry;
+       int i;
+
+       Inquiry = RequestInquiry(MediumChangerFD, &RequestSense);
+       if (Inquiry == NULL)
+       {
+               PrintRequestSense(&RequestSense);
+               FatalError("INQUIRY Command Failed\n");
+       }
+
+       printf("Product Type: %s\n", PeripheralDeviceType[Inquiry->PeripheralDeviceType]);
+
+       printf("Vendor ID: '");
+       for (i = 0; i < sizeof(Inquiry->VendorIdentification); i++)
+               printf("%c", Inquiry->VendorIdentification[i]);
+
+       printf("'\nProduct ID: '");
+       for (i = 0; i < sizeof(Inquiry->ProductIdentification); i++)
+               printf("%c", Inquiry->ProductIdentification[i]);
+
+       printf("'\nRevision: '");
+       for (i = 0; i < sizeof(Inquiry->ProductRevisionLevel); i++)
+               printf("%c", Inquiry->ProductRevisionLevel[i]);
+       printf("'\n");
+
+       if (Inquiry->MChngr)
+       {
+               /* check the attached-media-changer bit... */
+               printf("Attached Changer API: Yes\n");
+       }
+       else
+       {
+               printf("Attached Changer API: No\n");
+       }
+
+       free(Inquiry);          /* well, we're about to exit, but ... */
 }
 
 
@@ -136,321 +147,505 @@ static void ReportInquiry(DEVICE_TYPE MediumChangerFD)
 #define TAPEALERT_SIZE 2048  /* max size of tapealert buffer. */ 
 #define MAX_TAPE_ALERT 0x41
 
-static char *tapealert_messages[]= {
-  "Undefined", /* 0 */
-  "         Read: Having problems reading (slowing down)", /* 1 */
-  "        Write: Having problems writing (losing capacity)", /* 2 */
-  "   Hard Error: Uncorrectable read/write error", /* 3 */
-  "        Media: Media Performance Degraded, Data Is At Risk", /* 4 */
-  " Read Failure: Tape faulty or tape drive broken", /* 5 */
-  "Write Failure: Tape faulty or tape drive broken", /* 6 */
-  "   Media Life: The tape has reached the end of its useful life", /* 7 */
-  "Not Data Grade:Replace cartridge with one  containing data grade tape",/*8*/
-  "Write Protect: Attempted to write to a write-protected cartridge",/*9 */
-  "   No Removal: Cannot unload, initiator is preventing media removal", /*a*/
-  "Cleaning Media:Cannot back up or restore to a cleaning cartridge", /* b */
-  "   Bad Format: The loaded tape contains data in an unsupported format", /*c */
-  " Snapped Tape: The data cartridge contains a broken tape", /* d */
-  "Undefined", /* e */
-  "Undefined", /* f */
-  "Undefined", /* 10 */
-  "Undefined", /* 11 */
-  "Undefined", /* 12 */
-  "Undefined", /* 13 */
-  "    Clean Now: The tape drive neads cleaning NOW", /* 0x14 */
-  "Clean Periodic:The tape drive needs to be cleaned at next opportunity", /* 0x15 */
-  "Cleaning Media:Cannot clean because cleaning cartridge used up, insert new cleaning cartridge to clean the drive", /* 0x16 */
-  "Undefined", /* 0x17 */
-  "Undefined", /* 0x18 */
-  "Undefined", /* 0x19 */
-  "Undefined", /* 0x1a */
-  "Undefined", /* 0x1b */
-  "Undefined", /* 0x1c */
-  "Undefined", /* 0x1d */
-  "   Hardware A: Tape drive has a problem not read/write related", /* 0x1e */
-  "   Hardware B: Tape drive has a problem not read/write related", /* 0x1f */
-  "    Interface: Problem with SCSI interface between tape drive and initiator", /* 0x20 */
-  "  Eject Media: The current operation has failed. Eject and reload media", /* 0x21 */
-  "Download Fail: Attempt to download new firmware failed", /* 0x22 */
-  "Undefined", /* 0x23 */
-  "Undefined", /* 0x24 */
-  "Undefined", /* 0x25 */
-  "Undefined", /* 0x26 */
-  "Undefined", /* 0x27 */
-  "Loader Hardware A: Changer having problems communicating with tape drive", /* 0x28   40 */
-  "Loader Stray Tape: Stray tape left in drive from prior error", /* 0x29 41 */
-  "Loader Hardware B: Autoloader mechanism has a fault", /* 0x2a 42 */
-  "  Loader Door: Loader door is open, please close it", /* 0x2b 43 */
-  "Undefined", /* 0x2c */
-  "Undefined", /* 0x2d */
-  "Undefined", /* 0x2e */
-  "Undefined", /* 0x2f */
-  "Undefined", /* 0x30 */
-  "Undefined", /* 0x31 */
-  "Undefined", /* 0x32 */
-  "Undefined", /* 0x33 */
-  "Undefined", /* 0x34 */
-  "Undefined", /* 0x35 */
-  "Undefined", /* 0x36 */
-  "Undefined", /* 0x37 */
-  "Undefined", /* 0x38 */
-  "Undefined", /* 0x39 */
-  "Undefined", /* 0x3a */
-  "Undefined", /* 0x3b */
-  "Undefined", /* 0x3c */
-  "Undefined", /* 0x3d */
-  "Undefined", /* 0x3e */
-  "Undefined", /* 0x3f */
-  "Undefined" /* 0x40 */
+static char *tapealert_messages[] =
+{
+       "Undefined", /* 0 */
+       "         Read: Having problems reading (slowing down)", /* 1 */
+       "        Write: Having problems writing (losing capacity)", /* 2 */
+       "   Hard Error: Uncorrectable read/write error", /* 3 */
+       "        Media: Media Performance Degraded, Data Is At Risk", /* 4 */
+       " Read Failure: Tape faulty or tape drive broken", /* 5 */
+       "Write Failure: Tape faulty or tape drive broken", /* 6 */
+       "   Media Life: The tape has reached the end of its useful life", /* 7 */
+       "Not Data Grade:Replace cartridge with one  containing data grade tape",/*8*/
+       "Write Protect: Attempted to write to a write-protected cartridge",/*9 */
+       "   No Removal: Cannot unload, initiator is preventing media removal", /*a*/
+       "Cleaning Media:Cannot back up or restore to a cleaning cartridge", /* b */
+       "   Bad Format: The loaded tape contains data in an unsupported format", /*c */
+       " Snapped Tape: The data cartridge contains a broken tape", /* d */
+       "Undefined", /* e */
+       "Undefined", /* f */
+       "Undefined", /* 10 */
+       "Undefined", /* 11 */
+       "Undefined", /* 12 */
+       "Undefined", /* 13 */
+       "    Clean Now: The tape drive neads cleaning NOW", /* 0x14 */
+       "Clean Periodic:The tape drive needs to be cleaned at next opportunity", /* 0x15 */
+       "Cleaning Media:Cannot clean because cleaning cartridge used up, insert new cleaning cartridge to clean the drive", /* 0x16 */
+       "Undefined", /* 0x17 */
+       "Undefined", /* 0x18 */
+       "Undefined", /* 0x19 */
+       "Undefined", /* 0x1a */
+       "Undefined", /* 0x1b */
+       "Undefined", /* 0x1c */
+       "Undefined", /* 0x1d */
+       "   Hardware A: Tape drive has a problem not read/write related", /* 0x1e */
+       "   Hardware B: Tape drive has a problem not read/write related", /* 0x1f */
+       "    Interface: Problem with SCSI interface between tape drive and initiator", /* 0x20 */
+       "  Eject Media: The current operation has failed. Eject and reload media", /* 0x21 */
+       "Download Fail: Attempt to download new firmware failed", /* 0x22 */
+       "Undefined", /* 0x23 */
+       "Undefined", /* 0x24 */
+       "Undefined", /* 0x25 */
+       "Undefined", /* 0x26 */
+       "Undefined", /* 0x27 */
+       "Loader Hardware A: Changer having problems communicating with tape drive", /* 0x28   40 */
+       "Loader Stray Tape: Stray tape left in drive from prior error", /* 0x29 41 */
+       "Loader Hardware B: Autoloader mechanism has a fault", /* 0x2a 42 */
+       "  Loader Door: Loader door is open, please close it", /* 0x2b 43 */
+       "Undefined", /* 0x2c */
+       "Undefined", /* 0x2d */
+       "Undefined", /* 0x2e */
+       "Undefined", /* 0x2f */
+       "Undefined", /* 0x30 */
+       "Undefined", /* 0x31 */
+       "Undefined", /* 0x32 */
+       "Undefined", /* 0x33 */
+       "Undefined", /* 0x34 */
+       "Undefined", /* 0x35 */
+       "Undefined", /* 0x36 */
+       "Undefined", /* 0x37 */
+       "Undefined", /* 0x38 */
+       "Undefined", /* 0x39 */
+       "Undefined", /* 0x3a */
+       "Undefined", /* 0x3b */
+       "Undefined", /* 0x3c */
+       "Undefined", /* 0x3d */
+       "Undefined", /* 0x3e */
+       "Undefined", /* 0x3f */
+       "Undefined" /* 0x40 */
 };
 
+typedef struct TapeCapacityStruct
+{
+       unsigned int partition0_remaining;
+       unsigned int partition1_remaining;
+       unsigned int partition0_size;
+       unsigned int partition1_size;
+}      TapeCapacity;
+
+#if defined(DEBUG)
+/* DEBUG */
+static void dump_data(unsigned char *data, int len)
+{
+       if (len != 0)
+       {
+               fprintf(stderr,"DATA:");
+               PrintHex(1, data, len);
+       }
+       else
+       {
+               fprintf(stderr, "**NO DATA**\n");
+       }
+}
+#endif
+
 
-struct tapealert_struct {
-  int length;
-  unsigned char *data;
+/* Request the tape capacity page defined by some DAT autoloaders. */
+
+static TapeCapacity *RequestTapeCapacity(DEVICE_TYPE fd, RequestSense_T *sense)
+{
+       CDB_T CDB;
+       TapeCapacity *result;
+       int result_len;
+
+       unsigned char buffer[TAPEALERT_SIZE]; /* Overkill, but ... */
+
+       slow_bzero((char *)buffer,TAPEALERT_SIZE); /*zero it... */
+
+       /* now to create the CDB block: */
+       CDB[0] = 0x4d;   /* Log Sense */
+       CDB[1] = 0;   
+       CDB[2] = 0x31;   /* Tape Capacity Page. */
+       CDB[3] = 0;
+       CDB[4] = 0;
+       CDB[5] = 0;
+       CDB[6] = 0;
+       CDB[7] = TAPEALERT_SIZE >> 8 & 0xff;    /* hi byte, allocation size */
+       CDB[8] = TAPEALERT_SIZE & 0xff;                 /* lo byte, allocation size */
+       CDB[9] = 0;                                                             /* reserved */ 
+
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 10, buffer, TAPEALERT_SIZE, sense) != 0)
+       {
+               /*    fprintf(stderr,"RequestTapeCapacity: Command failed: Log Sense\n"); */
+               return NULL;
+       }
+
+       /* dump_data(buffer,64); */
+
+       /* okay, we have stuff in the result buffer: the first 4 bytes are a header:
+       * byte 0 should be 0x31, byte 1 == 0, bytes 2,3 tell how long the
+       * log page is. 
+       */
+       if ((buffer[0]&0x3f) != 0x31)
+       {
+               /*    fprintf(stderr,"RequestTapeCapacity: Invalid header for page (not 0x31).\n"); */
+               return NULL;
+       }
+
+       result_len = ((int)buffer[2] << 8) + buffer[3];
+
+       if (result_len != 32)
+       {
+               /*   fprintf(stderr,"RequestTapeCapacity: Page was %d bytes long, not 32 bytes\n",result_len); */
+               return NULL; /* This Is Not The Page You're Looking For */
+       }
+
+       result = xmalloc(sizeof(TapeCapacity));
+
+       /* okay, now allocate data and move the buffer over there: */
+
+               /*      0  1  2  3  4  5  6  7  8  9
+       DATA:   31 00 00 20 00 01 4c 04 01 3a
+                       10 11 12 13 14 15 16 17 18 19
+       DATA:   81 0c 00 02 4c 04 00 00 00 00
+                       20 21 22 23 24 25 26 27 28 29
+       DATA:   00 03 4c 04 01 3f 4b 1f 00 04
+                       30 31 32 33 34 35
+       DATA:   4c 04 00 00 00 00 00 00 00 00
+       DATA:   00 00 00 00 00 00 00 00 00 00
+       DATA:   00 00 00 00 00 00 00 00 00 00
+       DATA:   00 00 00 00
+       */
+
+       result->partition0_remaining =
+               ((unsigned int)buffer[8]  << 24) +
+               ((unsigned int)buffer[9]  << 16) +
+               ((unsigned int)buffer[10] <<  8) + 
+               buffer[11];
+
+       result->partition1_remaining =
+               ((unsigned int)buffer[16] << 24) +
+               ((unsigned int)buffer[17] << 16) +
+               ((unsigned int)buffer[18] <<  8) +
+               buffer[19];
+
+       result->partition0_size =
+               ((unsigned int)buffer[24] << 24) +
+               ((unsigned int)buffer[25] << 16) +
+               ((unsigned int)buffer[26] <<  8) +
+               buffer[27];
+
+       result->partition1_size =
+               ((unsigned int)buffer[32] << 24) +
+               ((unsigned int)buffer[33] << 16) +
+               ((unsigned int)buffer[34] <<  8) +
+               buffer[35]; 
+
+       return result;
+}
+
+
+
+struct tapealert_struct
+{
+       int length;
+       unsigned char *data;
 };
-  
-  
-static struct tapealert_struct *RequestTapeAlert(DEVICE_TYPE fd, RequestSense_T *sense) {
-  CDB_T CDB;
-  
-  struct tapealert_struct *result;
-  int i,tapealert_len,result_idx;
-  
-  unsigned char buffer[TAPEALERT_SIZE];
-  unsigned char *walkptr;
-
-  slow_bzero(buffer,TAPEALERT_SIZE); /*zero it... */
-
-  /* now to create the CDB block: */
-  CDB[0]=0x4d;   /* Log Sense */
-  CDB[1]=0;   
-  CDB[2]=0x2e;   /* Tape Alert Page. */
-  CDB[3]=0;
-  CDB[4]=0;
-  CDB[5]=0;
-  CDB[6]=0;
-  CDB[7]=TAPEALERT_SIZE>>8 & 0xff;  /* hi byte, allocation size */
-  CDB[8]=TAPEALERT_SIZE & 0xff;     /* lo byte, allocation size */
-  CDB[9]=0;  /* reserved */ 
-
-  if (SCSI_ExecuteCommand(fd,Input,&CDB,10,buffer,TAPEALERT_SIZE,sense)!=0){
-    return NULL;
-  }
-
-  result=xmalloc(sizeof(struct tapealert_struct));
-
-  /* okay, we have stuff in the result buffer: the first 4 bytes are a header:
-   * byte 0 should be 0x2e, byte 1 == 0, bytes 2,3 tell how long the
-   * tapealert page is. 
-   */
-  if ((buffer[0]&0x3f) != 0x2e) {
-    result->data=NULL;
-    result->length=0;
-    return result;
-  }
-
-  tapealert_len=(((int)buffer[2])<<8) + buffer[3];
-  
-
-  if (!tapealert_len) {
-    result->length=0;
-    result->data=NULL;
-    return result;
-  }
-
-  /* okay, now allocate data and move the buffer over there: */
-  result->length=MAX_TAPE_ALERT;
-  result->data=xzmalloc(MAX_TAPE_ALERT); /* alloc & zero. */
-  
-  walkptr=&buffer[4];
-  i=0;
-  while (i<tapealert_len) {
-    
-
-    result_idx=(((int)walkptr[0])<<8) + walkptr[1]; /* the parameter #. */
-    if (result_idx > 0 && result_idx < MAX_TAPE_ALERT) {
-      if (walkptr[4]) {
-       result->data[result_idx]=1; 
-      } else {
-       result->data[result_idx]=0;
-      }
+
+static struct tapealert_struct *RequestTapeAlert(DEVICE_TYPE fd, RequestSense_T *sense)
+{
+       CDB_T CDB;
+
+       struct tapealert_struct *result;
+       int i, tapealert_len, result_idx;
+
+       unsigned char buffer[TAPEALERT_SIZE];
+       unsigned char *walkptr;
+
+       slow_bzero((char *)buffer, TAPEALERT_SIZE); /*zero it... */
+
+       /* now to create the CDB block: */
+       CDB[0] = 0x4d;  /* Log Sense */
+       CDB[1] = 0;
+       CDB[2] = 0x2e;  /* Tape Alert Page. */
+       CDB[3] = 0;
+       CDB[4] = 0;
+       CDB[5] = 0;
+       CDB[6] = 0;
+       CDB[7] = TAPEALERT_SIZE >> 8 & 0xff;    /* hi byte, allocation size */
+       CDB[8] = TAPEALERT_SIZE & 0xff;                 /* lo byte, allocation size */
+       CDB[9] = 0;                                                             /* reserved */
+
+       if (SCSI_ExecuteCommand(fd,Input,&CDB,10,buffer,TAPEALERT_SIZE,sense)!=0)
+       {
+               return NULL;
+       }
+
+       result = xmalloc(sizeof(struct tapealert_struct));
+
+       /* okay, we have stuff in the result buffer: the first 4 bytes are a header:
+        * byte 0 should be 0x2e, byte 1 == 0, bytes 2,3 tell how long the
+        * tapealert page is. 
+        */
+       if ((buffer[0]&0x3f) != 0x2e)
+       {
+               result->data = NULL;
+               result->length = 0;
+               return result;
+       }
+
+       tapealert_len = ((int)buffer[2] << 8) + buffer[3];
+
+       if (!tapealert_len)
+       {
+               result->length = 0;
+               result->data = NULL;
+               return result;
+       }
+
+       /* okay, now allocate data and move the buffer over there: */
+       result->length = MAX_TAPE_ALERT;
+       result->data = xzmalloc(MAX_TAPE_ALERT); /* alloc & zero. */
+
+       walkptr = &buffer[4];
+       i = 0;
+
+       while (i < tapealert_len)
+       {
+               result_idx=(((int)walkptr[0])<<8) + walkptr[1]; /* the parameter #. */
+               if (result_idx > 0 && result_idx < MAX_TAPE_ALERT)
+               {
+                       if (walkptr[4])
+                       {
+                               result->data[result_idx] = 1; 
+                       }
+                       else
+                       {
+                               result->data[result_idx] = 0;
+                       }
 #ifdef DEBUGOLD1
-      fprintf(stderr,"Alert[0x%x]=%d\n",result_idx,result->data[result_idx]);
-      fflush(stderr);
+                       fprintf(stderr,"Alert[0x%x]=%d\n",result_idx,result->data[result_idx]);
+                       fflush(stderr);
 #endif
-    } else {
-      FatalError("Invalid tapealert page: %d\n",result_idx);
-    }
-    i=i+4+walkptr[3]; /* length byte! */
-    walkptr=walkptr+4+walkptr[3]; /* next! */
-  }
-  return result;
+               }
+               else
+               {
+                       FatalError("Invalid tapealert page: %d\n",result_idx);
+               }
+
+               i = i + 4 + walkptr[3]; /* length byte! */
+               walkptr = walkptr + 4 + walkptr[3]; /* next! */
+       }
+       return result;
 }
 
-static void ReportTapeAlert(DEVICE_TYPE fd) {
-  /* we actually ignore a bad sense reading, like might happen if the 
-   * tape drive does not support the tapealert page. 
-   */
-  
-  RequestSense_T RequestSense;
-  
-  struct tapealert_struct *result;
-  int i;
-
-  result=RequestTapeAlert(fd,&RequestSense);
-  if (!result) return; /* sorry. Don't print sense here. */
-  if (!result->length) return; /* sorry, no alerts valid. */
-  
-  for (i=0;i<result->length;i++) {
-    if (result->data[i]) {
-      printf("TapeAlert[%d]:%s.\n",i,tapealert_messages[i]);
-    }
-  }
-  free(result->data);
-  free(result);
-  return;
-}
+static void ReportTapeCapacity(DEVICE_TYPE fd)
+{
+       /* we actually ignore a bad sense reading, like might happen if the 
+        * tape drive does not support the tape capacity page. 
+        */
 
-static unsigned char
-*mode_sense(DEVICE_TYPE fd, int pagenum, int alloc_len,  RequestSense_T *RequestSense) {
-  CDB_T CDB;
-
-  unsigned char *input_buffer; /*the input buffer -- has junk prepended to
-                               * actual sense page. 
-                               */
-  unsigned char *tmp;
-  unsigned char *retval;  /* the return value. */
-  int i,pagelen;
-
-  if (alloc_len > 255) {
-    FatalError("mode_sense(6) can only read up to 255 characters!\n");
-  }
-
-  input_buffer=(unsigned char *)xzmalloc(256); /* overdo it, eh? */
-
-  /* clear the sense buffer: */
-  slow_bzero((char *)RequestSense,sizeof(RequestSense_T));
-  
-
-  /* returns an array of bytes in the page, or, if not possible, NULL. */
-  CDB[0]=0x1a; /* Mode Sense(6) */
-  CDB[1]=0; 
-  CDB[2]=pagenum; /* the page to read. */
-  CDB[3]=0;
-  CDB[4]=255; /* allocation length. This does max of 256 bytes! */
-  CDB[5]=0;
-  
-  if (SCSI_ExecuteCommand(fd,Input,&CDB,6,
-                         input_buffer,255,RequestSense) != 0) {
-#ifdef DEBUG_MODE_SENSE
-    fprintf(stderr,"Could not execute mode sense...\n");
-    fflush(stderr);
-#endif
-    return NULL; /* sorry, couldn't do it. */
-  }
-
-  /* Oh hell, write protect is the only thing I have: always print
-   * it if our mode page was 0x0fh, before skipping past buffer: 
-   * if the media is *NOT* write protected, just skip, sigh. 
-   *
-   * Oh poops, the blocksize is reported in the block descriptor header
-<   * too. Again, just print if our mode page was 0x0f...
-   */
-  if (pagenum == 0x0f) {
-    int blocklen;
-    if (input_buffer[2] & 0x80) {
-      printf("WriteProtect: yes\n");
-    }
-    if (input_buffer[2] & 0x70) {
-      printf("BufferedMode: yes\n");
-    }
-    if (input_buffer[1] ) {
-      printf("Medium Type: 0x%x\n", input_buffer[1]);
-    } else {
-      printf("Medium Type: Not Loaded\n");
-    }
-    printf("Density Code: 0x%x\n", input_buffer[4]);
-    /* Put out the block size: */
-    blocklen=((int)input_buffer[9]<<16)+
-      ((int)input_buffer[10]<<8)+
-      input_buffer[11];
-    printf("BlockSize: %d\n", blocklen);
-    /* This doesn't seem to do anything useful on my Tandberg so I
-     * am taking it out -- elg
-     */ 
-    /* Put out the # Blocks */
-    /* blocklen=((int)input_buffer[5]<<16)+ */
-    /*      ((int)input_buffer[6]<<8)+ */
-    /*      input_buffer[7]; */
-    /* printf("Num Blocks:  %d\n", blocklen); */
-  }
-  /* First skip past any header.... */
-  tmp=input_buffer+4+input_buffer[3];
-  /* now find out real length of page... */
-  pagelen=tmp[1]+2;
-  retval=xmalloc(pagelen);
-  /* and copy our data to the new page. */
-  for (i=0;i<pagelen;i++) {
-    retval[i]=tmp[i];
-  }
-  /* okay, free our input buffer: */
-  free(input_buffer);
-  return retval;
+       RequestSense_T RequestSense;
+
+       TapeCapacity *result;
+
+       result=RequestTapeCapacity(fd,&RequestSense);
+
+       if (!result)
+               return;
+
+       printf("Partition 0 Remaining Kbytes: %d\n", result->partition0_remaining);
+       printf("Partition 0 Size in Kbytes: %d\n", result->partition0_size);
+
+       if (result->partition1_size)
+       {
+               printf("Partition 1 Remaining Kbytes: %d\n", result->partition1_remaining);
+               printf("Partition 1 Size in Kbytes: %d\n", result->partition1_size);
+       }
+
+       free(result);
 }
 
 
 
+static void ReportTapeAlert(DEVICE_TYPE fd)
+{
+       /* we actually ignore a bad sense reading, like might happen if the 
+        * tape drive does not support the tapealert page. 
+        */
 
+       RequestSense_T RequestSense;
 
-#define DCE_MASK 0x80
-#define DCC_MASK 0x40
-#define DDE_MASK 0x80
+       struct tapealert_struct *result;
+       int i;
+
+       result=RequestTapeAlert(fd,&RequestSense);
+
+       if (!result)
+               return; /* sorry. Don't print sense here. */
+
+       if (!result->length)
+               return; /* sorry, no alerts valid. */
+
+       for (i = 0; i < result->length; i++)
+       {
+               if (result->data[i])
+               {
+                       printf("TapeAlert[%d]: %s.\n", i, tapealert_messages[i]);
+               }
+       }
+
+       free(result->data);
+       free(result);
+}
 
-static void ReportCompressionPage(DEVICE_TYPE fd) {
-  /* actually ignore a bad sense reading, like might happen if the tape
-   * drive does not support the mode sense compression page. 
-   */
+static unsigned char
+*mode_sense(DEVICE_TYPE fd, char pagenum, int alloc_len,  RequestSense_T *RequestSense)
+{
+       CDB_T CDB;
 
-  RequestSense_T RequestSense;
+       unsigned char *input_buffer;
+       unsigned char *tmp;
+       unsigned char *retval;
+       int i, pagelen;
 
-  unsigned char *compression_page;
+       if (alloc_len > 255)
+       {
+               FatalError("mode_sense(6) can only read up to 255 characters!\n");
+       }
 
+       input_buffer = (unsigned char *)xzmalloc(256); /* overdo it, eh? */
 
-  compression_page=mode_sense(fd,0x0f,16,&RequestSense);
+       /* clear the sense buffer: */
+       slow_bzero((char *)RequestSense, sizeof(RequestSense_T));
 
-  if (!compression_page) {
-    return;  /* sorry! */
-  }
+       /* returns an array of bytes in the page, or, if not possible, NULL. */
+       CDB[0] = 0x1a; /* Mode Sense(6) */
+       CDB[1] = 0; 
+       CDB[2] = pagenum; /* the page to read. */
+       CDB[3] = 0;
+       CDB[4] = 255; /* allocation length. This does max of 256 bytes! */
+       CDB[5] = 0;
 
-  /* Okay, we now have the compression page. Now print stuff from it: */
-  printf("DataCompEnabled: %s\n", (compression_page[2]&DCE_MASK)? "yes" : "no");
-  printf("DataCompCapable: %s\n", (compression_page[2]&DCC_MASK)? "yes" : "no");
-  printf("DataDeCompEnabled: %s\n", (compression_page[3]&DDE_MASK)? "yes" : "no");
-  printf("CompType: 0x%x\n",
-        (compression_page[4]<<24)+(compression_page[5]<<16)+(compression_page[6]<<8)+compression_page[7]);
-  printf("DeCompType: 0x%x\n",
-       (compression_page[8]<<24)+ (compression_page[9]<<16)+(compression_page[10]<<8)+compression_page[11]);
-  free(compression_page);
-  return;
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 6, input_buffer, 255, RequestSense) != 0)
+       {
+#ifdef DEBUG_MODE_SENSE
+               fprintf(stderr,"Could not execute mode sense...\n");
+               fflush(stderr);
+#endif
+               return NULL; /* sorry, couldn't do it. */
+       }
+
+       /* Oh hell, write protect is the only thing I have: always print
+        * it if our mode page was 0x0fh, before skipping past buffer: 
+        * if the media is *NOT* write protected, just skip, sigh. 
+        *
+        * Oh poops, the blocksize is reported in the block descriptor header
+        * <   * too. Again, just print if our mode page was 0x0f...
+        */
+       if (pagenum == 0x0f)
+       {
+               int blocklen;
+
+               if (input_buffer[2] & 0x80)
+               {
+                       printf("WriteProtect: yes\n");
+               }
+
+               if (input_buffer[2] & 0x70)
+               {
+                       printf("BufferedMode: yes\n");
+               }
+
+               if (input_buffer[1] )
+               {
+                       printf("Medium Type: 0x%x\n", input_buffer[1]);
+               }
+               else
+               {
+                       printf("Medium Type: Not Loaded\n");
+               }
+
+               printf("Density Code: 0x%x\n", input_buffer[4]);
+               /* Put out the block size: */
+
+               blocklen =      ((int)input_buffer[9]  << 16)+
+                                       ((int)input_buffer[10] <<  8)+
+                                       input_buffer[11];
+
+               printf("BlockSize: %d\n", blocklen);
+       }
+
+       /* First skip past any header.... */
+       tmp = input_buffer + 4 + input_buffer[3];
+
+       /* now find out real length of page... */
+       pagelen = tmp[1] + 2;
+       retval = xmalloc(pagelen);
+
+       /* and copy our data to the new page. */
+       for (i=0;i<pagelen;i++)
+       {
+               retval[i]=tmp[i];
+       }
+
+       /* okay, free our input buffer: */
+       free(input_buffer);
+       return retval;
 }
-  
+
+
+#define DCE_MASK 0x80
+#define DCC_MASK 0x40
+#define DDE_MASK 0x80
+
+static void ReportCompressionPage(DEVICE_TYPE fd)
+{
+       /* actually ignore a bad sense reading, like might happen if the tape
+       * drive does not support the mode sense compression page. 
+       */
+
+       RequestSense_T RequestSense;
+
+       unsigned char *compression_page;
+
+       compression_page=mode_sense(fd,0x0f,16,&RequestSense);
+
+       if (!compression_page)
+       {
+               return;  /* sorry! */
+       }
+
+       /* Okay, we now have the compression page. Now print stuff from it: */
+       printf("DataCompEnabled: %s\n", (compression_page[2] & DCE_MASK)? "yes" : "no");
+       printf("DataCompCapable: %s\n", (compression_page[2] & DCC_MASK)? "yes" : "no");
+       printf("DataDeCompEnabled: %s\n", (compression_page[3] & DDE_MASK)? "yes" : "no");
+       printf("CompType: 0x%x\n",
+               (compression_page[4] << 24) +
+               (compression_page[5] << 16) +
+               (compression_page[6] <<  8) +
+                compression_page[7]);
+
+       printf("DeCompType: 0x%x\n",
+               (compression_page[8]  << 24) +
+               (compression_page[9]  << 16) +
+               (compression_page[10] <<  8) +
+                compression_page[11]);
+
+       free(compression_page);
+}
+
 /* Now for the device configuration mode page: */
 
-static void ReportConfigPage(DEVICE_TYPE fd) {
-  RequestSense_T RequestSense;
-  unsigned char *config_page;
-  
-  config_page=mode_sense(fd,0x10,16,&RequestSense);
-  if (!config_page) return;
-
-  /* Now to print the stuff: */
-  printf("ActivePartition: %d\n",config_page[3]);
-  /* The following does NOT work accurately on any tape drive I know of... */
-  /*  printf("DevConfigComp: %s\n", config_page[14] ? "yes" : "no"); */
-  printf("EarlyWarningSize: %d\n",
-        (config_page[11]<<16)+(config_page[12]<<8)+config_page[13]);
-  return;
+static void ReportConfigPage(DEVICE_TYPE fd)
+{
+       RequestSense_T RequestSense;
+       unsigned char *config_page;
+
+       config_page = mode_sense(fd, 0x10, 16, &RequestSense);
+       if (!config_page)
+               return;
+
+       /* Now to print the stuff: */
+       printf("ActivePartition: %d\n", config_page[3]);
+
+       /* The following does NOT work accurately on any tape drive I know of... */
+       /*  printf("DevConfigComp: %s\n", config_page[14] ? "yes" : "no"); */
+       printf("EarlyWarningSize: %d\n",
+               (config_page[11] << 16) +
+               (config_page[12] <<  8) +
+                config_page[13]);
 }
 
 /* ***************************************
@@ -467,156 +662,163 @@ static void ReportConfigPage(DEVICE_TYPE fd) {
  *
  ********************************************/
 
-static void ReportPartitionPage(DEVICE_TYPE fd) {
-  RequestSense_T RequestSense;
-  unsigned char *partition_page;
+static void ReportPartitionPage(DEVICE_TYPE fd)
+{
+       RequestSense_T RequestSense;
+       unsigned char *partition_page;
+
+       int num_parts,max_parts;
+       int i;
 
-  int num_parts,max_parts;
-  int i;
+       partition_page=mode_sense(fd,0x11,255,&RequestSense);
+       if (!partition_page)
+               return;
 
-  partition_page=mode_sense(fd,0x11,255,&RequestSense);
-  if (!partition_page) return;
+       /* Okay, now we have either old format or new format: */
+       num_parts = partition_page[3];
+       max_parts = partition_page[2];
 
-  /* Okay, now we have either old format or new format: */
-  num_parts=partition_page[3];
-  max_parts=partition_page[2];
+       printf("NumPartitions: %d\n", num_parts);
+       printf("MaxPartitions: %d\n", max_parts);
 
-  printf("NumPartitions:%d\n",num_parts);
-  printf("MaxPartitions:%d\n",max_parts);
-  if (!num_parts) {  /* if no additional partitions, then ... */ 
-    free(partition_page);
-    return;
-  }
-  
-  /* we know we have at least one partition if we got here. Check the
-   * page size field. If it is 8 or below, then we are the old format....
-   */
+       if (!num_parts)
+       {
+               /* if no additional partitions, then ... */ 
+               free(partition_page);
+               return;
+       }
+
+       /* we know we have at least one partition if we got here. Check the
+        * page size field. If it is 8 or below, then we are the old format....
+        */
 
 #ifdef DEBUG_PARTITION
-  fprintf(stderr,"partition_page[1]=%d\n",partition_page[1]);
-  fflush(stderr);
+       fprintf(stderr,"partition_page[1]=%d\n",partition_page[1]);
+       fflush(stderr);
 #endif
-  if (partition_page[1]==8) {
-    /* old-style! */
-    printf("Partition1:%d\n",(partition_page[8]<<8)+partition_page[9]);
-  } else {
-    /* new-style! */
-    for (i=0;i<=max_parts;i++) {
-#ifdef DEBUG_PARTITION    
-      fprintf(stderr,"partition%d:[%d]%d [%d]%d\n",i,8+i*2,
-             partition_page[8+i*2]<<8, 9+i*2,partition_page[9+i*2]);
-      fflush(stderr);
+       if (partition_page[1]==8)
+       {
+               /* old-style! */
+               printf("Partition1: %d\n",(partition_page[8]<<8)+partition_page[9]);
+       }
+       else
+       {
+               /* new-style! */
+               for (i=0;i<=max_parts;i++)
+               {
+#ifdef DEBUG_PARTITION
+                       fprintf(stderr,"partition%d:[%d]%d [%d]%d\n", i, 8 + i * 2,
+                       partition_page[8+i*2]<<8, 9+i*2,partition_page[9 + i * 2]);
+                       fflush(stderr);
 #endif
-      printf("Partition%d:%d\n",i,
-            (partition_page[8+i*2]<<8)+partition_page[9+i*2]);
-    }
-  }
-  free(partition_page);
-  return;
+                       printf("Partition%d: %d\n", i,
+                                       (partition_page[8 + i * 2] << 8) + partition_page[9 + i * 2]);
+               }
+       }
+       free(partition_page);
 }
 
-static void ReportSerialNumber(DEVICE_TYPE fd) {
-  /* actually ignore a bad sense reading, like might happen if the
-     tape drive does not support the inquiry page 0x80. 
-  */
+static void ReportSerialNumber(DEVICE_TYPE fd)
+{
+       /*      Actually ignore a bad sense reading, like might happen if the
+               tape drive does not support the inquiry page 0x80. 
+       */
+
+       RequestSense_T sense;
+       CDB_T CDB;
 
-  RequestSense_T sense;
-  CDB_T CDB;
 #define WILD_SER_SIZE 30
-  unsigned char buffer[WILD_SER_SIZE]; /* just wildly overestimate serial# length! */
-
-  int i,lim;
-  char *bufptr; 
-  
-  CDB[0]=0x12;  /* INQUIRY */
-  CDB[1]= 1;     /* EVPD = 1 */
-  CDB[2]=0x80;   /* The serial # page, hopefully. */
-  CDB[3]=0  ; /* reserved */
-  CDB[4]=WILD_SER_SIZE;
-  CDB[5]=0;
-
-  if (SCSI_ExecuteCommand(fd, Input, &CDB, 6,
-                         &buffer, sizeof(buffer), &sense) != 0)  {
-    /* PrintRequestSense(&sense); */ /* zap debugging output :-) */
-    /* printf("No Serial Number: None\n"); */
-    return; 
-  }
-  
-  /* okay, we have something in our buffer. Byte 3 should be the length of
-     the sernum field, and bytes 4 onward are the serial #. */
-  
-  lim=(int)buffer[3];
-  bufptr= &(buffer[4]);
-  
-  printf("SerialNumber: '");
-  for (i=0;i<lim;i++) {
-    putchar(*bufptr++);
-  }
-  printf("'\n");
-  return ; /* done! */
+unsigned char buffer[WILD_SER_SIZE]; /* just wildly overestimate serial# length! */
+
+       int i, lim;
+       char *bufptr; 
+
+       CDB[0] = 0x12;                  /* INQUIRY */
+       CDB[1] = 1;                             /* EVPD = 1 */
+       CDB[2] = 0x80;                  /* The serial # page, hopefully. */
+       CDB[3] = 0;                             /* reserved */
+       CDB[4] = WILD_SER_SIZE;
+       CDB[5] = 0;
+
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 6, &buffer, sizeof(buffer), &sense) != 0)
+       {
+               /* PrintRequestSense(&sense); */ /* zap debugging output :-) */
+               /* printf("No Serial Number: None\n"); */
+               return; 
+       }
+
+       /* okay, we have something in our buffer. Byte 3 should be the length of
+       the sernum field, and bytes 4 onward are the serial #. */
+
+       lim = (int)buffer[3];
+       bufptr = (char *)&(buffer[4]);
+
+       printf("SerialNumber: '");
+       for (i=0;i<lim;i++)
+       {
+               putchar(*bufptr++);
+       }
+       printf("'\n");
 }
-    
 
 /*  Read Block Limits! */
 
-void ReportBlockLimits(DEVICE_TYPE fd) {
-  RequestSense_T sense;
-  CDB_T CDB;
-  unsigned char buffer[6];
-
-
-  CDB[0]=0x05;  /* READ_BLOCK_LIMITS */
-  CDB[1]=0;
-  CDB[2]=0;
-  CDB[3]=0;  /* 1-5 all unused. */
-  CDB[4]=0;
-  CDB[5]=0; 
-
-  slow_bzero((unsigned char *)&sense,sizeof(RequestSense_T));
-  if (SCSI_ExecuteCommand(fd,Input,&CDB,6,buffer,6,&sense)!=0){
-    return;
-  }
-  
-  /* okay, but if we did get a result, print it: */
-  printf("MinBlock:%d\n",
-        (buffer[4]<<8)+buffer[5]);
-  printf("MaxBlock:%d\n",
-        (buffer[1]<<16)+(buffer[2]<<8)+buffer[3]);
-
-  return;
+void ReportBlockLimits(DEVICE_TYPE fd)
+{
+       RequestSense_T sense;
+       CDB_T CDB;
+       unsigned char buffer[6];
+
+       CDB[0] = 0x05;  /* READ_BLOCK_LIMITS */
+       CDB[1] = 0;
+       CDB[2] = 0;
+       CDB[3] = 0;             /* 1-5 all unused. */
+       CDB[4] = 0;
+       CDB[5] = 0; 
+
+       slow_bzero((char *)&sense,sizeof(RequestSense_T));
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 6, buffer, 6, &sense) != 0)
+       {
+               return;
+       }
+
+       /* okay, but if we did get a result, print it: */
+       printf("MinBlock: %d\n", (buffer[4] << 8) + buffer[5]);
+       printf("MaxBlock: %d\n", (buffer[1] << 16) + (buffer[2]<<8) + buffer[3]);
 }
-  
+
 /* Do a READ_POSITION. This may not be always valid, but (shrug). */
-void ReadPosition(DEVICE_TYPE fd) {
-  RequestSense_T sense;
-  CDB_T CDB;
-  unsigned char buffer[20];
-  unsigned int position;
-
-
-  CDB[0]=0x34;  /* READ_POSITION */
-  CDB[1]=0;
-  CDB[2]=0;
-  CDB[3]=0;  /* 1-9 all unused. */
-  CDB[4]=0;
-  CDB[5]=0; 
-  CDB[6]=0;
-  CDB[7]=0;
-  CDB[8]=0;
-  CDB[9]=0;
-
-  slow_bzero((unsigned char *)&sense,sizeof(RequestSense_T));
-
-  /* set the timeout: */
-  SCSI_Set_Timeout(2); /* set timeout to 2 seconds! */
-
-  /* if we don't get a result (e.g. we issue this to a disk drive), punt. */
-  if (SCSI_ExecuteCommand(fd,Input,&CDB,10,buffer,20,&sense)!=0){
-    return;
-  }
-  
-  SCSI_Default_Timeout(); /* reset it to 5 minutes, sigh! */
-  /* okay, but if we did get a result, print it: */
+void ReadPosition(DEVICE_TYPE fd)
+{
+       RequestSense_T sense;
+       CDB_T CDB;
+       unsigned char buffer[20];
+       unsigned int position;
+
+       CDB[0] = 0x34;          /* READ_POSITION */
+       CDB[1] = 0;
+       CDB[2] = 0;
+       CDB[3] = 0;                     /* 1-9 all unused. */
+       CDB[4] = 0;
+       CDB[5] = 0;
+       CDB[6] = 0;
+       CDB[7] = 0;
+       CDB[8] = 0;
+       CDB[9] = 0;
+
+       slow_bzero((char *)&sense, sizeof(RequestSense_T));
+
+       SCSI_Set_Timeout(2); /* set timeout to 2 seconds! */
+
+       /* if we don't get a result (e.g. we issue this to a disk drive), punt. */
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 10, buffer, 20, &sense) != 0)
+       {
+               return;
+       }
+
+       SCSI_Default_Timeout(); /* reset it to 5 minutes, sigh! */
+       /* okay, but if we did get a result, print it: */
+
 #define RBL_BOP 0x80
 #define RBL_EOP 0x40
 #define RBL_BCU 0x20
@@ -625,73 +827,81 @@ void ReadPosition(DEVICE_TYPE fd) {
 #define RBL_BPU 0x04
 #define RBL_PERR 0x02
 
-  /* If we have BOP, go ahead and print that. */
-  if (buffer[0]&RBL_BOP) {
-    printf("BOP: yes\n");
-  }
-  /* if we have valid data, print it: */
-  if (buffer[0]&RBL_BPU) {
-    printf("Block Position: -1");
-  } else {
-    
-    position= (unsigned int) (((unsigned int)buffer[4]<<24) +
-                             ((unsigned int)buffer[5]<<16) + 
-                             ((unsigned int)buffer[6]<<8) + buffer[7]);
-    printf("Block Position: %d\n",position);
-  }
-  return;
+       /* If we have BOP, go ahead and print that. */
+       if (buffer[0]&RBL_BOP)
+       {
+               printf("BOP: yes\n");
+       }
+
+       /* if we have valid data, print it: */
+       if (buffer[0]&RBL_BPU)
+       {
+               printf("Block Position: -1");
+       }
+       else
+       {
+               position = (unsigned int)(((unsigned int)buffer[4] << 24) +
+                                                                 ((unsigned int)buffer[5] << 16) +
+                                                                 ((unsigned int)buffer[6] <<  8) +
+                                                                       buffer[7]);
+
+               printf("Block Position: %d\n",position);
+       }
 }
 
 /* Test unit ready: This will tell us whether the tape drive
  * is currently ready to read or write.
  */
 
-int TestUnitReady(DEVICE_TYPE fd) {
-  RequestSense_T sense;
-  CDB_T CDB;
-  unsigned char buffer[6];
-
-
-  CDB[0]=0x00;  /* TEST_UNIT_READY */
-  CDB[1]=0;
-  CDB[2]=0;
-  CDB[3]=0;  /* 1-5 all unused. */
-  CDB[4]=0;
-  CDB[5]=0; 
-
-  slow_bzero((unsigned char *)&sense,sizeof(RequestSense_T));
-  if (SCSI_ExecuteCommand(fd,Input,&CDB,6,buffer,0,&sense)!=0){
-    printf("Ready: no\n");
-    return 0;
-  }
-  
-  printf("Ready: yes\n");
-  return 1;
+int TestUnitReady(DEVICE_TYPE fd)
+{
+       RequestSense_T sense;
+       CDB_T CDB;
+       unsigned char buffer[6];
+
+       CDB[0] = 0x00;          /* TEST_UNIT_READY */
+       CDB[1] = 0;
+       CDB[2] = 0;
+       CDB[3] = 0;                     /* 1-5 all unused. */
+       CDB[4] = 0;
+       CDB[5] = 0;
+
+       slow_bzero((char *)&sense,sizeof(RequestSense_T));
+       if (SCSI_ExecuteCommand(fd,Input,&CDB,6,buffer,0,&sense)!=0)
+       {
+               printf("Ready: no\n");
+               return 0;
+       }
+
+       printf("Ready: yes\n");
+       return 1;
 }
 
 /* We write a filemarks of 0 before going to grab position, in order
  * to insure that data in the buffer is not a problem. 
  */
 
-int WriteFileMarks(DEVICE_TYPE fd,int count) {
-  RequestSense_T sense;
-  CDB_T CDB;
-  unsigned char buffer[6];
-
-
-  CDB[0]=0x10;  /* WRITE_FILE_MARKS */
-  CDB[1]=0;
-  CDB[2]=(count >> 16) & 0xff;
-  CDB[3]=(count >>8) & 0xff;
-  CDB[4]=count & 0xff;
-  CDB[5]=0; 
-
-  /* we really don't care if this command works or not, sigh.  */
-  slow_bzero((unsigned char *)&sense,sizeof(RequestSense_T));
-  if (SCSI_ExecuteCommand(fd,Input,&CDB,6,buffer,0,&sense)!=0){
-    return 1;
-  }
-  return 0;
+int WriteFileMarks(DEVICE_TYPE fd,int count)
+{
+       RequestSense_T sense;
+       CDB_T CDB;
+       unsigned char buffer[6];
+
+       CDB[0] = 0x10;  /* WRITE_FILE_MARKS */
+       CDB[1] = 0;
+       CDB[2] = (unsigned char)(count >> 16);
+       CDB[3] = (unsigned char)(count >> 8);
+       CDB[4] = (unsigned char)count;
+       CDB[5] = 0; 
+
+       /* we really don't care if this command works or not, sigh.  */
+       slow_bzero((char *)&sense, sizeof(RequestSense_T));
+       if (SCSI_ExecuteCommand(fd, Input, &CDB, 6, buffer, 0, &sense) != 0)
+       {
+               return 1;
+       }
+
+       return 0;
 }
 
 
@@ -702,52 +912,57 @@ int WriteFileMarks(DEVICE_TYPE fd,int count) {
  */
 #ifdef HAVE_GET_ID_LUN
 
-static void ReportIDLun(DEVICE_TYPE fd) {
-  scsi_id_t *scsi_id;
+static void ReportIDLun(DEVICE_TYPE fd)
+{
+       scsi_id_t *scsi_id;
 
-  scsi_id=SCSI_GetIDLun(fd);
-  printf("SCSI ID: %d\nSCSI LUN: %d\n",scsi_id->id,scsi_id->lun);
+       scsi_id = SCSI_GetIDLun(fd);
+       printf("SCSI ID: %d\nSCSI LUN: %d\n", scsi_id->id, scsi_id->lun);
 }
 
 #endif
 
 /* we only have one argument: "-f <device>". */
-int main(int argc, char **argv) {
-  DEVICE_TYPE fd;
-  char *filename;
-
-  argv0=argv[0];
-  
-  if (argc != 3) {
-    fprintf(stderr,"argc=%d",argc);
-    usage();
-  }
-
-  if (strcmp(argv[1],"-f")!=0) {
-    usage();
-  }
-  filename=argv[2];
-  
-  fd=SCSI_OpenDevice(filename);
-  
-  /* Now to call the various routines: */
-  ReportInquiry(fd);
-  ReportSerialNumber(fd);
-  ReportTapeAlert(fd);
-  /* ReportConfigPage(fd);  */
-  /* ReportPartitionPage(fd); */
-  ReportBlockLimits(fd); 
-#ifdef HAVE_GET_ID_LUN
-  ReportIDLun(fd);
-#endif
+int main(int argc, char **argv)
+{
+       DEVICE_TYPE fd;
+       char *filename;
+
+       argv0=argv[0];
+
+       if (argc != 3)
+       {
+               fprintf(stderr,"argc=%d",argc);
+               usage();
+       }
 
-  /* okay, we should only report position if the unit is ready :-(. */
-  if (TestUnitReady(fd)) {
-    ReportCompressionPage(fd); 
-    ReadPosition(fd); 
-  }
+       if (strcmp(argv[1],"-f")!=0)
+       {
+               usage();
+       }
+       filename=argv[2];
 
+       fd=SCSI_OpenDevice(filename);
+
+       /* Now to call the various routines: */
+       ReportInquiry(fd);
+       ReportSerialNumber(fd);
+       ReportTapeAlert(fd);
+       ReportBlockLimits(fd); 
+
+#ifdef HAVE_GET_ID_LUN
+       ReportIDLun(fd);
+#endif
 
-  exit(0);
+       /* okay, we should only report position if the unit is ready :-(. */
+       if (TestUnitReady(fd))
+       {
+               ReportCompressionPage(fd); 
+               ReadPosition(fd); 
+               ReportTapeCapacity(fd);         /* only if we have it */
+               ReportConfigPage(fd);           /* only valid if unit is ready. */
+               ReportPartitionPage(fd); 
+       }
+
+       exit(0);
 }
-      
index 6cd76854c4c08e9d86b47f67a179d7e0f0c6dc33..5b3257225e7d4032b844c163b914f6d4a475b1d0 100644 (file)
 
 typedef struct scsi$desc
 {
-  unsigned int SCSI$L_OPCODE;      /* SCSI Operation Code */
-  unsigned int SCSI$L_FLAGS;       /* SCSI Flags Bit Map */
-  unsigned char *SCSI$A_CMD_ADDR;   /* ->SCSI Command Buffer */
-  unsigned int SCSI$L_CMD_LEN;     /* SCSI Command Length (bytes) */
-  unsigned char *SCSI$A_DATA_ADDR;  /* ->SCSI Data Buffer */
-  unsigned int SCSI$L_DATA_LEN;            /* SCSI Data Length (bytes) */
-  unsigned int SCSI$L_PAD_LEN;     /* SCSI Pad Length (bytes) */
-  unsigned int SCSI$L_PH_CH_TMOUT;  /* SCSI Phase Change Timeout (seconds) */
-  unsigned int SCSI$L_DISCON_TMOUT; /* SCSI Disconnect Timeout (seconds) */
-  unsigned int SCSI$L_RES_1;       /* Reserved */
-  unsigned int SCSI$L_RES_2;       /* Reserved */
-  unsigned int SCSI$L_RES_3;       /* Reserved */
-  unsigned int SCSI$L_RES_4;       /* Reserved */
-  unsigned int SCSI$L_RES_5;       /* Reserved */
-  unsigned int SCSI$L_RES_6;       /* Reserved */
+       unsigned int SCSI$L_OPCODE;         /* SCSI Operation Code */
+       unsigned int SCSI$L_FLAGS;          /* SCSI Flags Bit Map */
+       unsigned char *SCSI$A_CMD_ADDR;   /* ->SCSI Command Buffer */
+       unsigned int SCSI$L_CMD_LEN;        /* SCSI Command Length (bytes) */
+       unsigned char *SCSI$A_DATA_ADDR;  /* ->SCSI Data Buffer */
+       unsigned int SCSI$L_DATA_LEN;       /* SCSI Data Length (bytes) */
+       unsigned int SCSI$L_PAD_LEN;        /* SCSI Pad Length (bytes) */
+       unsigned int SCSI$L_PH_CH_TMOUT;  /* SCSI Phase Change Timeout (seconds) */
+       unsigned int SCSI$L_DISCON_TMOUT; /* SCSI Disconnect Timeout (seconds) */
+       unsigned int SCSI$L_RES_1;          /* Reserved */
+       unsigned int SCSI$L_RES_2;          /* Reserved */
+       unsigned int SCSI$L_RES_3;          /* Reserved */
+       unsigned int SCSI$L_RES_4;          /* Reserved */
+       unsigned int SCSI$L_RES_5;          /* Reserved */
+       unsigned int SCSI$L_RES_6;          /* Reserved */
 }
 SCSI$DESC;
 
@@ -95,10 +95,10 @@ SCSI$DESC;
 
 typedef struct scsi$iosb
 {
-  unsigned short SCSI$W_VMS_STAT;   /* VMS Status Code */
-  unsigned long SCSI$L_IOSB_TFR_CNT; /* Actual Byte Count Transferred */
-  unsigned char SCSI$B_IOSB_FILL_1; /* Unused */
-  unsigned char SCSI$B_IOSB_STS;    /* SCSI Device Status */
+       unsigned short SCSI$W_VMS_STAT;         /* VMS Status Code */
+       unsigned long SCSI$L_IOSB_TFR_CNT;      /* Actual Byte Count Transferred */
+       unsigned char SCSI$B_IOSB_FILL_1;       /* Unused */
+       unsigned char SCSI$B_IOSB_STS;          /* SCSI Device Status */
 }
 SCSI$IOSB;
 
@@ -133,240 +133,268 @@ SCSI$IOSB;
 
 static struct dsc$descriptor_s *descr(char *String)
 {
-  static struct dsc$descriptor_s d_descrtbl[DESCR_CNT];
-  static unsigned short descridx = 0;
-  struct dsc$descriptor_s *d_ret = &d_descrtbl[descridx];
-  descridx = (descridx + 1) & (DESCR_CNT - 1);
-  d_ret->dsc$w_length = strlen((const char *) String);
-  d_ret->dsc$a_pointer = String;
-  d_ret->dsc$b_class = 0;
-  d_ret->dsc$b_dtype = 0;
-  return d_ret;
+       static struct dsc$descriptor_s d_descrtbl[DESCR_CNT];
+       static unsigned short descridx = 0;
+       struct dsc$descriptor_s *d_ret = &d_descrtbl[descridx];
+       descridx = (descridx + 1) & (DESCR_CNT - 1);
+       d_ret->dsc$w_length = strlen((const char *) String);
+       d_ret->dsc$a_pointer = String;
+       d_ret->dsc$b_class = 0;
+       d_ret->dsc$b_dtype = 0;
+
+       return d_ret;
 }
 
 
 static int SCSI_OpenDevice(char *DeviceName)
 {
-  unsigned long d_dev[2], iosb[2], Status;
-  union prvdef setprivs, newprivs;
-  unsigned long ismnt = 0;
-  unsigned long dvcls = 0;
-  unsigned long dchr2 = 0;
-  int DeviceFD = 0;
-  struct itmlst_3 {
-    unsigned short ilen;
-    unsigned short code;
-    unsigned long *returnP;
-    unsigned long ignored;
-  } dvi_itmlst[] = { { 4, DVI$_MNT, 0 /*&ismnt*/, 0 },
-                    { 4, DVI$_DEVCLASS, 0 /*&dvcls*/, 0 },
-                    { 4, DVI$_DEVCHAR2, 0 /*&dchr2*/, 0 },
-                    { 0, 0, 0, 0 } };
-  dvi_itmlst[0].returnP = &ismnt;
-  dvi_itmlst[1].returnP = &dvcls;
-  dvi_itmlst[2].returnP = &dchr2;
-  Status = sys$alloc(descr(DeviceName), 0, 0, 0, 0);
-  if (FailureStatusP(Status))
-    {
-      VMS_ExitCode = Status;
-      FatalError("cannot allocate device '%s' - %X\n", DeviceName, Status);
-    }
-  Status = sys$assign(descr(DeviceName), &DeviceFD, 0, 0);
-  if (FailureStatusP(Status))
-    {
-      VMS_ExitCode = Status;
-      FatalError("cannot open device '%s' - %X\n", DeviceName, Status);
-    }
-  Status = sys$getdviw(0, DeviceFD, 0, &dvi_itmlst, &iosb, 0, 0, 0);
-  if (FailureStatusP(Status))
-    {
-      VMS_ExitCode = Status;
-      FatalError("cannot $getdvi(1) on device '%s' - %X\n", DeviceName, Status);
-    }
-  if (FailureStatusP(Status = iosb[0]))
-    {
-      VMS_ExitCode = Status;
-      FatalError("cannot $getdvi(2) on device '%s' - %X\n", DeviceName, Status);
-    }
-  if (dvcls != DC$_TAPE)
-    {
-      VMS_ExitCode = SS$_IVDEVNAM;
-      FatalError("specified device is NOT a magtape: operation denied\n");
-    }
+       unsigned long d_dev[2], iosb[2], Status;
+       union prvdef setprivs, newprivs;
+       unsigned long ismnt = 0;
+       unsigned long dvcls = 0;
+       unsigned long dchr2 = 0;
+       int DeviceFD = 0;
+       struct itmlst_3
+       {
+               unsigned short ilen;
+               unsigned short code;
+               unsigned long *returnP;
+               unsigned long ignored;
+       }
+       dvi_itmlst[] = {
+               { 4, DVI$_MNT, 0 /*&ismnt*/, 0 },
+               { 4, DVI$_DEVCLASS, 0 /*&dvcls*/, 0 },
+               { 4, DVI$_DEVCHAR2, 0 /*&dchr2*/, 0 },
+               { 0, 0, 0, 0 }
+       };
+
+       dvi_itmlst[0].returnP = &ismnt;
+       dvi_itmlst[1].returnP = &dvcls;
+       dvi_itmlst[2].returnP = &dchr2;
+
+       Status = sys$alloc(descr(DeviceName), 0, 0, 0, 0);
+
+       if (FailureStatusP(Status))
+       {
+               VMS_ExitCode = Status;
+               FatalError("cannot allocate device '%s' - %X\n", DeviceName, Status);
+       }
+
+       Status = sys$assign(descr(DeviceName), &DeviceFD, 0, 0);
+       if (FailureStatusP(Status))
+       {
+               VMS_ExitCode = Status;
+               FatalError("cannot open device '%s' - %X\n", DeviceName, Status);
+       }
+
+       Status = sys$getdviw(0, DeviceFD, 0, &dvi_itmlst, &iosb, 0, 0, 0);
+       if (FailureStatusP(Status))
+       {
+               VMS_ExitCode = Status;
+               FatalError("cannot $getdvi(1) on device '%s' - %X\n", DeviceName, Status);
+       }
+
+       if (FailureStatusP(Status = iosb[0]))
+       {
+               VMS_ExitCode = Status;
+               FatalError("cannot $getdvi(2) on device '%s' - %X\n", DeviceName, Status);
+       }
+
+       if (dvcls != DC$_TAPE)
+       {
+               VMS_ExitCode = SS$_IVDEVNAM;
+               FatalError("specified device is NOT a magtape: operation denied\n");
+       }
 #ifndef __DECC
 #ifndef DEV$M_SCSI
 #define DEV$M_SCSI 0x1000000
 #endif
 #endif
-  if (~dchr2 & DEV$M_SCSI)
-    {
-      VMS_ExitCode = SS$_IVDEVNAM;
-      FatalError("specified magtape is NOT a SCSI device: operation denied\n");
-    }
+       if (~dchr2 & DEV$M_SCSI)
+       {
+               VMS_ExitCode = SS$_IVDEVNAM;
+               FatalError("specified magtape is NOT a SCSI device: operation denied\n");
+       }
 #if USING_DEC_DRIVE | USING_LDRSET
 #ifndef __DECC
 #ifndef DEV$M_LDR
 #define DEV$M_LDR 0x100000
 #endif
 #endif
-  if (~dchr2 & DEV$M_LDR)
-    {
-      VMS_ExitCode = SS$_IVDEVNAM;
-      FatalError(
-       "specified SCSI magtape does not have a loader: operation denied\n");
-    }
+       if (~dchr2 & DEV$M_LDR)
+       {
+               VMS_ExitCode = SS$_IVDEVNAM;
+               FatalError("specified SCSI magtape does not have a loader: operation denied\n");
+       }
 #endif
-  if (ismnt)
-    {
-      VMS_ExitCode = SS$_DEVMOUNT;
-      FatalError("specified device is mounted: operation denied\n");
-    }
-  ots$move5(0, 0, 0, sizeof(newprivs), &newprivs);
-  newprivs.prv$v_diagnose = 1;
-  newprivs.prv$v_log_io = 1;
-  newprivs.prv$v_phy_io = 1;
-  Status = sys$setprv(1, &newprivs, 0, 0);
-  if (FailureStatusP(Status))
-    {
-      VMS_ExitCode = Status;
-      FatalError(
-       "error enabling privs (diagnose,log_io,phy_io): operation denied\n");
-    }
-  Status = sys$setprv(1, 0, 0, &setprivs);
-  if (FailureStatusP(Status))
-    {
-      VMS_ExitCode = Status;
-      FatalError("error retrieving current privs: operation denied\n");
-    }
-  if (!setprivs.prv$v_diagnose)
-    {
-      VMS_ExitCode = SS$_NODIAGNOSE;
-      FatalError("DIAGNOSE privilege is required: operation denied\n");
-    }
-  if (!setprivs.prv$v_phy_io && !setprivs.prv$v_log_io)
-    {
-      VMS_ExitCode = SS$_NOPHY_IO;
-      FatalError("PHY_IO or LOG_IO privilege is required: operation denied\n");
-    }
-  return DeviceFD;
+       if (ismnt)
+       {
+               VMS_ExitCode = SS$_DEVMOUNT;
+               FatalError("specified device is mounted: operation denied\n");
+       }
+
+       ots$move5(0, 0, 0, sizeof(newprivs), &newprivs);
+       newprivs.prv$v_diagnose = 1;
+       newprivs.prv$v_log_io = 1;
+       newprivs.prv$v_phy_io = 1;
+       Status = sys$setprv(1, &newprivs, 0, 0);
+
+       if (FailureStatusP(Status))
+       {
+               VMS_ExitCode = Status;
+               FatalError("error enabling privs (diagnose,log_io,phy_io): operation denied\n");
+       }
+
+       Status = sys$setprv(1, 0, 0, &setprivs);
+       if (FailureStatusP(Status))
+       {
+               VMS_ExitCode = Status;
+               FatalError("error retrieving current privs: operation denied\n");
+       }
+
+       if (!setprivs.prv$v_diagnose)
+       {
+               VMS_ExitCode = SS$_NODIAGNOSE;
+               FatalError("DIAGNOSE privilege is required: operation denied\n");
+       }
+
+       if (!setprivs.prv$v_phy_io && !setprivs.prv$v_log_io)
+       {
+               VMS_ExitCode = SS$_NOPHY_IO;
+               FatalError("PHY_IO or LOG_IO privilege is required: operation denied\n");
+       }
+
+       return DeviceFD;
 }
 
 
-static void SCSI_CloseDevice(char *DeviceName,
-                            int DeviceFD)
+static void SCSI_CloseDevice(char *DeviceName, int DeviceFD)
 {
-  unsigned long Status;
-  Status = sys$dassgn(DeviceFD);
-  if (FailureStatusP(Status))
-    FatalError("cannot close SCSI device '%s' - %X\n", DeviceName, Status);
+       unsigned long Status;
+
+       Status = sys$dassgn(DeviceFD);
+       if (FailureStatusP(Status))
+               FatalError("cannot close SCSI device '%s' - %X\n", DeviceName, Status);
 }
 
 
-static int SCSI_ExecuteCommand(int DeviceFD,
-                              Direction_T Direction,
-                              CDB_T *CDB,
-                              int CDB_Length,
-                              void *DataBuffer,
-                              int DataBufferLength,
-                              RequestSense_T *RequestSense)
+static int SCSI_ExecuteCommand(        int DeviceFD,
+                                                               Direction_T Direction,
+                                                               CDB_T *CDB,
+                                                               int CDB_Length,
+                                                               void *DataBuffer,
+                                                               int DataBufferLength,
+                                                               RequestSense_T *RequestSense)
 {
-  SCSI$DESC cmd_desc;
-  SCSI$IOSB cmd_iosb;
-  unsigned long Status;
-  int Result;
-  memset(RequestSense, 0, sizeof(RequestSense_T));
-  /* Issue the QIO to send the SCSI Command. */
-  ots$move5(0, 0, 0, sizeof(cmd_desc), &cmd_desc);
-  cmd_desc.SCSI$L_OPCODE = 1; /* Only defined SCSI opcode... a VMS thing */
-  cmd_desc.SCSI$A_CMD_ADDR = CDB;
-  cmd_desc.SCSI$L_CMD_LEN = CDB_Length;
-  cmd_desc.SCSI$A_DATA_ADDR = DataBuffer;
-  cmd_desc.SCSI$L_DATA_LEN = DataBufferLength;
-  cmd_desc.SCSI$L_PAD_LEN = 0;
-  cmd_desc.SCSI$L_PH_CH_TMOUT = 180; /* SCSI Phase Change Timeout (seconds) */
-  cmd_desc.SCSI$L_DISCON_TMOUT = 180; /* SCSI Disconnect Timeout (seconds) */
-  switch (Direction)
-    {
-      /*
-       NOTE: Do NOT include flag SCSI$K_FL_ENAB_SYNC.
-             It does NOT work for this case.
-      */
-    case Input:
-      cmd_desc.SCSI$L_FLAGS = SCSI$K_READ | SCSI$K_FL_ENAB_DIS;
-      break;
-    case Output:
-      cmd_desc.SCSI$L_FLAGS = SCSI$K_WRITE | SCSI$K_FL_ENAB_DIS;
-      break;
-    }
-  /* Issue the SCSI Command. */
-  Status = sys$qiow(MK_EFN, DeviceFD, IO$_DIAGNOSE, &cmd_iosb, 0, 0,
-                    &cmd_desc, sizeof(cmd_desc), 0, 0, 0, 0);
-  Result = SCSI$K_GOOD;
-  if (Status & 1)
-    Status = cmd_iosb.SCSI$W_VMS_STAT;
-  if (Status & 1)
-    Result = cmd_iosb.SCSI$B_IOSB_STS;
-  if (Result != SCSI$K_GOOD)
-    {
-      unsigned char RequestSenseCDB[6] =
-       { 0x03 /* REQUEST_SENSE */, 0, 0, 0, sizeof(RequestSense_T), 0 };
-      printf("SCSI command error: %d - requesting sense data\n", Result);
-      /* Execute Request Sense to determine the failure reason. */
-      ots$move5(0, 0, 0, sizeof(cmd_desc), &cmd_desc);
-      cmd_desc.SCSI$L_OPCODE = 1; /* Only defined SCSI opcode... a VMS thing */
-      cmd_desc.SCSI$L_FLAGS = SCSI$K_READ | SCSI$K_FL_ENAB_DIS;
-      cmd_desc.SCSI$A_CMD_ADDR = RequestSenseCDB;
-      cmd_desc.SCSI$L_CMD_LEN = 6;
-      cmd_desc.SCSI$A_DATA_ADDR = RequestSense;
-      cmd_desc.SCSI$L_DATA_LEN = sizeof(RequestSense_T);
-      cmd_desc.SCSI$L_PH_CH_TMOUT = 180;
-      cmd_desc.SCSI$L_DISCON_TMOUT = 180;
-      /* Issue the QIO to send the Request Sense Command. */
-      Status = sys$qiow(MK_EFN, DeviceFD, IO$_DIAGNOSE, &cmd_iosb, 0, 0,
-                       &cmd_desc, sizeof(cmd_desc), 0, 0, 0, 0);
-      if (FailureStatusP(Status))
+       SCSI$DESC cmd_desc;
+       SCSI$IOSB cmd_iosb;
+       unsigned long Status;
+       int Result;
+       memset(RequestSense, 0, sizeof(RequestSense_T));
+       /* Issue the QIO to send the SCSI Command. */
+       ots$move5(0, 0, 0, sizeof(cmd_desc), &cmd_desc);
+       cmd_desc.SCSI$L_OPCODE = 1; /* Only defined SCSI opcode... a VMS thing */
+       cmd_desc.SCSI$A_CMD_ADDR = CDB;
+       cmd_desc.SCSI$L_CMD_LEN = CDB_Length;
+       cmd_desc.SCSI$A_DATA_ADDR = DataBuffer;
+       cmd_desc.SCSI$L_DATA_LEN = DataBufferLength;
+       cmd_desc.SCSI$L_PAD_LEN = 0;
+       cmd_desc.SCSI$L_PH_CH_TMOUT = 180; /* SCSI Phase Change Timeout (seconds) */
+       cmd_desc.SCSI$L_DISCON_TMOUT = 180; /* SCSI Disconnect Timeout (seconds) */
+
+       switch (Direction)
        {
-         printf("?Error returned from REQUEST_SENSE(1): %%X%08lX\n", Status);
-         sys$exit(Status);
+       /*
+       NOTE: Do NOT include flag SCSI$K_FL_ENAB_SYNC.
+       It does NOT work for this case.
+       */
+       case Input:
+               cmd_desc.SCSI$L_FLAGS = SCSI$K_READ | SCSI$K_FL_ENAB_DIS;
+               break;
+
+       case Output:
+               cmd_desc.SCSI$L_FLAGS = SCSI$K_WRITE | SCSI$K_FL_ENAB_DIS;
+               break;
        }
-      /* Check the VMS Status from QIO. */
-      Status = cmd_iosb.SCSI$W_VMS_STAT;
-      if (FailureStatusP(Status))
+
+       /* Issue the SCSI Command. */
+       Status = sys$qiow(MK_EFN, DeviceFD, IO$_DIAGNOSE, &cmd_iosb, 0, 0,
+       &cmd_desc, sizeof(cmd_desc), 0, 0, 0, 0);
+       Result = SCSI$K_GOOD;
+
+       if (Status & 1)
+               Status = cmd_iosb.SCSI$W_VMS_STAT;
+
+       if (Status & 1)
+               Result = cmd_iosb.SCSI$B_IOSB_STS;
+
+       if (Result != SCSI$K_GOOD)
        {
-         printf("?Error returned from REQUEST_SENSE(2): %%X%08lX\n", Status);
-         sys$exit(Status);
+               unsigned char RequestSenseCDB[6] =
+                       { 0x03 /* REQUEST_SENSE */, 0, 0, 0, sizeof(RequestSense_T), 0 };
+
+               printf("SCSI command error: %d - requesting sense data\n", Result);
+
+               /* Execute Request Sense to determine the failure reason. */
+               ots$move5(0, 0, 0, sizeof(cmd_desc), &cmd_desc);
+               cmd_desc.SCSI$L_OPCODE = 1; /* Only defined SCSI opcode... a VMS thing */
+               cmd_desc.SCSI$L_FLAGS = SCSI$K_READ | SCSI$K_FL_ENAB_DIS;
+               cmd_desc.SCSI$A_CMD_ADDR = RequestSenseCDB;
+               cmd_desc.SCSI$L_CMD_LEN = 6;
+               cmd_desc.SCSI$A_DATA_ADDR = RequestSense;
+               cmd_desc.SCSI$L_DATA_LEN = sizeof(RequestSense_T);
+               cmd_desc.SCSI$L_PH_CH_TMOUT = 180;
+               cmd_desc.SCSI$L_DISCON_TMOUT = 180;
+
+               /* Issue the QIO to send the Request Sense Command. */
+               Status = sys$qiow(MK_EFN, DeviceFD, IO$_DIAGNOSE, &cmd_iosb, 0, 0,
+                       &cmd_desc, sizeof(cmd_desc), 0, 0, 0, 0);
+               if (FailureStatusP(Status))
+               {
+                       printf("?Error returned from REQUEST_SENSE(1): %%X%08lX\n", Status);
+                       sys$exit(Status);
+               }
+
+               /* Check the VMS Status from QIO. */
+               Status = cmd_iosb.SCSI$W_VMS_STAT;
+               if (FailureStatusP(Status))
+               {
+                       printf("?Error returned from REQUEST_SENSE(2): %%X%08lX\n", Status);
+                       sys$exit(Status);
+               }
        }
-    }
-  return Result;
+       return Result;
 }
 
 
 static void VMS_DefineStatusSymbols(void)
 {
-  char SymbolName[32], SymbolValue[32];
-  int StorageElementNumber;
-  if (DataTransferElementFull)
-    {
-      /* Define MTX_DTE Symbol (environment variable) as 'FULL:n'. */
-      sprintf(SymbolValue, "FULL:%d",
-             DataTransferElementSourceStorageElementNumber);
-      lib$set_symbol(descr("MTX_DTE"), descr(SymbolValue), &2);
-    }
-  else
-    {
-      /* Define MTX_DTE Symbol (environment variable) as 'EMPTY'. */
-      lib$set_symbol(descr("MTX_DTE"), descr("EMPTY"), &2);
-    }
-  /* Define MTX_MSZ Symbol (environment variable) "Magazine SiZe" as 'n'. */
-  sprintf(SymbolValue, "%d", StorageElementCount);
-  lib$set_symbol(descr("MTX_MSZ"), descr(SymbolValue), &2);
-  for (StorageElementNumber = 1;
-       StorageElementNumber <= StorageElementCount;
-       StorageElementNumber++)
-    {
-      sprintf(SymbolName, "MTX_STE%02d", StorageElementNumber);
-      strcpy(SymbolValue,
-            (StorageElementFull[StorageElementNumber] ? "FULL" : "EMPTY"));
-      lib$set_symbol(descr(SymbolName), descr(SymbolValue), &2);
-    }
+       char SymbolName[32], SymbolValue[32];
+       int StorageElementNumber;
+
+       if (DataTransferElementFull)
+       {
+               /* Define MTX_DTE Symbol (environment variable) as 'FULL:n'. */
+               sprintf(SymbolValue, "FULL:%d",
+               DataTransferElementSourceStorageElementNumber);
+               lib$set_symbol(descr("MTX_DTE"), descr(SymbolValue), &2);
+       }
+       else
+       {
+               /* Define MTX_DTE Symbol (environment variable) as 'EMPTY'. */
+               lib$set_symbol(descr("MTX_DTE"), descr("EMPTY"), &2);
+       }
+
+       /* Define MTX_MSZ Symbol (environment variable) "Magazine SiZe" as 'n'. */
+       sprintf(SymbolValue, "%d", StorageElementCount);
+       lib$set_symbol(descr("MTX_MSZ"), descr(SymbolValue), &2);
+       for (StorageElementNumber = 1;
+                StorageElementNumber <= StorageElementCount;
+                StorageElementNumber++)
+       {
+               sprintf(SymbolName, "MTX_STE%02d", StorageElementNumber);
+               strcpy(SymbolValue,
+                       (StorageElementFull[StorageElementNumber] ? "FULL" : "EMPTY"));
+               lib$set_symbol(descr(SymbolName), descr(SymbolValue), &2);
+       }
 }