1#ifndef __TIDY_PLATFORM_H__
2#define __TIDY_PLATFORM_H__
3
4/* platform.h -- Platform specifics
5
6 (c) 1998-2008 (W3C) MIT, ERCIM, Keio University
7 See tidy.h for the copyright notice.
8
9 CVS Info :
10
11 $Author: arnaud02 $
12 $Date: 2008/03/17 12:57:01 $
13 $Revision: 1.66 $
14
15*/
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/*
22 Uncomment and edit one of the following #defines if you
23 want to specify the config file at compile-time.
24*/
25
26/* #define TIDY_CONFIG_FILE "/etc/tidy_config.txt" */ /* original */
27/* #define TIDY_CONFIG_FILE "/etc/tidyrc" */
28/* #define TIDY_CONFIG_FILE "/etc/tidy.conf" */
29
30/*
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.
35*/
36/* #define TIDY_USER_CONFIG_FILE "~/.tidyrc" */
37
38/*
39 Uncomment the following #define if your
40 system supports the call getpwnam().
41 E.g. Unix and Linux.
42
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
47
48 Contributed by Todd Lewis.
49*/
50
51/* #define SUPPORT_GETPWNAM */
52
53
54/* Enable/disable support for Big5 and Shift_JIS character encodings */
55#ifndef SUPPORT_ASIAN_ENCODINGS
56#define SUPPORT_ASIAN_ENCODINGS 1
57#endif
58
59/* Enable/disable support for UTF-16 character encodings */
60#ifndef SUPPORT_UTF16_ENCODINGS
61#define SUPPORT_UTF16_ENCODINGS 1
62#endif
63
64/* Enable/disable support for additional accessibility checks */
65#ifndef SUPPORT_ACCESSIBILITY_CHECKS
66#define SUPPORT_ACCESSIBILITY_CHECKS 1
67#endif
68
69
70/* Convenience defines for Mac platforms */
71
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
75#ifndef PLATFORM_NAME
76#define PLATFORM_NAME "Mac OS"
77#endif
78
79/* needed for access() */
80#if !defined(_POSIX) && !defined(NO_ACCESS_SUPPORT)
81#define NO_ACCESS_SUPPORT
82#endif
83
84#ifdef SUPPORT_GETPWNAM
85#undef SUPPORT_GETPWNAM
86#endif
87
88#elif defined(__APPLE__) && defined(__MACH__)
89/* Mac OS X (client) 10.x (or server 1.x/10.x) - gcc or Metrowerks MachO compilers */
90#define MAC_OS_X
91#ifndef PLATFORM_NAME
92#define PLATFORM_NAME "Mac OS X"
93#endif
94#endif
95
96#if defined(MAC_OS_CLASSIC) || defined(MAC_OS_X)
97/* Any OS on Mac platform */
98#define MAC_OS
99#define FILENAMES_CASE_SENSITIVE 0
100#define strcasecmp strcmp
101#ifndef DFLT_REPL_CHARENC
102#define DFLT_REPL_CHARENC MACROMAN
103#endif
104#endif
105
106/* Convenience defines for BSD like platforms */
107
108#if defined(__FreeBSD__)
109#define BSD_BASED_OS
110#ifndef PLATFORM_NAME
111#define PLATFORM_NAME "FreeBSD"
112#endif
113
114#elif defined(__NetBSD__)
115#define BSD_BASED_OS
116#ifndef PLATFORM_NAME
117#define PLATFORM_NAME "NetBSD"
118#endif
119
120#elif defined(__OpenBSD__)
121#define BSD_BASED_OS
122#ifndef PLATFORM_NAME
123#define PLATFORM_NAME "OpenBSD"
124#endif
125
126#elif defined(__DragonFly__)
127#define BSD_BASED_OS
128#ifndef PLATFORM_NAME
129#define PLATFORM_NAME "DragonFly"
130#endif
131
132#elif defined(__MINT__)
133#define BSD_BASED_OS
134#ifndef PLATFORM_NAME
135#define PLATFORM_NAME "FreeMiNT"
136#endif
137
138#elif defined(__bsdi__)
139#define BSD_BASED_OS
140#ifndef PLATFORM_NAME
141#define PLATFORM_NAME "BSD/OS"
142#endif
143
144#endif
145
146/* Convenience defines for Windows platforms */
147
148#if defined(WINDOWS) || defined(_WIN32)
149
150#define WINDOWS_OS
151#ifndef PLATFORM_NAME
152#define PLATFORM_NAME "Windows"
153#endif
154
155#if defined(__MWERKS__) || defined(__MSL__)
156/* not available with Metrowerks Standard Library */
157
158#ifdef SUPPORT_GETPWNAM
159#undef SUPPORT_GETPWNAM
160#endif
161
162/* needed for setmode() */
163#if !defined(NO_SETMODE_SUPPORT)
164#define NO_SETMODE_SUPPORT
165#endif
166
167#define strcasecmp _stricmp
168
169#endif
170
171#if defined(__BORLANDC__)
172#define strcasecmp stricmp
173#endif
174
175#define FILENAMES_CASE_SENSITIVE 0
176#define SUPPORT_POSIX_MAPPED_FILES 0
177
178#endif
179
180/* Convenience defines for Linux platforms */
181
182#if defined(linux) && defined(__alpha__)
183/* Linux on Alpha - gcc compiler */
184#define LINUX_OS
185#ifndef PLATFORM_NAME
186#define PLATFORM_NAME "Linux/Alpha"
187#endif
188
189#elif defined(linux) && defined(__sparc__)
190/* Linux on Sparc - gcc compiler */
191#define LINUX_OS
192#ifndef PLATFORM_NAME
193#define PLATFORM_NAME "Linux/Sparc"
194#endif
195
196#elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
197/* Linux on x86 - gcc compiler */
198#define LINUX_OS
199#ifndef PLATFORM_NAME
200#define PLATFORM_NAME "Linux/x86"
201#endif
202
203#elif defined(linux) && defined(__powerpc__)
204/* Linux on PPC - gcc compiler */
205#define LINUX_OS
206
207#if defined(__linux__) && defined(__powerpc__)
208
209/* #if #system(linux) */
210/* MkLinux on PPC - gcc (egcs) compiler */
211/* #define MAC_OS_MKLINUX */
212#ifndef PLATFORM_NAME
213#define PLATFORM_NAME "MkLinux"
214#endif
215
216#else
217
218#ifndef PLATFORM_NAME
219#define PLATFORM_NAME "Linux/PPC"
220#endif
221
222#endif
223
224#elif defined(linux) || defined(__linux__)
225/* generic Linux */
226#define LINUX_OS
227#ifndef PLATFORM_NAME
228#define PLATFORM_NAME "Linux"
229#endif
230
231#endif
232
233/* Convenience defines for Solaris platforms */
234
235#if defined(sun)
236#define SOLARIS_OS
237#ifndef PLATFORM_NAME
238#define PLATFORM_NAME "Solaris"
239#endif
240#endif
241
242/* Convenience defines for HPUX + gcc platforms */
243
244#if defined(__hpux)
245#define HPUX_OS
246#ifndef PLATFORM_NAME
247#define PLATFORM_NAME "HPUX"
248#endif
249#endif
250
251/* Convenience defines for RISCOS + gcc platforms */
252
253#if defined(__riscos__)
254#define RISC_OS
255#ifndef PLATFORM_NAME
256#define PLATFORM_NAME "RISC OS"
257#endif
258#endif
259
260/* Convenience defines for OS/2 + icc/gcc platforms */
261
262#if defined(__OS2__) || defined(__EMX__)
263#define OS2_OS
264#ifndef PLATFORM_NAME
265#define PLATFORM_NAME "OS/2"
266#endif
267#define FILENAMES_CASE_SENSITIVE 0
268#define strcasecmp stricmp
269#endif
270
271/* Convenience defines for IRIX */
272
273#if defined(__sgi)
274#define IRIX_OS
275#ifndef PLATFORM_NAME
276#define PLATFORM_NAME "SGI IRIX"
277#endif
278#endif
279
280/* Convenience defines for AIX */
281
282#if defined(_AIX)
283#define AIX_OS
284#ifndef PLATFORM_NAME
285#define PLATFORM_NAME "IBM AIX"
286#endif
287#endif
288
289
290/* Convenience defines for BeOS platforms */
291
292#if defined(__BEOS__)
293#define BE_OS
294#ifndef PLATFORM_NAME
295#define PLATFORM_NAME "BeOS"
296#endif
297#endif
298
299/* Convenience defines for Cygwin platforms */
300
301#if defined(__CYGWIN__)
302#define CYGWIN_OS
303#ifndef PLATFORM_NAME
304#define PLATFORM_NAME "Cygwin"
305#endif
306#define FILENAMES_CASE_SENSITIVE 0
307#endif
308
309/* Convenience defines for OpenVMS */
310
311#if defined(__VMS)
312#define OPENVMS_OS
313#ifndef PLATFORM_NAME
314#define PLATFORM_NAME "OpenVMS"
315#endif
316#define FILENAMES_CASE_SENSITIVE 0
317#endif
318
319/* Convenience defines for DEC Alpha OSF + gcc platforms */
320
321#if defined(__osf__)
322#define OSF_OS
323#ifndef PLATFORM_NAME
324#define PLATFORM_NAME "DEC Alpha OSF"
325#endif
326#endif
327
328/* Convenience defines for ARM platforms */
329
330#if defined(__arm)
331#define ARM_OS
332
333#if defined(forARM) && defined(__NEWTON_H)
334
335/* Using Newton C++ Tools ARMCpp compiler */
336#define NEWTON_OS
337#ifndef PLATFORM_NAME
338#define PLATFORM_NAME "Newton"
339#endif
340
341#else
342
343#ifndef PLATFORM_NAME
344#define PLATFORM_NAME "ARM"
345#endif
346
347#endif
348
349#endif
350
351#include <ctype.h>
352#include <stdio.h>
353#include <setjmp.h> /* for longjmp on error exit */
354#include <stdlib.h>
355#include <stdarg.h> /* may need <varargs.h> for Unix V */
356#include <string.h>
357#include <assert.h>
358
359#ifdef NEEDS_MALLOC_H
360#include <malloc.h>
361#endif
362
363#ifdef SUPPORT_GETPWNAM
364#include <pwd.h>
365#endif
366
367#ifdef NEEDS_UNISTD_H
368#include <unistd.h> /* needed for unlink on some Unix systems */
369#endif
370
371/* This can be set at compile time. Usually Windows,
372** except for Macintosh builds.
373*/
374#ifndef DFLT_REPL_CHARENC
375#define DFLT_REPL_CHARENC WIN1252
376#endif
377
378/* By default, use case-sensitive filename comparison.
379*/
380#ifndef FILENAMES_CASE_SENSITIVE
381#define FILENAMES_CASE_SENSITIVE 1
382#endif
383
384
385/*
386 Tidy preserves the last modified time for the files it
387 cleans up.
388*/
389
390/*
391 If your platform doesn't support <utime.h> and the
392 utime() function, or <sys/futime> and the futime()
393 function then set PRESERVE_FILE_TIMES to 0.
394
395 If your platform doesn't support <sys/utime.h> and the
396 futime() function, then set HAS_FUTIME to 0.
397
398 If your platform supports <utime.h> and the
399 utime() function requires the file to be
400 closed first, then set UTIME_NEEDS_CLOSED_FILE to 1.
401*/
402
403/* Keep old PRESERVEFILETIMES define for compatibility */
404#ifdef PRESERVEFILETIMES
405#undef PRESERVE_FILE_TIMES
406#define PRESERVE_FILE_TIMES PRESERVEFILETIMES
407#endif
408
409#ifndef PRESERVE_FILE_TIMES
410#if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS)
411#define PRESERVE_FILE_TIMES 0
412#else
413#define PRESERVE_FILE_TIMES 1
414#endif
415#endif
416
417#if PRESERVE_FILE_TIMES
418
419#ifndef HAS_FUTIME
420#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#define HAS_FUTIME 0
422#else
423#define HAS_FUTIME 1
424#endif
425#endif
426
427#ifndef UTIME_NEEDS_CLOSED_FILE
428#if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS)
429#define UTIME_NEEDS_CLOSED_FILE 1
430#else
431#define UTIME_NEEDS_CLOSED_FILE 0
432#endif
433#endif
434
435#if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__))
436#include <sys/types.h>
437#include <sys/stat.h>
438#else
439#include <stat.h>
440#endif
441
442#if HAS_FUTIME
443#include <sys/utime.h>
444#else
445#include <utime.h>
446#endif /* HASFUTIME */
447
448/*
449 MS Windows needs _ prefix for Unix file functions.
450 Not required by Metrowerks Standard Library (MSL).
451
452 Tidy uses following for preserving the last modified time.
453
454 WINDOWS automatically set by Win16 compilers.
455 _WIN32 automatically set by Win32 compilers.
456*/
457#if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
458
459#define futime _futime
460#define fstat _fstat
461#define utimbuf _utimbuf /* Windows seems to want utimbuf */
462#define stat _stat
463#define utime _utime
464#define vsnprintf _vsnprintf
465#endif /* _WIN32 */
466
467#endif /* PRESERVE_FILE_TIMES */
468
469/*
470 MS Windows needs _ prefix for Unix file functions.
471 Not required by Metrowerks Standard Library (MSL).
472
473 WINDOWS automatically set by Win16 compilers.
474 _WIN32 automatically set by Win32 compilers.
475*/
476#if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
477
478#ifndef __WATCOMC__
479#define fileno _fileno
480#define setmode _setmode
481#endif
482
483#define access _access
484#define strcasecmp _stricmp
485
486#if _MSC_VER > 1000
487#pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */
488#pragma warning( disable : 4100 ) /* unreferenced formal parameter */
489#pragma warning( disable : 4706 ) /* assignment within conditional expression */
490#endif
491
492#if _MSC_VER > 1300
493#pragma warning( disable : 4996 ) /* disable depreciation warning */
494#endif
495
496#endif /* _WIN32 */
497
498#if defined(_WIN32)
499
500#if (defined(_USRDLL) || defined(_WINDLL)) && !defined(TIDY_EXPORT)
501#define TIDY_EXPORT __declspec( dllexport )
502#endif
503
504#ifndef TIDY_CALL
505#ifdef _WIN64
506# define TIDY_CALL __fastcall
507#else
508# define TIDY_CALL __stdcall
509#endif
510#endif
511
512#endif /* _WIN32 */
513
514/* hack for gnu sys/types.h file which defines uint and ulong */
515
516#if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
517#include <sys/types.h>
518#endif
519#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)
520# undef uint
521typedef unsigned int uint;
522#endif
523#if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
524# undef ulong
525typedef unsigned long ulong;
526#endif
527
528/*
529With GCC 4, __attribute__ ((visibility("default"))) can be used along compiling with tidylib
530with "-fvisibility=hidden". See http://gcc.gnu.org/wiki/Visibility and build/gmake/Makefile.
531*/
532/*
533#if defined(__GNUC__) && __GNUC__ >= 4
534#define TIDY_EXPORT __attribute__ ((visibility("default")))
535#endif
536*/
537
538#ifndef TIDY_EXPORT /* Define it away for most builds */
539#define TIDY_EXPORT
540#endif
541
542#ifndef TIDY_STRUCT
543#define TIDY_STRUCT
544#endif
545
546typedef unsigned char byte;
547
548typedef uint tchar; /* single, full character */
549typedef char tmbchar; /* single, possibly partial character */
550#ifndef TMBSTR_DEFINED
551typedef tmbchar* tmbstr; /* pointer to buffer of possibly partial chars */
552typedef const tmbchar* ctmbstr; /* Ditto, but const */
553#define NULLSTR (tmbstr)""
554#define TMBSTR_DEFINED
555#endif
556
557#ifndef TIDY_CALL
558#define TIDY_CALL
559#endif
560
561#if defined(__GNUC__) || defined(__INTEL_COMPILER)
562# define ARG_UNUSED(x) x __attribute__((unused))
563#else
564# define ARG_UNUSED(x) x
565#endif
566
567/* HAS_VSNPRINTF triggers the use of "vsnprintf", which is safe related to
568 buffer overflow. Therefore, we make it the default unless HAS_VSNPRINTF
569 has been defined. */
570#ifndef HAS_VSNPRINTF
571# define HAS_VSNPRINTF 1
572#endif
573
574#ifndef SUPPORT_POSIX_MAPPED_FILES
575# define SUPPORT_POSIX_MAPPED_FILES 1
576#endif
577
578/*
579 bool is a reserved word in some but
580 not all C++ compilers depending on age
581 work around is to avoid bool altogether
582 by introducing a new enum called Bool
583*/
584/* We could use the C99 definition where supported
585typedef _Bool Bool;
586#define no (_Bool)0
587#define yes (_Bool)1
588*/
589typedef enum
590{
591 no,
592 yes
593} Bool;
594
595/* for NULL pointers
596#define null ((const void*)0)
597extern void* null;
598*/
599
600#if defined(DMALLOC)
601#include "dmalloc.h"
602#endif
603
604/* Opaque data structure.
605* Cast to implementation type struct within lib.
606* This will reduce inter-dependencies/conflicts w/ application code.
607*/
608#if 1
609#define opaque_type( typenam )\
610struct _##typenam { int _opaque; };\
611typedef struct _##typenam const * typenam
612#else
613#define opaque_type(typenam) typedef const void* typenam
614#endif
615
616/* Opaque data structure used to pass back
617** and forth to keep current position in a
618** list or other collection.
619*/
620opaque_type( TidyIterator );
621
622#ifdef __cplusplus
623} /* extern "C" */
624#endif
625
626#endif /* __TIDY_PLATFORM_H__ */
627
628
629/*
630 * local variables:
631 * mode: c
632 * indent-tabs-mode: nil
633 * c-basic-offset: 4
634 * eval: (c-set-offset 'substatement-open 0)
635 * end:
636 */
637