#ifndef __PLATFORM_H__
#define __PLATFORM_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SUPPORT_ASIAN_ENCODINGS
#define SUPPORT_ASIAN_ENCODINGS 1
#endif
#ifndef SUPPORT_UTF16_ENCODINGS
#define SUPPORT_UTF16_ENCODINGS 1
#endif
#ifndef SUPPORT_ACCESSIBILITY_CHECKS
#define SUPPORT_ACCESSIBILITY_CHECKS 1
#endif
#ifndef TIDY_APPLE_CHANGES
#define TIDY_APPLE_CHANGES 1
#endif
#if defined(macintosh)
#define MAC_OS_CLASSIC
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Mac OS"
#endif
#if !defined(_POSIX) && !defined(NO_ACCESS_SUPPORT)
#define NO_ACCESS_SUPPORT
#endif
#ifdef SUPPORT_GETPWNAM
#undef SUPPORT_GETPWNAM
#endif
#elif defined(__APPLE__) && defined(__MACH__)
#define MAC_OS_X
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Mac OS X"
#endif
#endif
#if defined(TIDY_APPLE_CHANGES)
#if defined(MAC_OS_X)
#define HAS_VSNPRINTF 1
#ifndef DFLT_REPL_CHARENC
#define DFLT_REPL_CHARENC WIN1252
#endif
#endif
#endif
#if defined(MAC_OS_CLASSIC) || defined(MAC_OS_X)
#define MAC_OS
#define FILENAMES_CASE_SENSITIVE 0
#define strcasecmp strcmp
#ifndef DFLT_REPL_CHARENC
#define DFLT_REPL_CHARENC MACROMAN
#endif
#endif
#if defined(__FreeBSD__)
#define BSD_BASED_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "FreeBSD"
#endif
#elif defined(__NetBSD__)
#define BSD_BASED_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "NetBSD"
#endif
#elif defined(__OpenBSD__)
#define BSD_BASED_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "OpenBSD"
#endif
#elif defined(__MINT__)
#define BSD_BASED_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "FreeMiNT"
#endif
#elif defined(__bsdi__)
#define BSD_BASED_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "BSD/OS"
#endif
#endif
#if defined(WINDOWS) || defined(_WIN32)
#define WINDOWS_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Windows"
#endif
#if defined(__MWERKS__) || defined(__MSL__)
#ifdef SUPPORT_GETPWNAM
#undef SUPPORT_GETPWNAM
#endif
#if !defined(NO_SETMODE_SUPPORT)
#define NO_SETMODE_SUPPORT
#endif
#define strcasecmp _stricmp
#endif
#if defined(__BORLANDC__)
#define strcasecmp stricmp
#endif
#define FILENAMES_CASE_SENSITIVE 0
#endif
#if defined(linux) && defined(__alpha__)
#define LINUX_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Linux/Alpha"
#endif
#elif defined(linux) && defined(__sparc__)
#define LINUX_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Linux/Sparc"
#endif
#elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
#define LINUX_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Linux/x86"
#endif
#elif defined(linux) && defined(__powerpc__)
#define LINUX_OS
#if defined(__linux__) && defined(__powerpc__)
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "MkLinux"
#endif
#else
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Linux/PPC"
#endif
#endif
#elif defined(linux) || defined(__linux__)
#define LINUX_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Linux"
#endif
#endif
#if defined(sun)
#define SOLARIS_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Solaris"
#endif
#endif
#if defined(__hpux)
#define HPUX_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "HPUX"
#endif
#endif
#if defined(__riscos__)
#define RISC_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "RISC OS"
#endif
#endif
#if defined(__OS2__) || defined(__EMX__)
#define OS2_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "OS/2"
#endif
#define FILENAMES_CASE_SENSITIVE 0
#define strcasecmp stricmp
#endif
#if defined(__sgi)
#define IRIX_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "SGI IRIX"
#endif
#endif
#if defined(_AIX)
#define AIX_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "IBM AIX"
#endif
#endif
#if defined(__BEOS__)
#define BE_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "BeOS"
#endif
#endif
#if defined(__CYGWIN__)
#define CYGWIN_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Cygwin"
#endif
#define FILENAMES_CASE_SENSITIVE 0
#endif
#if defined(__VMS)
#define OPENVMS_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "OpenVMS"
#endif
#define FILENAMES_CASE_SENSITIVE 0
#endif
#if defined(__osf__)
#define OSF_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "DEC Alpha OSF"
#endif
#endif
#if defined(__arm)
#define ARM_OS
#if defined(forARM) && defined(__NEWTON_H)
#define NEWTON_OS
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "Newton"
#endif
#else
#ifndef PLATFORM_NAME
#define PLATFORM_NAME "ARM"
#endif
#endif
#endif
#include <ctype.h>
#include <stdio.h>
#include <setjmp.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#ifdef NEEDS_MALLOC_H
#include <malloc.h>
#endif
#ifdef SUPPORT_GETPWNAM
#include <pwd.h>
#endif
#ifdef NEEDS_UNISTD_H
#include <unistd.h>
#endif
#ifndef DFLT_REPL_CHARENC
#define DFLT_REPL_CHARENC WIN1252
#endif
#ifndef FILENAMES_CASE_SENSITIVE
#define FILENAMES_CASE_SENSITIVE 1
#endif
#ifdef PRESERVEFILETIMES
#undef PRESERVE_FILE_TIMES
#define PRESERVE_FILE_TIMES PRESERVEFILETIMES
#endif
#ifndef PRESERVE_FILE_TIMES
#if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS)
#define PRESERVE_FILE_TIMES 0
#else
#define PRESERVE_FILE_TIMES 1
#endif
#endif
#if PRESERVE_FILE_TIMES
#ifndef HAS_FUTIME
#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__)
#define HAS_FUTIME 0
#else
#define HAS_FUTIME 1
#endif
#endif
#ifndef UTIME_NEEDS_CLOSED_FILE
#if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS)
#define UTIME_NEEDS_CLOSED_FILE 1
#else
#define UTIME_NEEDS_CLOSED_FILE 0
#endif
#endif
#if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__))
#include <sys/types.h>
#include <sys/stat.h>
#else
#include <stat.h>
#endif
#if HAS_FUTIME
#include <sys/utime.h>
#else
#include <utime.h>
#endif
#if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
#define futime _futime
#define fstat _fstat
#define utimbuf _utimbuf
#define stat _stat
#define utime _utime
#define vsnprintf _vsnprintf
#endif
#endif
#if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
#ifndef __WATCOMC__
#define fileno _fileno
#define setmode _setmode
#endif
#define access _access
#define strcasecmp _stricmp
#if _MSC_VER > 1000
#pragma warning( disable : 4189 )
#pragma warning( disable : 4100 )
#pragma warning( disable : 4706 )
#endif
#endif
#if defined(_WIN32)
#if (defined(_USRDLL) || defined(_WINDLL)) && !defined(TIDY_EXPORT)
#define TIDY_EXPORT __declspec( dllexport )
#endif
#ifndef TIDY_CALL
#ifdef _WIN64
# define TIDY_CALL __fastcall
#else
# define TIDY_CALL __stdcall
#endif
#endif
#endif
#if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
#include <sys/types.h>
#endif
#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)
# undef uint
typedef unsigned int uint;
#endif
#if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
# undef ulong
typedef unsigned long ulong;
#endif
#ifndef TIDY_EXPORT
#define TIDY_EXPORT
#endif
#ifndef TIDY_STRUCT
#define TIDY_STRUCT
#endif
typedef unsigned char byte;
typedef uint tchar;
typedef char tmbchar;
#ifndef TMBSTR_DEFINED
typedef tmbchar* tmbstr;
typedef const tmbchar* ctmbstr;
#define NULLSTR (tmbstr)""
#define TMBSTR_DEFINED
#endif
#ifndef TIDY_CALL
#define TIDY_CALL
#endif
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
# define ARG_UNUSED(x) x __attribute__((unused))
#else
# define ARG_UNUSED(x) x
#endif
#ifndef HAS_VSNPRINTF
# define HAS_VSNPRINTF 1
#endif
typedef enum
{
no,
yes
} Bool;
#if defined(DMALLOC)
#include "dmalloc.h"
#endif
void *MemAlloc(size_t size);
void *MemRealloc(void *mem, size_t newsize);
void MemFree(void *mem);
void ClearMemory(void *, size_t size);
void FatalError( ctmbstr msg );
#if 1
#define opaque_type( typenam )\
struct _##typenam { int _opaque; };\
typedef struct _##typenam* typenam
#else
#define opaque_type(typenam) typedef void* typenam
#endif
opaque_type( TidyIterator );
#ifdef __cplusplus
}
#endif
#endif