1 | #ifndef MTOOLS_STREAM_H
|
---|
2 | #define MTOOLS_STREAM_H
|
---|
3 |
|
---|
4 | typedef struct Stream_t {
|
---|
5 | struct Class_t *Class;
|
---|
6 | int refs;
|
---|
7 | struct Stream_t *Next;
|
---|
8 | struct Stream_t *Buffer;
|
---|
9 | } Stream_t;
|
---|
10 |
|
---|
11 | #include "mtools.h"
|
---|
12 | #include "msdos.h"
|
---|
13 |
|
---|
14 | #include "llong.h"
|
---|
15 |
|
---|
16 | typedef struct Class_t {
|
---|
17 | int (*read)(Stream_t *, char *, mt_off_t, size_t);
|
---|
18 | int (*write)(Stream_t *, char *, mt_off_t, size_t);
|
---|
19 | int (*flush)(Stream_t *);
|
---|
20 | int (*freeFunc)(Stream_t *);
|
---|
21 | int (*set_geom)(Stream_t *, device_t *, device_t *, int media,
|
---|
22 | struct bootsector *);
|
---|
23 | int (*get_data)(Stream_t *, time_t *, mt_size_t *, int *, int *);
|
---|
24 | int (*pre_allocate)(Stream_t *, mt_size_t);
|
---|
25 | } Class_t;
|
---|
26 |
|
---|
27 | #define READS(stream, buf, address, size) \
|
---|
28 | (stream)->Class->read( (stream), (char *) (buf), (address), (size) )
|
---|
29 |
|
---|
30 | #define WRITES(stream, buf, address, size) \
|
---|
31 | (stream)->Class->write( (stream), (char *) (buf), (address), (size) )
|
---|
32 |
|
---|
33 | #define SET_GEOM(stream, dev, orig_dev, media, boot) \
|
---|
34 | (stream)->Class->set_geom( (stream), (dev), (orig_dev), (media), (boot) )
|
---|
35 |
|
---|
36 | #define GET_DATA(stream, date, size, type, address) \
|
---|
37 | (stream)->Class->get_data( (stream), (date), (size), (type), (address) )
|
---|
38 |
|
---|
39 | #define PRE_ALLOCATE(stream, size) \
|
---|
40 | (stream)->Class->pre_allocate((stream), (size))
|
---|
41 |
|
---|
42 | int flush_stream(Stream_t *Stream);
|
---|
43 | Stream_t *copy_stream(Stream_t *Stream);
|
---|
44 | int free_stream(Stream_t **Stream);
|
---|
45 |
|
---|
46 | #define FLUSH(stream) \
|
---|
47 | flush_stream( (stream) )
|
---|
48 |
|
---|
49 | #define FREE(stream) \
|
---|
50 | free_stream( (stream) )
|
---|
51 |
|
---|
52 | #define COPY(stream) \
|
---|
53 | copy_stream( (stream) )
|
---|
54 |
|
---|
55 |
|
---|
56 | #define DeclareThis(x) x *This = (x *) Stream
|
---|
57 |
|
---|
58 | int force_write(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
|
---|
59 | int force_read(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
|
---|
60 |
|
---|
61 | extern struct Stream_t *default_drive;
|
---|
62 |
|
---|
63 | int get_data_pass_through(Stream_t *Stream, time_t *date, mt_size_t *size,
|
---|
64 | int *type, int *address);
|
---|
65 |
|
---|
66 | int read_pass_through(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
|
---|
67 | int write_pass_through(Stream_t *Stream, char *buf, mt_off_t start, size_t len);
|
---|
68 |
|
---|
69 |
|
---|
70 | #endif
|
---|
71 |
|
---|