HTML Tidy  0.1
platform.h
00001 #ifndef __TIDY_PLATFORM_H__
00002 #define __TIDY_PLATFORM_H__
00003 
00004 /* platform.h -- Platform specifics
00005 
00006   (c) 1998-2008 (W3C) MIT, ERCIM, Keio University
00007   See tidy.h for the copyright notice.
00008 
00009   CVS Info :
00010 
00011     $Author: arnaud02 $ 
00012     $Date: 2008/03/17 12:57:01 $ 
00013     $Revision: 1.66 $ 
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(__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 /* Convenience defines for Windows platforms */
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 /* not available with Metrowerks Standard Library */
00157 
00158 #ifdef SUPPORT_GETPWNAM
00159 #undef SUPPORT_GETPWNAM
00160 #endif
00161 
00162 /* needed for setmode() */
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 /* Convenience defines for Linux platforms */
00181  
00182 #if defined(linux) && defined(__alpha__)
00183 /* Linux on Alpha - gcc compiler */
00184 #define LINUX_OS
00185 #ifndef PLATFORM_NAME
00186 #define PLATFORM_NAME "Linux/Alpha"
00187 #endif
00188 
00189 #elif defined(linux) && defined(__sparc__)
00190 /* Linux on Sparc - gcc compiler */
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 /* Linux on x86 - gcc compiler */
00198 #define LINUX_OS
00199 #ifndef PLATFORM_NAME
00200 #define PLATFORM_NAME "Linux/x86"
00201 #endif
00202 
00203 #elif defined(linux) && defined(__powerpc__)
00204 /* Linux on PPC - gcc compiler */
00205 #define LINUX_OS
00206 
00207 #if defined(__linux__) && defined(__powerpc__)
00208 
00209 /* #if #system(linux) */
00210 /* MkLinux on PPC  - gcc (egcs) compiler */
00211 /* #define MAC_OS_MKLINUX */
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 /* generic Linux */
00226 #define LINUX_OS
00227 #ifndef PLATFORM_NAME
00228 #define PLATFORM_NAME "Linux"
00229 #endif
00230 
00231 #endif
00232 
00233 /* Convenience defines for Solaris platforms */
00234  
00235 #if defined(sun)
00236 #define SOLARIS_OS
00237 #ifndef PLATFORM_NAME
00238 #define PLATFORM_NAME "Solaris"
00239 #endif
00240 #endif
00241 
00242 /* Convenience defines for HPUX + gcc platforms */
00243 
00244 #if defined(__hpux)
00245 #define HPUX_OS
00246 #ifndef PLATFORM_NAME
00247 #define PLATFORM_NAME "HPUX"
00248 #endif
00249 #endif
00250 
00251 /* Convenience defines for RISCOS + gcc platforms */
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 /* Convenience defines for OS/2 + icc/gcc platforms */
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 /* Convenience defines for IRIX */
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 /* Convenience defines for AIX */
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 /* Convenience defines for BeOS platforms */
00291 
00292 #if defined(__BEOS__)
00293 #define BE_OS
00294 #ifndef PLATFORM_NAME
00295 #define PLATFORM_NAME "BeOS"
00296 #endif
00297 #endif
00298 
00299 /* Convenience defines for Cygwin platforms */
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 /* Convenience defines for OpenVMS */
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 /* Convenience defines for DEC Alpha OSF + gcc platforms */
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 /* Convenience defines for ARM platforms */
00329 
00330 #if defined(__arm)
00331 #define ARM_OS
00332 
00333 #if defined(forARM) && defined(__NEWTON_H)
00334 
00335 /* Using Newton C++ Tools ARMCpp compiler */
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>  /* for longjmp on error exit */
00354 #include <stdlib.h>
00355 #include <stdarg.h>  /* may need <varargs.h> for Unix V */
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>  /* needed for unlink on some Unix systems */
00369 #endif
00370 
00371 /* This can be set at compile time.  Usually Windows,
00372 ** except for Macintosh builds.
00373 */
00374 #ifndef DFLT_REPL_CHARENC
00375 #define DFLT_REPL_CHARENC WIN1252
00376 #endif
00377 
00378 /* By default, use case-sensitive filename comparison.
00379 */
00380 #ifndef FILENAMES_CASE_SENSITIVE
00381 #define FILENAMES_CASE_SENSITIVE 1
00382 #endif
00383 
00384 
00385 /*
00386   Tidy preserves the last modified time for the files it
00387   cleans up.
00388 */
00389 
00390 /*
00391   If your platform doesn't support <utime.h> and the
00392   utime() function, or <sys/futime> and the futime()
00393   function then set PRESERVE_FILE_TIMES to 0.
00394   
00395   If your platform doesn't support <sys/utime.h> and the
00396   futime() function, then set HAS_FUTIME to 0.
00397   
00398   If your platform supports <utime.h> and the
00399   utime() function requires the file to be
00400   closed first, then set UTIME_NEEDS_CLOSED_FILE to 1.
00401 */
00402 
00403 /* Keep old PRESERVEFILETIMES define for compatibility */
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 /* HASFUTIME */
00447 
00448 /*
00449   MS Windows needs _ prefix for Unix file functions.
00450   Not required by Metrowerks Standard Library (MSL).
00451   
00452   Tidy uses following for preserving the last modified time.
00453 
00454   WINDOWS automatically set by Win16 compilers.
00455   _WIN32 automatically set by Win32 compilers.
00456 */
00457 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
00458 
00459 #define futime _futime
00460 #define fstat _fstat
00461 #define utimbuf _utimbuf /* Windows seems to want utimbuf */
00462 #define stat _stat
00463 #define utime _utime
00464 #define vsnprintf _vsnprintf
00465 #endif /* _WIN32 */
00466 
00467 #endif /* PRESERVE_FILE_TIMES */
00468 
00469 /*
00470   MS Windows needs _ prefix for Unix file functions.
00471   Not required by Metrowerks Standard Library (MSL).
00472   
00473   WINDOWS automatically set by Win16 compilers.
00474   _WIN32 automatically set by Win32 compilers.
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 ) /* local variable is initialized but not referenced */
00488 #pragma warning( disable : 4100 ) /* unreferenced formal parameter */
00489 #pragma warning( disable : 4706 ) /* assignment within conditional expression */
00490 #endif
00491 
00492 #if _MSC_VER > 1300
00493 #pragma warning( disable : 4996 ) /* disable depreciation warning */
00494 #endif
00495 
00496 #endif /* _WIN32 */
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 /* _WIN32 */
00513 
00514 /* hack for gnu sys/types.h file which defines uint and ulong */
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 With GCC 4,  __attribute__ ((visibility("default"))) can be used along compiling with tidylib 
00530 with "-fvisibility=hidden". See http://gcc.gnu.org/wiki/Visibility and build/gmake/Makefile.
00531 */
00532 /*
00533 #if defined(__GNUC__) && __GNUC__ >= 4
00534 #define TIDY_EXPORT __attribute__ ((visibility("default")))
00535 #endif
00536 */
00537 
00538 #ifndef TIDY_EXPORT /* Define it away for most builds */
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;         /* single, full character */
00549 typedef char tmbchar;       /* single, possibly partial character */
00550 #ifndef TMBSTR_DEFINED
00551 typedef tmbchar* tmbstr;    /* pointer to buffer of possibly partial chars */
00552 typedef const tmbchar* ctmbstr; /* Ditto, but const */
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 /* HAS_VSNPRINTF triggers the use of "vsnprintf", which is safe related to
00568    buffer overflow. Therefore, we make it the default unless HAS_VSNPRINTF
00569    has been defined. */
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   bool is a reserved word in some but
00580   not all C++ compilers depending on age
00581   work around is to avoid bool altogether
00582   by introducing a new enum called Bool
00583 */
00584 /* We could use the C99 definition where supported
00585 typedef _Bool Bool;
00586 #define no (_Bool)0
00587 #define yes (_Bool)1
00588 */
00589 typedef enum
00590 {
00591    no,
00592    yes
00593 } Bool;
00594 
00595 /* for NULL pointers 
00596 #define null ((const void*)0)
00597 extern void* null;
00598 */
00599 
00600 #if defined(DMALLOC)
00601 #include "dmalloc.h"
00602 #endif
00603 
00604 /* Opaque data structure.
00605 *  Cast to implementation type struct within lib.
00606 *  This will reduce inter-dependencies/conflicts w/ application code.
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 /* Opaque data structure used to pass back
00617 ** and forth to keep current position in a
00618 ** list or other collection.
00619 */
00620 opaque_type( TidyIterator );
00621 
00622 #ifdef __cplusplus
00623 } /* extern "C" */
00624 #endif
00625 
00626 #endif /* __TIDY_PLATFORM_H__ */
00627 
00628 
00629 /*
00630  * local variables:
00631  * mode: c
00632  * indent-tabs-mode: nil
00633  * c-basic-offset: 4
00634  * eval: (c-set-offset 'substatement-open 0)
00635  * end:
00636  */