Debian Codegraph @

terps/tads/tads2/msdos/oswin.h

raw symbols SCIP
1 /* $Header: d:/cvsroot/tads/TADS2/msdos/OSWIN.H,v 1.4 1999/07/11 00:46:37 MJRoberts Exp $ */
2
3 /*
4 * Copyright (c) 1998, 2002 Michael J. Roberts. All Rights Reserved.
5 *
6 * Please see the accompanying license file, LICENSE.TXT, for information
7 * on using and copying this software.
8 */
9 /*
10 Name
11 oswin.h - OS definitions for 32-bit Windows (95/98/NT)
12 Function
13
14 Notes
15
16 Modified
17 10/17/98 MJRoberts - Creation
18 */
19
20 #ifndef OSWIN_H
21 #define OSWIN_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include <share.h>
28 #include <fcntl.h>
29
30 /* include general DOS/Windows definitions */
31 #include "osdosbas.h"
32
33 /* ------------------------------------------------------------------------ */
34 /*
35 * Application instance handle global variable. The code with the
36 * WinMain() entrypoint function must provide a definition of this
37 * variable, and must initialize it to the application instance handle.
38 *
39 * We implement this as a global variable partly for simplicity, but
40 * mostly because it will make it evident at link time if the WinMain
41 * routine forgets to define this.
42 *
43 * (Note that the definition below is commented out so that we avoid
44 * using the windows.h type HINSTANCE in this portable interface file.
45 * The actual extern is in oswin.c; this comment is here for documentary
46 * purposes only.)
47 */
48 /* extern HINSTANCE oss_G_hinstance; */
49
50
51 /* ------------------------------------------------------------------------ */
52 /*
53 * System name and long description
54 */
55 #define OS_SYSTEM_NAME "WIN32"
56 #define OS_SYSTEM_LDESC "Windows"
57
58
59 /* ------------------------------------------------------------------------ */
60 /*
61 * Opening Files. We use the special share-mode version of fopen so
62 * that we can enforce reasonable file-sharing rules: opening a file for
63 * reading locks out writers; opening a file for writing locks out
64 * readers as well as other writers.
65 *
66 * Other than the sharing modes, we'll use normal stdio routines for our
67 * file interfaces.
68 */
69
70 /* newline sequence - DOS/Windows use CR-LF */
71 #define OS_NEWLINE_SEQ "\r\n"
72
73 /* internal file-open routine */
74 osfildef *os_fsopen(const char *fname, const char *mode, int omode, int sh);
75
76 /* open text file for reading; returns NULL on error */
77 /* osfildef *osfoprt(const char *fname, os_filetype_t typ); */
78 #define osfoprt(fname, typ) \
79 os_fsopen(fname, "r", _O_RDONLY | _O_TEXT, _SH_DENYWR)
80
81 /* open text file for 'volatile' reading; returns NULL on error */
82 /* osfildef *osfoprtv(const char *fname, os_filetype_t typ); */
83 #define osfoprtv(fname, typ) \
84 os_fsopen(fname, "r", _O_RDONLY | _O_TEXT, _SH_DENYNO)
85
86 /* open text file for writing; returns NULL on error */
87 /* osfildef *osfopwt(const char *fname, os_filetype_t typ); */
88 #define osfopwt(fname, typ) \
89 os_fsopen(fname, "w", \
90 _O_CREAT | _O_TRUNC | _O_WRONLY | _O_TEXT, _SH_DENYWR)
91
92 /* open text file for reading/writing; don't truncate */
93 #define osfoprwt(fname, typ) \
94 os_fsopen(fname, "r+", _O_CREAT | _O_RDWR | _O_TEXT, _SH_DENYRW)
95
96 /* open text file for reading/writing; truncate; returns NULL on error */
97 /* osfildef *osfoprwtt(const char *fname, os_filetype_t typ); */
98 #define osfoprwtt(fname, typ) \
99 os_fsopen(fname, "w+", \
100 _O_CREAT | _O_TRUNC | _O_RDWR | _O_TEXT, _SH_DENYWR)
101
102 /* open binary file for writing; returns NULL on error */
103 /* osfildef *osfopwb(const char *fname, os_filetype_t typ); */
104 #define osfopwb(fname, typ) \
105 os_fsopen(fname, "wb", \
106 _O_CREAT | _O_TRUNC | _O_WRONLY | _O_BINARY, _SH_DENYWR)
107
108 /* open SOURCE file for reading - use appropriate text/binary mode */
109 /* osfildef *osfoprs(const char *fname, os_filetype_t typ); */
110 #define osfoprs(fname, typ) \
111 os_fsopen(fname, "rb", _O_RDONLY | _O_BINARY, _SH_DENYWR)
112
113 /* open binary file for reading; returns NULL on erorr */
114 /* osfildef *osfoprb(const char *fname, os_filetype_t typ); */
115 #define osfoprb(fname, typ) \
116 os_fsopen(fname, "rb", _O_RDONLY | _O_BINARY, _SH_DENYWR)
117
118 /* open binary file for 'volatile' reading; returns NULL on erorr */
119 /* osfildef *osfoprbv(const char *fname, os_filetype_t typ); */
120 #define osfoprbv(fname, typ) \
121 os_fsopen(fname, "rb", _O_RDONLY | _O_BINARY, _SH_DENYNO)
122
123 /* open binary file for reading/writing; don't truncate */
124 #define osfoprwb(fname, typ) \
125 os_fsopen(fname, "r+b", _O_CREAT | _O_RDWR | _O_BINARY, _SH_DENYRW)
126
127 /* open binary file for reading/writing; truncate; returns NULL on error */
128 /* osfildef *osfoprwtb(const char *fname, os_filetype_t typ); */
129 #define osfoprwtb(fname, typ) \
130 os_fsopen(fname, "w+b", \
131 _O_CREAT | _O_TRUNC | _O_RDWR | _O_BINARY, _SH_DENYWR)
132
133
134 /* ------------------------------------------------------------------------ */
135 /*
136 * sprintf equivalents with buffer allocation
137 */
138 int os_asprintf(char **bufptr, const char *fmt, ...);
139 int os_vasprintf(char **bufptr, const char *fmt, va_list ap);
140
141
142 /* ------------------------------------------------------------------------ */
143 /*
144 * Set the initial directory for os_askfile dialogs
145 */
146 void oss_set_open_file_dir(const char *dir);
147
148
149 /* ------------------------------------------------------------------------ */
150 /*
151 * If error messages are to be included in the executable, define
152 * ERR_LINK_MESSAGES. Otherwise, they'll be read from an external
153 * file that is to be opened with oserrop().
154 */
155 /* #define ERR_LINK_MESSAGES */
156
157
158 /* ------------------------------------------------------------------------ */
159 /*
160 * Update progress display with current info, if appropriate. This can
161 * be used to provide a status display during compilation. Most
162 * command-line implementations will just ignore this notification; this
163 * can be used for GUI compiler implementations to provide regular
164 * display updates during compilation to show the progress so far.
165 */
166 #define os_progress(fname, linenum)
167
168
169 /* ------------------------------------------------------------------------ */
170 /*
171 * Single/double quote matching macros. Used to allow systems with
172 * extended character codes with weird quote characters (such as Mac) to
173 * match the weird characters.
174 */
175 #define os_squote(c) ((c) == '\'')
176 #define os_dquote(c) ((c) == '"')
177 #define os_qmatch(a, b) ((a) == (b))
178
179 /* ------------------------------------------------------------------------ */
180 /*
181 * theoretical maximum osmalloc size is all of memory
182 */
183 #define OSMALMAX 0xffffffffL
184
185
186 /* ------------------------------------------------------------------------ */
187 /*
188 * usage lines for 32-bit command-line tools
189 */
190 # define OS_TC_USAGE "usage: tc32 [options] file"
191 # define OS_TR_USAGE "usage: t2r32 [options] file"
192 # define OS_TDB_USAGE "usage: tdb32 [options] file"
193
194 /* add the special console-mode options messages, if appropriate */
195 # ifndef HTMLTADS
196 # define ERR_TRUS_OS_FIRST ERR_TRUS_DOS32_1
197 # define ERR_TRUS_OS_LAST ERR_TRUS_DOS32_L
198 # endif
199
200
201 /* ------------------------------------------------------------------------ */
202 /*
203 * Make default buffer sizes huge, since we can be fairly liberal with
204 * memory on win95/nt
205 */
206 #include "osbigmem.h"
207
208 #ifdef __cplusplus
209 }
210 #endif
211
212 #endif /* OSWIN_H */
213