home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
drdobbs
/
c_spec
/
sources
/
mydos.h
< prev
next >
Wrap
C/C++ Source or Header
|
1986-02-20
|
4KB
|
115 lines
/*----------------------------------------------------------------------+
* |
* MYDOS.H Various defines for talking to dos |
* |
*----------------------------------------------------------------------+
*
* Typdefs for using dos(). Note that this structure can be used
* by the various routines supplied by Lattice (intdos, bdos etc.)
* but dos() can't use the structure defined in Lattice's dos.h.
*
* Since "REGS" and "byte" are both also defined in dos.h, you
* shouldn't #include both of them in the same place.
*/
typedef short word;
typedef char byte;
struct LREG { word ax, bx, cx, dx, si, di, es, cs, ss, ds;};
struct SREG { byte al,ah, bl,bh, cl,ch, dl,dh; };
typedef union
{
struct LREG x ;
struct SREG h ;
}
REGS;
/*----------------------------------------------------------------------
* Stuff needed to get a directory from MSDOS
*
* The FILE_INFO type structure is filled by a find first or find
* next command (dos system calls 0x4e and 0x4f).
*/
typedef struct
{
char fi_resv[21]; /* Bytes 0-20 Reserved by DOS */
char fi_attrib; /* Byte 21 File attribute */
short fi_time; /* Bytes 22-23 Create/update time */
short fi_date; /* Bytes 24-25 Create/update date */
long fi_fsize; /* Bytes 26-27 File size in bytes */
char fi_name[13]; /* Bytes 28-40 File name & extension */
}
FILE_INFO;
/*----------------------------------------------------------------------
* This kludge is needed because the IBM assembler won't recognize
* lower-case names. If you're using the new (ver 4.x) Microsoft
* assembler then these #defines aren't necessary.
*/
#ifdef IBM
#define gregs(x) GREGS(x)
#define mydos(x) MYDOS(x)
#endif
/*----------------------------------------------------------------------*/
/*
* Macros to extract information from a FILE_INFO. In all these macros
* the argument "p" is a poshorter to a FILE_INFO structure. Note that
* the C_YEAR and C_SEC macros compensate for MSDOS wierdnessess.
*
* IS_READONLY(p) File is read only.
* IS_HIDDEN(p) File is invisible in normal directory searches
* IS_SYSTEM(p) File is a system file
* IS_LABEL(p) Info is a volume label, not a file.
* IS_SUBDIR(p) File is a directory
* IS_DIRTY(p) True when file is written to and closed, set to
* False by the program backup.
* C_HR(p) Hour of last update or create (0-23)
* C_MIN(p) Minute of last update or create (0-59)
* C_SEC(p) Second of last update or create (0-59)
* C_YEAR(p) Year of last update or create (1980-2099)
* C_MONTH(p) Month of last update or create (1-12)
* C_DAY(p) Day of last update or create (1-31)
*/
#define READONLY 0x01 /* Attribute bits */
#define HIDDEN 0x02
#define SYSTEM 0x04
#define LABEL 0x08
#define SUBDIR 0x10
#define DIRTY 0x20
#define ALL (READONLY | DIRTY | SYSTEM | HIDDEN | SUBDIR | LABEL)
#define ALL_FILES (READONLY | DIRTY | SYSTEM | HIDDEN )
#define NORM_FILES (READONLY | DIRTY )
#define IS_READONLY(p) ((p)->fi_attrib & READONLY )
#define IS_HIDDEN(p) ((p)->fi_attrib & HIDDEN )
#define IS_SYSTEM(p) ((p)->fi_attrib & SYSTEM )
#define IS_LABEL(p) ((p)->fi_attrib & LABEL )
#define IS_SUBDIR(p) ((p)->fi_attrib & SUBDIR )
#define IS_DIRTY(p) ((p)->fi_attrib & DIRTY )
#define C_HR(p) ( ((p)->fi_time >> 11) & 0x1f )
#define C_MIN(p) ( ((p)->fi_time >> 5) & 0x3f )
#define C_SEC(p) ( ((p)->fi_time << 1) & 0x3e )
#define C_YEAR(p) ((((p)->fi_date >> 9) & 0x7f ) + 1980)
#define C_MONTH(p) ( ((p)->fi_date >> 5) & 0x0f )
#define C_DAY(p) ( ((p)->fi_date ) & 0x1f )
/*----------------------------------------------------------------------
* Directory related BDOS function numbers
*/
#define FINDFIRST 0x4e
#define FINDNEXT 0x4f
#define SETDTA 0x1a
#define GETDTA 0x2f
#define CARRY 0x01 /* Mask for carry bit */