+// ----------------------------------------------------------------------------
+// printf() family saga
+// ----------------------------------------------------------------------------
+
+/*
+ For some systems vsnprintf() exists in the system libraries but not in the
+ headers, so we need to declare it ourselves to be able to use it.
+ */
+#if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
+ extern "C"
+ int vsnprintf(char *str, size_t size, const char *format, va_list ap);
+#endif // !HAVE_VSNPRINTF_DECL
+
+/*
+ First of all, we always want to define safe snprintf() function to be used
+ instead of sprintf(). Some compilers already have it (or rather vsnprintf()
+ which we really need...), otherwise we implement it using our own printf()
+ code.
+
+ We define function with a trailing underscore here because the real one is a
+ wrapper around it as explained below
+ */
+#ifndef wxVsnprintf_
+ #if wxUSE_UNICODE
+ #if defined(HAVE__VSNWPRINTF)
+ #define wxVsnprintf_ _vsnwprintf
+ /* MinGW?MSVCRT has the wrong vswprintf */
+ #elif defined(HAVE_VSWPRINTF) && !defined(__MINGW32__)
+ #define wxVsnprintf_ vswprintf
+ #endif
+ #else // ASCII
+ // all versions of CodeWarrior supported by wxWindows apparently have
+ // vsnprintf()
+ #if defined(HAVE_VSNPRINTF) || defined(__MWERKS__)
+ // assume we have snprintf() too if we have vsnprintf()
+ #define wxVsnprintf_ vsnprintf
+ #define wxSnprintf_ snprintf
+ #endif
+ #endif
+#endif // wxVsnprintf_ not defined yet
+
+#ifndef wxSnprintf_
+ // no [v]snprintf(), cook our own
+ WXDLLEXPORT int wxSnprintf_(wxChar *buf, size_t len, const wxChar *format,
+ ...) ATTRIBUTE_PRINTF_3;
+#endif
+#ifndef wxVsnprintf_
+ WXDLLEXPORT int wxVsnprintf_(wxChar *buf, size_t len, const wxChar *format,
+ va_list argptr);
+#endif
+
+/*
+ In Unicode mode we need to have all standard functions such as wprintf() and
+ so on but not all systems have them so use our own implementations in this
+ case.
+ */
+#if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
+ #define wxNEED_WPRINTF
+#endif
+
+/*
+ More Unicode complications: although both ANSI C and C++ define a number of
+ wide character functions such as wprintf(), not all environments have them.
+ Worse, those which do have different behaviours: under Windows, %s format
+ specifier changes its meaning in Unicode build and expects a Unicode string
+ while under Unix/POSIX it still means an ASCII string even for wprintf() and
+ %ls has to be used for wide strings.
+
+ We choose to always emulate Windows behaviour as more useful for us so even
+ if we have wprintf() we still must wrap it in a non trivial wxPrintf().
+
+ However, if we don't have any vswprintf() at all we don't need to redefine
+ anything as our own wxVsnprintf_() already behaves as needed.
+*/
+#ifndef wxVsnprintf_
+ #undef wxNEED_PRINTF_CONVERSION
+#endif
+
+#if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
+ // we need to implement all wide character printf and scanf functions
+ // either because we don't have them at all or because they don't have the
+ // semantics we need
+
+ #include <stdio.h> // for FILE
+
+ int wxScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
+ int wxSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
+ int wxFscanf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
+ int wxVsscanf( const wxChar *str, const wxChar *format, va_list ap );
+ int wxPrintf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
+ int wxSprintf( wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
+ int wxFprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
+ int wxVfprintf( FILE *stream, const wxChar *format, va_list ap );
+ int wxVprintf( const wxChar *format, va_list ap );
+ int wxVsprintf( wxChar *str, const wxChar *format, va_list ap );
+#endif // wxNEED_PRINTF_CONVERSION
+
+// these 2 can be simply mapped to the versions with underscore at the end
+// if we don't have to do the conversion
+#ifdef wxNEED_PRINTF_CONVERSION
+ int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3;
+ int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap );
+#else
+ #define wxSnprintf wxSnprintf_
+ #define wxVsnprintf wxVsnprintf_
+#endif
+
+// ----------------------------------------------------------------------------
+// various functions which might not be available in libc and for which we
+// provide our own replacements in wxchar.cpp
+// ----------------------------------------------------------------------------
+
+// ctype.h functions
+//
+// VZ: note that this is never defined currently
+#ifdef wxNEED_WX_CTYPE_H
+ WXDLLEXPORT int wxIsalnum(wxChar ch);
+ WXDLLEXPORT int wxIsalpha(wxChar ch);
+ WXDLLEXPORT int wxIsctrl(wxChar ch);
+ WXDLLEXPORT int wxIsdigit(wxChar ch);
+ WXDLLEXPORT int wxIsgraph(wxChar ch);
+ WXDLLEXPORT int wxIslower(wxChar ch);
+ WXDLLEXPORT int wxIsprint(wxChar ch);
+ WXDLLEXPORT int wxIspunct(wxChar ch);
+ WXDLLEXPORT int wxIsspace(wxChar ch);
+ WXDLLEXPORT int wxIsupper(wxChar ch);
+ WXDLLEXPORT int wxIsxdigit(wxChar ch);
+ WXDLLEXPORT int wxTolower(wxChar ch);
+ WXDLLEXPORT int wxToupper(wxChar ch);
+#endif // wxNEED_WX_CTYPE_H
+
+// under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks
+// the file parsing -- this may be true for 5.0 as well, update #ifdef then
+#if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
+ #undef wxIsspace
+ #define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c))
+#endif // VC++
+
+
+// string.h functions
+//
+// VZ: this is never defined neither currently
+#ifdef wxNEED_WX_STRING_H
+ WXDLLEXPORT wxChar * wxStrcat(wxChar *dest, const wxChar *src);
+ WXDLLEXPORT const wxChar * wxStrchr(const wxChar *s, wxChar c);
+ WXDLLEXPORT wxChar * wxStrchr(wxChar *s, wxChar c)
+ { return (wxChar *)wxStrchr((const wxChar *)s, c); }
+ WXDLLEXPORT int wxStrcmp(const wxChar *s1, const wxChar *s2);
+ WXDLLEXPORT int wxStrcoll(const wxChar *s1, const wxChar *s2);
+ WXDLLEXPORT wxChar * wxStrcpy(wxChar *dest, const wxChar *src);
+ WXDLLEXPORT size_t wxStrcspn(const wxChar *s, const wxChar *reject);
+ WXDLLEXPORT size_t wxStrlen(const wxChar *s);
+ WXDLLEXPORT wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n);
+ WXDLLEXPORT int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n);
+ WXDLLEXPORT wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n);
+ WXDLLEXPORT const wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept);
+ WXDLLEXPORT wxChar * wxStrpbrk(wxChar *s, const wxChar *accept)
+ { return (wxChar *)wxStrpbrk((const wxChar *)s, accept); }
+ WXDLLEXPORT const wxChar * wxStrrchr(const wxChar *s, wxChar c);
+ WXDLLEXPORT wxChar * wxStrrchr(wxChar *s, wxChar c)
+ { return (wxChar *)wxStrrchr((const wxChar *)s, c); }
+ WXDLLEXPORT size_t wxStrspn(const wxChar *s, const wxChar *accept);
+ WXDLLEXPORT const wxChar * wxStrstr(const wxChar *haystack, const wxChar *needle);
+ WXDLLEXPORT wxChar *wxStrstr(wxChar *haystack, const wxChar *needle)
+ { return (wxChar *)wxStrstr((const wxChar *)haystack, needle); }
+ WXDLLEXPORT double wxStrtod(const wxChar *nptr, wxChar **endptr);
+ WXDLLEXPORT long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
+ WXDLLEXPORT unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base);
+ WXDLLEXPORT size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n);
+#endif // wxNEED_WX_STRING_H
+
+#ifndef wxStrdupA
+WXDLLEXPORT char *wxStrdupA(const char *psz);
+#endif
+
+#ifndef wxStrdupW
+WXDLLEXPORT wchar_t *wxStrdupW(const wchar_t *pwz);