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