HTML Tidy  5.4.0
The HTACG Tidy HTML Project
tidyplatform.h
Go to the documentation of this file.
1 #ifndef __TIDY_PLATFORM_H__
2 #define __TIDY_PLATFORM_H__
3 
4 /** @file tidyplatform.h - Platform specifics
5 
6  (c) 1998-2016 (W3C) MIT, ERCIM, Keio University
7  See tidy.h for the copyright notice.
8 
9  This file is included by tidy.h, and need not
10  be included sepearately. It sets a number of
11  default defines, and a PLATFORM_NAME, and includes
12  the most common system headers.
13 
14 */
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /*
21  Uncomment and edit one of the following #defines if you
22  want to specify the config file at compile-time.
23 */
24 
25 /* #define TIDY_CONFIG_FILE "/etc/tidy_config.txt" */ /* original */
26 /* #define TIDY_CONFIG_FILE "/etc/tidyrc" */
27 /* #define TIDY_CONFIG_FILE "/etc/tidy.conf" */
28 
29 /*
30  Uncomment the following #define if you are on a system
31  supporting the HOME environment variable.
32  It enables tidy to find config files named ~/.tidyrc if
33  the HTML_TIDY environment variable is not set.
34 */
35 /* #define TIDY_USER_CONFIG_FILE "~/.tidyrc" */
36 
37 /*
38  Uncomment the following #define if your
39  system supports the call getpwnam().
40  E.g. Unix and Linux.
41 
42  It enables tidy to find files named
43  ~your/foo for use in the HTML_TIDY environment
44  variable or CONFIG_FILE or USER_CONFIGFILE or
45  on the command line: -config ~joebob/tidy.cfg
46 
47  Contributed by Todd Lewis.
48 */
49 
50 /* #define SUPPORT_GETPWNAM */
51 
52 
53 /* Enable/disable support for Big5 and Shift_JIS character encodings */
54 #ifndef SUPPORT_ASIAN_ENCODINGS
55 #define SUPPORT_ASIAN_ENCODINGS 1
56 #endif
57 
58 /* Enable/disable support for UTF-16 character encodings */
59 #ifndef SUPPORT_UTF16_ENCODINGS
60 #define SUPPORT_UTF16_ENCODINGS 1
61 #endif
62 
63 /* Enable/disable support for additional accessibility checks */
64 #ifndef SUPPORT_ACCESSIBILITY_CHECKS
65 #define SUPPORT_ACCESSIBILITY_CHECKS 1
66 #endif
67 
68 /* Enable/disable support for additional languages */
69 #ifndef SUPPORT_LOCALIZATIONS
70 #define SUPPORT_LOCALIZATIONS 1
71 #endif
72 
73 
74 /* Convenience defines for Mac platforms */
75 
76 #if defined(macintosh)
77 /* Mac OS 6.x/7.x/8.x/9.x, with or without CarbonLib - MPW or Metrowerks 68K/PPC compilers */
78 #define MAC_OS_CLASSIC
79 #ifndef PLATFORM_NAME
80 #define PLATFORM_NAME "Mac OS"
81 #endif
82 
83 /* needed for access() */
84 #if !defined(_POSIX) && !defined(NO_ACCESS_SUPPORT)
85 #define NO_ACCESS_SUPPORT
86 #endif
87 
88 #ifdef SUPPORT_GETPWNAM
89 #undef SUPPORT_GETPWNAM
90 #endif
91 
92 #elif defined(__APPLE__) && defined(__MACH__)
93 /* Mac OS X (client) 10.x (or server 1.x/10.x) - gcc or Metrowerks MachO compilers */
94 #define MAC_OS_X
95 #ifndef PLATFORM_NAME
96 #define PLATFORM_NAME "Mac OS X"
97 #endif
98 #endif
99 
100 #if defined(MAC_OS_CLASSIC) || defined(MAC_OS_X)
101 /* Any OS on Mac platform */
102 #define MAC_OS
103 #define FILENAMES_CASE_SENSITIVE 0
104 #define strcasecmp strcmp
105 #endif
106 
107 /* Convenience defines for BSD like platforms */
108 
109 #if defined(__FreeBSD__)
110 #define BSD_BASED_OS
111 #ifndef PLATFORM_NAME
112 #define PLATFORM_NAME "FreeBSD"
113 #endif
114 
115 #elif defined(__NetBSD__)
116 #define BSD_BASED_OS
117 #ifndef PLATFORM_NAME
118 #define PLATFORM_NAME "NetBSD"
119 #endif
120 
121 #elif defined(__OpenBSD__)
122 #define BSD_BASED_OS
123 #ifndef PLATFORM_NAME
124 #define PLATFORM_NAME "OpenBSD"
125 #endif
126 
127 #elif defined(__DragonFly__)
128 #define BSD_BASED_OS
129 #ifndef PLATFORM_NAME
130 #define PLATFORM_NAME "DragonFly"
131 #endif
132 
133 #elif defined(__MINT__)
134 #define BSD_BASED_OS
135 #ifndef PLATFORM_NAME
136 #define PLATFORM_NAME "FreeMiNT"
137 #endif
138 
139 #elif defined(__bsdi__)
140 #define BSD_BASED_OS
141 #ifndef PLATFORM_NAME
142 #define PLATFORM_NAME "BSD/OS"
143 #endif
144 
145 #endif
146 
147 /* Convenience defines for Windows platforms */
148 
149 #if defined(WINDOWS) || defined(_WIN32)
150 
151 #define WINDOWS_OS
152 #ifndef PLATFORM_NAME
153 #define PLATFORM_NAME "Windows"
154 #endif
155 
156 #if defined(__MWERKS__) || defined(__MSL__)
157 /* not available with Metrowerks Standard Library */
158 
159 #ifdef SUPPORT_GETPWNAM
160 #undef SUPPORT_GETPWNAM
161 #endif
162 
163 /* needed for setmode() */
164 #if !defined(NO_SETMODE_SUPPORT)
165 #define NO_SETMODE_SUPPORT
166 #endif
167 
168 #define strcasecmp _stricmp
169 
170 #endif
171 
172 #if defined(__BORLANDC__)
173 #define strcasecmp stricmp
174 #endif
175 
176 #define FILENAMES_CASE_SENSITIVE 0
177 #define SUPPORT_POSIX_MAPPED_FILES 0
178 
179 #endif
180 
181 /* Convenience defines for Linux platforms */
182 
183 #if defined(linux) && defined(__alpha__)
184 /* Linux on Alpha - gcc compiler */
185 #define LINUX_OS
186 #ifndef PLATFORM_NAME
187 #define PLATFORM_NAME "Linux/Alpha"
188 #endif
189 
190 #elif defined(linux) && defined(__sparc__)
191 /* Linux on Sparc - gcc compiler */
192 #define LINUX_OS
193 #ifndef PLATFORM_NAME
194 #define PLATFORM_NAME "Linux/Sparc"
195 #endif
196 
197 #elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
198 /* Linux on x86 - gcc compiler */
199 #define LINUX_OS
200 #ifndef PLATFORM_NAME
201 #define PLATFORM_NAME "Linux/x86"
202 #endif
203 
204 #elif defined(linux) && defined(__powerpc__)
205 /* Linux on PPC - gcc compiler */
206 #define LINUX_OS
207 
208 #if defined(__linux__) && defined(__powerpc__)
209 
210 /* #if #system(linux) */
211 /* MkLinux on PPC - gcc (egcs) compiler */
212 /* #define MAC_OS_MKLINUX */
213 #ifndef PLATFORM_NAME
214 #define PLATFORM_NAME "MkLinux"
215 #endif
216 
217 #else
218 
219 #ifndef PLATFORM_NAME
220 #define PLATFORM_NAME "Linux/PPC"
221 #endif
222 
223 #endif
224 
225 #elif defined(linux) || defined(__linux__)
226 /* generic Linux */
227 #define LINUX_OS
228 #ifndef PLATFORM_NAME
229 #define PLATFORM_NAME "Linux"
230 #endif
231 
232 #endif
233 
234 /* Convenience defines for Solaris platforms */
235 
236 #if defined(sun)
237 #define SOLARIS_OS
238 #ifndef PLATFORM_NAME
239 #define PLATFORM_NAME "Solaris"
240 #endif
241 #endif
242 
243 /* Convenience defines for HPUX + gcc platforms */
244 
245 #if defined(__hpux)
246 #define HPUX_OS
247 #ifndef PLATFORM_NAME
248 #define PLATFORM_NAME "HPUX"
249 #endif
250 #endif
251 
252 /* Convenience defines for RISCOS + gcc platforms */
253 
254 #if defined(__riscos__)
255 #define RISC_OS
256 #ifndef PLATFORM_NAME
257 #define PLATFORM_NAME "RISC OS"
258 #endif
259 #endif
260 
261 /* Convenience defines for OS/2 + icc/gcc platforms */
262 
263 #if defined(__OS2__) || defined(__EMX__)
264 #define OS2_OS
265 #ifndef PLATFORM_NAME
266 #define PLATFORM_NAME "OS/2"
267 #endif
268 #define FILENAMES_CASE_SENSITIVE 0
269 #define strcasecmp stricmp
270 #endif
271 
272 /* Convenience defines for IRIX */
273 
274 #if defined(__sgi)
275 #define IRIX_OS
276 #ifndef PLATFORM_NAME
277 #define PLATFORM_NAME "SGI IRIX"
278 #endif
279 #endif
280 
281 /* Convenience defines for AIX */
282 
283 #if defined(_AIX)
284 #define AIX_OS
285 #ifndef PLATFORM_NAME
286 #define PLATFORM_NAME "IBM AIX"
287 #endif
288 #endif
289 
290 
291 /* Convenience defines for BeOS platforms */
292 
293 #if defined(__BEOS__)
294 #define BE_OS
295 #ifndef PLATFORM_NAME
296 #define PLATFORM_NAME "BeOS"
297 #endif
298 #endif
299 
300 /* Convenience defines for Cygwin platforms */
301 
302 #if defined(__CYGWIN__)
303 #define CYGWIN_OS
304 #ifndef PLATFORM_NAME
305 #define PLATFORM_NAME "Cygwin"
306 #endif
307 #define FILENAMES_CASE_SENSITIVE 0
308 #endif
309 
310 /* Convenience defines for OpenVMS */
311 
312 #if defined(__VMS)
313 #define OPENVMS_OS
314 #ifndef PLATFORM_NAME
315 #define PLATFORM_NAME "OpenVMS"
316 #endif
317 #define FILENAMES_CASE_SENSITIVE 0
318 #endif
319 
320 /* Convenience defines for DEC Alpha OSF + gcc platforms */
321 
322 #if defined(__osf__)
323 #define OSF_OS
324 #ifndef PLATFORM_NAME
325 #define PLATFORM_NAME "DEC Alpha OSF"
326 #endif
327 #endif
328 
329 /* Convenience defines for ARM platforms */
330 
331 #if defined(__arm)
332 #define ARM_OS
333 
334 #if defined(forARM) && defined(__NEWTON_H)
335 
336 /* Using Newton C++ Tools ARMCpp compiler */
337 #define NEWTON_OS
338 #ifndef PLATFORM_NAME
339 #define PLATFORM_NAME "Newton"
340 #endif
341 
342 #else
343 
344 #ifndef PLATFORM_NAME
345 #define PLATFORM_NAME "ARM"
346 #endif
347 
348 #endif
349 
350 #endif
351 
352 #include <ctype.h>
353 #include <stdio.h>
354 #include <setjmp.h> /* for longjmp on error exit */
355 #include <stdlib.h>
356 #include <stdarg.h> /* may need <varargs.h> for Unix V */
357 #include <string.h>
358 #include <assert.h>
359 
360 #ifdef NEEDS_MALLOC_H
361 #include <malloc.h>
362 #endif
363 
364 #ifdef SUPPORT_GETPWNAM
365 #include <pwd.h>
366 #endif
367 
368 #ifdef NEEDS_UNISTD_H
369 #include <unistd.h> /* needed for unlink on some Unix systems */
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__) || defined(__GLIBC__)
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 #if !(defined(__WATCOMC__) || defined(__MINGW32__))
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) && !defined(TIDY_STATIC)
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,
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  */
unsigned char byte
Definition: tidyplatform.h:550
const tmbchar * ctmbstr
Definition: tidyplatform.h:556
Bool
Definition: tidyplatform.h:593
tmbchar * tmbstr
Definition: tidyplatform.h:555
unsigned int uint
Definition: tidyplatform.h:525
char tmbchar
Definition: tidyplatform.h:553
#define opaque_type(typenam)
Definition: tidyplatform.h:613
uint tchar
Definition: tidyplatform.h:552