fix lintian issues
[debian/mtx] / mtxl.h
1 /* 
2   MTX -- SCSI Tape Attached Medium Changer Control Program
3
4   Copyright 1997-1998 Leonard N. Zubkoff <lnz@dandelion.com>
5   Copyright 2007-2008 by Robert Nelson <robertn@the-nelsons.org>
6   This file created by Eric Lee Green <eric@badtux.org>
7   
8   This program is free software; you may redistribute and/or modify it under
9   the terms of the GNU General Public License Version 2 as published by the
10   Free Software Foundation.
11
12   This program is distributed in the hope that it will be useful, but
13   WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
14   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15   for complete details.
16
17   $Date: 2008-08-19 03:03:38 -0700 (Tue, 19 Aug 2008) $
18   $Revision: 193 $
19 */
20
21 /* Much of the guts of mtx.c has been extracted to mtxl.c, a library file
22  * full of utility routines. This file is the header file for that library.
23  *   -E
24  */
25
26 #ifndef MTXL_H
27 #define MTXL_H 1
28
29 #include "mtx.h"
30
31 #undef min
32 #undef max
33
34 void FatalError(char *ErrorMessage, ...);
35 void *xmalloc(size_t Size);
36 void *xzmalloc(size_t Size);
37 void slow_bzero(char *buffer, int numchars);
38
39 DEVICE_TYPE SCSI_OpenDevice(char *DeviceName);
40 void SCSI_CloseDevice(char *DeviceName, DEVICE_TYPE DeviceFD);
41 int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
42                                Direction_T Direction,
43                                CDB_T *CDB,
44                                int CDB_Length,
45                                void *DataBuffer,
46                                int DataBufferLength,
47                                RequestSense_T *RequestSense);
48
49 void PrintRequestSense(RequestSense_T *RequestSense);
50
51 int BigEndian16(unsigned char *BigEndianData);
52 int BigEndian24(unsigned char *BigEndianData);
53 int min(int x, int y);
54 int max(int x, int y);
55
56 void PrintHex(int Indent, unsigned char *Buffer, int Length);
57 int ClearUnitAttention(DEVICE_TYPE fd, RequestSense_T *RequestSense);
58
59 ElementStatus_T *ReadElementStatus(     DEVICE_TYPE MediumChangerFD,
60                                                                         RequestSense_T *RequestSense,
61                                                                         Inquiry_T *inquiry_info,
62                                                                         SCSI_Flags_T *flags);
63
64 Inquiry_T *RequestInquiry(      DEVICE_TYPE fd,
65                                                         RequestSense_T *RequestSense);
66
67 RequestSense_T *MoveMedium(     DEVICE_TYPE MediumChangerFD,
68                                                         int SourceAddress,
69                                                         int DestinationAddress, 
70                                                         ElementStatus_T *ElementStatus, 
71                                                         Inquiry_T *inquiry_info,
72                                                         SCSI_Flags_T *flags);
73
74 RequestSense_T *ExchangeMedium( DEVICE_TYPE MediumChangerFD,
75                                                                 int SourceAddress,
76                                                                 int DestinationAddress,
77                                                                 int Dest2Address,
78                                                                 ElementStatus_T *ElementStatus, 
79                                                                 SCSI_Flags_T *flags);
80
81 RequestSense_T *PositionElement(DEVICE_TYPE MediumChangerFD,
82                                                                 int DestinationAddress,
83                                                                 ElementStatus_T *ElementStatus);
84
85 int Inventory(DEVICE_TYPE MediumChangerFD);  /* inventory library */
86 int LoadUnload(DEVICE_TYPE fd, int bLoad); /* load/unload tape, magazine or disc */
87 int StartStop(DEVICE_TYPE fd, int bStart); /* start/stop device */
88 int LockUnlock(DEVICE_TYPE fd, int bLock); /* lock/unlock medium in device */
89 RequestSense_T *Erase(DEVICE_TYPE fd);        /* send SHORT erase to drive */
90
91 void SCSI_Set_Timeout(int secs); /* set the SCSI timeout */
92 void SCSI_Default_Timeout(void);  /* go back to default timeout */
93
94 /* we may not have this function :-(. */
95 #ifdef HAVE_GET_ID_LUN
96    scsi_id_t *SCSI_GetIDLun(DEVICE_TYPE fd);
97 #endif
98
99 /* These two hacks are so that I can stick the tongue out on an
100  * NSM optical jukebox. 
101  */ 
102 NSM_Result_T *RecNSMHack(DEVICE_TYPE MediumChangerFD, 
103                          int param_len, int timeout);
104
105 int SendNSMHack(DEVICE_TYPE MediumChangerFD, NSM_Param_T *nsm_command, 
106                 int param_len, int timeout);
107
108 #endif
109