1 /*============================================================================
\r
3 portable.h v1.00 Written by Scott Robert Ladd.
\r
5 _MSC_VER Microsoft C 6.0 and later
\r
6 _QC Microsoft Quick C 2.51 and later
\r
7 __TURBOC__ Borland Turbo C, Turbo C++, and Borland C++
\r
8 __BORLANDC__ Borland C++
\r
9 __ZTC__ Zortech C++ and Symantec C++
\r
12 __POWERC Mix Power C
\r
15 09/14/93 Fred Cole Moved MK_FP() macro to end of file to avoid
\r
16 redefinition error when dos.h gets included
\r
17 at the in/outport definitions for __TURBOC__
\r
18 09/15/93 Thad Smith Add conditional code for TC 2.01
\r
19 Fix findfirst/findnext support for ZTC 3.0
\r
20 10/15/93 Bob Stout Revise find first/next support
\r
21 04/03/94 Bob Stout Add Power C support, FAR
\r
22 ============================================================================*/
\r
25 /* prevent multiple inclusions of this header file */
\r
27 #if !defined(PORTABLE_H)
\r
31 ** Correct far pointer syntax
\r
34 #if defined(__POWERC) || (defined(__TURBOC__) && !defined(__BORLANDC__))
\r
40 /*----------------------------------------------------------------------------
\r
41 Directory search macros and data structures
\r
43 DOSFileData MS-DOS file data structure
\r
44 FIND_FIRST MS-DOS function 0x4E -- find first file matchine spec
\r
45 FIND_NEXT MS-DOS function 0x4F -- find subsequent files
\r
46 ----------------------------------------------------------------------------*/
\r
48 /* make sure the structure is packed on byte boundary */
\r
50 #if defined(_MSC_VER) || defined(_QC) || defined(__WATCOM__)
\r
52 #elif defined(__ZTC__)
\r
54 #elif defined(__TURBOC__) && (__TURBOC__ > 0x202)
\r
58 /* use this structure in place of compiler-defined file structure */
\r
69 /* set structure alignment to default */
\r
71 #if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__)
\r
73 #elif defined (__ZTC__)
\r
75 #elif defined(__TURBOC__) && (__TURBOC__ > 0x202)
\r
79 /* include proper header files and create macros */
\r
81 #if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC)
\r
83 #define FIND_FIRST(spec,attr,buf) _dos_findfirst(spec,attr,\
\r
84 (struct find_t *)buf)
\r
85 #define FIND_NEXT(buf) _dos_findnext((struct find_t *)buf)
\r
86 #elif defined (__TURBOC__)
\r
88 #define FIND_FIRST(spec,attr,buf) findfirst(spec,(struct ffblk *)buf,attr)
\r
89 #define FIND_NEXT(buf) findnext((struct ffblk *)buf)
\r
90 #elif defined (__ZTC__)
\r
92 #define FIND_FIRST(spec,attr,buf) _dos_findfirst(spec,attr,\
\r
93 (struct find_t *)buf)
\r
94 #define FIND_NEXT(buf) _dos_findnext((struct find_t *)buf)
\r
97 /*----------------------------------------------------------------------------
\r
100 IN_PORT read byte from I/O port
\r
101 IN_PORTW read word from I/O port
\r
102 OUT_PORT write byte to I/O port
\r
103 OUT_PORTW write word to I/O port
\r
104 ----------------------------------------------------------------------------*/
\r
106 #if defined(__TURBOC__)
\r
108 #define IN_PORT(port) inportb(port)
\r
109 #define IN_PORTW(port) inport(port)
\r
110 #define OUT_PORT(port, val) outportb(port, val)
\r
111 #define OUT_PORTW(port, val) outport(port, val)
\r
115 #define IN_PORT(port) inp(port)
\r
116 #define IN_PORTW(port) inpw(port)
\r
117 #define OUT_PORT(port, val) outp(port, val)
\r
118 #define OUT_PORTW(port, val) outpw(port, val)
\r
120 /*----------------------------------------------------------------------------
\r
121 Borland pseudo register macros
\r
123 These macros replace references to Borland's pseudo register
\r
124 variables and geninterrup() funciton with traditional struct
\r
125 REGS/int86 references.
\r
126 ----------------------------------------------------------------------------*/
\r
128 #if !defined(__TURBOC__)
\r
131 extern union REGS CPURegs;
\r
133 #define _AX CPURegs.x.ax
\r
134 #define _BX CPURegs.x.bx
\r
135 #define _CX CPURegs.x.cx
\r
136 #define _DX CPURegs.x.dx
\r
138 #define _AH CPURegs.h.ah
\r
139 #define _AL CPURegs.h.al
\r
140 #define _BH CPURegs.h.bh
\r
141 #define _BL CPURegs.h.bl
\r
142 #define _CH CPURegs.h.ch
\r
143 #define _CL CPURegs.h.cl
\r
144 #define _DH CPURegs.h.dh
\r
145 #define _DL CPURegs.h.dl
\r
147 #define geninterrupt(n) int86(n,&CPURegs,&CPURegs);
\r
148 #define O_DENYALL 0x10
\r
149 #define O_DENYWRITE 0x20
\r
150 #define O_DENYREAD 0x30
\r
151 #define O_DENYNONE 0x40
\r
156 /*----------------------------------------------------------------------------
\r
157 Pointer-related macros
\r
159 MK_FP creates a far pointer from segment and offset values
\r
160 ----------------------------------------------------------------------------*/
\r
162 #if !defined(MK_FP)
\r
163 #define MK_FP(seg,off) ((void FAR *)(((long)(seg) << 16)|(unsigned)(off)))
\r