1/*	SCCS Id: @(#)def_os2.h	3.4	1993/01/19	*/
2/* Copyright (c) Timo Hakulinen, 1990, 1991, 1992, 1993.	  */
3/* NetHack may be freely redistributed.  See license for details. */
4
5/*
6 *	Only a small portion of all OS/2 defines are needed, so the
7 *	actual include files often need not be used.  In fact,
8 *	including the full headers may stall the compile in DOS.
9 */
10
11#ifdef OS2_USESYSHEADERS
12
13# define INCL_NOPMAPI
14# define INCL_DOSFILEMGR
15# define INCL_DOS
16# define INCL_SUB
17
18#include <os2.h>
19
20#else
21
22typedef char CHAR;
23typedef void VOID;
24
25typedef unsigned char UCHAR;
26typedef unsigned short USHORT;
27typedef unsigned int UINT;
28typedef unsigned long ULONG;
29typedef unsigned char BYTE;
30
31# ifdef OS2_32BITAPI
32
33typedef unsigned long SHANDLE;
34typedef USHORT HKBD;
35typedef USHORT HVIO;
36
37#  define CCHMAXPATHCOMP 256
38
39#  ifdef OS2_CSET2
40#   define API16 _Far16 _Pascal
41#   define DAT16
42#   define API32 _System
43#   define KbdGetStatus KBD16GETSTATUS
44#   define KbdSetStatus KBD16SETSTATUS
45#   define KbdCharIn    KBD16CHARIN
46#   define KbdPeek      KBD16PEEK
47#   define VioGetMode   VIO16GETMODE
48#   define VioSetCurPos VIO16SETCURPOS
49#  else
50#   define API16
51#   define DAT16
52#   define API32
53#  endif
54
55#  define DAT
56
57# else /* OS2_32BITAPI */
58
59typedef unsigned short SHANDLE;
60typedef SHANDLE HKBD;
61typedef SHANDLE HVIO;
62
63#  define CCHMAXPATHCOMP 13
64
65#  ifdef OS2_MSC
66#   define API16 pascal far
67#   define DAT16
68#  endif
69
70#  define DAT DAT16
71
72# endif /* OS2_32BITAPI */
73
74typedef USHORT * DAT16 PUSHORT;
75typedef BYTE * DAT16 PBYTE;
76typedef ULONG * DAT PULONG;
77typedef VOID * DAT PVOID;
78
79typedef SHANDLE HDIR;
80typedef HDIR * DAT PHDIR;
81
82typedef char * DAT16 PCH;
83typedef char * DAT PSZ;
84
85/* all supported compilers understand this */
86
87# pragma pack(2)
88
89typedef struct {
90	UCHAR  chChar;
91	UCHAR  chScan;
92	UCHAR  fbStatus;
93	UCHAR  bNlsShift;
94	USHORT fsState;
95	ULONG  time;
96} KBDKEYINFO;
97
98typedef KBDKEYINFO * DAT16 PKBDKEYINFO;
99
100/* File time and date types */
101
102typedef struct {
103	UINT twosecs : 5;
104	UINT minutes : 6;
105	UINT hours   : 5;
106} FTIME;
107
108typedef struct {
109	UINT day     : 5;
110	UINT month   : 4;
111	UINT year    : 7;
112} FDATE;
113
114# ifdef OS2_32BITAPI
115
116typedef struct {
117	ULONG oNextEntryOffset;
118	FDATE fdateCreation;
119	FTIME ftimeCreation;
120	FDATE fdateLastAccess;
121	FTIME ftimeLastAccess;
122	FDATE fdateLastWrite;
123	FTIME ftimeLastWrite;
124	ULONG cbFile;
125	ULONG cbFileAlloc;
126	ULONG attrFile;
127	UCHAR cchName;
128	CHAR  achName[CCHMAXPATHCOMP];
129} FILEFINDBUF3;
130
131# else
132
133typedef struct {
134	FDATE  fdateCreation;
135	FTIME  ftimeCreation;
136	FDATE  fdateLastAccess;
137	FTIME  ftimeLastAccess;
138	FDATE  fdateLastWrite;
139	FTIME  ftimeLastWrite;
140	ULONG  cbFile;
141	ULONG  cbFileAlloc;
142	USHORT attrFile;
143	UCHAR  cchName;
144	CHAR   achName[CCHMAXPATHCOMP];
145} FILEFINDBUF;
146
147typedef FILEFINDBUF * DAT16 PFILEFINDBUF;
148
149# endif /* OS2_32BITAPI */
150
151typedef struct {
152	ULONG  idFileSystem;
153	ULONG  cSectorUnit;
154	ULONG  cUnit;
155	ULONG  cUnitAvail;
156	USHORT cbSector;
157} FSALLOCATE;
158
159typedef struct {
160	USHORT cb;
161	USHORT fsMask;
162	USHORT chTurnAround;
163	USHORT fsInterim;
164	USHORT fsState;
165} KBDINFO;
166
167typedef KBDINFO * DAT16 PKBDINFO;
168
169typedef struct {
170	USHORT cb;
171	UCHAR  fbType;
172	UCHAR  color;
173	USHORT col;
174	USHORT row;
175	USHORT hres;
176	USHORT vres;
177	UCHAR  fmt_ID;
178	UCHAR  attrib;
179	ULONG  buf_addr;
180	ULONG  buf_length;
181	ULONG  full_length;
182	ULONG  partial_length;
183	PCH    ext_data_addr;
184} VIOMODEINFO;
185
186typedef VIOMODEINFO * DAT16 PVIOMODEINFO;
187
188# pragma pack()
189
190/* OS2 API functions */
191
192USHORT API16 KbdGetStatus(PKBDINFO, HKBD);
193USHORT API16 KbdSetStatus(PKBDINFO, HKBD);
194USHORT API16 KbdCharIn(PKBDKEYINFO, USHORT, HKBD);
195USHORT API16 KbdPeek(PKBDKEYINFO, HKBD);
196
197USHORT API16 VioGetMode(PVIOMODEINFO, HVIO);
198USHORT API16 VioSetCurPos(USHORT, USHORT, HVIO);
199
200# ifdef OS2_32BITAPI
201ULONG API32 DosQueryFSInfo(ULONG, ULONG, PVOID, ULONG);
202ULONG API32 DosFindFirst(PSZ, PHDIR, ULONG, PVOID, ULONG, PULONG, ULONG);
203ULONG API32 DosFindNext(HDIR, PVOID, ULONG, PULONG);
204ULONG API32 DosSetDefaultDisk(ULONG);
205# else
206USHORT API16 DosQFSInfo(USHORT, USHORT, PBYTE, USHORT);
207USHORT API16 DosFindFirst(PSZ, PHDIR, USHORT, PFILEFINDBUF, USHORT, PUSHORT, ULONG);
208USHORT API16 DosFindNext(HDIR, PFILEFINDBUF, USHORT, PUSHORT);
209USHORT API16 DosSelectDisk(USHORT);
210# endif /* OS2_32BITAPI */
211
212#endif /* OS2_USESYSHEADERS */
213