OSDN Git Service

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