~ubuntu-branches/ubuntu/vivid/tidy/vivid

« back to all changes in this revision

Viewing changes to include/platform.h

  • Committer: Bazaar Package Importer
  • Author(s): Jason Thomas
  • Date: 2002-03-08 10:58:30 UTC
  • Revision ID: james.westby@ubuntu.com-20020308105830-he5azqenf1sq4jak
Tags: 20020301-1
* New upstream version.
* fix '--add-xml-decl yes --add-xml-space yes' crash bug
  thanks to  Cesar Eduardo Barros <cesarb@nitnet.com.br>
  and upstream.
  (closes: #137124)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* platform.h
 
2
 
 
3
  (c) 1998-2002 (W3C) MIT, INRIA, Keio University
 
4
  See tidy.c for the copyright notice.
 
5
 
 
6
  CVS Info :
 
7
 
 
8
    $Author: terry_teague $ 
 
9
    $Date: 2002/02/18 02:27:04 $ 
 
10
    $Revision: 1.23 $ 
 
11
 
 
12
*/
 
13
 
 
14
/*
 
15
  Uncomment and edit one of the following #defines if you
 
16
  want to specify the config file at compile-time.
 
17
*/
 
18
 
 
19
/* #define CONFIG_FILE "/etc/tidy_config.txt" */ /* original */
 
20
/* #define CONFIG_FILE "/etc/tidyrc" */
 
21
/* #define CONFIG_FILE "/etc/tidy.conf" */
 
22
 
 
23
/*
 
24
  Uncomment the following #define if you are on a Unix system
 
25
  supporting the call getpwnam() and the HOME environment variable.
 
26
  It enables tidy to find config files named ~/.tidyrc and
 
27
  ~your/.tidyrc etc if the HTML_TIDY environment
 
28
  variable is not set. Contributed by Todd Lewis.
 
29
*/
 
30
 
 
31
/* #define SUPPORT_GETPWNAM */
 
32
 
 
33
/* Enable/disable support for Big5 and Shift_JIS character encodings */
 
34
#ifndef SUPPORT_ASIAN_ENCODINGS
 
35
#define SUPPORT_ASIAN_ENCODINGS 0
 
36
#endif
 
37
 
 
38
/* Enable/disable support for UTF-16 character encodings */
 
39
#ifndef SUPPORT_UTF16_ENCODINGS
 
40
#define SUPPORT_UTF16_ENCODINGS 0
 
41
#endif
 
42
 
 
43
/* Convenience defines for Mac platforms */
 
44
 
 
45
#if defined(macintosh)
 
46
/* Mac OS 6.x/7.x/8.x/9.x, with or without CarbonLib - MPW or Metrowerks 68K/PPC compilers */
 
47
#define MAC_OS_CLASSIC
 
48
#ifndef PLATFORM_NAME
 
49
#define PLATFORM_NAME "Mac OS"
 
50
#endif
 
51
 
 
52
#elif defined(__linux__) && defined(__powerpc__)
 
53
#if #system(linux)
 
54
/* MkLinux on PPC  - gcc (egcs) compiler */
 
55
#define MAC_OS_MKLINUX
 
56
#ifndef PLATFORM_NAME
 
57
#define PLATFORM_NAME "MkLinux"
 
58
#endif
 
59
#endif
 
60
 
 
61
#elif defined(__APPLE__) && defined(__MACH__)
 
62
/* Mac OS X (client) 10.x (or server 1.x/10.x) - gcc or Metrowerks MachO compilers */
 
63
#define MAC_OS_X
 
64
#ifndef PLATFORM_NAME
 
65
#define PLATFORM_NAME "Mac OS X"
 
66
#endif
 
67
 
 
68
#endif
 
69
 
 
70
#if defined(MAC_OS_CLASSIC) || defined(MAC_OS_MKLINUX) || defined(MAC_OS_X)
 
71
/* Any OS on Mac platform */
 
72
#define MAC_OS
 
73
#endif
 
74
 
 
75
/* Convenience defines for BSD like platforms */
 
76
 
 
77
#if defined(__FreeBSD__)
 
78
#define BSD_BASED_OS
 
79
#ifndef PLATFORM_NAME
 
80
#define PLATFORM_NAME "FreeBSD"
 
81
#endif
 
82
 
 
83
#elif defined(__NetBSD__)
 
84
#define BSD_BASED_OS
 
85
#ifndef PLATFORM_NAME
 
86
#define PLATFORM_NAME "NetBSD"
 
87
#endif
 
88
 
 
89
#elif defined(__OpenBSD__)
 
90
#define BSD_BASED_OS
 
91
#ifndef PLATFORM_NAME
 
92
#define PLATFORM_NAME "OpenBSD"
 
93
#endif
 
94
 
 
95
#elif defined(__MINT__)
 
96
#define BSD_BASED_OS
 
97
#ifndef PLATFORM_NAME
 
98
#define PLATFORM_NAME "FreeMiNT"
 
99
#endif
 
100
 
 
101
#endif
 
102
 
 
103
/* Convenience defines for Windows platforms */
 
104
 
 
105
#if defined(WINDOWS) || defined(_WIN32)
 
106
#define WINDOWS_OS
 
107
#define PLATFORM_NAME "Windows"
 
108
#endif
 
109
 
 
110
/* Convenience defines for Linux platforms */
 
111
 
 
112
#if defined(linux) && defined(__alpha__)
 
113
/* Linux on Alpha - gcc compiler */
 
114
#define LINUX_OS
 
115
#ifndef PLATFORM_NAME
 
116
#define PLATFORM_NAME "Linux/Alpha"
 
117
#endif
 
118
 
 
119
#elif defined(linux) && defined(__sparc__)
 
120
/* Linux on Sparc - gcc compiler */
 
121
#define LINUX_OS
 
122
#ifndef PLATFORM_NAME
 
123
#define PLATFORM_NAME "Linux/Sparc"
 
124
#endif
 
125
 
 
126
#elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
 
127
/* Linux on x86 - gcc compiler */
 
128
#define LINUX_OS
 
129
#ifndef PLATFORM_NAME
 
130
#define PLATFORM_NAME "Linux/x86"
 
131
#endif
 
132
 
 
133
#elif defined(linux) && defined(__powerpc__)
 
134
/* Linux on PPC - gcc compiler */
 
135
#define LINUX_OS
 
136
#ifndef PLATFORM_NAME
 
137
#define PLATFORM_NAME "Linux/PPC"
 
138
#endif
 
139
 
 
140
#elif defined(linux) || defined(__linux__)
 
141
/* generic Linux */
 
142
#define LINUX_OS
 
143
#ifndef PLATFORM_NAME
 
144
#define PLATFORM_NAME "Linux"
 
145
#endif
 
146
 
 
147
#endif
 
148
 
 
149
/* Convenience defines for Solaris platforms */
 
150
 
 
151
#if defined(sun)
 
152
#define SOLARIS_OS
 
153
#ifndef PLATFORM_NAME
 
154
#define PLATFORM_NAME "Solaris"
 
155
#endif
 
156
#endif
 
157
 
 
158
/* Convenience defines for HPUX + gcc platforms */
 
159
 
 
160
#if defined(__hpux)
 
161
#define HPUX_OS
 
162
#ifndef PLATFORM_NAME
 
163
#define PLATFORM_NAME "HPUX"
 
164
#endif
 
165
#endif
 
166
 
 
167
/* Convenience defines for RISCOS + gcc platforms */
 
168
 
 
169
#if defined(__riscos__)
 
170
#define RISC_OS
 
171
#ifndef PLATFORM_NAME
 
172
#define PLATFORM_NAME "RISC OS"
 
173
#endif
 
174
#endif
 
175
 
 
176
/* Convenience defines for OS/2 + icc/gcc platforms */
 
177
 
 
178
#if defined(__OS2__) || defined(__IBMC__) || defined(__EMX__)
 
179
#define OS2_OS
 
180
#ifndef PLATFORM_NAME
 
181
#define PLATFORM_NAME "OS/2"
 
182
#endif
 
183
#endif
 
184
 
 
185
/* Convenience defines for BeOS platforms */
 
186
 
 
187
#if defined(__BEOS__)
 
188
#define BE_OS
 
189
#ifndef PLATFORM_NAME
 
190
#define PLATFORM_NAME "BeOS"
 
191
#endif
 
192
#endif
 
193
 
 
194
/* Convenience defines for Cygwin platforms */
 
195
 
 
196
#if defined(__CYGWIN__)
 
197
#define CYGWIN_OS
 
198
#ifndef PLATFORM_NAME
 
199
#define PLATFORM_NAME "Cygwin"
 
200
#endif
 
201
#endif
 
202
 
 
203
#include <ctype.h>
 
204
#include <stdio.h>
 
205
#include <setjmp.h>  /* for longjmp on error exit */
 
206
#include <stdlib.h>
 
207
#include <stdarg.h>  /* may need <varargs.h> for Unix V */
 
208
#include <string.h>
 
209
#include <assert.h>
 
210
 
 
211
#ifdef NEEDS_MALLOC_H
 
212
#include <malloc.h>
 
213
#endif
 
214
 
 
215
#ifdef SUPPORT_GETPWNAM
 
216
#include <pwd.h>
 
217
#endif
 
218
 
 
219
#ifdef NEEDS_UNISTD_H
 
220
#include <unistd.h>  /* needed for unlink on some Unix systems */
 
221
#endif
 
222
 
 
223
/*
 
224
  Tidy preserves the last modified time for the files it
 
225
  cleans up.
 
226
*/
 
227
 
 
228
/*
 
229
  If your platform doesn't support <utime.h> and the
 
230
  utime() function, or <sys/futime> and the futime()
 
231
  function then set PRESERVE_FILE_TIMES to 0.
 
232
  
 
233
  If your platform doesn't support <sys/utime.h> and the
 
234
  futime() function, then set HAS_FUTIME to 0.
 
235
  
 
236
  If your platform supports <utime.h> and the
 
237
  utime() function requires the file to be
 
238
  closed first, then set UTIME_NEEDS_CLOSED_FILE to 1.
 
239
*/
 
240
 
 
241
/* Keep old PRESERVEFILETIMES define for compatibility */
 
242
#ifdef PRESERVEFILETIMES
 
243
#undef PRESERVE_FILE_TIMES
 
244
#define PRESERVE_FILE_TIMES PRESERVEFILETIMES
 
245
#endif
 
246
 
 
247
#ifndef PRESERVE_FILE_TIMES
 
248
#if defined(RISC_OS)
 
249
#define PRESERVE_FILE_TIMES 0
 
250
#else
 
251
#define PRESERVE_FILE_TIMES 1
 
252
#endif
 
253
#endif
 
254
 
 
255
#if PRESERVE_FILE_TIMES
 
256
 
 
257
#ifndef HAS_FUTIME
 
258
#if defined(CYGWIN_OS) || defined(BE_OS) || defined(OS2_OS) || defined(HPUX_OS) || defined(SOLARIS_OS) || defined(LINUX_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__)
 
259
#define HAS_FUTIME 0
 
260
#else
 
261
#define HAS_FUTIME 1
 
262
#endif
 
263
#endif
 
264
 
 
265
#ifndef UTIME_NEEDS_CLOSED_FILE
 
266
#if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__)
 
267
#define UTIME_NEEDS_CLOSED_FILE 1
 
268
#else
 
269
#define UTIME_NEEDS_CLOSED_FILE 0
 
270
#endif
 
271
#endif
 
272
 
 
273
#if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__))
 
274
#include <sys/types.h> 
 
275
#include <sys/stat.h>
 
276
#else
 
277
#include <stat.h>
 
278
#endif
 
279
 
 
280
#if HAS_FUTIME
 
281
#include <sys/utime.h>
 
282
#else
 
283
#include <utime.h>
 
284
#endif /* HASFUTIME */
 
285
 
 
286
/*
 
287
  MS Windows needs _ prefix for Unix file functions.
 
288
  Not required by Metrowerks Standard Library (MSL).
 
289
  
 
290
  Tidy uses following for preserving the last modified time.
 
291
 
 
292
  WINDOWS automatically set by Win16 compilers.
 
293
  _WIN32 automatically set by Win32 compilers.
 
294
*/
 
295
#if defined(_WIN32) && !defined(__MSL__)
 
296
#define futime _futime
 
297
#define fstat _fstat
 
298
#define utimbuf _utimbuf
 
299
#define stat _stat
 
300
#define fileno _fileno
 
301
#endif /* _WIN32 */
 
302
 
 
303
#endif /* PRESERVE_FILE_TIMES */
 
304
 
 
305
/* hack for gnu sys/types.h file  which defines uint and ulong */
 
306
/* you may need to delete the #ifndef and #endif on your system */
 
307
 
 
308
#ifndef __USE_MISC
 
309
#if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS_X)
 
310
#include <sys/types.h>
 
311
#else
 
312
#ifndef _INCLUDE_HPUX_SOURCE
 
313
typedef unsigned int uint;
 
314
#endif /* _INCLUDE_HPUX_SOURCE */
 
315
typedef unsigned long ulong;
 
316
#endif /* BSDs */
 
317
#endif /* __USE_MISC */
 
318
 
 
319
typedef unsigned char byte;
 
320
           
 
321
/*
 
322
  bool is a reserved word in some but
 
323
  not all C++ compilers depending on age
 
324
  work around is to avoid bool altogether
 
325
  by introducing a new enum called Bool
 
326
*/
 
327
typedef enum
 
328
{
 
329
   no,
 
330
   yes
 
331
} Bool;
 
332
 
 
333
/* for null pointers */
 
334
#define null 0
 
335
 
 
336
/*
 
337
  portability hack for deleting files - this is used
 
338
  in pprint.c for deleting superfluous slides.
 
339
 
 
340
  Win32 defines _unlink as per Unix unlink function.
 
341
  Except, MSVC will not recognize unlink() w/ 
 
342
  language extensions disabled (i.e. pure ANSI mode).
 
343
 
 
344
  WINDOWS automatically set by Win16 compilers.
 
345
  _WIN32 automatically set by Win32 compilers.
 
346
*/
 
347
 
 
348
#if defined(WINDOWS_OS) && !defined(__MSL__)
 
349
#define unlink _unlink
 
350
#endif
 
351
 
 
352
#if defined(RISC_OS)
 
353
#define unlink remove
 
354
#endif
 
355
 
 
356
#if defined(DMALLOC)
 
357
#include "dmalloc.h"
 
358
#endif
 
359
 
 
360
/* were defined in html.h - TRT */
 
361
void *MemAlloc(uint size);
 
362
void *MemRealloc(void *mem, uint newsize);
 
363
void MemFree(void *mem);
 
364
void ClearMemory(void *, uint size);