forked from Tronix286/DOSMID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fio.h
48 lines (36 loc) · 1.69 KB
/
fio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* File I/O, based on DOS int 21h calls
* This file is part of the DOSMid project
* http://dosmid.sourceforge.net
*
* Copyright (C) 2018 Mateusz Viste
*/
#ifndef fio_h_sentinel
#define fio_h_sentinel
#define FIO_SEEK_START 0
#define FIO_SEEK_CUR 1
#define FIO_SEEK_END 2
#define FIO_OPEN_RD 0
#define FIO_OPEN_WR 1
#define FIO_OPEN_RW 2
#define FIO_FLAG_SEEKSYNC 1
#define FIO_CACHE 32
struct fiofile {
unsigned short int fh; /* file handle (as used by DOS) */
unsigned long int flen; /* file length */
unsigned long int curpos; /* current offset position (ftell) */
unsigned char buff[FIO_CACHE]; /* buffer storage */
unsigned long int bufoffs; /* offset of buffer */
unsigned char flags; /* flags */
};
/* open file fname and set fhandle with the associated file handle. returns 0 on success, non-zero otherwise */
int fio_open(const char far *fname, int mode, struct fiofile *f);
/* reads count bytes from file pointed at by fhandle, and writes the data into buff. returns the number of bytes actually read */
int fio_read(struct fiofile *f, void far *buff, int count);
/* seek to offset position of file pointed at by fhandle. returns current file position on success, a negative error otherwise */
signed long int fio_seek(struct fiofile *f, unsigned short int origin, signed long int offset);
/* reads a line from file pointed at by fhandle, fill buff up to buflen bytes. returns the line length (possibly longer than buflen) */
int fio_getline(struct fiofile *f, void far *buff, short int buflen);
/* close file handle. returns 0 on success, non-zero otherwise */
int fio_close(struct fiofile *f);
#endif