platform.h

00001 #ifndef __PLATFORM_H__
00002 #define __PLATFORM_H__
00003 
00004 /* platform.h -- Platform specifics
00005 
00006   (c) 1998-2004 (W3C) MIT, ERCIM, Keio University
00007   See tidy.h for the copyright notice.
00008 
00009   CVS Info :
00010 
00011     $Author: terry_teague $ 
00012     $Date: 2004/03/19 03:10:19 $ 
00013     $Revision: 1.49 $ 
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 #define FILENAMES_CASE_SENSITIVE 0
00166 
00167 #endif
00168 
00169 /* Convenience defines for Linux platforms */
00170  
00171 #if defined(linux) && defined(__alpha__)
00172 /* Linux on Alpha - gcc compiler */
00173 #define LINUX_OS
00174 #ifndef PLATFORM_NAME
00175 #define PLATFORM_NAME "Linux/Alpha"
00176 #endif
00177 
00178 #elif defined(linux) && defined(__sparc__)
00179 /* Linux on Sparc - gcc compiler */
00180 #define LINUX_OS
00181 #ifndef PLATFORM_NAME
00182 #define PLATFORM_NAME "Linux/Sparc"
00183 #endif
00184 
00185 #elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
00186 /* Linux on x86 - gcc compiler */
00187 #define LINUX_OS
00188 #ifndef PLATFORM_NAME
00189 #define PLATFORM_NAME "Linux/x86"
00190 #endif
00191 
00192 #elif defined(linux) && defined(__powerpc__)
00193 /* Linux on PPC - gcc compiler */
00194 #define LINUX_OS
00195 
00196 #if defined(__linux__) && defined(__powerpc__)
00197 
00198 /* #if #system(linux) */
00199 /* MkLinux on PPC  - gcc (egcs) compiler */
00200 /* #define MAC_OS_MKLINUX */
00201 #ifndef PLATFORM_NAME
00202 #define PLATFORM_NAME "MkLinux"
00203 #endif
00204 
00205 #else
00206 
00207 #ifndef PLATFORM_NAME
00208 #define PLATFORM_NAME "Linux/PPC"
00209 #endif
00210 
00211 #endif
00212 
00213 #elif defined(linux) || defined(__linux__)
00214 /* generic Linux */
00215 #define LINUX_OS
00216 #ifndef PLATFORM_NAME
00217 #define PLATFORM_NAME "Linux"
00218 #endif
00219 
00220 #endif
00221 
00222 /* Convenience defines for Solaris platforms */
00223  
00224 #if defined(sun)
00225 #define SOLARIS_OS
00226 #ifndef PLATFORM_NAME
00227 #define PLATFORM_NAME "Solaris"
00228 #endif
00229 #endif
00230 
00231 /* Convenience defines for HPUX + gcc platforms */
00232 
00233 #if defined(__hpux)
00234 #define HPUX_OS
00235 #ifndef PLATFORM_NAME
00236 #define PLATFORM_NAME "HPUX"
00237 #endif
00238 #endif
00239 
00240 /* Convenience defines for RISCOS + gcc platforms */
00241 
00242 #if defined(__riscos__)
00243 #define RISC_OS
00244 #ifndef PLATFORM_NAME
00245 #define PLATFORM_NAME "RISC OS"
00246 #endif
00247 #endif
00248 
00249 /* Convenience defines for OS/2 + icc/gcc platforms */
00250 
00251 #if defined(__OS2__) || defined(__EMX__)
00252 #define OS2_OS
00253 #ifndef PLATFORM_NAME
00254 #define PLATFORM_NAME "OS/2"
00255 #endif
00256 #define FILENAMES_CASE_SENSITIVE 0
00257 #define strcasecmp stricmp
00258 #endif
00259 
00260 /* Convenience defines for IRIX */
00261 
00262 #if defined(__sgi)
00263 #define IRIX_OS
00264 #ifndef PLATFORM_NAME
00265 #define PLATFORM_NAME "SGI IRIX"
00266 #endif
00267 #endif
00268 
00269 /* Convenience defines for AIX */
00270 
00271 #if defined(_AIX)
00272 #define AIX_OS
00273 #ifndef PLATFORM_NAME
00274 #define PLATFORM_NAME "IBM AIX"
00275 #endif
00276 #endif
00277 
00278 
00279 /* Convenience defines for BeOS platforms */
00280 
00281 #if defined(__BEOS__)
00282 #define BE_OS
00283 #ifndef PLATFORM_NAME
00284 #define PLATFORM_NAME "BeOS"
00285 #endif
00286 #endif
00287 
00288 /* Convenience defines for Cygwin platforms */
00289 
00290 #if defined(__CYGWIN__)
00291 #define CYGWIN_OS
00292 #ifndef PLATFORM_NAME
00293 #define PLATFORM_NAME "Cygwin"
00294 #endif
00295 #define FILENAMES_CASE_SENSITIVE 0
00296 #endif
00297 
00298 /* Convenience defines for OpenVMS */
00299 
00300 #if defined(__VMS)
00301 #define OPENVMS_OS
00302 #ifndef PLATFORM_NAME
00303 #define PLATFORM_NAME "OpenVMS"
00304 #endif
00305 #define FILENAMES_CASE_SENSITIVE 0
00306 #endif
00307 
00308 /* Convenience defines for DEC Alpha OSF + gcc platforms */
00309 
00310 #if defined(__osf__)
00311 #define OSF_OS
00312 #ifndef PLATFORM_NAME
00313 #define PLATFORM_NAME "DEC Alpha OSF"
00314 #endif
00315 #endif
00316 
00317 /* Convenience defines for ARM platforms */
00318 
00319 #if defined(__arm)
00320 #define ARM_OS
00321 
00322 #if defined(forARM) && defined(__NEWTON_H)
00323 
00324 /* Using Newton C++ Tools ARMCpp compiler */
00325 #define NEWTON_OS
00326 #ifndef PLATFORM_NAME
00327 #define PLATFORM_NAME "Newton"
00328 #endif
00329 
00330 #else
00331 
00332 #ifndef PLATFORM_NAME
00333 #define PLATFORM_NAME "ARM"
00334 #endif
00335 
00336 #endif
00337 
00338 #endif
00339 
00340 #include <ctype.h>
00341 #include <stdio.h>
00342 #include <setjmp.h>  /* for longjmp on error exit */
00343 #include <stdlib.h>
00344 #include <stdarg.h>  /* may need <varargs.h> for Unix V */
00345 #include <string.h>
00346 #include <assert.h>
00347 
00348 #ifdef NEEDS_MALLOC_H
00349 #include <malloc.h>
00350 #endif
00351 
00352 #ifdef SUPPORT_GETPWNAM
00353 #include <pwd.h>
00354 #endif
00355 
00356 #ifdef NEEDS_UNISTD_H
00357 #include <unistd.h>  /* needed for unlink on some Unix systems */
00358 #endif
00359 
00360 /* This can be set at compile time.  Usually Windows,
00361 ** except for Macintosh builds.
00362 */
00363 #ifndef DFLT_REPL_CHARENC
00364 #define DFLT_REPL_CHARENC WIN1252
00365 #endif
00366 
00367 /* By default, use case-sensitive filename comparison.
00368 */
00369 #ifndef FILENAMES_CASE_SENSITIVE
00370 #define FILENAMES_CASE_SENSITIVE 1
00371 #endif
00372 
00373 
00374 /*
00375   Tidy preserves the last modified time for the files it
00376   cleans up.
00377 */
00378 
00379 /*
00380   If your platform doesn't support <utime.h> and the
00381   utime() function, or <sys/futime> and the futime()
00382   function then set PRESERVE_FILE_TIMES to 0.
00383   
00384   If your platform doesn't support <sys/utime.h> and the
00385   futime() function, then set HAS_FUTIME to 0.
00386   
00387   If your platform supports <utime.h> and the
00388   utime() function requires the file to be
00389   closed first, then set UTIME_NEEDS_CLOSED_FILE to 1.
00390 */
00391 
00392 /* Keep old PRESERVEFILETIMES define for compatibility */
00393 #ifdef PRESERVEFILETIMES
00394 #undef PRESERVE_FILE_TIMES
00395 #define PRESERVE_FILE_TIMES PRESERVEFILETIMES
00396 #endif
00397 
00398 #ifndef PRESERVE_FILE_TIMES
00399 #if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS)
00400 #define PRESERVE_FILE_TIMES 0
00401 #else
00402 #define PRESERVE_FILE_TIMES 1
00403 #endif
00404 #endif
00405 
00406 #if PRESERVE_FILE_TIMES
00407 
00408 #ifndef HAS_FUTIME
00409 #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__)
00410 #define HAS_FUTIME 0
00411 #else
00412 #define HAS_FUTIME 1
00413 #endif
00414 #endif
00415 
00416 #ifndef UTIME_NEEDS_CLOSED_FILE
00417 #if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS)
00418 #define UTIME_NEEDS_CLOSED_FILE 1
00419 #else
00420 #define UTIME_NEEDS_CLOSED_FILE 0
00421 #endif
00422 #endif
00423 
00424 #if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__))
00425 #include <sys/types.h> 
00426 #include <sys/stat.h>
00427 #else
00428 #include <stat.h>
00429 #endif
00430 
00431 #if HAS_FUTIME
00432 #include <sys/utime.h>
00433 #else
00434 #include <utime.h>
00435 #endif /* HASFUTIME */
00436 
00437 /*
00438   MS Windows needs _ prefix for Unix file functions.
00439   Not required by Metrowerks Standard Library (MSL).
00440   
00441   Tidy uses following for preserving the last modified time.
00442 
00443   WINDOWS automatically set by Win16 compilers.
00444   _WIN32 automatically set by Win32 compilers.
00445 */
00446 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
00447 
00448 #define futime _futime
00449 #define fstat _fstat
00450 #define utimbuf _utimbuf /* Windows seems to want utimbuf */
00451 #define stat _stat
00452 #define utime _utime
00453 #define vsnprintf _vsnprintf
00454 #endif /* _WIN32 */
00455 
00456 #endif /* PRESERVE_FILE_TIMES */
00457 
00458 /*
00459   MS Windows needs _ prefix for Unix file functions.
00460   Not required by Metrowerks Standard Library (MSL).
00461   
00462   WINDOWS automatically set by Win16 compilers.
00463   _WIN32 automatically set by Win32 compilers.
00464 */
00465 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
00466 
00467 #ifndef __WATCOMC__
00468 #define fileno _fileno
00469 #define setmode _setmode
00470 #endif
00471 
00472 #define access _access
00473 #define strcasecmp _stricmp
00474 
00475 #if _MSC_VER > 1000
00476 #pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */
00477 #pragma warning( disable : 4100 ) /* unreferenced formal parameter */
00478 #pragma warning( disable : 4706 ) /* assignment within conditional expression */
00479 #pragma warning( disable : 4068 ) /* unknown #pragma unused(...) */
00480 #endif
00481 
00482 #endif /* _WIN32 */
00483 
00484 #if defined(_WIN32)
00485 
00486 #if (defined(_USRDLL) || defined(_WINDLL)) && !defined(TIDY_EXPORT)
00487 #define TIDY_EXPORT __declspec( dllexport ) 
00488 #endif
00489 
00490 #endif /* _WIN32 */
00491 
00492 /* hack for gnu sys/types.h file which defines uint and ulong */
00493 
00494 #if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
00495 #include <sys/types.h>
00496 #endif
00497 #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)
00498 typedef unsigned int uint;
00499 #endif
00500 #if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
00501 typedef unsigned long ulong;
00502 #endif
00503 
00504 #ifndef TIDY_EXPORT /* Define it away for most builds */
00505 #define TIDY_EXPORT
00506 #endif
00507 
00508 #ifndef TIDY_STRUCT
00509 #define TIDY_STRUCT
00510 #endif
00511 
00512 typedef unsigned char byte;
00513 
00514 typedef uint tchar;         /* single, full character */
00515 typedef char tmbchar;       /* single, possibly partial character */
00516 #ifndef TMBSTR_DEFINED
00517 typedef tmbchar* tmbstr;    /* pointer to buffer of possibly partial chars */
00518 typedef const tmbchar* ctmbstr; /* Ditto, but const */
00519 #define NULLSTR (tmbstr)""
00520 #define TMBSTR_DEFINED
00521 #endif
00522 
00523            
00524 /*
00525   bool is a reserved word in some but
00526   not all C++ compilers depending on age
00527   work around is to avoid bool altogether
00528   by introducing a new enum called Bool
00529 */
00530 typedef enum
00531 {
00532    no,
00533    yes
00534 } Bool;
00535 
00536 /* for NULL pointers 
00537 #define null ((const void*)0)
00538 extern void* null;
00539 */
00540 
00541 #if defined(DMALLOC)
00542 #include "dmalloc.h"
00543 #endif
00544 
00545 void *MemAlloc(size_t size);
00546 void *MemRealloc(void *mem, size_t newsize);
00547 void MemFree(void *mem);
00548 void ClearMemory(void *, size_t size);
00549 void FatalError( ctmbstr msg );
00550 
00551 /* Opaque data structure.
00552 *  Cast to implementation type struct within lib.
00553 *  This will reduce inter-dependencies/conflicts w/ application code.
00554 */
00555 #if 1
00556 /*
00557 *  Please note - this definition assumes your compiler uses 'int' for enums.
00558 */
00559 #define opaque_type( typenam )\
00560 struct _##typenam { int _opaque; };\
00561 typedef struct _##typenam* typenam
00562 #else
00563 #define opaque_type(typenam) typedef void* typenam
00564 #endif
00565 
00566 /* Opaque data structure used to pass back
00567 ** and forth to keep current position in a
00568 ** list or other collection.
00569 */
00570 opaque_type( TidyIterator );
00571 
00572 #ifdef __cplusplus
00573 } /* extern "C" */
00574 #endif
00575 
00576 #endif /* __PLATFORM_H__ */

Generated on Tue May 24 15:39:30 2005 for HTML Tidy by  doxygen 1.4.2