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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/*============================================================================
portable.h v1.00 Written by Scott Robert Ladd.
_MSC_VER Microsoft C 6.0 and later
_QC Microsoft Quick C 2.51 and later
__TURBOC__ Borland Turbo C, Turbo C++, and Borland C++
__BORLANDC__ Borland C++
__ZTC__ Zortech C++ and Symantec C++
__SC__ Symantec C++
__WATCOM__ WATCOM C
__POWERC Mix Power C
Revised:
09/14/93 Fred Cole Moved MK_FP() macro to end of file to avoid
redefinition error when dos.h gets included
at the in/outport definitions for __TURBOC__
09/15/93 Thad Smith Add conditional code for TC 2.01
Fix findfirst/findnext support for ZTC 3.0
10/15/93 Bob Stout Revise find first/next support
04/03/94 Bob Stout Add Power C support, FAR
============================================================================*/
/* prevent multiple inclusions of this header file */
#if !defined(PORTABLE_H)
#define PORTABLE_H
/*
** Correct far pointer syntax
*/
#if defined(__POWERC) || (defined(__TURBOC__) && !defined(__BORLANDC__))
#define FAR far
#else
#define FAR _far
#endif
/*----------------------------------------------------------------------------
Directory search macros and data structures
DOSFileData MS-DOS file data structure
FIND_FIRST MS-DOS function 0x4E -- find first file matchine spec
FIND_NEXT MS-DOS function 0x4F -- find subsequent files
----------------------------------------------------------------------------*/
/* make sure the structure is packed on byte boundary */
#if defined(_MSC_VER) || defined(_QC) || defined(__WATCOM__)
#pragma pack(1)
#elif defined(__ZTC__)
#pragma ZTC align 1
#elif defined(__TURBOC__) && (__TURBOC__ > 0x202)
#pragma option -a-
#endif
/* use this structure in place of compiler-defined file structure */
typedef struct {
char reserved[21];
char attrib;
unsigned time;
unsigned date;
long size;
char name[13];
} DOSFileData;
/* set structure alignment to default */
#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__)
#pragma pack()
#elif defined (__ZTC__)
#pragma ZTC align
#elif defined(__TURBOC__) && (__TURBOC__ > 0x202)
#pragma option -a.
#endif
/* include proper header files and create macros */
#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC)
#include "direct.h"
#define FIND_FIRST(spec,attr,buf) _dos_findfirst(spec,attr,\
(struct find_t *)buf)
#define FIND_NEXT(buf) _dos_findnext((struct find_t *)buf)
#elif defined (__TURBOC__)
#include "dir.h"
#define FIND_FIRST(spec,attr,buf) findfirst(spec,(struct ffblk *)buf,attr)
#define FIND_NEXT(buf) findnext((struct ffblk *)buf)
#elif defined (__ZTC__)
#include "dos.h"
#define FIND_FIRST(spec,attr,buf) _dos_findfirst(spec,attr,\
(struct find_t *)buf)
#define FIND_NEXT(buf) _dos_findnext((struct find_t *)buf)
#endif
/*----------------------------------------------------------------------------
I/O Port Macros
IN_PORT read byte from I/O port
IN_PORTW read word from I/O port
OUT_PORT write byte to I/O port
OUT_PORTW write word to I/O port
----------------------------------------------------------------------------*/
#if defined(__TURBOC__)
#include "dos.h"
#define IN_PORT(port) inportb(port)
#define IN_PORTW(port) inport(port)
#define OUT_PORT(port, val) outportb(port, val)
#define OUT_PORTW(port, val) outport(port, val)
#else
#include "conio.h"
#define IN_PORT(port) inp(port)
#define IN_PORTW(port) inpw(port)
#define OUT_PORT(port, val) outp(port, val)
#define OUT_PORTW(port, val) outpw(port, val)
/*----------------------------------------------------------------------------
Borland pseudo register macros
These macros replace references to Borland's pseudo register
variables and geninterrup() funciton with traditional struct
REGS/int86 references.
----------------------------------------------------------------------------*/
#if !defined(__TURBOC__)
#include "dos.h"
extern union REGS CPURegs;
#define _AX CPURegs.x.ax
#define _BX CPURegs.x.bx
#define _CX CPURegs.x.cx
#define _DX CPURegs.x.dx
#define _AH CPURegs.h.ah
#define _AL CPURegs.h.al
#define _BH CPURegs.h.bh
#define _BL CPURegs.h.bl
#define _CH CPURegs.h.ch
#define _CL CPURegs.h.cl
#define _DH CPURegs.h.dh
#define _DL CPURegs.h.dl
#define geninterrupt(n) int86(n,&CPURegs,&CPURegs);
#define O_DENYALL 0x10
#define O_DENYWRITE 0x20
#define O_DENYREAD 0x30
#define O_DENYNONE 0x40
#endif
#endif
/*----------------------------------------------------------------------------
Pointer-related macros
MK_FP creates a far pointer from segment and offset values
----------------------------------------------------------------------------*/
#if !defined(MK_FP)
#define MK_FP(seg,off) ((void FAR *)(((long)(seg) << 16)|(unsigned)(off)))
#endif
#endif
|