HTML Tidy  0.1
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 #if _MSC_VER > 1000
481 #pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */
482 #pragma warning( disable : 4100 ) /* unreferenced formal parameter */
483 #pragma warning( disable : 4706 ) /* assignment within conditional expression */
484 #endif
485 
486 #if _MSC_VER > 1300
487 #pragma warning( disable : 4996 ) /* disable depreciation warning */
488 #endif
489 
490 #endif /* _WIN32 */
491 
492 #if defined(_WIN32)
493 
494 #if (defined(_USRDLL) || defined(_WINDLL)) && !defined(TIDY_EXPORT)
495 #define TIDY_EXPORT __declspec( dllexport )
496 #endif
497 
498 #ifndef TIDY_CALL
499 #ifdef _WIN64
500 # define TIDY_CALL __fastcall
501 #else
502 # define TIDY_CALL __stdcall
503 #endif
504 #endif
505 
506 #endif /* _WIN32 */
507 
508 /* hack for gnu sys/types.h file which defines uint and ulong */
509 
510 #if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
511 #include <sys/types.h>
512 #endif
513 #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)
514 # undef uint
515 typedef unsigned int uint;
516 #endif
517 #if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
518 # undef ulong
519 typedef unsigned long ulong;
520 #endif
521 
522 /*
523 With GCC 4, __attribute__ ((visibility("default"))) can be used along compiling with tidylib
524 with "-fvisibility=hidden". See http://gcc.gnu.org/wiki/Visibility and build/gmake/Makefile.
525 */
526 /*
527 #if defined(__GNUC__) && __GNUC__ >= 4
528 #define TIDY_EXPORT __attribute__ ((visibility("default")))
529 #endif
530 */
531 
532 #ifndef TIDY_EXPORT /* Define it away for most builds */
533 #define TIDY_EXPORT
534 #endif
535 
536 #ifndef TIDY_STRUCT
537 #define TIDY_STRUCT
538 #endif
539 
540 typedef unsigned char byte;
541 
542 typedef uint tchar; /* single, full character */
543 typedef char tmbchar; /* single, possibly partial character */
544 #ifndef TMBSTR_DEFINED
545 typedef tmbchar* tmbstr; /* pointer to buffer of possibly partial chars */
546 typedef const tmbchar* ctmbstr; /* Ditto, but const */
547 #define NULLSTR (tmbstr)""
548 #define TMBSTR_DEFINED
549 #endif
550 
551 #ifndef TIDY_CALL
552 #define TIDY_CALL
553 #endif
554 
555 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
556 # define ARG_UNUSED(x) x __attribute__((unused))
557 #else
558 # define ARG_UNUSED(x) x
559 #endif
560 
561 /* HAS_VSNPRINTF triggers the use of "vsnprintf", which is safe related to
562  buffer overflow. Therefore, we make it the default unless HAS_VSNPRINTF
563  has been defined. */
564 #ifndef HAS_VSNPRINTF
565 # define HAS_VSNPRINTF 1
566 #endif
567 
568 #ifndef SUPPORT_POSIX_MAPPED_FILES
569 # define SUPPORT_POSIX_MAPPED_FILES 1
570 #endif
571 
572 /*
573  bool is a reserved word in some but
574  not all C++ compilers depending on age
575  work around is to avoid bool altogether
576  by introducing a new enum called Bool
577 */
578 /* We could use the C99 definition where supported
579 typedef _Bool Bool;
580 #define no (_Bool)0
581 #define yes (_Bool)1
582 */
583 typedef enum
584 {
585  no,
586  yes
587 } Bool;
588 
589 /* for NULL pointers
590 #define null ((const void*)0)
591 extern void* null;
592 */
593 
594 #if defined(DMALLOC)
595 #include "dmalloc.h"
596 #endif
597 
598 /* Opaque data structure.
599 * Cast to implementation type struct within lib.
600 * This will reduce inter-dependencies/conflicts w/ application code.
601 */
602 #if 1
603 #define opaque_type( typenam )\
604 struct _##typenam { int _opaque; };\
605 typedef struct _##typenam const * typenam
606 #else
607 #define opaque_type(typenam) typedef const void* typenam
608 #endif
609 
610 /* Opaque data structure used to pass back
611 ** and forth to keep current position in a
612 ** list or other collection.
613 */
614 opaque_type( TidyIterator );
615 
616 #ifdef __cplusplus
617 } /* extern "C" */
618 #endif
619 
620 #endif /* __TIDY_PLATFORM_H__ */
621 
622 
623 /*
624  * local variables:
625  * mode: c
626  * indent-tabs-mode: nil
627  * c-basic-offset: 4
628  * eval: (c-set-offset 'substatement-open 0)
629  * end:
630  */