/* 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>
# 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. */
# 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. */
#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];
} 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,
DataTransferElement = 4
}
ElementTypeCode_T;
+#endif
typedef struct ElementStatusDataHeader
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;
#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];
#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. */