| 1 | /* $Header: d:/cvsroot/tads/TADS2/msdos/OSDOS.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 | osdos.h - MS-DOS system definitions |
| 12 | Function |
| 13 | |
| 14 | Notes |
| 15 | |
| 16 | Modified |
| 17 | 10/17/98 MJRoberts - Creation |
| 18 | */ |
| 19 | |
| 20 | #ifndef OSDOS_H |
| 21 | #define OSDOS_H |
| 22 | |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| 27 | /* include general DOS/Windows definitions */ |
| 28 | #include "osdosbas.h" |
| 29 | |
| 30 | /* ------------------------------------------------------------------------ */ |
| 31 | /* |
| 32 | * System name and long desription (for banner) |
| 33 | */ |
| 34 | #ifdef DJGPP |
| 35 | # define OS_SYSTEM_NAME "DJGPP" |
| 36 | #else |
| 37 | # define OS_SYSTEM_NAME "MSDOS" |
| 38 | #endif |
| 39 | |
| 40 | #define OS_SYSTEM_LDESC "MS-DOS" |
| 41 | |
| 42 | |
| 43 | /* ------------------------------------------------------------------------ */ |
| 44 | /* |
| 45 | * File Opening - use stdio |
| 46 | */ |
| 47 | |
| 48 | /* newline sequence - DOS/Windows use CR-LF */ |
| 49 | #define OS_NEWLINE_SEQ "\r\n" |
| 50 | |
| 51 | /* open text file for reading; returns NULL on error */ |
| 52 | /* osfildef *osfoprt(const char *fname, os_filetype_t typ); */ |
| 53 | #define osfoprt(fname, typ) fopen(fname, "r") |
| 54 | |
| 55 | /* open text file for 'volatile' reading; returns NULL on error */ |
| 56 | /* osfildef *osfoprtv(const char *fname, os_filetype_t typ); */ |
| 57 | #define osfoprtv(fname, typ) osfoprt(fname, typ) |
| 58 | |
| 59 | /* open text file for writing; returns NULL on error */ |
| 60 | /* osfildef *osfopwt(const char *fname, os_filetype_t typ); */ |
| 61 | #define osfopwt(fname, typ) fopen(fname, "w") |
| 62 | |
| 63 | /* open text file for reading/writing; don't truncate */ |
| 64 | osfildef *osfoprwt(const char *fname, os_filetype_t typ); |
| 65 | |
| 66 | /* open text file for reading/writing; truncate; returns NULL on error */ |
| 67 | /* osfildef *osfoprwtt(const char *fname, os_filetype_t typ); */ |
| 68 | #define osfoprwtt(fname, typ) fopen(fname, "w+") |
| 69 | |
| 70 | /* open binary file for writing; returns NULL on error */ |
| 71 | /* osfildef *osfopwb(const char *fname, os_filetype_t typ); */ |
| 72 | #define osfopwb(fname, typ) fopen(fname, "wb") |
| 73 | |
| 74 | /* open SOURCE file for reading - use appropriate text/binary mode */ |
| 75 | /* osfildef *osfoprs(const char *fname, os_filetype_t typ); */ |
| 76 | #define osfoprs(fname, typ) fopen(fname, "rb") |
| 77 | |
| 78 | /* open binary file for reading; returns NULL on erorr */ |
| 79 | /* osfildef *osfoprb(const char *fname, os_filetype_t typ); */ |
| 80 | #define osfoprb(fname, typ) fopen(fname, "rb") |
| 81 | |
| 82 | /* open binary file for 'volatile' reading; returns NULL on erorr */ |
| 83 | /* osfildef *osfoprbv(const char *fname, os_filetype_t typ); */ |
| 84 | #define osfoprbv(fname, typ) osfoprb(fname, typ) |
| 85 | |
| 86 | /* open binary file for reading/writing; don't truncate */ |
| 87 | osfildef *osfoprwb(const char *fname, os_filetype_t typ); |
| 88 | |
| 89 | /* open binary file for reading/writing; truncate; returns NULL on error */ |
| 90 | /* osfildef *osfoprwtb(const char *fname, os_filetype_t typ); */ |
| 91 | #define osfoprwtb(fname, typ) fopen(fname, "w+b") |
| 92 | |
| 93 | |
| 94 | /* ------------------------------------------------------------------------ */ |
| 95 | /* |
| 96 | * Duplicate a file handle |
| 97 | */ |
| 98 | osfildef *osfdup(osfildef *fp, const char *mode); |
| 99 | |
| 100 | /* ------------------------------------------------------------------------ */ |
| 101 | /* |
| 102 | * sprintf equivalents with buffer allocation |
| 103 | */ |
| 104 | int os_asprintf(char **bufptr, const char *fmt, ...); |
| 105 | int os_vasprintf(char **bufptr, const char *fmt, va_list ap); |
| 106 | |
| 107 | |
| 108 | |
| 109 | /* ------------------------------------------------------------------------ */ |
| 110 | /* |
| 111 | * Set "busy" cursor on/off. For systems with a mouse cursor, set the |
| 112 | * cursor to an appropriate shape to notify the user that the system is |
| 113 | * busy. Does nothing on DOS. |
| 114 | */ |
| 115 | /* void os_csr_busy(int show_as_busy); */ |
| 116 | #define os_csr_busy(show_as_busy) |
| 117 | |
| 118 | |
| 119 | /* ------------------------------------------------------------------------ */ |
| 120 | /* |
| 121 | * If error messages are to be included in the executable, define |
| 122 | * ERR_LINK_MESSAGES. Otherwise, they'll be read from an external |
| 123 | * file that is to be opened with oserrop(). |
| 124 | */ |
| 125 | #ifdef DJGPP |
| 126 | #define ERR_LINK_MESSAGES |
| 127 | #endif |
| 128 | |
| 129 | |
| 130 | /* ------------------------------------------------------------------------ */ |
| 131 | /* |
| 132 | * Update progress display with linfdef info, if appropriate. This can |
| 133 | * be used to provide a status display during compilation. Most |
| 134 | * command-line implementations will just ignore this notification; this |
| 135 | * can be used for GUI compiler implementations to provide regular |
| 136 | * display updates during compilation to show the progress so far. |
| 137 | */ |
| 138 | #define os_progress(fname, linenum) |
| 139 | |
| 140 | |
| 141 | /* ------------------------------------------------------------------------ */ |
| 142 | /* |
| 143 | * Single/double quote matching macros. Used to allow systems with |
| 144 | * extended character codes with weird quote characters (such as Mac) to |
| 145 | * match the weird characters. |
| 146 | */ |
| 147 | #define os_squote(c) ((c) == '\'') |
| 148 | #define os_dquote(c) ((c) == '"') |
| 149 | #define os_qmatch(a, b) ((a) == (b)) |
| 150 | |
| 151 | |
| 152 | /* ------------------------------------------------------------------------ */ |
| 153 | /* |
| 154 | * on 16-bit protected-mode DOS, we need to check manually for break, so |
| 155 | * do this in os_yield; on other DOS versions, we don't need to do |
| 156 | * anything in os_yield |
| 157 | */ |
| 158 | #ifdef MSDOS |
| 159 | # ifndef __DPMI16__ |
| 160 | # define os_yield() FALSE |
| 161 | # endif |
| 162 | #endif |
| 163 | |
| 164 | |
| 165 | /* ------------------------------------------------------------------------ */ |
| 166 | /* |
| 167 | * theoretical maximum osmalloc size is all of memory |
| 168 | */ |
| 169 | #ifdef __32BIT__ |
| 170 | # define OSMALMAX 0xffffffffL |
| 171 | #else /* !__32BIT__ */ |
| 172 | # define OSMALMAX 0xffffL |
| 173 | #endif /* __32BIT__ */ |
| 174 | |
| 175 | |
| 176 | /* ------------------------------------------------------------------------ */ |
| 177 | /* |
| 178 | * Usage lines - for protected mode, we use different names for the |
| 179 | * executables, so reflect that in the usage lines. This isn't needed |
| 180 | * for the real-mode DOS versions, since they use the deault command |
| 181 | * names. |
| 182 | */ |
| 183 | #ifdef __DPMI16__ |
| 184 | # define OS_TC_USAGE "usage: tcx [options] file" |
| 185 | # define OS_TR_USGAE "usage: trx [options] file" |
| 186 | # define OS_TDB_USAGE "usage: tdbx [options] file" |
| 187 | #endif |
| 188 | |
| 189 | /* add the special TR option messages */ |
| 190 | #define ERR_TRUS_OS_FIRST ERR_TRUS_DOS_1 |
| 191 | #define ERR_TRUS_OS_LAST ERR_TRUS_DOS_L |
| 192 | |
| 193 | /* |
| 194 | * If we're in 16-bit mode, either real or protected, reduce the default |
| 195 | * stack size, since the real system stack is very constrained for these |
| 196 | * executables. (The interpreter consumes system stack in proportion to |
| 197 | * TADS stack space, so limiting the TADS stack will help ensure we |
| 198 | * don't overflow system stack.) |
| 199 | */ |
| 200 | #ifndef __32BIT__ |
| 201 | # define TRD_STKSIZ 100 |
| 202 | # define TRD_STKSIZ_MSG " -ms size stack size (default 100 elements)" |
| 203 | #endif |
| 204 | |
| 205 | |
| 206 | #ifdef DJGPP |
| 207 | # define OS_TC_USAGE "usage: tadsc [options] file" |
| 208 | # define OS_TR_USAGE "usage: tadsr [options] file" |
| 209 | |
| 210 | /* |
| 211 | * Make default buffer sizes huge, since we can be fairly liberal with |
| 212 | * memory on DJGPP |
| 213 | */ |
| 214 | #include "osbigmem.h" |
| 215 | |
| 216 | /* |
| 217 | * Swapping off by default, since DJGPP has virtual memory |
| 218 | */ |
| 219 | # define OS_DEFAULT_SWAP_ENABLED 0 |
| 220 | |
| 221 | /* |
| 222 | * argv[0] required by dbgu.c |
| 223 | */ |
| 224 | extern char *__dos_argv0; /* from crt0.h */ |
| 225 | # define ARG0 __dos_argv0 |
| 226 | |
| 227 | # ifndef TADS_OEM_NAME |
| 228 | # define TADS_OEM_VERSION "0" |
| 229 | # define OS_SYSTEM_PATCHSUBLVL "0" |
| 230 | # define TADS_OEM_NAME "[email protected]" |
| 231 | # endif |
| 232 | #endif /* DJGPP */ |
| 233 | |
| 234 | |
| 235 | #ifdef __cplusplus |
| 236 | } |
| 237 | #endif |
| 238 | |
| 239 | #endif /* OSDOS_H */ |
| 240 |