forked from ifrotz/iosfrotz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosansi.h
218 lines (173 loc) · 6.52 KB
/
osansi.h
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/******************************************************************************
* *
* Copyright (C) 2006-2009 by Tor Andersson. *
* Copyright (C) 2010 by Ben Cressey. *
* *
* This file is part of Gargoyle. *
* *
* Gargoyle is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* Gargoyle is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with Gargoyle; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
* *
*****************************************************************************/
#ifndef OSANSI_H
#define OSANSI_H
#define MAC_OS /* tell tads not to let os do paging */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define TRUE 1
#define FALSE 0
#ifdef __cplusplus
extern "C" {
#endif
#include "osbigmem.h"
/* ------------------------------------------------------------------------ */
/*
* All the stuff osifc.h forgot to tell me about...
*/
#define TADS_OEM_NAME "iFrotz"
/* Replace stricmp with strcasecmp */
#define strnicmp strncasecmp
#define stricmp strcasecmp
/* far pointer type qualifier (null on most platforms) */
#define osfar_t
#define far
/* cast an expression to void */
#define DISCARD (void)
/* ignore OS_LOADDS definitions */
#define OS_LOADDS
/* copy a structure - dst and src are structures, not pointers */
#define OSCPYSTRUCT(dst,src) ((dst) = (src))
#define memicmp os_memicmp
int os_memicmp(const char *a, const char *b, int n);
/* ------------------------------------------------------------------------ */
/*
* Platform Identifiers. You must define the following macros in your
*/
#define OS_SYSTEM_NAME "Generic"
/*
* Message Linking Configuration. You should #define ERR_LINK_MESSAGES
*/
#define ERR_LINK_MESSAGES
/*
* Program Exit Codes. These values are used for the argument to exit()
*/
#define OSEXSUCC 0
#define OSEXFAIL 1
/*
* Basic memory management interface. These functions are merely
*/
#define OSMALMAX 0xffffffff
#define osmalloc malloc
#define osfree free
#define osrealloc realloc
#define os_vasprintf vasprintf
/*
* Basic file I/O interface. These functions are merely documented
*/
#define OSFNMAX 1024
#ifdef _WIN32
#define OSPATHCHAR '\\'
#define OSPATHALT "/:"
#define OSPATHURL "\\/"
#define OSPATHSEP ';'
#define OSPATHPWD "."
#define OS_NEWLINE_SEQ "\r\n"
#else
#define OSPATHCHAR '/'
#define OSPATHALT ""
#define OSPATHURL "/"
#define OSPATHSEP ':'
#define OSPATHPWD "."
#define OS_NEWLINE_SEQ "\n"
#endif
#define OSFSK_SET 0
#define OSFSK_CUR 1
#define OSFSK_END 2
#define OSFOPRB 3
typedef FILE osfildef;
osfildef *osfoprt(const char *fname, os_filetype_t typ);
osfildef *osfopwt(const char *fname, os_filetype_t typ);
osfildef *osfoprwt(const char *fname, os_filetype_t typ);
osfildef *osfoprwtt(const char *fname, os_filetype_t typ);
osfildef *osfopwb(const char *fname, os_filetype_t typ);
osfildef *osfoprs(const char *fname, os_filetype_t typ);
osfildef *osfoprb(const char *fname, os_filetype_t typ);
osfildef *osfoprwb(const char *fname, os_filetype_t typ);
osfildef *osfoprwtb(const char *fname, os_filetype_t typ);
char *osfgets(char *buf, size_t len, osfildef *fp);
int osfputs(const char *buf, osfildef *fp);
void os_fprintz(osfildef *fp, const char *str);
void os_fprint(osfildef *fp, const char *str, size_t len);
int osfwb(osfildef *fp, const void *buf, int bufl);
int osfrb(osfildef *fp, void *buf, int bufl);
size_t osfrbc(osfildef *fp, void *buf, size_t bufl);
long osfpos(osfildef *fp);
int osfseek(osfildef *fp, long pos, int mode);
int osfflush(osfildef *fp);
void osfcls(osfildef *fp);
int osfdel(const char *fname);
int osfacc(const char *fname);
int osfgetc(osfildef *fp);
void os_put_buffer (const char *buf, size_t len);
void os_get_buffer (char *buf, size_t len, size_t init);
unsigned char *os_fill_buffer (unsigned char *buf, size_t len);
/*
* Convert string to all-lowercase.
*/
char *os_strlwr(char *s);
/*
* Character classifications for quote characters. os_squote() returns
*/
#define os_squote(c) ((c) == '\'')
#define os_dquote(c) ((c) == '"')
#define os_qmatch(a, b) ((a) == (b))
/*
* OS_MAXWIDTH - the maximum width of a line of text. Most platforms use
*/
#define OS_MAXWIDTH 255
#define OS_ATTR_HILITE OS_ATTR_BOLD
#define OS_ATTR_EM OS_ATTR_ITALIC
#define OS_ATTR_STRONG OS_ATTR_BOLD
/*
* TADS 2 swapping configuration. Define OS_DEFAULT_SWAP_ENABLED to 0
*/
#define OS_DEFAULT_SWAP_ENABLED 0
#include <dirent.h>
typedef DIR* osdirhdl_t;
/* file type/mode bits */
#define OSFMODE_FILE S_IFREG
#define OSFMODE_DIR S_IFDIR
#define OSFMODE_CHAR S_IFCHR
#define OSFMODE_BLK S_IFBLK
#define OSFMODE_PIPE S_IFIFO
#define OSFMODE_LINK S_IFLNK
#ifdef S_IFSOCK
#define OSFMODE_SOCKET S_IFSOCK
#else
#define OSFMODE_SOCKET 0
#endif
/* File attribute bits. */
#define OSFATTR_HIDDEN 0x0001
#define OSFATTR_SYSTEM 0x0002
#define OSFATTR_READ 0x0004
#define OSFATTR_WRITE 0x0008
/* Get a file's stat() type. */
int osfmode( const char* fname, int follow_links, unsigned long* mode,
unsigned long* attr );
#define os_rename_file(from, to) (rename(from, to) == 0)
#ifdef __cplusplus
}
#endif
#endif /* OSANSI_H */