00001 #ifndef __TIDY_PLATFORM_H__
00002 #define __TIDY_PLATFORM_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #ifndef SUPPORT_ASIAN_ENCODINGS
00056 #define SUPPORT_ASIAN_ENCODINGS 1
00057 #endif
00058
00059
00060 #ifndef SUPPORT_UTF16_ENCODINGS
00061 #define SUPPORT_UTF16_ENCODINGS 1
00062 #endif
00063
00064
00065 #ifndef SUPPORT_ACCESSIBILITY_CHECKS
00066 #define SUPPORT_ACCESSIBILITY_CHECKS 1
00067 #endif
00068
00069
00070
00071
00072 #if defined(macintosh)
00073
00074 #define MAC_OS_CLASSIC
00075 #ifndef PLATFORM_NAME
00076 #define PLATFORM_NAME "Mac OS"
00077 #endif
00078
00079
00080 #if !defined(_POSIX) && !defined(NO_ACCESS_SUPPORT)
00081 #define NO_ACCESS_SUPPORT
00082 #endif
00083
00084 #ifdef SUPPORT_GETPWNAM
00085 #undef SUPPORT_GETPWNAM
00086 #endif
00087
00088 #elif defined(__APPLE__) && defined(__MACH__)
00089
00090 #define MAC_OS_X
00091 #ifndef PLATFORM_NAME
00092 #define PLATFORM_NAME "Mac OS X"
00093 #endif
00094 #endif
00095
00096 #if defined(MAC_OS_CLASSIC) || defined(MAC_OS_X)
00097
00098 #define MAC_OS
00099 #define FILENAMES_CASE_SENSITIVE 0
00100 #define strcasecmp strcmp
00101 #ifndef DFLT_REPL_CHARENC
00102 #define DFLT_REPL_CHARENC MACROMAN
00103 #endif
00104 #endif
00105
00106
00107
00108 #if defined(__FreeBSD__)
00109 #define BSD_BASED_OS
00110 #ifndef PLATFORM_NAME
00111 #define PLATFORM_NAME "FreeBSD"
00112 #endif
00113
00114 #elif defined(__NetBSD__)
00115 #define BSD_BASED_OS
00116 #ifndef PLATFORM_NAME
00117 #define PLATFORM_NAME "NetBSD"
00118 #endif
00119
00120 #elif defined(__OpenBSD__)
00121 #define BSD_BASED_OS
00122 #ifndef PLATFORM_NAME
00123 #define PLATFORM_NAME "OpenBSD"
00124 #endif
00125
00126 #elif defined(__DragonFly__)
00127 #define BSD_BASED_OS
00128 #ifndef PLATFORM_NAME
00129 #define PLATFORM_NAME "DragonFly"
00130 #endif
00131
00132 #elif defined(__MINT__)
00133 #define BSD_BASED_OS
00134 #ifndef PLATFORM_NAME
00135 #define PLATFORM_NAME "FreeMiNT"
00136 #endif
00137
00138 #elif defined(__bsdi__)
00139 #define BSD_BASED_OS
00140 #ifndef PLATFORM_NAME
00141 #define PLATFORM_NAME "BSD/OS"
00142 #endif
00143
00144 #endif
00145
00146
00147
00148 #if defined(WINDOWS) || defined(_WIN32)
00149
00150 #define WINDOWS_OS
00151 #ifndef PLATFORM_NAME
00152 #define PLATFORM_NAME "Windows"
00153 #endif
00154
00155 #if defined(__MWERKS__) || defined(__MSL__)
00156
00157
00158 #ifdef SUPPORT_GETPWNAM
00159 #undef SUPPORT_GETPWNAM
00160 #endif
00161
00162
00163 #if !defined(NO_SETMODE_SUPPORT)
00164 #define NO_SETMODE_SUPPORT
00165 #endif
00166
00167 #define strcasecmp _stricmp
00168
00169 #endif
00170
00171 #if defined(__BORLANDC__)
00172 #define strcasecmp stricmp
00173 #endif
00174
00175 #define FILENAMES_CASE_SENSITIVE 0
00176 #define SUPPORT_POSIX_MAPPED_FILES 0
00177
00178 #endif
00179
00180
00181
00182 #if defined(linux) && defined(__alpha__)
00183
00184 #define LINUX_OS
00185 #ifndef PLATFORM_NAME
00186 #define PLATFORM_NAME "Linux/Alpha"
00187 #endif
00188
00189 #elif defined(linux) && defined(__sparc__)
00190
00191 #define LINUX_OS
00192 #ifndef PLATFORM_NAME
00193 #define PLATFORM_NAME "Linux/Sparc"
00194 #endif
00195
00196 #elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
00197
00198 #define LINUX_OS
00199 #ifndef PLATFORM_NAME
00200 #define PLATFORM_NAME "Linux/x86"
00201 #endif
00202
00203 #elif defined(linux) && defined(__powerpc__)
00204
00205 #define LINUX_OS
00206
00207 #if defined(__linux__) && defined(__powerpc__)
00208
00209
00210
00211
00212 #ifndef PLATFORM_NAME
00213 #define PLATFORM_NAME "MkLinux"
00214 #endif
00215
00216 #else
00217
00218 #ifndef PLATFORM_NAME
00219 #define PLATFORM_NAME "Linux/PPC"
00220 #endif
00221
00222 #endif
00223
00224 #elif defined(linux) || defined(__linux__)
00225
00226 #define LINUX_OS
00227 #ifndef PLATFORM_NAME
00228 #define PLATFORM_NAME "Linux"
00229 #endif
00230
00231 #endif
00232
00233
00234
00235 #if defined(sun)
00236 #define SOLARIS_OS
00237 #ifndef PLATFORM_NAME
00238 #define PLATFORM_NAME "Solaris"
00239 #endif
00240 #endif
00241
00242
00243
00244 #if defined(__hpux)
00245 #define HPUX_OS
00246 #ifndef PLATFORM_NAME
00247 #define PLATFORM_NAME "HPUX"
00248 #endif
00249 #endif
00250
00251
00252
00253 #if defined(__riscos__)
00254 #define RISC_OS
00255 #ifndef PLATFORM_NAME
00256 #define PLATFORM_NAME "RISC OS"
00257 #endif
00258 #endif
00259
00260
00261
00262 #if defined(__OS2__) || defined(__EMX__)
00263 #define OS2_OS
00264 #ifndef PLATFORM_NAME
00265 #define PLATFORM_NAME "OS/2"
00266 #endif
00267 #define FILENAMES_CASE_SENSITIVE 0
00268 #define strcasecmp stricmp
00269 #endif
00270
00271
00272
00273 #if defined(__sgi)
00274 #define IRIX_OS
00275 #ifndef PLATFORM_NAME
00276 #define PLATFORM_NAME "SGI IRIX"
00277 #endif
00278 #endif
00279
00280
00281
00282 #if defined(_AIX)
00283 #define AIX_OS
00284 #ifndef PLATFORM_NAME
00285 #define PLATFORM_NAME "IBM AIX"
00286 #endif
00287 #endif
00288
00289
00290
00291
00292 #if defined(__BEOS__)
00293 #define BE_OS
00294 #ifndef PLATFORM_NAME
00295 #define PLATFORM_NAME "BeOS"
00296 #endif
00297 #endif
00298
00299
00300
00301 #if defined(__CYGWIN__)
00302 #define CYGWIN_OS
00303 #ifndef PLATFORM_NAME
00304 #define PLATFORM_NAME "Cygwin"
00305 #endif
00306 #define FILENAMES_CASE_SENSITIVE 0
00307 #endif
00308
00309
00310
00311 #if defined(__VMS)
00312 #define OPENVMS_OS
00313 #ifndef PLATFORM_NAME
00314 #define PLATFORM_NAME "OpenVMS"
00315 #endif
00316 #define FILENAMES_CASE_SENSITIVE 0
00317 #endif
00318
00319
00320
00321 #if defined(__osf__)
00322 #define OSF_OS
00323 #ifndef PLATFORM_NAME
00324 #define PLATFORM_NAME "DEC Alpha OSF"
00325 #endif
00326 #endif
00327
00328
00329
00330 #if defined(__arm)
00331 #define ARM_OS
00332
00333 #if defined(forARM) && defined(__NEWTON_H)
00334
00335
00336 #define NEWTON_OS
00337 #ifndef PLATFORM_NAME
00338 #define PLATFORM_NAME "Newton"
00339 #endif
00340
00341 #else
00342
00343 #ifndef PLATFORM_NAME
00344 #define PLATFORM_NAME "ARM"
00345 #endif
00346
00347 #endif
00348
00349 #endif
00350
00351 #include <ctype.h>
00352 #include <stdio.h>
00353 #include <setjmp.h>
00354 #include <stdlib.h>
00355 #include <stdarg.h>
00356 #include <string.h>
00357 #include <assert.h>
00358
00359 #ifdef NEEDS_MALLOC_H
00360 #include <malloc.h>
00361 #endif
00362
00363 #ifdef SUPPORT_GETPWNAM
00364 #include <pwd.h>
00365 #endif
00366
00367 #ifdef NEEDS_UNISTD_H
00368 #include <unistd.h>
00369 #endif
00370
00371
00372
00373
00374 #ifndef DFLT_REPL_CHARENC
00375 #define DFLT_REPL_CHARENC WIN1252
00376 #endif
00377
00378
00379
00380 #ifndef FILENAMES_CASE_SENSITIVE
00381 #define FILENAMES_CASE_SENSITIVE 1
00382 #endif
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 #ifdef PRESERVEFILETIMES
00405 #undef PRESERVE_FILE_TIMES
00406 #define PRESERVE_FILE_TIMES PRESERVEFILETIMES
00407 #endif
00408
00409 #ifndef PRESERVE_FILE_TIMES
00410 #if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS)
00411 #define PRESERVE_FILE_TIMES 0
00412 #else
00413 #define PRESERVE_FILE_TIMES 1
00414 #endif
00415 #endif
00416
00417 #if PRESERVE_FILE_TIMES
00418
00419 #ifndef HAS_FUTIME
00420 #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__)
00421 #define HAS_FUTIME 0
00422 #else
00423 #define HAS_FUTIME 1
00424 #endif
00425 #endif
00426
00427 #ifndef UTIME_NEEDS_CLOSED_FILE
00428 #if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS)
00429 #define UTIME_NEEDS_CLOSED_FILE 1
00430 #else
00431 #define UTIME_NEEDS_CLOSED_FILE 0
00432 #endif
00433 #endif
00434
00435 #if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__))
00436 #include <sys/types.h>
00437 #include <sys/stat.h>
00438 #else
00439 #include <stat.h>
00440 #endif
00441
00442 #if HAS_FUTIME
00443 #include <sys/utime.h>
00444 #else
00445 #include <utime.h>
00446 #endif
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
00458
00459 #define futime _futime
00460 #define fstat _fstat
00461 #define utimbuf _utimbuf
00462 #define stat _stat
00463 #define utime _utime
00464 #define vsnprintf _vsnprintf
00465 #endif
00466
00467 #endif
00468
00469
00470
00471
00472
00473
00474
00475
00476 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
00477
00478 #ifndef __WATCOMC__
00479 #define fileno _fileno
00480 #define setmode _setmode
00481 #endif
00482
00483 #define access _access
00484 #define strcasecmp _stricmp
00485
00486 #if _MSC_VER > 1000
00487 #pragma warning( disable : 4189 )
00488 #pragma warning( disable : 4100 )
00489 #pragma warning( disable : 4706 )
00490 #endif
00491
00492 #if _MSC_VER > 1300
00493 #pragma warning( disable : 4996 )
00494 #endif
00495
00496 #endif
00497
00498 #if defined(_WIN32)
00499
00500 #if (defined(_USRDLL) || defined(_WINDLL)) && !defined(TIDY_EXPORT)
00501 #define TIDY_EXPORT __declspec( dllexport )
00502 #endif
00503
00504 #ifndef TIDY_CALL
00505 #ifdef _WIN64
00506 # define TIDY_CALL __fastcall
00507 #else
00508 # define TIDY_CALL __stdcall
00509 #endif
00510 #endif
00511
00512 #endif
00513
00514
00515
00516 #if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
00517 #include <sys/types.h>
00518 #endif
00519 #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)
00520 # undef uint
00521 typedef unsigned int uint;
00522 #endif
00523 #if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
00524 # undef ulong
00525 typedef unsigned long ulong;
00526 #endif
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538 #ifndef TIDY_EXPORT
00539 #define TIDY_EXPORT
00540 #endif
00541
00542 #ifndef TIDY_STRUCT
00543 #define TIDY_STRUCT
00544 #endif
00545
00546 typedef unsigned char byte;
00547
00548 typedef uint tchar;
00549 typedef char tmbchar;
00550 #ifndef TMBSTR_DEFINED
00551 typedef tmbchar* tmbstr;
00552 typedef const tmbchar* ctmbstr;
00553 #define NULLSTR (tmbstr)""
00554 #define TMBSTR_DEFINED
00555 #endif
00556
00557 #ifndef TIDY_CALL
00558 #define TIDY_CALL
00559 #endif
00560
00561 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
00562 # define ARG_UNUSED(x) x __attribute__((unused))
00563 #else
00564 # define ARG_UNUSED(x) x
00565 #endif
00566
00567
00568
00569
00570 #ifndef HAS_VSNPRINTF
00571 # define HAS_VSNPRINTF 1
00572 #endif
00573
00574 #ifndef SUPPORT_POSIX_MAPPED_FILES
00575 # define SUPPORT_POSIX_MAPPED_FILES 1
00576 #endif
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589 typedef enum
00590 {
00591 no,
00592 yes
00593 } Bool;
00594
00595
00596
00597
00598
00599
00600 #if defined(DMALLOC)
00601 #include "dmalloc.h"
00602 #endif
00603
00604
00605
00606
00607
00608 #if 1
00609 #define opaque_type( typenam )\
00610 struct _##typenam { int _opaque; };\
00611 typedef struct _##typenam const * typenam
00612 #else
00613 #define opaque_type(typenam) typedef const void* typenam
00614 #endif
00615
00616
00617
00618
00619
00620 opaque_type( TidyIterator );
00621
00622 #ifdef __cplusplus
00623 }
00624 #endif
00625
00626 #endif
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636