platform.h

00001 #ifndef __PLATFORM_H__
00002 #define __PLATFORM_H__
00003 
00004 /* platform.h -- Platform specifics
00005 
00006   (c) 1998-2006 (W3C) MIT, ERCIM, Keio University
00007   See tidy.h for the copyright notice.
00008 
00009   CVS Info :
00010 
00011     $Author: arnaud02 $ 
00012     $Date: 2006/07/03 14:08:57 $ 
00013     $Revision: 1.57 $ 
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 CONFIG_FILE "/etc/tidy_config.txt" */ /* original */
00027 /* #define CONFIG_FILE "/etc/tidyrc" */
00028 /* #define 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 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 
00171 #endif
00172 
00173 /* Convenience defines for Linux platforms */
00174  
00175 #if defined(linux) && defined(__alpha__)
00176 /* Linux on Alpha - gcc compiler */
00177 #define LINUX_OS
00178 #ifndef PLATFORM_NAME
00179 #define PLATFORM_NAME "Linux/Alpha"
00180 #endif
00181 
00182 #elif defined(linux) && defined(__sparc__)
00183 /* Linux on Sparc - gcc compiler */
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 /* Linux on x86 - gcc compiler */
00191 #define LINUX_OS
00192 #ifndef PLATFORM_NAME
00193 #define PLATFORM_NAME "Linux/x86"
00194 #endif
00195 
00196 #elif defined(linux) && defined(__powerpc__)
00197 /* Linux on PPC - gcc compiler */
00198 #define LINUX_OS
00199 
00200 #if defined(__linux__) && defined(__powerpc__)
00201 
00202 /* #if #system(linux) */
00203 /* MkLinux on PPC  - gcc (egcs) compiler */
00204 /* #define MAC_OS_MKLINUX */
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 /* generic Linux */
00219 #define LINUX_OS
00220 #ifndef PLATFORM_NAME
00221 #define PLATFORM_NAME "Linux"
00222 #endif
00223 
00224 #endif
00225 
00226 /* Convenience defines for Solaris platforms */
00227  
00228 #if defined(sun)
00229 #define SOLARIS_OS
00230 #ifndef PLATFORM_NAME
00231 #define PLATFORM_NAME "Solaris"
00232 #endif
00233 #endif
00234 
00235 /* Convenience defines for HPUX + gcc platforms */
00236 
00237 #if defined(__hpux)
00238 #define HPUX_OS
00239 #ifndef PLATFORM_NAME
00240 #define PLATFORM_NAME "HPUX"
00241 #endif
00242 #endif
00243 
00244 /* Convenience defines for RISCOS + gcc platforms */
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 /* Convenience defines for OS/2 + icc/gcc platforms */
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 /* Convenience defines for IRIX */
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 /* Convenience defines for AIX */
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 /* Convenience defines for BeOS platforms */
00284 
00285 #if defined(__BEOS__)
00286 #define BE_OS
00287 #ifndef PLATFORM_NAME
00288 #define PLATFORM_NAME "BeOS"
00289 #endif
00290 #endif
00291 
00292 /* Convenience defines for Cygwin platforms */
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 /* Convenience defines for OpenVMS */
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 /* Convenience defines for DEC Alpha OSF + gcc platforms */
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 /* Convenience defines for ARM platforms */
00322 
00323 #if defined(__arm)
00324 #define ARM_OS
00325 
00326 #if defined(forARM) && defined(__NEWTON_H)
00327 
00328 /* Using Newton C++ Tools ARMCpp compiler */
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>  /* for longjmp on error exit */
00347 #include <stdlib.h>
00348 #include <stdarg.h>  /* may need <varargs.h> for Unix V */
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>  /* needed for unlink on some Unix systems */
00362 #endif
00363 
00364 /* This can be set at compile time.  Usually Windows,
00365 ** except for Macintosh builds.
00366 */
00367 #ifndef DFLT_REPL_CHARENC
00368 #define DFLT_REPL_CHARENC WIN1252
00369 #endif
00370 
00371 /* By default, use case-sensitive filename comparison.
00372 */
00373 #ifndef FILENAMES_CASE_SENSITIVE
00374 #define FILENAMES_CASE_SENSITIVE 1
00375 #endif
00376 
00377 
00378 /*
00379   Tidy preserves the last modified time for the files it
00380   cleans up.
00381 */
00382 
00383 /*
00384   If your platform doesn't support <utime.h> and the
00385   utime() function, or <sys/futime> and the futime()
00386   function then set PRESERVE_FILE_TIMES to 0.
00387   
00388   If your platform doesn't support <sys/utime.h> and the
00389   futime() function, then set HAS_FUTIME to 0.
00390   
00391   If your platform supports <utime.h> and the
00392   utime() function requires the file to be
00393   closed first, then set UTIME_NEEDS_CLOSED_FILE to 1.
00394 */
00395 
00396 /* Keep old PRESERVEFILETIMES define for compatibility */
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 /* HASFUTIME */
00440 
00441 /*
00442   MS Windows needs _ prefix for Unix file functions.
00443   Not required by Metrowerks Standard Library (MSL).
00444   
00445   Tidy uses following for preserving the last modified time.
00446 
00447   WINDOWS automatically set by Win16 compilers.
00448   _WIN32 automatically set by Win32 compilers.
00449 */
00450 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
00451 
00452 #define futime _futime
00453 #define fstat _fstat
00454 #define utimbuf _utimbuf /* Windows seems to want utimbuf */
00455 #define stat _stat
00456 #define utime _utime
00457 #define vsnprintf _vsnprintf
00458 #endif /* _WIN32 */
00459 
00460 #endif /* PRESERVE_FILE_TIMES */
00461 
00462 /*
00463   MS Windows needs _ prefix for Unix file functions.
00464   Not required by Metrowerks Standard Library (MSL).
00465   
00466   WINDOWS automatically set by Win16 compilers.
00467   _WIN32 automatically set by Win32 compilers.
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 ) /* local variable is initialized but not referenced */
00481 #pragma warning( disable : 4100 ) /* unreferenced formal parameter */
00482 #pragma warning( disable : 4706 ) /* assignment within conditional expression */
00483 #endif
00484 
00485 #endif /* _WIN32 */
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 #ifdef _WIN64
00495 #  define TIDY_CALL __fastcall
00496 #else
00497 #  define TIDY_CALL __stdcall
00498 #endif
00499 #endif
00500 
00501 #endif /* _WIN32 */
00502 
00503 /* hack for gnu sys/types.h file which defines uint and ulong */
00504 
00505 #if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
00506 #include <sys/types.h>
00507 #endif
00508 #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)
00509 typedef unsigned int uint;
00510 #endif
00511 #if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
00512 typedef unsigned long ulong;
00513 #endif
00514 
00515 /*
00516 With GCC 4,  __attribute__ ((visibility("default"))) can be used along compiling with tidylib 
00517 with "-fvisibility=hidden". See http://gcc.gnu.org/wiki/Visibility and build/gmake/Makefile.
00518 */
00519 /*
00520 #if defined(__GNUC__) && __GNUC__ >= 4
00521 #define TIDY_EXPORT __attribute__ ((visibility("default")))
00522 #endif
00523 */
00524 
00525 #ifndef TIDY_EXPORT /* Define it away for most builds */
00526 #define TIDY_EXPORT 
00527 #endif
00528 
00529 #ifndef TIDY_STRUCT
00530 #define TIDY_STRUCT
00531 #endif
00532 
00533 typedef unsigned char byte;
00534 
00535 typedef uint tchar;         /* single, full character */
00536 typedef char tmbchar;       /* single, possibly partial character */
00537 #ifndef TMBSTR_DEFINED
00538 typedef tmbchar* tmbstr;    /* pointer to buffer of possibly partial chars */
00539 typedef const tmbchar* ctmbstr; /* Ditto, but const */
00540 #define NULLSTR (tmbstr)""
00541 #define TMBSTR_DEFINED
00542 #endif
00543 
00544 #ifndef TIDY_CALL
00545 #define TIDY_CALL
00546 #endif
00547 
00548 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
00549 # define ARG_UNUSED(x) x __attribute__((unused))
00550 #else
00551 # define ARG_UNUSED(x) x
00552 #endif
00553 
00554 /* HAS_VSNPRINTF triggers the use of "vsnprintf", which is safe related to
00555    buffer overflow. Therefore, we make it the default unless HAS_VSNPRINTF
00556    has been defined. */
00557 #ifndef HAS_VSNPRINTF
00558 # define HAS_VSNPRINTF 1
00559 #endif
00560 
00561 /*
00562   bool is a reserved word in some but
00563   not all C++ compilers depending on age
00564   work around is to avoid bool altogether
00565   by introducing a new enum called Bool
00566 */
00567 /* We could use the C99 definition where supported
00568 typedef _Bool Bool;
00569 #define no (_Bool)0
00570 #define yes (_Bool)1
00571 */
00572 typedef enum
00573 {
00574    no,
00575    yes
00576 } Bool;
00577 
00578 /* for NULL pointers 
00579 #define null ((const void*)0)
00580 extern void* null;
00581 */
00582 
00583 #if defined(DMALLOC)
00584 #include "dmalloc.h"
00585 #endif
00586 
00587 void *MemAlloc(size_t size);
00588 void *MemRealloc(void *mem, size_t newsize);
00589 void MemFree(void *mem);
00590 void ClearMemory(void *, size_t size);
00591 void FatalError( ctmbstr msg );
00592 
00593 /* Opaque data structure.
00594 *  Cast to implementation type struct within lib.
00595 *  This will reduce inter-dependencies/conflicts w/ application code.
00596 */
00597 #if 1
00598 #define opaque_type( typenam )\
00599 struct _##typenam { int _opaque; };\
00600 typedef struct _##typenam* typenam
00601 #else
00602 #define opaque_type(typenam) typedef void* typenam
00603 #endif
00604 
00605 /* Opaque data structure used to pass back
00606 ** and forth to keep current position in a
00607 ** list or other collection.
00608 */
00609 opaque_type( TidyIterator );
00610 
00611 #ifdef __cplusplus
00612 } /* extern "C" */
00613 #endif
00614 
00615 #endif /* __PLATFORM_H__ */

Generated on Fri Feb 20 22:00:27 2009 for HTML Tidy by  doxygen 1.5.6