Debian Codegraph @

libsrc/os/unix/iodev.c

raw
1 /*===========================================================================
2 Copyright (C) 1995-2009 European Southern Observatory (ESO)
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public
15 License along with this program; if not, write to the Free
16 Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
17 MA 02139, USA.
18
19 Correspondence concerning ESO-MIDAS should be addressed as follows:
20 Internet e-mail: [email protected]
21 Postal address: European Southern Observatory
22 Data Management Division
23 Karl-Schwarzschild-Strasse 2
24 D 85748 Garching bei Muenchen
25 GERMANY
26 ===========================================================================*/
27
28 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
29 .TYPE Module
30 .NAME iodev (dummy version)
31 .LANGUAGE C
32 .AUTHOR IPG-ESO Garching
33 .CATEGORY Host operating system interfaces. Tape management.
34 .COMMENTS Tape management.
35 The functions of this module perform basic i/o to
36 magnetic tapes on Ultrix enviroments
37 .REMARK This is a dummy version of iodev.c for systems without
38 1/2" tape interface.
39 Because every IO interface for tapes is an implementation
40 dependent, and that varies from one system to other.
41 The real iodev.c must be implemented for every system
42 particularly, and must be included in the $MIDASHOME/local
43 directory.
44 .VERSION 1.0 12-Aug-1988 Implementation C. Guirao
45 .VERSION 1.1 12-Oct-1989 New design (several iodev's)
46 .VERSION 1.2 18-May-1990 osuclose has 2 parameters...
47
48 090324 last modif
49 ------------------------------------------------------------*/
50
51 #include <fcntl.h>
52 #include <osudef.h>
53 #include <oserror.h>
54 #include <proto_os.h> /* ANSI-C prototyping */
55
56 /*#define next_iodev*/ /* NO NEXT iodev in chain */
57 static char class_name[] = "mt"; /* MAgnetic Tape Class */
58
59 #ifdef __STDC__
60 static int ioinfo(int fd , struct osustat * s , int * fileno , long * blkno)
61 #else
62 static int ioinfo(fd, s, fileno, blkno)
63 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
64 .PURPOSE Retrieve Info concerning an opened device
65 .RETURNS 0 (success) / -1 (error)
66 ------------------------------------------------------------*/
67 int fd; /* IN: File Descriptor */
68 struct osustat *s; /* OUT: The filled components */
69 int *fileno; /* OUT: Where we are */
70 long *blkno; /* OUT: Where we are */
71 #endif
72 {
73 oserror = -1;
74 oserrmsg = "iodev: dummy version. \
75 Implement your own Tape interface in your local directory";
76 return(-1);
77 }
78
79 #if 0 /*================== No Function Implemented Here ==========*/
80 static int ioopen(name,mode,den)
81 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
82 .PURPOSE Open a tape device
83 .RETURNS File descriptor / -1 (error)
84 .REMARKS
85 ------------------------------------------------------------*/
86 char *name; /* IN: Physical name of tape device */
87 int mode; /* IN: Open mode */
88 int den; /* IN: Density. Not used */
89 {
90 }
91
92 static int ioclose(fd, option)
93 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
94 .PURPOSE Close the opened unit
95 .RETURNS 0 (success) / -1 (failure)
96 .REMARKS
97 ------------------------------------------------------------*/
98 int fd; /* IN: Tape file descriptor */
99 int option; /* IN: Option OPU_DISMOUNT */
100 {
101 }
102
103
104 static int ioread(fd, buffer, size)
105 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
106 .PURPOSE Read a block from a magnetic tape.
107 .RETURNS Bytes read / 0 for EOF (TapeMark) / -1 if error
108 .REMARKS
109 ------------------------------------------------------------*/
110 int fd; /* IN: Tape device file descriptor */
111 char *buffer; /* IN: Buffer for reading */
112 int size; /* IN: Length of bytes to be read */
113 {
114 }
115
116
117 static int iowrite(fd, buffer, size)
118 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
119 .PURPOSE Write a block on a magnetic tape.
120 .RETURNS Bytes written / -1 (error)
121 .REMARKS
122 ------------------------------------------------------------*/
123 int fd; /* IN: Tape device file descriptor */
124 char *buffer; /* IN: Buffer for reading */
125 int size; /* IN: Length of bytes to be read */
126 {
127 }
128
129
130 static int ioweof(fd)
131 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
132 .PURPOSE Write end-of-file record (tape_mark) on the tape.
133 .RETURNS 0 (success) / -1 (error)
134 .REMARKS
135 ------------------------------------------------------------*/
136 int fd; /* IN: Tape device file descriptor */
137 int ntm; /* IN: Number of tape marks */
138 {
139 }
140
141
142 static int iofsf(fd, ntm)
143 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
144 .PURPOSE Skip forward space file on a tape.
145 .RETURNS Tape marks skipped / -1 (error)
146 .REMARKS
147 ------------------------------------------------------------*/
148 int fd; /* IN: Tape device file descriptor */
149 int ntm; /* IN: Number of tape marks */
150 {
151 }
152
153
154 static int iobsf(fd, ntm)
155 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
156 .PURPOSE Skip backward space file on a tape.
157 .RETURNS Tape marks skipped / -1 (error)
158 .REMARKS
159 ------------------------------------------------------------*/
160 int fd; /* IN: Tape device file descriptor */
161 int ntm; /* IN: Number of tape marks */
162 {
163 }
164
165
166 static int iorew(fd)
167 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
168 .PURPOSE Rewind tape
169 .RETURNS 0 (success) / -1 (error)
170 .REMARKS
171 ------------------------------------------------------------*/
172 int fd; /* IN: Tape device file descriptor */
173 {
174 }
175
176
177 static int iosread(fd, spos, ssize, buffer, size)
178 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
179 .PURPOSE Read a block from a unit
180 .RETURNS Bytes read / -1 if error
181 ------------------------------------------------------------*/
182 int fd; /* IN: File descriptor */
183 long spos; /* IN: Sector Number */
184 int ssize; /* IN: Size of one sector */
185 char *buffer; /* IN: Buffer for reading */
186 int size; /* IN: Length of bytes to be read */
187 {
188 }
189
190 static int ioswrite(fd, spos, ssize, buffer, size)
191 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
192 .PURPOSE Read a block from a unit
193 .RETURNS Bytes read / -1 if error
194 ------------------------------------------------------------*/
195 int fd; /* IN: File descriptor */
196 long spos; /* IN: Sector Number */
197 int ssize; /* IN: Size of one sector */
198 char *buffer; /* IN: Buffer for reading */
199 int size; /* IN: Length of bytes to be read */
200 {
201 }
202
203 #endif /*============= END of Functions Templates ===============*/
204
205
206 /*=====================================================================
207 * Definition of the structure returned to osu
208 *=====================================================================*/
209
210 #ifdef next_iodev
211 struct iolist *next_iodev();
212 #else
213 #define next_iodev (IODEV)0
214 #endif
215
216 static OPITEM list_of_functions[] = {
217 { U_INFO, ioinfo},
218 /* { U_OPEN, ioopen}, */
219 /* { U_CLOSE, ioclose}, */
220 /* { U_READ, ioread}, */
221 /* { U_WRITE, iowrite}, */
222 /* { U_REWIND, iorew}, */
223 /* { U_WEOF, ioweof}, */
224 /* { U_FMF, iofsf}, */ /* File Move Forward */
225 /* { U_FMB, iobsf}, */ /* File Move Backward */
226 /* { U_EOM, ioeom} */ /* Move to EOMedia */
227 };
228
229 static struct iolist this_dev = {
230 next_iodev, /* Next iodev in List */
231 class_name, /* How it's written in DEVCAPFILE */
232 sizeof(list_of_functions)/sizeof(list_of_functions[0]),
233 list_of_functions
234 };
235
236 struct iolist *iodev()
237 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
238 .PURPOSE Get All definitions concerning this class of Devices
239 .RETURNS The iolist
240 .REMARKS Simply returns the local iolist address...
241 ------------------------------------------------------------*/
242 {
243 return(&this_dev);
244 }