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