platform.h

00001 #ifndef __TIDY_PLATFORM_H__
00002 #define __TIDY_PLATFORM_H__
00003 
00004 /* platform.h -- Platform specifics
00005 
00006   (c) 1998-2007 (W3C) MIT, ERCIM, Keio University
00007   See tidy.h for the copyright notice.
00008 
00009   CVS Info :
00010 
00011     $Author: arnaud02 $ 
00012     $Date: 2007/01/21 20:36:21 $ 
00013     $Revision: 1.62 $ 
00014 
00015 */
00016 
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020 
00021 /*
00022   Uncomment and edit one of the following #defines if you
00023   want to specify the config file at compile-time.
00024 */
00025 
00026 /* #define TIDY_CONFIG_FILE "/etc/tidy_config.txt" */ /* original */
00027 /* #define TIDY_CONFIG_FILE "/etc/tidyrc" */
00028 /* #define TIDY_CONFIG_FILE "/etc/tidy.conf" */
00029 
00030 /*
00031   Uncomment the following #define if you are on a system
00032   supporting the HOME environment variable.
00033   It enables tidy to find config files named ~/.tidyrc if 
00034   the HTML_TIDY environment variable is not set.
00035 */
00036 /* #define TIDY_USER_CONFIG_FILE "~/.tidyrc" */
00037 
00038 /*
00039   Uncomment the following #define if your
00040   system supports the call getpwnam(). 
00041   E.g. Unix and Linux.
00042 
00043   It enables tidy to find files named 
00044   ~your/foo for use in the HTML_TIDY environment
00045   variable or CONFIG_FILE or USER_CONFIGFILE or
00046   on the command line: -config ~joebob/tidy.cfg
00047 
00048   Contributed by Todd Lewis.
00049 */
00050 
00051 /* #define SUPPORT_GETPWNAM */
00052 
00053 
00054 /* Enable/disable support for Big5 and Shift_JIS character encodings */
00055 #ifndef SUPPORT_ASIAN_ENCODINGS
00056 #define SUPPORT_ASIAN_ENCODINGS 1
00057 #endif
00058 
00059 /* Enable/disable support for UTF-16 character encodings */
00060 #ifndef SUPPORT_UTF16_ENCODINGS
00061 #define SUPPORT_UTF16_ENCODINGS 1
00062 #endif
00063 
00064 /* Enable/disable support for additional accessibility checks */
00065 #ifndef SUPPORT_ACCESSIBILITY_CHECKS
00066 #define SUPPORT_ACCESSIBILITY_CHECKS 1
00067 #endif
00068 
00069 
00070 /* Convenience defines for Mac platforms */
00071 
00072 #if defined(macintosh)
00073 /* Mac OS 6.x/7.x/8.x/9.x, with or without CarbonLib - MPW or Metrowerks 68K/PPC compilers */
00074 #define MAC_OS_CLASSIC
00075 #ifndef PLATFORM_NAME
00076 #define PLATFORM_NAME "Mac OS"
00077 #endif
00078 
00079 /* needed for access() */
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 /* Mac OS X (client) 10.x (or server 1.x/10.x) - gcc or Metrowerks MachO compilers */
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 /* Any OS on Mac platform */
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 /* Convenience defines for BSD like platforms */
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 /* Convenience defines for Windows platforms */
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 /* not available with Metrowerks Standard Library */
00151 
00152 #ifdef SUPPORT_GETPWNAM
00153 #undef SUPPORT_GETPWNAM
00154 #endif
00155 
00156 /* needed for setmode() */
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 /* Convenience defines for Linux platforms */
00175  
00176 #if defined(linux) && defined(__alpha__)
00177 /* Linux on Alpha - gcc compiler */
00178 #define LINUX_OS
00179 #ifndef PLATFORM_NAME
00180 #define PLATFORM_NAME "Linux/Alpha"
00181 #endif
00182 
00183 #elif defined(linux) && defined(__sparc__)
00184 /* Linux on Sparc - gcc compiler */
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 /* Linux on x86 - gcc compiler */
00192 #define LINUX_OS
00193 #ifndef PLATFORM_NAME
00194 #define PLATFORM_NAME "Linux/x86"
00195 #endif
00196 
00197 #elif defined(linux) && defined(__powerpc__)
00198 /* Linux on PPC - gcc compiler */
00199 #define LINUX_OS
00200 
00201 #if defined(__linux__) && defined(__powerpc__)
00202 
00203 /* #if #system(linux) */
00204 /* MkLinux on PPC  - gcc (egcs) compiler */
00205 /* #define MAC_OS_MKLINUX */
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 /* generic Linux */
00220 #define LINUX_OS
00221 #ifndef PLATFORM_NAME
00222 #define PLATFORM_NAME "Linux"
00223 #endif
00224 
00225 #endif
00226 
00227 /* Convenience defines for Solaris platforms */
00228  
00229 #if defined(sun)
00230 #define SOLARIS_OS
00231 #ifndef PLATFORM_NAME
00232 #define PLATFORM_NAME "Solaris"
00233 #endif
00234 #endif
00235 
00236 /* Convenience defines for HPUX + gcc platforms */
00237 
00238 #if defined(__hpux)
00239 #define HPUX_OS
00240 #ifndef PLATFORM_NAME
00241 #define PLATFORM_NAME "HPUX"
00242 #endif
00243 #endif
00244 
00245 /* Convenience defines for RISCOS + gcc platforms */
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 /* Convenience defines for OS/2 + icc/gcc platforms */
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 /* Convenience defines for IRIX */
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 /* Convenience defines for AIX */
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 /* Convenience defines for BeOS platforms */
00285 
00286 #if defined(__BEOS__)
00287 #define BE_OS
00288 #ifndef PLATFORM_NAME
00289 #define PLATFORM_NAME "BeOS"
00290 #endif
00291 #endif
00292 
00293 /* Convenience defines for Cygwin platforms */
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 /* Convenience defines for OpenVMS */
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 /* Convenience defines for DEC Alpha OSF + gcc platforms */
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 /* Convenience defines for ARM platforms */
00323 
00324 #if defined(__arm)
00325 #define ARM_OS
00326 
00327 #if defined(forARM) && defined(__NEWTON_H)
00328 
00329 /* Using Newton C++ Tools ARMCpp compiler */
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>  /* for longjmp on error exit */
00348 #include <stdlib.h>
00349 #include <stdarg.h>  /* may need <varargs.h> for Unix V */
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>  /* needed for unlink on some Unix systems */
00363 #endif
00364 
00365 /* This can be set at compile time.  Usually Windows,
00366 ** except for Macintosh builds.
00367 */
00368 #ifndef DFLT_REPL_CHARENC
00369 #define DFLT_REPL_CHARENC WIN1252
00370 #endif
00371 
00372 /* By default, use case-sensitive filename comparison.
00373 */
00374 #ifndef FILENAMES_CASE_SENSITIVE
00375 #define FILENAMES_CASE_SENSITIVE 1
00376 #endif
00377 
00378 
00379 /*
00380   Tidy preserves the last modified time for the files it
00381   cleans up.
00382 */
00383 
00384 /*
00385   If your platform doesn't support <utime.h> and the
00386   utime() function, or <sys/futime> and the futime()
00387   function then set PRESERVE_FILE_TIMES to 0.
00388   
00389   If your platform doesn't support <sys/utime.h> and the
00390   futime() function, then set HAS_FUTIME to 0.
00391   
00392   If your platform supports <utime.h> and the
00393   utime() function requires the file to be
00394   closed first, then set UTIME_NEEDS_CLOSED_FILE to 1.
00395 */
00396 
00397 /* Keep old PRESERVEFILETIMES define for compatibility */
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 /* HASFUTIME */
00441 
00442 /*
00443   MS Windows needs _ prefix for Unix file functions.
00444   Not required by Metrowerks Standard Library (MSL).
00445   
00446   Tidy uses following for preserving the last modified time.
00447 
00448   WINDOWS automatically set by Win16 compilers.
00449   _WIN32 automatically set by Win32 compilers.
00450 */
00451 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
00452 
00453 #define futime _futime
00454 #define fstat _fstat
00455 #define utimbuf _utimbuf /* Windows seems to want utimbuf */
00456 #define stat _stat
00457 #define utime _utime
00458 #define vsnprintf _vsnprintf
00459 #endif /* _WIN32 */
00460 
00461 #endif /* PRESERVE_FILE_TIMES */
00462 
00463 /*
00464   MS Windows needs _ prefix for Unix file functions.
00465   Not required by Metrowerks Standard Library (MSL).
00466   
00467   WINDOWS automatically set by Win16 compilers.
00468   _WIN32 automatically set by Win32 compilers.
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 ) /* local variable is initialized but not referenced */
00482 #pragma warning( disable : 4100 ) /* unreferenced formal parameter */
00483 #pragma warning( disable : 4706 ) /* assignment within conditional expression */
00484 #endif
00485 
00486 #if _MSC_VER > 1300
00487 #pragma warning( disable : 4996 ) /* disable depreciation warning */
00488 #endif
00489 
00490 #endif /* _WIN32 */
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 /* _WIN32 */
00507 
00508 /* hack for gnu sys/types.h file which defines uint and ulong */
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 typedef unsigned int uint;
00515 #endif
00516 #if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
00517 typedef unsigned long ulong;
00518 #endif
00519 
00520 /*
00521 With GCC 4,  __attribute__ ((visibility("default"))) can be used along compiling with tidylib 
00522 with "-fvisibility=hidden". See http://gcc.gnu.org/wiki/Visibility and build/gmake/Makefile.
00523 */
00524 /*
00525 #if defined(__GNUC__) && __GNUC__ >= 4
00526 #define TIDY_EXPORT __attribute__ ((visibility("default")))
00527 #endif
00528 */
00529 
00530 #ifndef TIDY_EXPORT /* Define it away for most builds */
00531 #define TIDY_EXPORT 
00532 #endif
00533 
00534 #ifndef TIDY_STRUCT
00535 #define TIDY_STRUCT
00536 #endif
00537 
00538 typedef unsigned char byte;
00539 
00540 typedef uint tchar;         /* single, full character */
00541 typedef char tmbchar;       /* single, possibly partial character */
00542 #ifndef TMBSTR_DEFINED
00543 typedef tmbchar* tmbstr;    /* pointer to buffer of possibly partial chars */
00544 typedef const tmbchar* ctmbstr; /* Ditto, but const */
00545 #define NULLSTR (tmbstr)""
00546 #define TMBSTR_DEFINED
00547 #endif
00548 
00549 #ifndef TIDY_CALL
00550 #define TIDY_CALL
00551 #endif
00552 
00553 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
00554 # define ARG_UNUSED(x) x __attribute__((unused))
00555 #else
00556 # define ARG_UNUSED(x) x
00557 #endif
00558 
00559 /* HAS_VSNPRINTF triggers the use of "vsnprintf", which is safe related to
00560    buffer overflow. Therefore, we make it the default unless HAS_VSNPRINTF
00561    has been defined. */
00562 #ifndef HAS_VSNPRINTF
00563 # define HAS_VSNPRINTF 1
00564 #endif
00565 
00566 #ifndef SUPPORT_POSIX_MAPPED_FILES
00567 # define SUPPORT_POSIX_MAPPED_FILES 1
00568 #endif
00569 
00570 /*
00571   bool is a reserved word in some but
00572   not all C++ compilers depending on age
00573   work around is to avoid bool altogether
00574   by introducing a new enum called Bool
00575 */
00576 /* We could use the C99 definition where supported
00577 typedef _Bool Bool;
00578 #define no (_Bool)0
00579 #define yes (_Bool)1
00580 */
00581 typedef enum
00582 {
00583    no,
00584    yes
00585 } Bool;
00586 
00587 /* for NULL pointers 
00588 #define null ((const void*)0)
00589 extern void* null;
00590 */
00591 
00592 #if defined(DMALLOC)
00593 #include "dmalloc.h"
00594 #endif
00595 
00596 /** Wrappers for easy memory allocation using an allocator */
00597 #define TidyAlloc(allocator, size) ((allocator)->vtbl->alloc((allocator), (size)))
00598 #define TidyRealloc(allocator, block, size) ((allocator)->vtbl->realloc((allocator), (block), (size)))
00599 #define TidyFree(allocator, block) ((allocator)->vtbl->free((allocator), (block)))
00600 #define TidyPanic(allocator, msg) ((allocator)->vtbl->panic((allocator), (msg)))
00601 
00602 /** Wrappers for easy memory allocation using the document's allocator */
00603 #define TidyDocAlloc(doc, size) TidyAlloc((doc)->allocator, size)
00604 #define TidyDocRealloc(doc, block, size) TidyRealloc((doc)->allocator, block, size)
00605 #define TidyDocFree(doc, block) TidyFree((doc)->allocator, block)
00606 #define TidyDocPanic(doc, msg) TidyPanic((doc)->allocator, msg)
00607 
00608 #define TidyClearMemory(block, size) memset((block), 0, (size))
00609  
00610 /* Opaque data structure.
00611 *  Cast to implementation type struct within lib.
00612 *  This will reduce inter-dependencies/conflicts w/ application code.
00613 */
00614 #if 1
00615 #define opaque_type( typenam )\
00616 struct _##typenam { int _opaque; };\
00617 typedef struct _##typenam* typenam
00618 #else
00619 #define opaque_type(typenam) typedef void* typenam
00620 #endif
00621 
00622 /* Opaque data structure used to pass back
00623 ** and forth to keep current position in a
00624 ** list or other collection.
00625 */
00626 opaque_type( TidyIterator );
00627 
00628 #ifdef __cplusplus
00629 } /* extern "C" */
00630 #endif
00631 
00632 #endif /* __TIDY_PLATFORM_H__ */
00633 
00634 
00635 /*
00636  * local variables:
00637  * mode: c
00638  * indent-tabs-mode: nil
00639  * c-basic-offset: 4
00640  * eval: (c-set-offset 'substatement-open 0)
00641  * end:
00642  */

Generated on Tue Jan 23 10:43:44 2007 for HTML Tidy by  doxygen 1.5.1