#ifndef MSFIO_H #define MSFIO_H 1 /* * MSFIO.H MS-DOS file I/O * * MSFIO.C and MSFIO.H provide file I/O operations to MS-DOS file structured * devices. This file deliberately resembles * * See MSFIO.TXT for additional documentation * * Copyright (c) 1991 Shal Farley * Cheshire Engineering Corporation * 650 Sierra Madre Villa Avenue, Suite 201 * Pasadena, California 91107 * (818) 351-5493 * (818) 351-8645 FAX * shal@alumni.caltech.edu * * This software may be used and distributed for any purpose without license or * royalty payments so long as the above copyright notice is preserved. If you * have any comments, bug fixes, improvements, or new programs based upon this * software I'd like to hear from you. */ #define MSFOPEN_MAX 2 /* Just for now, keep life simple */ #define MSFILENAME_MAX 27 /* "DEV:FILNAM.TYP:FILENAME.TYP" */ #define MSDEVNAME_MAX 14 /* "DEV:FILNAM.TYP" */ /* * The MSFILE structure, pointed to by return value from msfopen() */ typedef struct { long nbPos; /* current byte offset into file */ long nbMax; /* current byte offset into file */ UCHAR *pDEV; /* pointer to device info */ UCHAR *pDE; /* pointer to the directory entry */ int clust; /* cluster number of current nbPos */ #ifdef decus int fRead; /* Mode is "r" */ int fWrite; /* Mode is "w" */ int fAppend; /* Mode is "a" */ int fUpdate; /* Mode is "+" */ int fBinary; /* Mode is "b" or "n" */ #else /* not-decus */ unsigned int fRead : 1; /* Mode is "r" */ unsigned int fWrite : 1; /* Mode is "w" */ unsigned int fAppend : 1; /* Mode is "a" */ unsigned int fUpdate : 1; /* Mode is "+" */ unsigned int fBinary : 1; /* Mode is "b" or "n" */ #endif /* decus */ char sName[MSFILENAME_MAX]; /* MS-DOS "FILENAME.TYP" */ } MSFILE; /* * Prototypes for our functions, same as ANSI functions */ extern MSFILE *msfopen(); extern int msfclose(); extern int msremove(); extern int msfread(); extern int msfwrite(); extern int msfflush(); extern int msgetc(); extern int msputc(); extern void msperror(); /* * Prototypes for our non-ANSI functions */ extern unsigned msffirst(/* filename, attrib, fileinfo */); /* Get infomation about first matching file * char *filename; Wild-card file name string * USHORT attrib; Attribute match * MSSTAT *fileinfo; Structure to fill * Returns 0 on success, else errno. */ extern unsigned msfnext(/* fileinfo */); /* Get information about next matching file. * MSSTAT *fileinfo; Return from previous findfirst or findnext * Returns 0 on success, 1 if no more files. */ extern int msfstat(/* pF */); /* Get information about an open file. * MSFILE *pF; File * MSSTAT *pSTAT; Pointer to buffer for return data * Returns 0 on success, else -1 */ extern long msfilelength(/* pF */); /* Get length of an open file. * MSFILE *pF; File * Returns length of file in bytes */ extern USHORT msfeclust(/* clust, pf */); /* Lookup FAT entry for this cluster * USHORT clust; * MSDEV *pd; */ /* * Bits in ((MSFILE *)fd)->flags: */ #define MS_IOREAD 0000001 /* Open for reading */ #define MS_IOWRT 0000002 /* Open for writing */ #define MS_IONBF 0000004 /* Unbuffered "u" mode */ #define MS_IOMYBUF 0000010 /* io stuff got buffer */ #define MS_IOEOF 0000020 /* Eof seen if set */ #define MS_IOERR 0000040 /* Error seen if set */ #define MS_IOSTRG 0000100 /* for sprintf, sscanf */ #define MS_IORW 0000200 /* Open for read/write */ #if 0 /* * Bits in fd->_flag (all in high byte of that word) * These are needed for Dec-style i/o. */ #define IO_BZY 0000400 /* Buffer busy (RT11) */ #define IO_APN 0001000 /* Append mode open */ #define IO_NOS 0002000 /* No newlines needed */ #define IO_NEWL 0004000 /* RSX TTY newline hack */ #define IO_FIL 0010000 /* Disk file */ #define IO_TTY 0020000 /* Console terminal */ #define IO_REC 0040000 /* Record device */ #define IO_OPN 0100000 /* Open file */ #endif #endif /* MSFIO_H */