1 #ifndef __TIDY_PLATFORM_H__
2 #define __TIDY_PLATFORM_H__
4 /* platform.h -- Platform specifics
6 (c) 1998-2008 (W3C) MIT, ERCIM, Keio University
7 See tidy.h for the copyright notice.
16 Uncomment and edit one of the following #defines if you
17 want to specify the config file at compile-time.
20 /* #define TIDY_CONFIG_FILE "/etc/tidy_config.txt" */ /* original */
21 /* #define TIDY_CONFIG_FILE "/etc/tidyrc" */
22 /* #define TIDY_CONFIG_FILE "/etc/tidy.conf" */
25 Uncomment the following #define if you are on a system
26 supporting the HOME environment variable.
27 It enables tidy to find config files named ~/.tidyrc if
28 the HTML_TIDY environment variable is not set.
30 /* #define TIDY_USER_CONFIG_FILE "~/.tidyrc" */
33 Uncomment the following #define if your
34 system supports the call getpwnam().
37 It enables tidy to find files named
38 ~your/foo for use in the HTML_TIDY environment
39 variable or CONFIG_FILE or USER_CONFIGFILE or
40 on the command line: -config ~joebob/tidy.cfg
42 Contributed by Todd Lewis.
45 /* #define SUPPORT_GETPWNAM */
48 /* Enable/disable support for Big5 and Shift_JIS character encodings */
49 #ifndef SUPPORT_ASIAN_ENCODINGS
50 #define SUPPORT_ASIAN_ENCODINGS 1
53 /* Enable/disable support for UTF-16 character encodings */
54 #ifndef SUPPORT_UTF16_ENCODINGS
55 #define SUPPORT_UTF16_ENCODINGS 1
58 /* Enable/disable support for additional accessibility checks */
59 #ifndef SUPPORT_ACCESSIBILITY_CHECKS
60 #define SUPPORT_ACCESSIBILITY_CHECKS 1
64 /* Convenience defines for Mac platforms */
66 #if defined(macintosh)
67 /* Mac OS 6.x/7.x/8.x/9.x, with or without CarbonLib - MPW or Metrowerks 68K/PPC compilers */
68 #define MAC_OS_CLASSIC
70 #define PLATFORM_NAME "Mac OS"
73 /* needed for access() */
74 #if !defined(_POSIX) && !defined(NO_ACCESS_SUPPORT)
75 #define NO_ACCESS_SUPPORT
78 #ifdef SUPPORT_GETPWNAM
79 #undef SUPPORT_GETPWNAM
82 #elif defined(__APPLE__) && defined(__MACH__)
83 /* Mac OS X (client) 10.x (or server 1.x/10.x) - gcc or Metrowerks MachO compilers */
86 #define PLATFORM_NAME "Mac OS X"
90 #if defined(MAC_OS_CLASSIC) || defined(MAC_OS_X)
91 /* Any OS on Mac platform */
93 #define FILENAMES_CASE_SENSITIVE 0
94 #define strcasecmp strcmp
95 #ifndef DFLT_REPL_CHARENC
96 #define DFLT_REPL_CHARENC MACROMAN
100 /* Convenience defines for BSD like platforms */
102 #if defined(__FreeBSD__)
104 #ifndef PLATFORM_NAME
105 #define PLATFORM_NAME "FreeBSD"
108 #elif defined(__NetBSD__)
110 #ifndef PLATFORM_NAME
111 #define PLATFORM_NAME "NetBSD"
114 #elif defined(__OpenBSD__)
116 #ifndef PLATFORM_NAME
117 #define PLATFORM_NAME "OpenBSD"
120 #elif defined(__DragonFly__)
122 #ifndef PLATFORM_NAME
123 #define PLATFORM_NAME "DragonFly"
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
170 #define SUPPORT_POSIX_MAPPED_FILES 0
174 /* Convenience defines for Linux platforms */
176 #if defined(linux) && defined(__alpha__)
177 /* Linux on Alpha - gcc compiler */
179 #ifndef PLATFORM_NAME
180 #define PLATFORM_NAME "Linux/Alpha"
183 #elif defined(linux) && defined(__sparc__)
184 /* Linux on Sparc - gcc compiler */
186 #ifndef PLATFORM_NAME
187 #define PLATFORM_NAME "Linux/Sparc"
190 #elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
191 /* Linux on x86 - gcc compiler */
193 #ifndef PLATFORM_NAME
194 #define PLATFORM_NAME "Linux/x86"
197 #elif defined(linux) && defined(__powerpc__)
198 /* Linux on PPC - gcc compiler */
201 #if defined(__linux__) && defined(__powerpc__)
203 /* #if #system(linux) */
204 /* MkLinux on PPC - gcc (egcs) compiler */
205 /* #define MAC_OS_MKLINUX */
206 #ifndef PLATFORM_NAME
207 #define PLATFORM_NAME "MkLinux"
212 #ifndef PLATFORM_NAME
213 #define PLATFORM_NAME "Linux/PPC"
218 #elif defined(linux) || defined(__linux__)
221 #ifndef PLATFORM_NAME
222 #define PLATFORM_NAME "Linux"
227 /* Convenience defines for Solaris platforms */
231 #ifndef PLATFORM_NAME
232 #define PLATFORM_NAME "Solaris"
236 /* Convenience defines for HPUX + gcc platforms */
240 #ifndef PLATFORM_NAME
241 #define PLATFORM_NAME "HPUX"
245 /* Convenience defines for RISCOS + gcc platforms */
247 #if defined(__riscos__)
249 #ifndef PLATFORM_NAME
250 #define PLATFORM_NAME "RISC OS"
254 /* Convenience defines for OS/2 + icc/gcc platforms */
256 #if defined(__OS2__) || defined(__EMX__)
258 #ifndef PLATFORM_NAME
259 #define PLATFORM_NAME "OS/2"
261 #define FILENAMES_CASE_SENSITIVE 0
262 #define strcasecmp stricmp
265 /* Convenience defines for IRIX */
269 #ifndef PLATFORM_NAME
270 #define PLATFORM_NAME "SGI IRIX"
274 /* Convenience defines for AIX */
278 #ifndef PLATFORM_NAME
279 #define PLATFORM_NAME "IBM AIX"
284 /* Convenience defines for BeOS platforms */
286 #if defined(__BEOS__)
288 #ifndef PLATFORM_NAME
289 #define PLATFORM_NAME "BeOS"
293 /* Convenience defines for Cygwin platforms */
295 #if defined(__CYGWIN__)
297 #ifndef PLATFORM_NAME
298 #define PLATFORM_NAME "Cygwin"
300 #define FILENAMES_CASE_SENSITIVE 0
303 /* Convenience defines for OpenVMS */
307 #ifndef PLATFORM_NAME
308 #define PLATFORM_NAME "OpenVMS"
310 #define FILENAMES_CASE_SENSITIVE 0
313 /* Convenience defines for DEC Alpha OSF + gcc platforms */
317 #ifndef PLATFORM_NAME
318 #define PLATFORM_NAME "DEC Alpha OSF"
322 /* Convenience defines for ARM platforms */
327 #if defined(forARM) && defined(__NEWTON_H)
329 /* Using Newton C++ Tools ARMCpp compiler */
331 #ifndef PLATFORM_NAME
332 #define PLATFORM_NAME "Newton"
337 #ifndef PLATFORM_NAME
338 #define PLATFORM_NAME "ARM"
347 #include <setjmp.h> /* for longjmp on error exit */
349 #include <stdarg.h> /* may need <varargs.h> for Unix V */
353 #ifdef NEEDS_MALLOC_H
357 #ifdef SUPPORT_GETPWNAM
361 #ifdef NEEDS_UNISTD_H
362 #include <unistd.h> /* needed for unlink on some Unix systems */
365 /* This can be set at compile time. Usually Windows,
366 ** except for Macintosh builds.
368 #ifndef DFLT_REPL_CHARENC
369 #define DFLT_REPL_CHARENC WIN1252
372 /* By default, use case-sensitive filename comparison.
374 #ifndef FILENAMES_CASE_SENSITIVE
375 #define FILENAMES_CASE_SENSITIVE 1
380 Tidy preserves the last modified time for the files it
385 If your platform doesn't support <utime.h> and the
386 utime() function, or <sys/futime> and the futime()
387 function then set PRESERVE_FILE_TIMES to 0.
389 If your platform doesn't support <sys/utime.h> and the
390 futime() function, then set HAS_FUTIME to 0.
392 If your platform supports <utime.h> and the
393 utime() function requires the file to be
394 closed first, then set UTIME_NEEDS_CLOSED_FILE to 1.
397 /* Keep old PRESERVEFILETIMES define for compatibility */
398 #ifdef PRESERVEFILETIMES
399 #undef PRESERVE_FILE_TIMES
400 #define PRESERVE_FILE_TIMES PRESERVEFILETIMES
403 #ifndef PRESERVE_FILE_TIMES
404 #if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS)
405 #define PRESERVE_FILE_TIMES 0
407 #define PRESERVE_FILE_TIMES 1
411 #if PRESERVE_FILE_TIMES
414 #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__)
421 #ifndef UTIME_NEEDS_CLOSED_FILE
422 #if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS)
423 #define UTIME_NEEDS_CLOSED_FILE 1
425 #define UTIME_NEEDS_CLOSED_FILE 0
429 #if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__))
430 #include <sys/types.h>
431 #include <sys/stat.h>
437 #include <sys/utime.h>
440 #endif /* HASFUTIME */
443 MS Windows needs _ prefix for Unix file functions.
444 Not required by Metrowerks Standard Library (MSL).
446 Tidy uses following for preserving the last modified time.
448 WINDOWS automatically set by Win16 compilers.
449 _WIN32 automatically set by Win32 compilers.
451 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
453 #define futime _futime
455 #define utimbuf _utimbuf /* Windows seems to want utimbuf */
458 #define vsnprintf _vsnprintf
461 #endif /* PRESERVE_FILE_TIMES */
464 MS Windows needs _ prefix for Unix file functions.
465 Not required by Metrowerks Standard Library (MSL).
467 WINDOWS automatically set by Win16 compilers.
468 _WIN32 automatically set by Win32 compilers.
470 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
473 #define fileno _fileno
474 #define setmode _setmode
477 #define access _access
478 #define strcasecmp _stricmp
481 #define va_copy(dest, src) (dest = src)
485 #pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */
486 #pragma warning( disable : 4100 ) /* unreferenced formal parameter */
487 #pragma warning( disable : 4706 ) /* assignment within conditional expression */
491 #pragma warning( disable : 4996 ) /* disable depreciation warning */
498 #if (defined(_USRDLL) || defined(_WINDLL)) || defined(BUILD_SHARED_LIB) && !defined(TIDY_EXPORT)
499 #ifdef BUILDING_SHARED_LIB
500 #define TIDY_EXPORT __declspec( dllexport )
502 #define TIDY_EXPORT __declspec( dllimport )
505 #define TIDY_EXPORT extern
510 # define TIDY_CALL __fastcall
512 # define TIDY_CALL __stdcall
518 /* hack for gnu sys/types.h file which defines uint and ulong */
520 #if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
521 #include <sys/types.h>
523 #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)
525 typedef unsigned int uint;
527 #if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
529 typedef unsigned long ulong;
533 With GCC 4, __attribute__ ((visibility("default"))) can be used along compiling with tidylib
534 with "-fvisibility=hidden". See http://gcc.gnu.org/wiki/Visibility and build/gmake/Makefile.
537 #if defined(__GNUC__) && __GNUC__ >= 4
538 #define TIDY_EXPORT __attribute__ ((visibility("default")))
542 #ifndef TIDY_EXPORT /* Define it away for most builds */
550 typedef unsigned char byte;
552 typedef uint tchar; /* single, full character */
553 typedef char tmbchar; /* single, possibly partial character */
554 #ifndef TMBSTR_DEFINED
555 typedef tmbchar* tmbstr; /* pointer to buffer of possibly partial chars */
556 typedef const tmbchar* ctmbstr; /* Ditto, but const */
557 #define NULLSTR (tmbstr)""
558 #define TMBSTR_DEFINED
565 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
566 # define ARG_UNUSED(x) x __attribute__((unused))
568 # define ARG_UNUSED(x) x
571 /* HAS_VSNPRINTF triggers the use of "vsnprintf", which is safe related to
572 buffer overflow. Therefore, we make it the default unless HAS_VSNPRINTF
574 #ifndef HAS_VSNPRINTF
575 # define HAS_VSNPRINTF 1
578 #ifndef SUPPORT_POSIX_MAPPED_FILES
579 # define SUPPORT_POSIX_MAPPED_FILES 1
583 bool is a reserved word in some but
584 not all C++ compilers depending on age
585 work around is to avoid bool altogether
586 by introducing a new enum called Bool
588 /* We could use the C99 definition where supported
600 #define null ((const void*)0)
608 /* Opaque data structure.
609 * Cast to implementation type struct within lib.
610 * This will reduce inter-dependencies/conflicts w/ application code.
613 #define opaque_type( typenam )\
614 struct _##typenam { int _opaque; };\
615 typedef struct _##typenam const * typenam
617 #define opaque_type(typenam) typedef const void* typenam
620 /* Opaque data structure used to pass back
621 ** and forth to keep current position in a
622 ** list or other collection.
624 opaque_type( TidyIterator );
630 #endif /* __TIDY_PLATFORM_H__ */
636 * indent-tabs-mode: nil
638 * eval: (c-set-offset 'substatement-open 0)