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