Version:
~ [ 1.0 ] ~
1 #ifndef __PLATFORM_H__
2 #define __PLATFORM_H__
3
4 /* platform.h -- Platform specifics
5
6 (c) 1998-2005 (W3C) MIT, ERCIM, Keio University
7 See tidy.h for the copyright notice.
8
9 CVS Info :
10
11 $Author: arnaud02 $
12 $Date: 2005/06/15 12:45:39 $
13 $Revision: 1.55 $
14
15 */
16
17 #ifdef __cplusplus
18 extern "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 CONFIG_FILE "/etc/tidy_config.txt" */ /* original */
27 /* #define CONFIG_FILE "/etc/tidyrc" */
28 /* #define 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 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(__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
171 #endif
172
173 /* Convenience defines for Linux platforms */
174
175 #if defined(linux) && defined(__alpha__)
176 /* Linux on Alpha - gcc compiler */
177 #define LINUX_OS
178 #ifndef PLATFORM_NAME
179 #define PLATFORM_NAME "Linux/Alpha"
180 #endif
181
182 #elif defined(linux) && defined(__sparc__)
183 /* Linux on Sparc - gcc compiler */
184 #define LINUX_OS
185 #ifndef PLATFORM_NAME
186 #define PLATFORM_NAME "Linux/Sparc"
187 #endif
188
189 #elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
190 /* Linux on x86 - gcc compiler */
191 #define LINUX_OS
192 #ifndef PLATFORM_NAME
193 #define PLATFORM_NAME "Linux/x86"
194 #endif
195
196 #elif defined(linux) && defined(__powerpc__)
197 /* Linux on PPC - gcc compiler */
198 #define LINUX_OS
199
200 #if defined(__linux__) && defined(__powerpc__)
201
202 /* #if #system(linux) */
203 /* MkLinux on PPC - gcc (egcs) compiler */
204 /* #define MAC_OS_MKLINUX */
205 #ifndef PLATFORM_NAME
206 #define PLATFORM_NAME "MkLinux"
207 #endif
208
209 #else
210
211 #ifndef PLATFORM_NAME
212 #define PLATFORM_NAME "Linux/PPC"
213 #endif
214
215 #endif
216
217 #elif defined(linux) || defined(__linux__)
218 /* generic Linux */
219 #define LINUX_OS
220 #ifndef PLATFORM_NAME
221 #define PLATFORM_NAME "Linux"
222 #endif
223
224 #endif
225
226 /* Convenience defines for Solaris platforms */
227
228 #if defined(sun)
229 #define SOLARIS_OS
230 #ifndef PLATFORM_NAME
231 #define PLATFORM_NAME "Solaris"
232 #endif
233 #endif
234
235 /* Convenience defines for HPUX + gcc platforms */
236
237 #if defined(__hpux)
238 #define HPUX_OS
239 #ifndef PLATFORM_NAME
240 #define PLATFORM_NAME "HPUX"
241 #endif
242 #endif
243
244 /* Convenience defines for RISCOS + gcc platforms */
245
246 #if defined(__riscos__)
247 #define RISC_OS
248 #ifndef PLATFORM_NAME
249 #define PLATFORM_NAME "RISC OS"
250 #endif
251 #endif
252
253 /* Convenience defines for OS/2 + icc/gcc platforms */
254
255 #if defined(__OS2__) || defined(__EMX__)
256 #define OS2_OS
257 #ifndef PLATFORM_NAME
258 #define PLATFORM_NAME "OS/2"
259 #endif
260 #define FILENAMES_CASE_SENSITIVE 0
261 #define strcasecmp stricmp
262 #endif
263
264 /* Convenience defines for IRIX */
265
266 #if defined(__sgi)
267 #define IRIX_OS
268 #ifndef PLATFORM_NAME
269 #define PLATFORM_NAME "SGI IRIX"
270 #endif
271 #endif
272
273 /* Convenience defines for AIX */
274
275 #if defined(_AIX)
276 #define AIX_OS
277 #ifndef PLATFORM_NAME
278 #define PLATFORM_NAME "IBM AIX"
279 #endif
280 #endif
281
282
283 /* Convenience defines for BeOS platforms */
284
285 #if defined(__BEOS__)
286 #define BE_OS
287 #ifndef PLATFORM_NAME
288 #define PLATFORM_NAME "BeOS"
289 #endif
290 #endif
291
292 /* Convenience defines for Cygwin platforms */
293
294 #if defined(__CYGWIN__)
295 #define CYGWIN_OS
296 #ifndef PLATFORM_NAME
297 #define PLATFORM_NAME "Cygwin"
298 #endif
299 #define FILENAMES_CASE_SENSITIVE 0
300 #endif
301
302 /* Convenience defines for OpenVMS */
303
304 #if defined(__VMS)
305 #define OPENVMS_OS
306 #ifndef PLATFORM_NAME
307 #define PLATFORM_NAME "OpenVMS"
308 #endif
309 #define FILENAMES_CASE_SENSITIVE 0
310 #endif
311
312 /* Convenience defines for DEC Alpha OSF + gcc platforms */
313
314 #if defined(__osf__)
315 #define OSF_OS
316 #ifndef PLATFORM_NAME
317 #define PLATFORM_NAME "DEC Alpha OSF"
318 #endif
319 #endif
320
321 /* Convenience defines for ARM platforms */
322
323 #if defined(__arm)
324 #define ARM_OS
325
326 #if defined(forARM) && defined(__NEWTON_H)
327
328 /* Using Newton C++ Tools ARMCpp compiler */
329 #define NEWTON_OS
330 #ifndef PLATFORM_NAME
331 #define PLATFORM_NAME "Newton"
332 #endif
333
334 #else
335
336 #ifndef PLATFORM_NAME
337 #define PLATFORM_NAME "ARM"
338 #endif
339
340 #endif
341
342 #endif
343
344 #include <ctype.h>
345 #include <stdio.h>
346 #include <setjmp.h> /* for longjmp on error exit */
347 #include <stdlib.h>
348 #include <stdarg.h> /* may need <varargs.h> for Unix V */
349 #include <string.h>
350 #include <assert.h>
351
352 #ifdef NEEDS_MALLOC_H
353 #include <malloc.h>
354 #endif
355
356 #ifdef SUPPORT_GETPWNAM
357 #include <pwd.h>
358 #endif
359
360 #ifdef NEEDS_UNISTD_H
361 #include <unistd.h> /* needed for unlink on some Unix systems */
362 #endif
363
364 /* This can be set at compile time. Usually Windows,
365 ** except for Macintosh builds.
366 */
367 #ifndef DFLT_REPL_CHARENC
368 #define DFLT_REPL_CHARENC WIN1252
369 #endif
370
371 /* By default, use case-sensitive filename comparison.
372 */
373 #ifndef FILENAMES_CASE_SENSITIVE
374 #define FILENAMES_CASE_SENSITIVE 1
375 #endif
376
377
378 /*
379 Tidy preserves the last modified time for the files it
380 cleans up.
381 */
382
383 /*
384 If your platform doesn't support <utime.h> and the
385 utime() function, or <sys/futime> and the futime()
386 function then set PRESERVE_FILE_TIMES to 0.
387
388 If your platform doesn't support <sys/utime.h> and the
389 futime() function, then set HAS_FUTIME to 0.
390
391 If your platform supports <utime.h> and the
392 utime() function requires the file to be
393 closed first, then set UTIME_NEEDS_CLOSED_FILE to 1.
394 */
395
396 /* Keep old PRESERVEFILETIMES define for compatibility */
397 #ifdef PRESERVEFILETIMES
398 #undef PRESERVE_FILE_TIMES
399 #define PRESERVE_FILE_TIMES PRESERVEFILETIMES
400 #endif
401
402 #ifndef PRESERVE_FILE_TIMES
403 #if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS)
404 #define PRESERVE_FILE_TIMES 0
405 #else
406 #define PRESERVE_FILE_TIMES 1
407 #endif
408 #endif
409
410 #if PRESERVE_FILE_TIMES
411
412 #ifndef HAS_FUTIME
413 #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__)
414 #define HAS_FUTIME 0
415 #else
416 #define HAS_FUTIME 1
417 #endif
418 #endif
419
420 #ifndef UTIME_NEEDS_CLOSED_FILE
421 #if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS)
422 #define UTIME_NEEDS_CLOSED_FILE 1
423 #else
424 #define UTIME_NEEDS_CLOSED_FILE 0
425 #endif
426 #endif
427
428 #if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__))
429 #include <sys/types.h>
430 #include <sys/stat.h>
431 #else
432 #include <stat.h>
433 #endif
434
435 #if HAS_FUTIME
436 #include <sys/utime.h>
437 #else
438 #include <utime.h>
439 #endif /* HASFUTIME */
440
441 /*
442 MS Windows needs _ prefix for Unix file functions.
443 Not required by Metrowerks Standard Library (MSL).
444
445 Tidy uses following for preserving the last modified time.
446
447 WINDOWS automatically set by Win16 compilers.
448 _WIN32 automatically set by Win32 compilers.
449 */
450 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
451
452 #define futime _futime
453 #define fstat _fstat
454 #define utimbuf _utimbuf /* Windows seems to want utimbuf */
455 #define stat _stat
456 #define utime _utime
457 #define vsnprintf _vsnprintf
458 #endif /* _WIN32 */
459
460 #endif /* PRESERVE_FILE_TIMES */
461
462 /*
463 MS Windows needs _ prefix for Unix file functions.
464 Not required by Metrowerks Standard Library (MSL).
465
466 WINDOWS automatically set by Win16 compilers.
467 _WIN32 automatically set by Win32 compilers.
468 */
469 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
470
471 #ifndef __WATCOMC__
472 #define fileno _fileno
473 #define setmode _setmode
474 #endif
475
476 #define access _access
477 #define strcasecmp _stricmp
478
479 #if _MSC_VER > 1000
480 #pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */
481 #pragma warning( disable : 4100 ) /* unreferenced formal parameter */
482 #pragma warning( disable : 4706 ) /* assignment within conditional expression */
483 #endif
484
485 #endif /* _WIN32 */
486
487 #if defined(_WIN32)
488
489 #if (defined(_USRDLL) || defined(_WINDLL)) && !defined(TIDY_EXPORT)
490 #define TIDY_EXPORT __declspec( dllexport )
491 #endif
492
493 #ifndef TIDY_CALL
494 #define TIDY_CALL __stdcall
495 #endif
496
497 #endif /* _WIN32 */
498
499 /* hack for gnu sys/types.h file which defines uint and ulong */
500
501 #if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
502 #include <sys/types.h>
503 #endif
504 #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)
505 typedef unsigned int uint;
506 #endif
507 #if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
508 typedef unsigned long ulong;
509 #endif
510
511 #ifndef TIDY_EXPORT /* Define it away for most builds */
512 #define TIDY_EXPORT
513 #endif
514
515 #ifndef TIDY_STRUCT
516 #define TIDY_STRUCT
517 #endif
518
519 typedef unsigned char byte;
520
521 typedef uint tchar; /* single, full character */
522 typedef char tmbchar; /* single, possibly partial character */
523 #ifndef TMBSTR_DEFINED
524 typedef tmbchar* tmbstr; /* pointer to buffer of possibly partial chars */
525 typedef const tmbchar* ctmbstr; /* Ditto, but const */
526 #define NULLSTR (tmbstr)""
527 #define TMBSTR_DEFINED
528 #endif
529
530 #ifndef TIDY_CALL
531 #define TIDY_CALL
532 #endif
533
534 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
535 # define ARG_UNUSED(x) x __attribute__((unused))
536 #else
537 # define ARG_UNUSED(x) x
538 #endif
539
540 /* HAS_VSNPRINTF triggers the use of "vsnprintf", which is safe related to
541 buffer overflow. Therefore, we make it the default unless HAS_VSNPRINTF
542 has been defined. */
543 #ifndef HAS_VSNPRINTF
544 # define HAS_VSNPRINTF 1
545 #endif
546
547 /*
548 bool is a reserved word in some but
549 not all C++ compilers depending on age
550 work around is to avoid bool altogether
551 by introducing a new enum called Bool
552 */
553 /* We could use the C99 definition where supported
554 typedef _Bool Bool;
555 #define no (_Bool)0
556 #define yes (_Bool)1
557 */
558 typedef enum
559 {
560 no,
561 yes
562 } Bool;
563
564 /* for NULL pointers
565 #define null ((const void*)0)
566 extern void* null;
567 */
568
569 #if defined(DMALLOC)
570 #include "dmalloc.h"
571 #endif
572
573 void *MemAlloc(size_t size);
574 void *MemRealloc(void *mem, size_t newsize);
575 void MemFree(void *mem);
576 void ClearMemory(void *, size_t size);
577 void FatalError( ctmbstr msg );
578
579 /* Opaque data structure.
580 * Cast to implementation type struct within lib.
581 * This will reduce inter-dependencies/conflicts w/ application code.
582 */
583 #if 1
584 #define opaque_type( typenam )\
585 struct _##typenam { int _opaque; };\
586 typedef struct _##typenam* typenam
587 #else
588 #define opaque_type(typenam) typedef void* typenam
589 #endif
590
591 /* Opaque data structure used to pass back
592 ** and forth to keep current position in a
593 ** list or other collection.
594 */
595 opaque_type( TidyIterator );
596
597 #ifdef __cplusplus
598 } /* extern "C" */
599 #endif
600
601 #endif /* __PLATFORM_H__ */
602
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.