home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Comm / www / tidy_os4.lha / tidy / include / platform.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-07-29  |  12.9 KB  |  595 lines

  1. #ifndef __PLATFORM_H__
  2. #define __PLATFORM_H__
  3.  
  4. /* platform.h -- Platform specifics
  5.  
  6.   (c) 1998-2004 (W3C) MIT, ERCIM, Keio University
  7.   See tidy.h for the copyright notice.
  8.  
  9.   CVS Info :
  10.  
  11.     $Author: terry_teague $ 
  12.     $Date: 2004/03/19 03:10:19 $ 
  13.     $Revision: 1.49 $ 
  14.  
  15.   Extended for AmigaOS by E.Schwan 29.07.2004
  16.  
  17. */
  18.  
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22.  
  23. /*
  24.   Uncomment and edit one of the following #defines if you
  25.   want to specify the config file at compile-time.
  26. */
  27.  
  28. #if defined(__amigaos__) /*AmigaOS only */
  29. #define CONFIG_FILE "PROGDIR:tidy_config.txt"
  30. #else
  31. #define CONFIG_FILE "/etc/tidy_config.txt" /* original */
  32. /* #define CONFIG_FILE "/etc/tidyrc" */
  33. /* #define CONFIG_FILE "/etc/tidy.conf" */
  34. #endif
  35.  
  36. /*
  37.   Uncomment the following #define if you are on a system
  38.   supporting the HOME environment variable.
  39.   It enables tidy to find config files named ~/.tidyrc if 
  40.   the HTML_TIDY environment variable is not set.
  41. */
  42. /* #define USER_CONFIG_FILE "~/.tidyrc" */
  43.  
  44. /*
  45.   Uncomment the following #define if your
  46.   system supports the call getpwnam(). 
  47.   E.g. Unix and Linux.
  48.  
  49.   It enables tidy to find files named 
  50.   ~your/foo for use in the HTML_TIDY environment
  51.   variable or CONFIG_FILE or USER_CONFIGFILE or
  52.   on the command line: -config ~joebob/tidy.cfg
  53.  
  54.   Contributed by Todd Lewis.
  55. */
  56.  
  57. /* #define SUPPORT_GETPWNAM */
  58.  
  59.  
  60. /* Enable/disable support for Big5 and Shift_JIS character encodings */
  61. #ifndef SUPPORT_ASIAN_ENCODINGS
  62. #define SUPPORT_ASIAN_ENCODINGS 1
  63. #endif
  64.  
  65. /* Enable/disable support for UTF-16 character encodings */
  66. #ifndef SUPPORT_UTF16_ENCODINGS
  67. #define SUPPORT_UTF16_ENCODINGS 1
  68. #endif
  69.  
  70. /* Enable/disable support for additional accessibility checks */
  71. #ifndef SUPPORT_ACCESSIBILITY_CHECKS
  72. #define SUPPORT_ACCESSIBILITY_CHECKS 1
  73. #endif
  74.  
  75.  
  76. /* Convenience defines for Mac platforms */
  77.  
  78. #if defined(macintosh)
  79. /* Mac OS 6.x/7.x/8.x/9.x, with or without CarbonLib - MPW or Metrowerks 68K/PPC compilers */
  80. #define MAC_OS_CLASSIC
  81. #ifndef PLATFORM_NAME
  82. #define PLATFORM_NAME "Mac OS"
  83. #endif
  84.  
  85. /* needed for access() */
  86. #if !defined(_POSIX) && !defined(NO_ACCESS_SUPPORT)
  87. #define NO_ACCESS_SUPPORT
  88. #endif
  89.  
  90. #ifdef SUPPORT_GETPWNAM
  91. #undef SUPPORT_GETPWNAM
  92. #endif
  93.  
  94. #elif defined(__APPLE__) && defined(__MACH__)
  95. /* Mac OS X (client) 10.x (or server 1.x/10.x) - gcc or Metrowerks MachO compilers */
  96. #define MAC_OS_X
  97. #ifndef PLATFORM_NAME
  98. #define PLATFORM_NAME "Mac OS X"
  99. #endif
  100. #endif
  101.  
  102. #if defined(MAC_OS_CLASSIC) || defined(MAC_OS_X)
  103. /* Any OS on Mac platform */
  104. #define MAC_OS
  105. #define FILENAMES_CASE_SENSITIVE 0
  106. #define strcasecmp strcmp
  107. #ifndef DFLT_REPL_CHARENC
  108. #define DFLT_REPL_CHARENC MACROMAN
  109. #endif
  110. #endif
  111.  
  112. /* Convenience defines for BSD like platforms */
  113.  
  114. #if defined(__FreeBSD__)
  115. #define BSD_BASED_OS
  116. #ifndef PLATFORM_NAME
  117. #define PLATFORM_NAME "FreeBSD"
  118. #endif
  119.  
  120. #elif defined(__NetBSD__)
  121. #define BSD_BASED_OS
  122. #ifndef PLATFORM_NAME
  123. #define PLATFORM_NAME "NetBSD"
  124. #endif
  125.  
  126. #elif defined(__OpenBSD__)
  127. #define BSD_BASED_OS
  128. #ifndef PLATFORM_NAME
  129. #define PLATFORM_NAME "OpenBSD"
  130. #endif
  131.  
  132. #elif defined(__MINT__)
  133. #define BSD_BASED_OS
  134. #ifndef PLATFORM_NAME
  135. #define PLATFORM_NAME "FreeMiNT"
  136. #endif
  137.  
  138. #elif defined(__bsdi__)
  139. #define BSD_BASED_OS
  140. #ifndef PLATFORM_NAME
  141. #define PLATFORM_NAME "BSD/OS"
  142. #endif
  143.  
  144. #elif defined(__amigaos__)
  145. #define BSD_BASED_OS
  146. #ifndef PLATFORM_NAME
  147. #ifdef __amigaos4__
  148. #define PLATFORM_NAME "AmigaOS 4"
  149. typedef unsigned int uint;
  150. #define HAS_FUTIME 0
  151. #else // __amigaos4__
  152. #define PLATFORM_NAME "AmigaOS"
  153. #endif // __amigaos4__
  154. #endif
  155.  
  156. #endif
  157.  
  158. /* Convenience defines for Windows platforms */
  159.  
  160. #if defined(WINDOWS) || defined(_WIN32)
  161.  
  162. #define WINDOWS_OS
  163. #ifndef PLATFORM_NAME
  164. #define PLATFORM_NAME "Windows"
  165. #endif
  166.  
  167. #if defined(__MWERKS__) || defined(__MSL__)
  168. /* not available with Metrowerks Standard Library */
  169.  
  170. #ifdef SUPPORT_GETPWNAM
  171. #undef SUPPORT_GETPWNAM
  172. #endif
  173.  
  174. /* needed for setmode() */
  175. #if !defined(NO_SETMODE_SUPPORT)
  176. #define NO_SETMODE_SUPPORT
  177. #endif
  178.  
  179. #define strcasecmp _stricmp
  180.  
  181. #endif
  182.  
  183. #define FILENAMES_CASE_SENSITIVE 0
  184.  
  185. #endif
  186.  
  187. /* Convenience defines for Linux platforms */
  188.  
  189. #if defined(linux) && defined(__alpha__)
  190. /* Linux on Alpha - gcc compiler */
  191. #define LINUX_OS
  192. #ifndef PLATFORM_NAME
  193. #define PLATFORM_NAME "Linux/Alpha"
  194. #endif
  195.  
  196. #elif defined(linux) && defined(__sparc__)
  197. /* Linux on Sparc - gcc compiler */
  198. #define LINUX_OS
  199. #ifndef PLATFORM_NAME
  200. #define PLATFORM_NAME "Linux/Sparc"
  201. #endif
  202.  
  203. #elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
  204. /* Linux on x86 - gcc compiler */
  205. #define LINUX_OS
  206. #ifndef PLATFORM_NAME
  207. #define PLATFORM_NAME "Linux/x86"
  208. #endif
  209.  
  210. #elif defined(linux) && defined(__powerpc__)
  211. /* Linux on PPC - gcc compiler */
  212. #define LINUX_OS
  213.  
  214. #if defined(__linux__) && defined(__powerpc__)
  215.  
  216. /* #if #system(linux) */
  217. /* MkLinux on PPC  - gcc (egcs) compiler */
  218. /* #define MAC_OS_MKLINUX */
  219. #ifndef PLATFORM_NAME
  220. #define PLATFORM_NAME "MkLinux"
  221. #endif
  222.  
  223. #else
  224.  
  225. #ifndef PLATFORM_NAME
  226. #define PLATFORM_NAME "Linux/PPC"
  227. #endif
  228.  
  229. #endif
  230.  
  231. #elif defined(linux) || defined(__linux__)
  232. /* generic Linux */
  233. #define LINUX_OS
  234. #ifndef PLATFORM_NAME
  235. #define PLATFORM_NAME "Linux"
  236. #endif
  237.  
  238. #endif
  239.  
  240. /* Convenience defines for Solaris platforms */
  241.  
  242. #if defined(sun)
  243. #define SOLARIS_OS
  244. #ifndef PLATFORM_NAME
  245. #define PLATFORM_NAME "Solaris"
  246. #endif
  247. #endif
  248.  
  249. /* Convenience defines for HPUX + gcc platforms */
  250.  
  251. #if defined(__hpux)
  252. #define HPUX_OS
  253. #ifndef PLATFORM_NAME
  254. #define PLATFORM_NAME "HPUX"
  255. #endif
  256. #endif
  257.  
  258. /* Convenience defines for RISCOS + gcc platforms */
  259.  
  260. #if defined(__riscos__)
  261. #define RISC_OS
  262. #ifndef PLATFORM_NAME
  263. #define PLATFORM_NAME "RISC OS"
  264. #endif
  265. #endif
  266.  
  267. /* Convenience defines for OS/2 + icc/gcc platforms */
  268.  
  269. #if defined(__OS2__) || defined(__EMX__)
  270. #define OS2_OS
  271. #ifndef PLATFORM_NAME
  272. #define PLATFORM_NAME "OS/2"
  273. #endif
  274. #define FILENAMES_CASE_SENSITIVE 0
  275. #define strcasecmp stricmp
  276. #endif
  277.  
  278. /* Convenience defines for IRIX */
  279.  
  280. #if defined(__sgi)
  281. #define IRIX_OS
  282. #ifndef PLATFORM_NAME
  283. #define PLATFORM_NAME "SGI IRIX"
  284. #endif
  285. #endif
  286.  
  287. /* Convenience defines for AIX */
  288.  
  289. #if defined(_AIX)
  290. #define AIX_OS
  291. #ifndef PLATFORM_NAME
  292. #define PLATFORM_NAME "IBM AIX"
  293. #endif
  294. #endif
  295.  
  296.  
  297. /* Convenience defines for BeOS platforms */
  298.  
  299. #if defined(__BEOS__)
  300. #define BE_OS
  301. #ifndef PLATFORM_NAME
  302. #define PLATFORM_NAME "BeOS"
  303. #endif
  304. #endif
  305.  
  306. /* Convenience defines for Cygwin platforms */
  307.  
  308. #if defined(__CYGWIN__)
  309. #define CYGWIN_OS
  310. #ifndef PLATFORM_NAME
  311. #define PLATFORM_NAME "Cygwin"
  312. #endif
  313. #define FILENAMES_CASE_SENSITIVE 0
  314. #endif
  315.  
  316. /* Convenience defines for OpenVMS */
  317.  
  318. #if defined(__VMS)
  319. #define OPENVMS_OS
  320. #ifndef PLATFORM_NAME
  321. #define PLATFORM_NAME "OpenVMS"
  322. #endif
  323. #define FILENAMES_CASE_SENSITIVE 0
  324. #endif
  325.  
  326. /* Convenience defines for DEC Alpha OSF + gcc platforms */
  327.  
  328. #if defined(__osf__)
  329. #define OSF_OS
  330. #ifndef PLATFORM_NAME
  331. #define PLATFORM_NAME "DEC Alpha OSF"
  332. #endif
  333. #endif
  334.  
  335. /* Convenience defines for ARM platforms */
  336.  
  337. #if defined(__arm)
  338. #define ARM_OS
  339.  
  340. #if defined(forARM) && defined(__NEWTON_H)
  341.  
  342. /* Using Newton C++ Tools ARMCpp compiler */
  343. #define NEWTON_OS
  344. #ifndef PLATFORM_NAME
  345. #define PLATFORM_NAME "Newton"
  346. #endif
  347.  
  348. #else
  349.  
  350. #ifndef PLATFORM_NAME
  351. #define PLATFORM_NAME "ARM"
  352. #endif
  353.  
  354. #endif
  355.  
  356. #endif
  357.  
  358. #include <ctype.h>
  359. #include <stdio.h>
  360. #include <setjmp.h>  /* for longjmp on error exit */
  361. #include <stdlib.h>
  362. #include <stdarg.h>  /* may need <varargs.h> for Unix V */
  363. #include <string.h>
  364. #include <assert.h>
  365.  
  366. #ifdef NEEDS_MALLOC_H
  367. #include <malloc.h>
  368. #endif
  369.  
  370. #ifdef SUPPORT_GETPWNAM
  371. #include <pwd.h>
  372. #endif
  373.  
  374. #ifdef NEEDS_UNISTD_H
  375. #include <unistd.h>  /* needed for unlink on some Unix systems */
  376. #endif
  377.  
  378. /* This can be set at compile time.  Usually Windows,
  379. ** except for Macintosh builds.
  380. */
  381. #ifndef DFLT_REPL_CHARENC
  382. #define DFLT_REPL_CHARENC WIN1252
  383. #endif
  384.  
  385. /* By default, use case-sensitive filename comparison.
  386. */
  387. #ifndef FILENAMES_CASE_SENSITIVE
  388. #define FILENAMES_CASE_SENSITIVE 1
  389. #endif
  390.  
  391.  
  392. /*
  393.   Tidy preserves the last modified time for the files it
  394.   cleans up.
  395. */
  396.  
  397. /*
  398.   If your platform doesn't support <utime.h> and the
  399.   utime() function, or <sys/futime> and the futime()
  400.   function then set PRESERVE_FILE_TIMES to 0.
  401.   
  402.   If your platform doesn't support <sys/utime.h> and the
  403.   futime() function, then set HAS_FUTIME to 0.
  404.   
  405.   If your platform supports <utime.h> and the
  406.   utime() function requires the file to be
  407.   closed first, then set UTIME_NEEDS_CLOSED_FILE to 1.
  408. */
  409.  
  410. /* Keep old PRESERVEFILETIMES define for compatibility */
  411. #ifdef PRESERVEFILETIMES
  412. #undef PRESERVE_FILE_TIMES
  413. #define PRESERVE_FILE_TIMES PRESERVEFILETIMES
  414. #endif
  415.  
  416. #ifndef PRESERVE_FILE_TIMES
  417. #if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS)
  418. #define PRESERVE_FILE_TIMES 0
  419. #else
  420. #define PRESERVE_FILE_TIMES 1
  421. #endif
  422. #endif
  423.  
  424. #if PRESERVE_FILE_TIMES
  425.  
  426. #ifndef HAS_FUTIME
  427. #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__)
  428. #define HAS_FUTIME 0
  429. #else
  430. #define HAS_FUTIME 1
  431. #endif
  432. #endif
  433.  
  434. #ifndef UTIME_NEEDS_CLOSED_FILE
  435. #if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS)
  436. #define UTIME_NEEDS_CLOSED_FILE 1
  437. #else
  438. #define UTIME_NEEDS_CLOSED_FILE 0
  439. #endif
  440. #endif
  441.  
  442. #if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__))
  443. #include <sys/types.h> 
  444. #include <sys/stat.h>
  445. #else
  446. #include <stat.h>
  447. #endif
  448.  
  449. #if HAS_FUTIME
  450. #include <sys/utime.h>
  451. #else
  452. #include <utime.h>
  453. #endif /* HASFUTIME */
  454.  
  455. /*
  456.   MS Windows needs _ prefix for Unix file functions.
  457.   Not required by Metrowerks Standard Library (MSL).
  458.   
  459.   Tidy uses following for preserving the last modified time.
  460.  
  461.   WINDOWS automatically set by Win16 compilers.
  462.   _WIN32 automatically set by Win32 compilers.
  463. */
  464. #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
  465.  
  466. #define futime _futime
  467. #define fstat _fstat
  468. #define utimbuf _utimbuf /* Windows seems to want utimbuf */
  469. #define stat _stat
  470. #define utime _utime
  471. #define vsnprintf _vsnprintf
  472. #endif /* _WIN32 */
  473.  
  474. #endif /* PRESERVE_FILE_TIMES */
  475.  
  476. /*
  477.   MS Windows needs _ prefix for Unix file functions.
  478.   Not required by Metrowerks Standard Library (MSL).
  479.   
  480.   WINDOWS automatically set by Win16 compilers.
  481.   _WIN32 automatically set by Win32 compilers.
  482. */
  483. #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
  484.  
  485. #ifndef __WATCOMC__
  486. #define fileno _fileno
  487. #define setmode _setmode
  488. #endif
  489.  
  490. #define access _access
  491. #define strcasecmp _stricmp
  492.  
  493. #if _MSC_VER > 1000
  494. #pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */
  495. #pragma warning( disable : 4100 ) /* unreferenced formal parameter */
  496. #pragma warning( disable : 4706 ) /* assignment within conditional expression */
  497. #pragma warning( disable : 4068 ) /* unknown #pragma unused(...) */
  498. #endif
  499.  
  500. #endif /* _WIN32 */
  501.  
  502. #if defined(_WIN32)
  503.  
  504. #if (defined(_USRDLL) || defined(_WINDLL)) && !defined(TIDY_EXPORT)
  505. #define TIDY_EXPORT __declspec( dllexport ) 
  506. #endif
  507.  
  508. #endif /* _WIN32 */
  509.  
  510. /* hack for gnu sys/types.h file which defines uint and ulong */
  511.  
  512. #if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
  513. #include <sys/types.h>
  514. #endif
  515. #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)
  516. typedef unsigned int uint;
  517. #endif
  518. #if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
  519. typedef unsigned long ulong;
  520. #endif
  521.  
  522. #ifndef TIDY_EXPORT /* Define it away for most builds */
  523. #define TIDY_EXPORT
  524. #endif
  525.  
  526. #ifndef TIDY_STRUCT
  527. #define TIDY_STRUCT
  528. #endif
  529.  
  530. typedef unsigned char byte;
  531.  
  532. typedef uint tchar;         /* single, full character */
  533. typedef char tmbchar;       /* single, possibly partial character */
  534. #ifndef TMBSTR_DEFINED
  535. typedef tmbchar* tmbstr;    /* pointer to buffer of possibly partial chars */
  536. typedef const tmbchar* ctmbstr; /* Ditto, but const */
  537. #define NULLSTR (tmbstr)""
  538. #define TMBSTR_DEFINED
  539. #endif
  540.  
  541.            
  542. /*
  543.   bool is a reserved word in some but
  544.   not all C++ compilers depending on age
  545.   work around is to avoid bool altogether
  546.   by introducing a new enum called Bool
  547. */
  548. typedef enum
  549. {
  550.    no,
  551.    yes
  552. } Bool;
  553.  
  554. /* for NULL pointers 
  555. #define null ((const void*)0)
  556. extern void* null;
  557. */
  558.  
  559. #if defined(DMALLOC)
  560. #include "dmalloc.h"
  561. #endif
  562.  
  563. void *MemAlloc(size_t size);
  564. void *MemRealloc(void *mem, size_t newsize);
  565. void MemFree(void *mem);
  566. void ClearMemory(void *, size_t size);
  567. void FatalError( ctmbstr msg );
  568.  
  569. /* Opaque data structure.
  570. *  Cast to implementation type struct within lib.
  571. *  This will reduce inter-dependencies/conflicts w/ application code.
  572. */
  573. #if 1
  574. /*
  575. *  Please note - this definition assumes your compiler uses 'int' for enums.
  576. */
  577. #define opaque_type( typenam )\
  578. struct _##typenam { int _opaque; };\
  579. typedef struct _##typenam* typenam
  580. #else
  581. #define opaque_type(typenam) typedef void* typenam
  582. #endif
  583.  
  584. /* Opaque data structure used to pass back
  585. ** and forth to keep current position in a
  586. ** list or other collection.
  587. */
  588. opaque_type( TidyIterator );
  589.  
  590. #ifdef __cplusplus
  591. } /* extern "C" */
  592. #endif
  593.  
  594. #endif /* __PLATFORM_H__ */
  595.