1 #ifndef __TIDY_PLATFORM_H__
2 #define __TIDY_PLATFORM_H__
46 #if defined(TIDY_ENABLE_CONFIG_FILES)
47 # if !defined(TIDY_CONFIG_FILE)
48 # define TIDY_CONFIG_FILE "/etc/tidy.conf"
50 # if !defined(TIDY_USER_CONFIG_FILE)
51 # define TIDY_USER_CONFIG_FILE "~/.tidyrc"
54 # if defined(TIDY_CONFIG_FILE)
55 # undef TIDY_CONFIG_FILE
57 # if defined(TIDY_USER_CONFIG_FILE)
58 # undef TIDY_USER_CONFIG_FILE
81 #ifndef SUPPORT_LOCALIZATIONS
82 # define SUPPORT_LOCALIZATIONS 1
86 #ifndef SUPPORT_CONSOLE_APP
87 # define SUPPORT_CONSOLE_APP 1
97 #if defined(macintosh)
99 # define MAC_OS_CLASSIC
100 # ifndef PLATFORM_NAME
101 # define PLATFORM_NAME "Mac OS"
105 # if !defined(_POSIX) && !defined(NO_ACCESS_SUPPORT)
106 # define NO_ACCESS_SUPPORT
109 # ifdef SUPPORT_GETPWNAM
110 # undef SUPPORT_GETPWNAM
113 #elif defined(__APPLE__) && defined(__MACH__)
116 # ifndef PLATFORM_NAME
117 # include "TargetConditionals.h"
119 # define PLATFORM_NAME "Apple iOS"
121 # define PLATFORM_NAME "Apple macOS"
123 # define PLATFORM_NAME "Apple tvOS"
124 # elif TARGET_OS_WATCH
125 # define PLATFORM_NAME "Apple watchOS"
127 # define PLATFORM_NAME "Apple Unknown OS"
132 #if defined(MAC_OS_CLASSIC) || defined(MAC_OS_X)
135 # define FILENAMES_CASE_SENSITIVE 0
136 # define strcasecmp strcmp
141 #if defined(__FreeBSD__)
142 # define BSD_BASED_OS
143 # ifndef PLATFORM_NAME
144 # define PLATFORM_NAME "FreeBSD"
147 #elif defined(__NetBSD__)
148 # define BSD_BASED_OS
149 # ifndef PLATFORM_NAME
150 # define PLATFORM_NAME "NetBSD"
153 #elif defined(__OpenBSD__)
154 # define BSD_BASED_OS
155 # ifndef PLATFORM_NAME
156 # define PLATFORM_NAME "OpenBSD"
159 #elif defined(__DragonFly__)
160 # define BSD_BASED_OS
161 # ifndef PLATFORM_NAME
162 # define PLATFORM_NAME "DragonFly"
165 #elif defined(__MINT__)
166 # define BSD_BASED_OS
167 # ifndef PLATFORM_NAME
168 # define PLATFORM_NAME "FreeMiNT"
171 #elif defined(__bsdi__)
172 # define BSD_BASED_OS
173 # ifndef PLATFORM_NAME
174 # define PLATFORM_NAME "BSD/OS"
180 #if defined(WINDOWS) || defined(_WIN32)
183 # ifndef PLATFORM_NAME
184 # define PLATFORM_NAME "Windows"
187 # if defined(__MWERKS__) || defined(__MSL__)
189 # ifdef SUPPORT_GETPWNAM
190 # undef SUPPORT_GETPWNAM
193 # if !defined(NO_SETMODE_SUPPORT)
194 # define NO_SETMODE_SUPPORT
196 # define strcasecmp _stricmp
199 # if defined(__BORLANDC__)
200 # define strcasecmp stricmp
203 # define FILENAMES_CASE_SENSITIVE 0
204 # define SUPPORT_POSIX_MAPPED_FILES 0
210 #if defined(linux) && defined(__alpha__)
213 # ifndef PLATFORM_NAME
214 # define PLATFORM_NAME "Linux/Alpha"
217 #elif defined(linux) && defined(__sparc__)
220 # ifndef PLATFORM_NAME
221 # define PLATFORM_NAME "Linux/Sparc"
224 #elif defined(linux) && (defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__))
227 # ifndef PLATFORM_NAME
228 # define PLATFORM_NAME "Linux/x86"
231 #elif defined(linux) && defined(__powerpc__)
234 # if defined(__linux__) && defined(__powerpc__)
235 # ifndef PLATFORM_NAME
237 # define PLATFORM_NAME "MkLinux"
240 # ifndef PLATFORM_NAME
241 # define PLATFORM_NAME "Linux/PPC"
245 #elif defined(linux) || defined(__linux__)
248 # ifndef PLATFORM_NAME
249 # define PLATFORM_NAME "Linux"
257 # ifndef PLATFORM_NAME
258 # define PLATFORM_NAME "Solaris"
266 # ifndef PLATFORM_NAME
267 # define PLATFORM_NAME "HPUX"
273 #if defined(__riscos__)
275 # ifndef PLATFORM_NAME
276 # define PLATFORM_NAME "RISC OS"
282 #if defined(__OS2__) || defined(__EMX__)
284 # ifndef PLATFORM_NAME
285 # define PLATFORM_NAME "OS/2"
287 # define FILENAMES_CASE_SENSITIVE 0
288 # define strcasecmp stricmp
295 # ifndef PLATFORM_NAME
296 # define PLATFORM_NAME "SGI IRIX"
304 # ifndef PLATFORM_NAME
305 # define PLATFORM_NAME "IBM AIX"
311 #if defined(__BEOS__)
313 # ifndef PLATFORM_NAME
314 # define PLATFORM_NAME "BeOS"
320 #if defined(__HAIKU__)
322 # ifndef PLATFORM_NAME
323 # define PLATFORM_NAME "Haiku"
329 #if defined(__CYGWIN__)
331 # ifndef PLATFORM_NAME
332 # define PLATFORM_NAME "Cygwin"
334 # define FILENAMES_CASE_SENSITIVE 0
341 # ifndef PLATFORM_NAME
342 # define PLATFORM_NAME "OpenVMS"
344 # define FILENAMES_CASE_SENSITIVE 0
351 # ifndef PLATFORM_NAME
352 # define PLATFORM_NAME "DEC Alpha OSF"
360 # if defined(forARM) && defined(__NEWTON_H)
363 # ifndef PLATFORM_NAME
364 # define PLATFORM_NAME "Newton"
367 # ifndef PLATFORM_NAME
368 # define PLATFORM_NAME "ARM"
386 #ifdef NEEDS_MALLOC_H
390 #ifdef SUPPORT_GETPWNAM
394 #ifdef NEEDS_UNISTD_H
404 #ifndef FILENAMES_CASE_SENSITIVE
405 # define FILENAMES_CASE_SENSITIVE 1
424 #ifdef PRESERVEFILETIMES
425 # undef PRESERVE_FILE_TIMES
426 # define PRESERVE_FILE_TIMES PRESERVEFILETIMES
429 #ifndef PRESERVE_FILE_TIMES
430 # if defined(RISC_OS) || defined(OPENVMS_OS) || defined(OSF_OS)
431 # define PRESERVE_FILE_TIMES 0
433 # define PRESERVE_FILE_TIMES 1
437 #if PRESERVE_FILE_TIMES
440 # 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__) || defined(__GLIBC__) || defined(__HAIKU__)
441 # define HAS_FUTIME 0
443 # define HAS_FUTIME 1
447 # ifndef UTIME_NEEDS_CLOSED_FILE
448 # if defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(MAC_OS) || defined(__MSL__) || defined(LINUX_OS)
449 # define UTIME_NEEDS_CLOSED_FILE 1
451 # define UTIME_NEEDS_CLOSED_FILE 0
455 # if defined(MAC_OS_X) || (!defined(MAC_OS_CLASSIC) && !defined(__MSL__))
456 # include <sys/types.h>
457 # include <sys/stat.h>
463 # include <sys/utime.h>
468 #if defined(__HAIKU__)
470 #define va_copy(dest, src) (dest = src)
482 # if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
483 # define futime _futime
484 # define fstat _fstat
485 # define utimbuf _utimbuf
487 # define utime _utime
488 # define vsnprintf _vsnprintf
503 #if defined(_WIN32) && !defined(__MSL__) && !defined(__BORLANDC__)
505 # if !(defined(__WATCOMC__) || defined(__MINGW32__))
506 # define fileno _fileno
507 # define setmode _setmode
510 # if defined(_MSC_VER)
511 # define fileno _fileno
512 # if !defined(NDEBUG) && !defined(ENABLE_DEBUG_LOG) && !defined(DISABLE_DEBUG_LOG)
513 # define ENABLE_DEBUG_LOG
517 # define access _access
518 # define strcasecmp _stricmp
521 # define va_copy(dest, src) (dest = src)
525 # pragma warning( disable : 4189 )
526 # pragma warning( disable : 4100 )
527 # pragma warning( disable : 4706 )
531 # pragma warning( disable : 4996 )
538 # if (defined(_USRDLL) || defined(_WINDLL) || defined(BUILD_SHARED_LIB)) && !defined(TIDY_EXPORT) && !defined(TIDY_STATIC)
539 # ifdef BUILDING_SHARED_LIB
540 # define TIDY_EXPORT __declspec( dllexport )
542 # define TIDY_EXPORT __declspec( dllimport )
545 # define TIDY_EXPORT extern
550 # define TIDY_CALL __fastcall
552 # define TIDY_CALL __stdcall
556 # ifndef TIDY_THREAD_LOCAL
558 # define TIDY_THREAD_LOCAL __declspec( thread )
570 #if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
571 # include <sys/types.h>
574 #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) && !defined(__HAIKU__)
579 #if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32) || defined(__ANDROID__)
581 typedef unsigned long ulong;
610 #ifndef TIDY_THREAD_LOCAL
611 # define TIDY_THREAD_LOCAL __thread
614 #ifndef TIDY_INDENTATION_LIMIT
615 # define TIDY_INDENTATION_LIMIT 50
622 #ifndef TMBSTR_DEFINED
625 # define NULLSTR (tmbstr)""
626 # define TMBSTR_DEFINED
633 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
634 # define ARG_UNUSED(x) x __attribute__((unused))
635 # define FUNC_UNUSED __attribute__((unused))
637 # define ARG_UNUSED(x) x
644 #ifndef HAS_VSNPRINTF
645 # define HAS_VSNPRINTF 1
648 #ifndef SUPPORT_POSIX_MAPPED_FILES
649 # define SUPPORT_POSIX_MAPPED_FILES 1
673 # include "dmalloc.h"
681 #define opaque_type( typenam )\
682 struct _##typenam { int _opaque; };\
683 typedef struct _##typenam const * typenam
685 #define opaque_type(typenam) typedef const void* typenam