1 #ifndef MTOOLS_STREAM_H
2 #define MTOOLS_STREAM_H
4 /* Copyright 1996-1999,2001,2002,2005,2006,2008,2009 Alain Knaff.
5 * This file is part of mtools.
7 * Mtools is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * Mtools is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Mtools. If not, see <http://www.gnu.org/licenses/>.
21 typedef struct Stream_t {
22 struct Class_t *Class;
24 struct Stream_t *Next;
25 struct Stream_t *Buffer;
33 doscp_t *get_dosConvert_pass_through(Stream_t *Stream);
35 typedef struct Class_t {
36 int (*read)(Stream_t *, char *, mt_off_t, size_t);
37 int (*write)(Stream_t *, char *, mt_off_t, size_t);
38 int (*flush)(Stream_t *);
39 int (*freeFunc)(Stream_t *);
40 int (*set_geom)(Stream_t *, device_t *, device_t *, int media,
42 int (*get_data)(Stream_t *, time_t *, mt_size_t *, int *, int *);
43 int (*pre_allocate)(Stream_t *, mt_size_t);
45 doscp_t *(*get_dosConvert)(Stream_t *);
48 #define READS(stream, buf, address, size) \
49 ((stream)->Class->read)( (stream), (char *) (buf), (address), (size) )
51 #define WRITES(stream, buf, address, size) \
52 ((stream)->Class->write)( (stream), (char *) (buf), (address), (size) )
54 #define SET_GEOM(stream, dev, orig_dev, media, boot) \
55 (stream)->Class->set_geom( (stream), (dev), (orig_dev), (media), (boot) )
57 #define GET_DATA(stream, date, size, type, address) \
58 (stream)->Class->get_data( (stream), (date), (size), (type), (address) )
60 #define PRE_ALLOCATE(stream, size) \
61 (stream)->Class->pre_allocate((stream), (size))
63 #define GET_DOSCONVERT(stream) \
64 (stream)->Class->get_dosConvert((stream))
66 int flush_stream(Stream_t *Stream);
67 Stream_t *copy_stream(Stream_t *Stream);
68 int free_stream(Stream_t **Stream);
70 #define FLUSH(stream) \
71 flush_stream( (stream) )
73 #define FREE(stream) \
74 free_stream( (stream) )
76 #define COPY(stream) \
77 copy_stream( (stream) )
80 #define DeclareThis(x) x *This = (x *) Stream
82 int force_write(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
83 int force_read(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
85 int get_data_pass_through(Stream_t *Stream, time_t *date, mt_size_t *size,
86 int *type, int *address);
88 int read_pass_through(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
89 int write_pass_through(Stream_t *Stream, char *buf, mt_off_t start, size_t len);