Imported Upstream version 1.3.12
[debian/mtx] / mtx.h
diff --git a/mtx.h b/mtx.h
index 1144ea61f1a63d3243a1488a09bc8e30b4bedb9e..93b6c071b3b297e02f5ba17be3f5f72f9243c5a7 100644 (file)
--- a/mtx.h
+++ b/mtx.h
@@ -1,12 +1,13 @@
 /* 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.
+       Copyright 2007-2008 by Robert Nelson <robertn@the-nelsons.org>
+
+       $Date: 2008-08-19 03:03:38 -0700 (Tue, 19 Aug 2008) $
+       $Revision: 193 $
+       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 +78,27 @@ 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
+#  define WIN32_LEAN_AND_MEAN
+#  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
+#  define WIN32_LEAN_AND_MEAN
+#  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 +126,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 +190,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 +400,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 +418,7 @@ typedef enum ElementTypeCode
   DataTransferElement =                4
 }
 ElementTypeCode_T;
+#endif
 
 
 typedef struct ElementStatusDataHeader
@@ -445,6 +493,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 +531,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 +576,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. */