4
/* platform.h -- Platform specifics
6
(c) 1998-2005 (W3C) MIT, ERCIM, Keio University
7
See tidy.h for the copyright notice.
12
$Date: 2005/04/08 10:33:27 $
22
Uncomment and edit one of the following #defines if you
23
want to specify the config file at compile-time.
26
/* #define CONFIG_FILE "/etc/tidy_config.txt" */ /* original */
27
/* #define CONFIG_FILE "/etc/tidyrc" */
28
/* #define CONFIG_FILE "/etc/tidy.conf" */
31
Uncomment the following #define if you are on a system
32
supporting the HOME environment variable.
33
It enables tidy to find config files named ~/.tidyrc if
34
the HTML_TIDY environment variable is not set.
36
/* #define USER_CONFIG_FILE "~/.tidyrc" */
39
Uncomment the following #define if your
40
system supports the call getpwnam().
43
It enables tidy to find files named
44
~your/foo for use in the HTML_TIDY environment
45
variable or CONFIG_FILE or USER_CONFIGFILE or
46
on the command line: -config ~joebob/tidy.cfg
48
Contributed by Todd Lewis.
51
/* #define SUPPORT_GETPWNAM */
54
/* Enable/disable support for Big5 and Shift_JIS character encodings */
55
#ifndef SUPPORT_ASIAN_ENCODINGS
56
#define SUPPORT_ASIAN_ENCODINGS 1
59
/* Enable/disable support for UTF-16 character encodings */
60
#ifndef SUPPORT_UTF16_ENCODINGS
61
#define SUPPORT_UTF16_ENCODINGS 1
64
/* Enable/disable support for additional accessibility checks */
65
#ifndef SUPPORT_ACCESSIBILITY_CHECKS
66
#define SUPPORT_ACCESSIBILITY_CHECKS 1
70
/* Convenience defines for Mac platforms */
72
#if defined(macintosh)
73
/* Mac OS 6.x/7.x/8.x/9.x, with or without CarbonLib - MPW or Metrowerks 68K/PPC compilers */
74
#define MAC_OS_CLASSIC
76
#define PLATFORM_NAME "Mac OS"
79
/* needed for access() */
80
#if !defined(_POSIX) && !defined(NO_ACCESS_SUPPORT)
81
#define NO_ACCESS_SUPPORT
84
#ifdef SUPPORT_GETPWNAM
85
#undef SUPPORT_GETPWNAM
88
#elif defined(__APPLE__) && defined(__MACH__)
89
/* Mac OS X (client) 10.x (or server 1.x/10.x) - gcc or Metrowerks MachO compilers */
92
#define PLATFORM_NAME "Mac OS X"
96
#if defined(MAC_OS_CLASSIC) || defined(MAC_OS_X)
97
/* Any OS on Mac platform */
99
#define FILENAMES_CASE_SENSITIVE 0
100
#define strcasecmp strcmp
101
#ifndef DFLT_REPL_CHARENC
102
#define DFLT_REPL_CHARENC MACROMAN
106
/* Convenience defines for BSD like platforms */
108
#if defined(__FreeBSD__)
110
#ifndef PLATFORM_NAME
111
#define PLATFORM_NAME "FreeBSD"
114
#elif defined(__NetBSD__)
116
#ifndef PLATFORM_NAME
117
#define PLATFORM_NAME "NetBSD"
120
#elif defined(__OpenBSD__)
122
#ifndef PLATFORM_NAME
123
#define PLATFORM_NAME "OpenBSD"
126
#elif defined(__MINT__)
128
#ifndef PLATFORM_NAME
129
#define PLATFORM_NAME "FreeMiNT"
132
#elif defined(__bsdi__)
134
#ifndef PLATFORM_NAME
135
#define PLATFORM_NAME "BSD/OS"
140
/* Convenience defines for Windows platforms */
142
#if defined(WINDOWS) || defined(_WIN32)
145
#ifndef PLATFORM_NAME
146
#define PLATFORM_NAME "Windows"
149
#if defined(__MWERKS__) || defined(__MSL__)
150
/* not available with Metrowerks Standard Library */
152
#ifdef SUPPORT_GETPWNAM
153
#undef SUPPORT_GETPWNAM
156
/* needed for setmode() */
157
#if !defined(NO_SETMODE_SUPPORT)
158
#define NO_SETMODE_SUPPORT
161
#define strcasecmp _stricmp
165
#if defined(__BORLANDC__)
166
#define strcasecmp stricmp
169
#define FILENAMES_CASE_SENSITIVE 0
173
/* Convenience defines for Linux platforms */
175
#if defined(linux) && defined(__alpha__)
176
/* Linux on Alpha - gcc compiler */
178
#ifndef PLATFORM_NAME
179
#define PLATFORM_NAME "Linux/Alpha"
182
#elif defined(linux) && defined(__sparc__)
183
/* Linux on Sparc - gcc compiler */
185
#ifndef PLATFORM_NAME
186
#define PLATFORM_NAME "Linux/Sparc"
189
#elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
190
/* Linux on x86 - gcc compiler */
192
#ifndef PLATFORM_NAME
193
#define PLATFORM_NAME "Linux/x86"
196
#elif defined(linux) && defined(__powerpc__)
197
/* Linux on PPC - gcc compiler */
200
#if defined(__linux__) && defined(__powerpc__)
202
/* #if #system(linux) */
203
/* MkLinux on PPC - gcc (egcs) compiler */
204
/* #define MAC_OS_MKLINUX */
205
#ifndef PLATFORM_NAME
206
#define PLATFORM_NAME "MkLinux"
211
#ifndef PLATFORM_NAME
212
#define PLATFORM_NAME "Linux/PPC"
217
#elif defined(linux) || defined(__linux__)
220
#ifndef PLATFORM_NAME
221
#define PLATFORM_NAME "Linux"
226
/* Convenience defines for Solaris platforms */
230
#ifndef PLATFORM_NAME
231
#define PLATFORM_NAME "Solaris"
235
/* Convenience defines for HPUX + gcc platforms */
239
#ifndef PLATFORM_NAME
240
#define PLATFORM_NAME "HPUX"
244
/* Convenience defines for RISCOS + gcc platforms */
246
#if defined(__riscos__)
248
#ifndef PLATFORM_NAME
249
#define PLATFORM_NAME "RISC OS"
253
/* Convenience defines for OS/2 + icc/gcc platforms */
255
#if defined(__OS2__) || defined(__EMX__)
257
#ifndef PLATFORM_NAME
258
#define PLATFORM_NAME "OS/2"
260
#define FILENAMES_CASE_SENSITIVE 0
261
#define strcasecmp stricmp
264
/* Convenience defines for IRIX */
268
#ifndef PLATFORM_NAME
269
#define PLATFORM_NAME "SGI IRIX"
273
/* Convenience defines for AIX */
277
#ifndef PLATFORM_NAME
278
#define PLATFORM_NAME "IBM AIX"
283
/* Convenience defines for BeOS platforms */
285
#if defined(__BEOS__)
287
#ifndef PLATFORM_NAME
288
#define PLATFORM_NAME "BeOS"
292
/* Convenience defines for Cygwin platforms */
294
#if defined(__CYGWIN__)
296
#ifndef PLATFORM_NAME
297
#define PLATFORM_NAME "Cygwin"
299
#define FILENAMES_CASE_SENSITIVE 0
302
/* Convenience defines for OpenVMS */
306
#ifndef PLATFORM_NAME
307
#define PLATFORM_NAME "OpenVMS"
309
#define FILENAMES_CASE_SENSITIVE 0
312
/* Convenience defines for DEC Alpha OSF + gcc platforms */
316
#ifndef PLATFORM_NAME
317
#define PLATFORM_NAME "DEC Alpha OSF"
321
/* Convenience defines for ARM platforms */
326
#if defined(forARM) && defined(__NEWTON_H)
328
/* Using Newton C++ Tools ARMCpp compiler */
330
#ifndef PLATFORM_NAME
331
#define PLATFORM_NAME "Newton"
336
#ifndef PLATFORM_NAME
337
#define PLATFORM_NAME "ARM"
346
#include <setjmp.h> /* for longjmp on error exit */
348
#include <stdarg.h> /* may need <varargs.h> for Unix V */
352
#ifdef NEEDS_MALLOC_H
356
#ifdef SUPPORT_GETPWNAM
360
#ifdef NEEDS_UNISTD_H
361
#include <unistd.h> /* needed for unlink on some Unix systems */
364
/* This can be set at compile time. Usually Windows,
365
** except for Macintosh builds.
367
#ifndef DFLT_REPL_CHARENC
368
#define DFLT_REPL_CHARENC WIN1252
371
/* By default, use case-sensitive filename comparison.
373
#ifndef FILENAMES_CASE_SENSITIVE
374
#define FILENAMES_CASE_SENSITIVE 1
379
Tidy preserves the last modified time for the files it
384
If your platform doesn't support <utime.h> and the
385
utime() function, or <sys/futime> and the futime()
386
function then set PRESERVE_FILE_TIMES to 0.
388
If your platform doesn't support <sys/utime.h> and the
389
futime() function, then set HAS_FUTIME to 0.
391
If your platform supports <utime.h> and the
392
utime() function requires the file to be
393
closed first, then set UTIME_NEEDS_CLOSED_FILE to 1.
396
/* Keep old PRESERVEFILETIMES define for compatibility */
397
#ifdef PRESERVEFILETIMES
398
#undef PRESERVE_FILE_TIMES
399
#define PRESERVE_FILE_TIMES PRESERVEFILETIMES
402
#ifndef PRESERVE_FILE_TIMES
403
#if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS)
404
#define PRESERVE_FILE_TIMES 0
406
#define PRESERVE_FILE_TIMES 1
410
#if PRESERVE_FILE_TIMES
413
#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__) || defined(IRIX_OS) || defined(AIX_OS) || defined(__BORLANDC__)
420
#ifndef UTIME_NEEDS_CLOSED_FILE
421
#if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS)
422
#define UTIME_NEEDS_CLOSED_FILE 1
424
#define UTIME_NEEDS_CLOSED_FILE 0
428
#if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__))
429
#include <sys/types.h>
430
#include <sys/stat.h>
436
#include <sys/utime.h>
439
#endif /* HASFUTIME */
442
MS Windows needs _ prefix for Unix file functions.
443
Not required by Metrowerks Standard Library (MSL).
445
Tidy uses following for preserving the last modified time.
447
WINDOWS automatically set by Win16 compilers.
448
_WIN32 automatically set by Win32 compilers.
450
#if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
452
#define futime _futime
454
#define utimbuf _utimbuf /* Windows seems to want utimbuf */
457
#define vsnprintf _vsnprintf
460
#endif /* PRESERVE_FILE_TIMES */
463
MS Windows needs _ prefix for Unix file functions.
464
Not required by Metrowerks Standard Library (MSL).
466
WINDOWS automatically set by Win16 compilers.
467
_WIN32 automatically set by Win32 compilers.
469
#if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
472
#define fileno _fileno
473
#define setmode _setmode
476
#define access _access
477
#define strcasecmp _stricmp
480
#pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */
481
#pragma warning( disable : 4100 ) /* unreferenced formal parameter */
482
#pragma warning( disable : 4706 ) /* assignment within conditional expression */
489
#if (defined(_USRDLL) || defined(_WINDLL)) && !defined(TIDY_EXPORT)
490
#define TIDY_EXPORT __declspec( dllexport )
494
#define TIDY_CALL __stdcall
499
/* hack for gnu sys/types.h file which defines uint and ulong */
501
#if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
502
#include <sys/types.h>
504
#if !defined(HPUX_OS) && !defined(CYGWIN_OS) && !defined(MAC_OS_X) && !defined(BE_OS) && !defined(SOLARIS_OS) && !defined(BSD_BASED_OS) && !defined(OSF_OS) && !defined(IRIX_OS) && !defined(AIX_OS) && !defined(LINUX_OS)
505
typedef unsigned int uint;
507
#if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
508
typedef unsigned long ulong;
511
#ifndef TIDY_EXPORT /* Define it away for most builds */
519
typedef unsigned char byte;
521
typedef uint tchar; /* single, full character */
522
typedef char tmbchar; /* single, possibly partial character */
523
#ifndef TMBSTR_DEFINED
524
typedef tmbchar* tmbstr; /* pointer to buffer of possibly partial chars */
525
typedef const tmbchar* ctmbstr; /* Ditto, but const */
526
#define NULLSTR (tmbstr)""
527
#define TMBSTR_DEFINED
534
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
535
# define ARG_UNUSED(x) x __attribute__((unused))
537
# define ARG_UNUSED(x) x
540
/* HAS_VSNPRINTF triggers the use of "vsnprintf", which is safe related to
541
buffer overflow. Therefore, we make it the default unless HAS_VSNPRINTF
543
#ifndef HAS_VSNPRINTF
544
# define HAS_VSNPRINTF 1
548
bool is a reserved word in some but
549
not all C++ compilers depending on age
550
work around is to avoid bool altogether
551
by introducing a new enum called Bool
560
#define null ((const void*)0)
568
void *MemAlloc(size_t size);
569
void *MemRealloc(void *mem, size_t newsize);
570
void MemFree(void *mem);
571
void ClearMemory(void *, size_t size);
572
void FatalError( ctmbstr msg );
574
/* Opaque data structure.
575
* Cast to implementation type struct within lib.
576
* This will reduce inter-dependencies/conflicts w/ application code.
580
* Please note - this definition assumes your compiler uses 'int' for enums.
582
#define opaque_type( typenam )\
583
struct _##typenam { int _opaque; };\
584
typedef struct _##typenam* typenam
586
#define opaque_type(typenam) typedef void* typenam
589
/* Opaque data structure used to pass back
590
** and forth to keep current position in a
591
** list or other collection.
593
opaque_type( TidyIterator );
599
#endif /* __PLATFORM_H__ */