/[pcsx2_0.9.7]/branch/r3113_0.9.7_beta/3rdparty/wxWidgets/include/wx/wxchar.h
ViewVC logotype

Contents of /branch/r3113_0.9.7_beta/3rdparty/wxWidgets/include/wx/wxchar.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (show annotations) (download)
Tue Sep 7 03:29:01 2010 UTC (9 years, 5 months ago) by william
File MIME type: text/plain
File size: 49980 byte(s)
branching from upstream revision (http://pcsx2.googlecode.com/svn/trunk
): r3113 to
https://svn.netsolutions.dnsalias.com/websvn/ps2/pcsx2/pcsx2_0.9.7/branch/r3113_0.9.7_beta
1 /*
2 * Name: wx/wxchar.h
3 * Purpose: Declarations common to wx char/wchar_t usage (wide chars)
4 * Author: Joel Farley, Ove Kåven
5 * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
6 * Created: 1998/06/12
7 * RCS-ID: $Id: wxchar.h 50987 2008-01-02 16:31:38Z VZ $
8 * Copyright: (c) 1998-2006 wxWidgets dev team
9 * Licence: wxWindows licence
10 */
11
12 /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
13
14 #ifndef _WX_WXCHAR_H_
15 #define _WX_WXCHAR_H_
16
17 /* defs.h indirectly includes this file, so don't include it here */
18 #include "wx/platform.h"
19 #include "wx/dlimpexp.h"
20
21 #include <stdio.h> /* we use FILE below */
22
23 #if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
24 char *strtok_r(char *, const char *, char **);
25 #endif
26
27 /* check whether we have wchar_t and which size it is if we do */
28 #if !defined(wxUSE_WCHAR_T)
29 #if defined(__UNIX__)
30 #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__)
31 #define wxUSE_WCHAR_T 1
32 #else
33 #define wxUSE_WCHAR_T 0
34 #endif
35 #elif defined(__GNUWIN32__) && !defined(__MINGW32__)
36 #define wxUSE_WCHAR_T 0
37 #elif defined(__WATCOMC__)
38 #define wxUSE_WCHAR_T 0
39 #elif defined(__VISAGECPP__) && (__IBMCPP__ < 400)
40 #define wxUSE_WCHAR_T 0
41 #else
42 /* add additional compiler checks if this fails */
43 #define wxUSE_WCHAR_T 1
44 #endif
45 #endif /* !defined(wxUSE_WCHAR_T) */
46
47 /* Unicode support requires wchar_t */
48 #if wxUSE_UNICODE && !wxUSE_WCHAR_T
49 #error "wchar_t must be available in Unicode build"
50 #endif /* Unicode */
51
52 /*
53 Standard headers we need here.
54
55 NB: don't include any wxWidgets headers here because almost all of them include
56 this one!
57 */
58
59 /* Required for wxPrintf() etc */
60 #include <stdarg.h>
61
62 /* Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac */
63 /* and VC++ for Windows CE don't provide it */
64 #if defined(__VISUALC__) && __VISUALC__ >= 1400
65 #define wxStrdupA _strdup
66 #elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
67 /* use #define, not inline wrapper, as it is tested with #ifndef below */
68 #define wxStrdupA strdup
69 #endif
70
71 /*
72 non Unix compilers which do have wchar.h (but not tchar.h which is included
73 below and which includes wchar.h anyhow).
74
75 Actually MinGW has tchar.h, but it does not include wchar.h
76 */
77 #if defined(__MWERKS__) || defined(__VISAGECPP__) || defined(__MINGW32__) || defined(__WATCOMC__)
78 #ifndef HAVE_WCHAR_H
79 #define HAVE_WCHAR_H
80 #endif
81 #endif
82 #if defined(__MWERKS__) && !defined(__MACH__)
83 #ifndef HAVE_WCSLEN
84 #define HAVE_WCSLEN
85 #endif
86 #endif
87
88 #if wxUSE_WCHAR_T
89 #ifdef HAVE_WCHAR_H
90 /* the current (as of Nov 2002) version of cygwin has a bug in its */
91 /* wchar.h -- there is no extern "C" around the declarations in it and */
92 /* this results in linking errors later; also, at least on some */
93 /* Cygwin versions, wchar.h requires sys/types.h */
94 #ifdef __CYGWIN__
95 #include <sys/types.h>
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
99 #endif /* Cygwin */
100
101 #include <wchar.h>
102
103 #if defined(__CYGWIN__) && defined(__cplusplus)
104 }
105 #endif /* Cygwin and C++ */
106
107 #elif defined(HAVE_WCSTR_H)
108 /* old compilers have relevant declarations here */
109 #include <wcstr.h>
110 #elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__)
111 /* include stdlib.h for wchar_t */
112 #include <stdlib.h>
113 #endif /* HAVE_WCHAR_H */
114
115 #ifdef HAVE_WIDEC_H
116 #include <widec.h>
117 #endif
118 #endif /* wxUSE_WCHAR_T */
119
120 /* ---------------------------------------------------------------------------- */
121 /* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */
122 /* mapped to either char or wchar_t depending on the ASCII/Unicode mode and have */
123 /* the function mapping _tfoo() -> foo() or wfoo() */
124 /* ---------------------------------------------------------------------------- */
125
126 /* VC++ and BC++ starting with 5.2 have TCHAR support */
127 #ifdef __VISUALC__
128 #define wxHAVE_TCHAR_SUPPORT
129 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)
130 #define wxHAVE_TCHAR_SUPPORT
131 #include <ctype.h>
132 #include <memory.h>
133 #elif defined(__WATCOMC__)
134 #define wxHAVE_TCHAR_SUPPORT
135 #elif defined(__DMC__)
136 #define wxHAVE_TCHAR_SUPPORT
137 #elif defined(__WXPALMOS__)
138 #include <stddef.h>
139 #elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
140 #define wxHAVE_TCHAR_SUPPORT
141 #include <stddef.h>
142 #include <string.h>
143 #include <ctype.h>
144 #elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
145 /* VZ: the old VisualAge definitions were completely wrong and had no */
146 /* chance at all to work in Unicode build anyhow so let's pretend that */
147 /* VisualAge does _not_ support TCHAR for the moment (as indicated by */
148 /* "0 &&" above) until someone really has time to delve into Unicode */
149 /* issues under OS/2 */
150
151 /* VisualAge 4.0+ supports TCHAR */
152 #define wxHAVE_TCHAR_SUPPORT
153 #endif /* compilers with (good) TCHAR support */
154
155 #if defined(__MWERKS__)
156 /* Metrowerks only has wide char support for OS X >= 10.3 */
157 #if !defined(__DARWIN__) || \
158 (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
159 #define wxHAVE_MWERKS_UNICODE
160 #endif
161
162 #ifdef wxHAVE_MWERKS_UNICODE
163 #define HAVE_WPRINTF 1
164 #define HAVE_WCSRTOMBS 1
165 #define HAVE_VSWPRINTF 1
166 #endif
167 #endif /* __MWERKS__ */
168
169 #ifdef wxHAVE_TCHAR_SUPPORT
170 /* get TCHAR definition if we've got it */
171 #include <tchar.h>
172
173 /* we surely do have wchar_t if we have TCHAR */
174 #ifndef wxUSE_WCHAR_T
175 #define wxUSE_WCHAR_T 1
176 #endif /* !defined(wxUSE_WCHAR_T) */
177
178 /* and we also do have wcslen() */
179 #ifndef HAVE_WCSLEN
180 #define HAVE_WCSLEN
181 #endif
182 #endif /* wxHAVE_TCHAR_SUPPORT */
183
184 /* ---------------------------------------------------------------------------- */
185 /* define wxChar type */
186 /* ---------------------------------------------------------------------------- */
187
188 /* TODO: define wxCharInt to be equal to either int or wint_t? */
189
190 #if !wxUSE_UNICODE
191 typedef char wxChar;
192 typedef signed char wxSChar;
193 typedef unsigned char wxUChar;
194 #else /* Unicode */
195 /* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */
196 /* signed/unsigned version of it which (a) makes sense to me (unlike */
197 /* char wchar_t is always unsigned) and (b) was how the previous */
198 /* definitions worked so keep it like this */
199
200 /* Sun's SunPro compiler supports the wchar_t type and wide character */
201 /* functions, but does not define __WCHAR_TYPE__. Define it here to */
202 /* allow unicode enabled builds. */
203 #if defined(__SUNPRO_CC) || defined(__SUNPRO_C)
204 #define __WCHAR_TYPE__ wxchar_t
205 #endif
206
207 /* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */
208 /* comment below */
209 #if !defined(__WCHAR_TYPE__) || \
210 (!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
211 /* standard case */
212 typedef wchar_t wxChar;
213 typedef wchar_t wxSChar;
214 typedef wchar_t wxUChar;
215 #else /* __WCHAR_TYPE__ and gcc < 2.96 */
216 /* VS: wxWidgets used to define wxChar as __WCHAR_TYPE__ here. However, */
217 /* this doesn't work with new GCC 3.x compilers because wchar_t is */
218 /* C++'s builtin type in the new standard. OTOH, old compilers (GCC */
219 /* 2.x) won't accept new definition of wx{S,U}Char, therefore we */
220 /* have to define wxChar conditionally depending on detected */
221 /* compiler & compiler version. */
222 /* with old definition of wxChar. */
223 typedef __WCHAR_TYPE__ wxChar;
224 typedef __WCHAR_TYPE__ wxSChar;
225 typedef __WCHAR_TYPE__ wxUChar;
226 #endif /* __WCHAR_TYPE__ */
227 #endif /* ASCII/Unicode */
228
229 /* ---------------------------------------------------------------------------- */
230 /* define _T() and related macros */
231 /* ---------------------------------------------------------------------------- */
232
233 /* BSD systems define _T() to be something different in ctype.h, override it */
234 #if defined(__FreeBSD__) || defined(__DARWIN__)
235 #include <ctype.h>
236 #undef _T
237 #endif
238
239 /* could already be defined by tchar.h (it's quasi standard) */
240 #ifndef _T
241 #if !wxUSE_UNICODE
242 #define _T(x) x
243 #else /* Unicode */
244 /* use wxCONCAT_HELPER so that x could be expanded if it's a macro */
245 #define _T(x) wxCONCAT_HELPER(L, x)
246 #endif /* ASCII/Unicode */
247 #endif /* !defined(_T) */
248
249 /* although global macros with such names are normally bad, we want to have */
250 /* another name for _T() which should be used to avoid confusion between _T() */
251 /* and _() in wxWidgets sources */
252 #define wxT(x) _T(x)
253
254 /* this macro exists only for forward compatibility with wx 3.0 */
255 #define wxS(x) _T(x)
256
257 /* a helper macro allowing to make another macro Unicode-friendly, see below */
258 #define wxAPPLY_T(x) _T(x)
259
260 /* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */
261 #ifndef __TFILE__
262 #define __TFILE__ wxAPPLY_T(__FILE__)
263 #endif
264
265 #ifndef __TDATE__
266 #define __TDATE__ wxAPPLY_T(__DATE__)
267 #endif
268
269 #ifndef __TTIME__
270 #define __TTIME__ wxAPPLY_T(__TIME__)
271 #endif
272
273 /*
274 define wxFoo() function for each standard foo() function whose signature
275 (exceptionally including the return type) includes any mention of char:
276 wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
277 the same signature but with char replaced by wxChar which allows us to use
278 it in Unicode build as well
279 */
280
281 #ifdef wxHAVE_TCHAR_SUPPORT
282 #include <ctype.h>
283
284 #if defined(__WATCOMC__) && defined(UNICODE)
285 #define WXWCHAR_T_CAST(c) (wint_t)(c)
286 #else
287 #define WXWCHAR_T_CAST(c) c
288 #endif
289
290 /* ctype.h functions */
291 #define wxIsalnum(c) _istalnum(WXWCHAR_T_CAST(c))
292 #define wxIsalpha(c) _istalpha(WXWCHAR_T_CAST(c))
293 #define wxIscntrl(c) _istcntrl(WXWCHAR_T_CAST(c))
294 #define wxIsdigit(c) _istdigit(WXWCHAR_T_CAST(c))
295 #define wxIsgraph(c) _istgraph(WXWCHAR_T_CAST(c))
296 #define wxIslower(c) _istlower(WXWCHAR_T_CAST(c))
297 #define wxIsprint(c) _istprint(WXWCHAR_T_CAST(c))
298 #define wxIspunct(c) _istpunct(WXWCHAR_T_CAST(c))
299 #define wxIsspace(c) _istspace(WXWCHAR_T_CAST(c))
300 #define wxIsupper(c) _istupper(WXWCHAR_T_CAST(c))
301 #define wxIsxdigit(c) _istxdigit(WXWCHAR_T_CAST(c))
302
303 /*
304 There is a bug in VC6 C RTL: toxxx() functions dosn't do anything with
305 signed chars < 0, so "fix" it here.
306 */
307 #define wxTolower(c) _totlower((wxUChar)(c))
308 #define wxToupper(c) _totupper((wxUChar)(c))
309
310 /* locale.h functons */
311 #define wxSetlocale _tsetlocale
312
313 /* string.h functions */
314 #define wxStrcat _tcscat
315 #define wxStrchr _tcschr
316 #define wxStrcmp _tcscmp
317 #define wxStrcoll _tcscoll
318 #define wxStrcpy _tcscpy
319 #define wxStrcspn _tcscspn
320 #define wxStrdupW _wcsdup /* notice the 'W'! */
321 #define wxStrftime _tcsftime
322 #define wxStricmp _tcsicmp
323 #define wxStrnicmp _tcsnicmp
324 #define wxStrlen_ _tcslen /* used in wxStrlen inline function */
325 #define wxStrncat _tcsncat
326 #define wxStrncmp _tcsncmp
327 #define wxStrncpy _tcsncpy
328 #define wxStrpbrk _tcspbrk
329 #define wxStrrchr _tcsrchr
330 #define wxStrspn _tcsspn
331 #define wxStrstr _tcsstr
332 #define wxStrtod _tcstod
333 #define wxStrtol _tcstol
334 #define wxStrtoul _tcstoul
335 #ifdef __VISUALC__
336 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
337 #define wxStrtoll _tcstoi64
338 #define wxStrtoull _tcstoui64
339 #endif /* VC++ 7+ */
340 #endif
341 #define wxStrxfrm _tcsxfrm
342
343 /* stdio.h functions */
344 #define wxFgetc _fgettc
345 #define wxFgetchar _fgettchar
346 #define wxFgets _fgetts
347 #if wxUSE_UNICODE_MSLU
348 WXDLLIMPEXP_BASE FILE * wxMSLU__tfopen(const wxChar *name, const wxChar *mode);
349
350 #define wxFopen wxMSLU__tfopen
351 #else
352 #define wxFopen _tfopen
353 #endif
354 #define wxFputc _fputtc
355 #define wxFputchar _fputtchar
356 #define wxFprintf _ftprintf
357 #define wxFputs _fputts
358 #define wxFreopen _tfreopen
359 #define wxFscanf _ftscanf
360 #define wxGetc _gettc
361 #define wxGetchar _gettchar
362 #define wxGets _getts
363 #define wxPerror _tperror
364 #define wxPrintf _tprintf
365 #define wxPutc(c,f) _puttc(WXWCHAR_T_CAST(c),f)
366 #define wxPutchar _puttchar
367 #define wxPuts _putts
368 #define wxScanf _tscanf
369 #if defined(__DMC__)
370 #if wxUSE_UNICODE
371 /* Digital Mars adds count to _stprintf (C99) so prototype conversion see wxchar.cpp */
372 int wxSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) ;
373 #else
374 /* and there is a bug in D Mars tchar.h prior to 8.39.4n, so define as sprintf */
375 #define wxSprintf sprintf
376 #endif
377 #elif defined(__MINGW32__) && ( defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 )
378 #if wxUSE_UNICODE
379 /* MinGW with STLPort 5.1 adds count to swprintf (C99) so prototype conversion see wxchar.cpp */
380 int wxSprintf (wchar_t*, const wchar_t*, ...);
381 #else
382 /* MinGW with STLPort 5.1 has clashing defines for _stprintf so use sprintf */
383 #define wxSprintf sprintf
384 #endif
385 #else
386 #define wxSprintf _stprintf
387 #endif
388
389 #define wxSscanf _stscanf
390 #define wxTmpnam _ttmpnam
391 #define wxUngetc _tungetc
392 #define wxVfprintf _vftprintf
393 #define wxVprintf _vtprintf
394 #define wxVsscanf _vstscanf
395 #define wxVsprintf _vstprintf
396
397 /* special case: these functions are missing under Win9x with Unicows so we */
398 /* have to implement them ourselves */
399 #if wxUSE_UNICODE_MSLU
400 WXDLLIMPEXP_BASE int wxMSLU__trename(const wxChar *oldname, const wxChar *newname);
401 WXDLLIMPEXP_BASE int wxMSLU__tremove(const wxChar *name);
402
403 #define wxRemove wxMSLU__tremove
404 #define wxRename wxMSLU__trename
405 #else
406 #ifdef __WXWINCE__
407 /* carefully: wxRemove() must return 0 on success while DeleteFile()
408 returns 0 on error, so don't just define one as the other */
409 int wxRemove(const wxChar *path);
410 #else
411 #define wxRemove _tremove
412 #define wxRename _trename
413 #endif
414 #endif
415
416 /* stdlib.h functions */
417 #define wxAtoi _ttoi
418 #define wxAtol _ttol
419 /* #define wxAtof _tttof -- notice that there is no such thing (why?) */
420 /* there are no env vars at all under CE, so no _tgetenv neither */
421 #ifdef __WXWINCE__
422 /* can't define as inline function as this is a C file... */
423 #define wxGetenv(name) ((wxChar *)NULL)
424 #else
425 #define wxGetenv _tgetenv
426 #endif
427 #define wxSystem _tsystem
428
429 /* time.h functions */
430 #define wxAsctime _tasctime
431 #define wxCtime _tctime
432
433 #define wxMbstowcs mbstowcs
434 #define wxWcstombs wcstombs
435 #else /* !TCHAR-aware compilers */
436 /*
437 There are 2 unrelated problems with these functions under Mac:
438 a) Metrowerks MSL CRT implements them strictly in C99 sense and
439 doesn't support (very common) extension of allowing to call
440 mbstowcs(NULL, ...) which makes it pretty useless as you can't
441 know the size of the needed buffer
442 b) OS X <= 10.2 declares and even defined these functions but
443 doesn't really implement them -- they always return an error
444
445 So use our own replacements in both cases.
446 */
447 #if defined(__MWERKS__) && defined(__MSL__)
448 #define wxNEED_WX_MBSTOWCS
449 #endif
450
451 #ifdef __DARWIN__
452 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
453 #define wxNEED_WX_MBSTOWCS
454 #endif
455 #endif
456
457 #ifdef wxNEED_WX_MBSTOWCS
458 /* even though they are defined and "implemented", they are bad and just
459 stubs so we need our own - we need these even in ANSI builds!! */
460 WXDLLIMPEXP_BASE size_t wxMbstowcs (wchar_t *, const char *, size_t);
461 WXDLLIMPEXP_BASE size_t wxWcstombs (char *, const wchar_t *, size_t);
462 #else
463 #define wxMbstowcs mbstowcs
464 #define wxWcstombs wcstombs
465 #endif
466
467 /*
468 The system C library on Mac OS X 10.2 and below does not support
469 unicode: in other words all wide-character functions such as towupper et
470 al. do simply not exist so we need to provide our own in that context,
471 except for the wchar_t definition/typedef itself.
472
473 We need to do this for both project builder and CodeWarrior as
474 the latter uses the system C library in Mach builds for wide character
475 support, which as mentioned does not exist on 10.2 and below.
476 */
477 #if wxUSE_UNICODE && \
478 defined(__DARWIN__) && \
479 ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
480 /* we need everything! */
481 #define wxNEED_WX_STRING_H
482 #define wxNEED_WX_CTYPE_H
483
484 #define wxFgetchar(c) wxFgetc(c, stdin)
485 #define wxFputc wxPutc
486 #define wxFputchar(c) wxPutc(c, stdout)
487 #define wxGetc wxFgetc
488 #define wxGetchar(c) wxFgetc(c, stdin)
489
490 #include <stdio.h>
491
492 #define wxNEED_FGETC
493 #define wxNEED_FGETS
494 #define wxNEED_GETS
495 #define wxNEED_UNGETC
496
497 #define wxNEED_FPUTS
498 #define wxNEED_PUTS
499 #define wxNEED_PUTC
500
501 int wxFputs(const wxChar *ch, FILE *stream);
502 int wxPuts(const wxChar *ws);
503 int wxPutc(wxChar ch, FILE *stream);
504
505 #ifdef __cplusplus
506 extern "C" {
507 #endif
508 WXDLLIMPEXP_BASE size_t wxStrlen_(const wxChar *s);
509 #ifdef __cplusplus
510 }
511 #endif
512
513 #define wxPutchar(wch) wxPutc(wch, stdout)
514
515 #define wxNEED_PRINTF_CONVERSION
516 #define wxNEED_WX_STDIO_H
517 #define wxNEED_WX_STDLIB_H
518 #define wxNEED_WX_TIME_H
519
520 #elif wxUSE_UNICODE
521 #include <wctype.h>
522
523 /* this is probably glibc-specific */
524 #if defined(__WCHAR_TYPE__) && !defined(__MWERKS__)
525 /* ctype.h functions (wctype.h) */
526 #define wxIsalnum iswalnum
527 #define wxIsalpha iswalpha
528 #define wxIscntrl iswcntrl
529 #define wxIsdigit iswdigit
530 #define wxIsgraph iswgraph
531 #define wxIslower iswlower
532 #define wxIsprint iswprint
533 #define wxIspunct iswpunct
534 #define wxIsspace iswspace
535 #define wxIsupper iswupper
536 #define wxIsxdigit iswxdigit
537
538 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
539 /* /usr/include/wctype.h incorrectly declares translations */
540 /* tables which provokes tons of compile-time warnings -- try */
541 /* to correct this */
542 #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
543 #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
544 #else /* !glibc 2.0 */
545 #define wxTolower towlower
546 #define wxToupper towupper
547 #endif /* gcc/!gcc */
548
549 /* string.h functions (wchar.h) */
550 #define wxStrcat wcscat
551 #define wxStrchr wcschr
552 #define wxStrcmp wcscmp
553 #define wxStrcoll wcscoll
554 #define wxStrcpy wcscpy
555 #define wxStrcspn wcscspn
556 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
557 #define wxStrncat wcsncat
558 #define wxStrncmp wcsncmp
559 #define wxStrncpy wcsncpy
560 #define wxStrpbrk wcspbrk
561 #define wxStrrchr wcsrchr
562 #define wxStrspn wcsspn
563 #define wxStrstr wcsstr
564 #define wxStrtod wcstod
565 #define wxStrtol wcstol
566 #define wxStrtoul wcstoul
567 #ifdef HAVE_WCSTOULL
568 /* assume that we have wcstoull(), which is also C99, too */
569 #define wxStrtoll wcstoll
570 #define wxStrtoull wcstoull
571 #endif /* HAVE_WCSTOULL */
572 #define wxStrxfrm wcsxfrm
573
574 #define wxFgetc fgetwc
575 #define wxFgetchar fgetwchar
576 #define wxFgets fgetws
577 #define wxFputc fputwc
578 #define wxFputchar fputwchar
579 #define wxGetc getwc
580 #define wxGetchar getwchar
581 #define wxGets getws
582 #define wxUngetc ungetwc
583
584 #ifdef HAVE_FPUTWS
585 #define wxFputs fputws
586 #else
587 #define wxNEED_FPUTS
588 #include <stdio.h>
589 int wxFputs(const wxChar *ch, FILE *stream);
590 #endif
591
592 #ifdef HAVE_WPUTC
593 #define wxPutc wputc
594 #else
595 #define wxNEED_PUTC
596 #include <stdio.h>
597 int wxPutc(wxChar ch, FILE *stream);
598 #endif
599
600 #ifdef HAVE_WPUTCHAR
601 #define wxPutchar wputchar
602 #else
603 #define wxPutchar(wch) wxPutc(wch, stdout)
604 #endif
605
606 #ifdef HAVE_PUTWS
607 #define wxPuts putws
608 #else
609 #define wxNEED_PUTS
610 int wxPuts(const wxChar *ws);
611 #endif
612
613 /* we need %s to %ls conversion for printf and scanf etc */
614 #define wxNEED_PRINTF_CONVERSION
615
616 /* glibc doesn't have wide char equivalents of the other stuff so */
617 /* use our own versions */
618 #define wxNEED_WX_STDIO_H
619 #define wxNEED_WX_STDLIB_H
620 #define wxNEED_WX_TIME_H
621 #elif defined(__MWERKS__) && ( defined(__MSL__) || defined(__MACH__) )
622 /* ctype.h functions (wctype.h) */
623 #define wxIsalnum iswalnum
624 #define wxIsalpha iswalpha
625 #define wxIscntrl iswcntrl
626 #define wxIsdigit iswdigit
627 #define wxIsgraph iswgraph
628 #define wxIslower iswlower
629 #define wxIsprint iswprint
630 #define wxIspunct iswpunct
631 #define wxIsspace iswspace
632 #define wxIsupper iswupper
633 #define wxIsxdigit iswxdigit
634 #define wxTolower towlower
635 #define wxToupper towupper
636
637 /* string.h functions (wchar.h) */
638 #define wxStrcat wcscat
639 #define wxStrchr wcschr
640 #define wxStrcmp wcscmp
641 #define wxStrcoll wcscoll
642 #define wxStrcpy wcscpy
643 #define wxStrcspn wcscspn
644 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
645 #define wxStrncat wcsncat
646 #define wxStrncmp wcsncmp
647 #define wxStrncpy wcsncpy
648 #define wxStrpbrk wcspbrk
649 #define wxStrrchr wcsrchr
650 #define wxStrspn wcsspn
651 #define wxStrstr wcsstr
652 #define wxStrtod wcstod
653 #define wxStrtol wcstol
654 #define wxStrtoul wcstoul
655 #define wxStrxfrm wcsxfrm
656
657 #define wxFgetc fgetwc
658 #define wxFgetchar fgetwchar
659 #define wxFgets fgetws
660 #define wxFputc fputwc
661 #define wxFputchar fputwchar
662 #define wxGetc getwc
663 #define wxGetchar getwchar
664 #define wxGets getws
665 #define wxUngetc ungetwc
666
667 #define wxNEED_PRINTF_CONVERSION
668
669 #define wxPutc putwc
670 #define wxPutchar putwchar
671 #define wxFputs fputws
672
673 /* stdio.h functions */
674
675 #define wxNEED_WX_STDIO_H
676
677 /* stdlib.h functions */
678 #ifdef __MACH__
679 #define wxNEED_WX_STDLIB_H
680 #else
681 #define wxAtof watof
682 #define wxAtoi watoi
683 #define wxAtol watol
684 #define wxGetenv(a) ((wxChar*)NULL)
685 #define wxSystem(a) ((int)NULL)
686 #endif
687 /* time.h functions */
688 #define wxAsctime wasciitime
689 #define wxCtime wctime
690 /* #define wxStrftime wcsftime */
691
692 #define wxNEED_WX_TIME_H
693 #else /* !metrowerks for apple */
694 #error "Please define wide character functions for your environment"
695 #endif
696 #else /* ASCII */
697 #include <ctype.h>
698 #include <string.h>
699
700 /* ctype.h functions */
701 #define wxIsalnum isalnum
702 #define wxIsalpha isalpha
703 #define wxIscntrl iscntrl
704 #define wxIsdigit isdigit
705 #define wxIsgraph isgraph
706 #define wxIslower islower
707 #define wxIsprint isprint
708 #define wxIspunct ispunct
709 #define wxIsspace isspace
710 #define wxIsupper isupper
711 #define wxIsxdigit isxdigit
712 #define wxTolower tolower
713 #define wxToupper toupper
714
715 /* locale.h functons */
716 #define wxSetlocale setlocale
717
718 /* string.h functions */
719 #define wxStrcat strcat
720 #define wxStrchr strchr
721 #define wxStrcmp strcmp
722 #define wxStrcoll strcoll
723 #define wxStrcpy strcpy
724 #define wxStrcspn strcspn
725
726 /* wxStricmp and wxStrnicmp are defined below */
727 #define wxStrlen_ strlen /* used in wxStrlen inline function */
728 #define wxStrncat strncat
729 #define wxStrncmp strncmp
730 #define wxStrncpy strncpy
731 #define wxStrpbrk strpbrk
732 #define wxStrrchr strrchr
733 #define wxStrspn strspn
734 #define wxStrstr strstr
735 #define wxStrtod strtod
736 #ifdef HAVE_STRTOK_R
737 #define wxStrtok(str, sep, last) strtok_r(str, sep, last)
738 #endif
739 #define wxStrtol strtol
740 #define wxStrtoul strtoul
741 #ifdef HAVE_STRTOULL
742 /* assume that we have wcstoull(), which is also C99, too */
743 #define wxStrtoll strtoll
744 #define wxStrtoull strtoull
745 #endif /* HAVE_WCSTOULL */
746 #define wxStrxfrm strxfrm
747
748 /* stdio.h functions */
749 #define wxFopen fopen
750 #define wxFreopen freopen
751 #define wxRemove remove
752 #define wxRename rename
753
754 #define wxPerror perror
755 #define wxTmpnam tmpnam
756
757 #define wxFgetc fgetc
758 #define wxFgetchar fgetchar
759 #define wxFgets fgets
760 #define wxFputc fputc
761 #define wxFputs fputs
762 #define wxFputchar fputchar
763 #define wxFprintf fprintf
764 #define wxFscanf fscanf
765 #define wxGetc getc
766 #define wxGetchar getchar
767 #define wxGets gets
768 #define wxPrintf printf
769 #define wxPutc putc
770 #define wxPutchar putchar
771 #define wxPuts puts
772 #define wxScanf scanf
773 #define wxSprintf sprintf
774 #define wxSscanf sscanf
775 #define wxUngetc ungetc
776 #define wxVfprintf vfprintf
777 #define wxVprintf vprintf
778 #define wxVsscanf vsscanf
779 #define wxVsprintf vsprintf
780
781 /* stdlib.h functions */
782 #define wxAtof atof
783 #define wxAtoi atoi
784 #define wxAtol atol
785 #define wxGetenv getenv
786 #define wxSystem system
787
788 /* time.h functions */
789 #define wxAsctime asctime
790 #define wxCtime ctime
791 #define wxStrftime strftime
792 #endif /* Unicode/ASCII */
793 #endif /* TCHAR-aware compilers/the others */
794
795 #ifdef wxStrtoll
796 #define wxHAS_STRTOLL
797 #endif
798
799 /*
800 various special cases
801 */
802
803 /* define wxStricmp and wxStrnicmp for various compilers */
804
805 /* note that in Unicode mode we definitely are going to need our own version */
806 #if !defined(wxStricmp) && !wxUSE_UNICODE
807 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
808 defined(__SALFORDC__) || defined(__VISAGECPP__) || \
809 defined(__EMX__) || defined(__DJGPP__)
810 #define wxStricmp stricmp
811 #define wxStrnicmp strnicmp
812 #elif defined(__WXPALMOS__)
813 /* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
814 * quick hack should do until one can be written.
815 */
816 #define wxStricmp StrCaselessCompare
817 #define wxStrnicmp strnicmp
818 #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
819 (defined(__MWERKS__) && defined(__INTEL__))
820 #define wxStricmp _stricmp
821 #define wxStrnicmp _strnicmp
822 #elif defined(__UNIX__) || defined(__GNUWIN32__)
823 #define wxStricmp strcasecmp
824 #define wxStrnicmp strncasecmp
825 /* #else -- use wxWidgets implementation */
826 #endif
827 #endif /* !defined(wxStricmp) */
828
829 /* define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as */
830 /* it's used in wx/buffer.h -- and also might be used just below by wxStrlen() */
831 /* when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen) */
832 #if wxUSE_WCHAR_T
833 #ifdef HAVE_WCSLEN
834 #define wxWcslen wcslen
835 #else
836 WXDLLIMPEXP_BASE size_t wxWcslen(const wchar_t *s);
837 #endif
838 #endif /* wxUSE_WCHAR_T */
839
840 #ifdef __cplusplus
841 /* checks whether the passed in pointer is NULL and if the string is empty */
842 inline bool wxIsEmpty(const wxChar *p) { return !p || !*p; }
843
844 /* safe version of strlen() (returns 0 if passed NULL pointer) */
845 inline size_t wxStrlen(const wxChar *psz) { return psz ? wxStrlen_(psz) : 0; }
846 #endif
847
848 /*
849 each of strdup() and wcsdup() may or may not be available but we need both
850 of them anyhow for wx/buffer.h so we define the missing one(s) in
851 wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW
852 defined -- if this is somehow not the case in some situations, please
853 correct that and not the lines here
854 */
855 #if wxUSE_UNICODE
856 #define wxStrdup wxStrdupW
857 #else
858 #define wxStrdup wxStrdupA
859 #endif
860
861 #ifdef __cplusplus
862 WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
863 #endif
864
865 /* printf() family saga */
866
867 /*
868 For some systems [v]snprintf() exists in the system libraries but not in the
869 headers, so we need to declare it ourselves to be able to use it.
870 */
871 #if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
872 #ifdef __cplusplus
873 extern "C"
874 #else
875 extern
876 #endif
877 int vsnprintf(char *str, size_t size, const char *format, va_list ap);
878 #endif /* !HAVE_VSNPRINTF_DECL */
879
880 #if defined(HAVE_SNPRINTF) && !defined(HAVE_SNPRINTF_DECL)
881 #ifdef __cplusplus
882 extern "C"
883 #else
884 extern
885 #endif
886 WXDLLIMPEXP_BASE int snprintf(char *str, size_t size, const char *format, ...);
887 #endif /* !HAVE_SNPRINTF_DECL */
888
889 /* Wrapper for vsnprintf if it's 3rd parameter is non-const. Note: the
890 * same isn't done for snprintf below, the builtin wxSnprintf_ is used
891 * instead since it's already a simple wrapper */
892 #if defined __cplusplus && defined HAVE_BROKEN_VSNPRINTF_DECL
893 inline int wx_fixed_vsnprintf(char *str, size_t size, const char *format, va_list ap)
894 {
895 return vsnprintf(str, size, (char*)format, ap);
896 }
897 #endif
898
899 /*
900 MinGW MSVCRT has non-standard vswprintf() (for MSVC compatibility
901 presumably) and normally _vsnwprintf() is used instead (but as
902 STLPort 5.1 defines standard vswprintf(), don't do this for it)
903 */
904 #if defined(HAVE_VSWPRINTF) && defined(__MINGW32__) && !( defined(_STLPORT_VERSION) && _STLPORT_VERSION >= 0x510 )
905 #undef HAVE_VSWPRINTF
906 #endif
907
908 #if wxUSE_PRINTF_POS_PARAMS
909 /*
910 The systems where vsnprintf() supports positional parameters should
911 define the HAVE_UNIX98_PRINTF symbol.
912
913 On systems which don't (e.g. Windows) we are forced to use
914 our wxVsnprintf() implementation.
915 */
916 #if defined(HAVE_UNIX98_PRINTF)
917 #if wxUSE_UNICODE
918 #ifdef HAVE_VSWPRINTF
919 #define wxVsnprintf_ vswprintf
920 #endif
921 #else /* ASCII */
922 #ifdef HAVE_BROKEN_VSNPRINTF_DECL
923 #define wxVsnprintf_ wx_fixed_vsnprintf
924 #else
925 #define wxVsnprintf_ vsnprintf
926 #endif
927 #endif
928 #else /* !HAVE_UNIX98_PRINTF */
929 /*
930 The only compiler with positional parameters support under Windows
931 is VC++ 8.0 which provides a new xxprintf_p() functions family.
932 The 2003 PSDK includes a slightly earlier version of VC8 than the
933 main release and does not have the printf_p functions.
934 */
935 #if defined _MSC_FULL_VER && _MSC_FULL_VER >= 140050727 && !defined __WXWINCE__
936 #if wxUSE_UNICODE
937 #define wxVsnprintf_ _vswprintf_p
938 #else
939 #define wxVsnprintf_ _vsprintf_p
940 #endif
941 #endif
942 #endif /* HAVE_UNIX98_PRINTF/!HAVE_UNIX98_PRINTF */
943 #else /* !wxUSE_PRINTF_POS_PARAMS */
944 /*
945 We always want to define safe snprintf() function to be used instead of
946 sprintf(). Some compilers already have it (or rather vsnprintf() which
947 we really need...), otherwise we implement it using our own printf()
948 code.
949
950 We define function with a trailing underscore here because the real one
951 is a wrapper around it as explained below
952 */
953
954 /* first deal with TCHAR-aware compilers which have _vsntprintf */
955 #ifndef wxVsnprintf_
956 #if defined(__VISUALC__) || \
957 (defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
958 #define wxVsnprintf_ _vsntprintf
959 #define wxSnprintf_ _sntprintf
960 #endif
961 #endif
962
963 /* if this didn't work, define it separately for Unicode and ANSI builds */
964 #ifndef wxVsnprintf_
965 #if wxUSE_UNICODE
966 #if defined(HAVE__VSNWPRINTF)
967 #define wxVsnprintf_ _vsnwprintf
968 #elif defined(HAVE_VSWPRINTF)
969 #define wxVsnprintf_ vswprintf
970 #elif defined(__WATCOMC__)
971 #define wxVsnprintf_ _vsnwprintf
972 #define wxSnprintf_ _snwprintf
973 #endif
974 #else /* ASCII */
975 /*
976 All versions of CodeWarrior supported by wxWidgets apparently
977 have both snprintf() and vsnprintf()
978 */
979 #if defined(HAVE_SNPRINTF) \
980 || defined(__MWERKS__) || defined(__WATCOMC__)
981 #ifndef HAVE_BROKEN_SNPRINTF_DECL
982 #define wxSnprintf_ snprintf
983 #endif
984 #endif
985 #if defined(HAVE_VSNPRINTF) \
986 || defined(__MWERKS__) || defined(__WATCOMC__)
987 #ifdef HAVE_BROKEN_VSNPRINTF_DECL
988 #define wxVsnprintf_ wx_fixed_vsnprintf
989 #else
990 #define wxVsnprintf_ vsnprintf
991 #endif
992 #endif
993 #endif /* Unicode/ASCII */
994 #endif /* wxVsnprintf_ */
995 #endif /* wxUSE_PRINTF_POS_PARAMS/!wxUSE_PRINTF_POS_PARAMS */
996
997 #ifndef wxSnprintf_
998 /* no snprintf(), cook our own */
999 WXDLLIMPEXP_BASE int
1000 wxSnprintf_(wxChar *buf, size_t len, const wxChar *format, ...) ATTRIBUTE_PRINTF_3;
1001 #endif
1002 #ifndef wxVsnprintf_
1003 /* no (suitable) vsnprintf(), cook our own */
1004 WXDLLIMPEXP_BASE int
1005 wxVsnprintf_(wxChar *buf, size_t len, const wxChar *format, va_list argptr);
1006
1007 #define wxUSE_WXVSNPRINTF 1
1008 #else
1009 #define wxUSE_WXVSNPRINTF 0
1010 #endif
1011
1012 /*
1013 In Unicode mode we need to have all standard functions such as wprintf() and
1014 so on but not all systems have them so use our own implementations in this
1015 case.
1016 */
1017 #if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
1018 #define wxNEED_WPRINTF
1019 #endif
1020
1021 /*
1022 More Unicode complications: although both ANSI C and C++ define a number of
1023 wide character functions such as wprintf(), not all environments have them.
1024 Worse, those which do have different behaviours: under Windows, %s format
1025 specifier changes its meaning in Unicode build and expects a Unicode string
1026 while under Unix/POSIX it still means an ASCII string even for wprintf() and
1027 %ls has to be used for wide strings.
1028
1029 We choose to always emulate Windows behaviour as more useful for us so even
1030 if we have wprintf() we still must wrap it in a non trivial wxPrintf().
1031
1032 */
1033
1034 #if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
1035 /*
1036 we need to implement all wide character printf and scanf functions
1037 either because we don't have them at all or because they don't have the
1038 semantics we need
1039 */
1040 int wxScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
1041 int wxSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1042 int wxFscanf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1043 int wxVsscanf( const wxChar *str, const wxChar *format, va_list ap );
1044 int wxPrintf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
1045 int wxSprintf( wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1046 int wxFprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1047 int wxVfprintf( FILE *stream, const wxChar *format, va_list ap );
1048 int wxVprintf( const wxChar *format, va_list ap );
1049 int wxVsprintf( wxChar *str, const wxChar *format, va_list ap );
1050 #endif /* wxNEED_PRINTF_CONVERSION */
1051
1052 /* these 2 can be simply mapped to the versions with underscore at the end */
1053 /* if we don't have to do the conversion */
1054 /*
1055 However, if we don't have any vswprintf() at all we don't need to redefine
1056 anything as our own wxVsnprintf_() already behaves as needed.
1057 */
1058 #if defined(wxNEED_PRINTF_CONVERSION) && defined(wxVsnprintf_)
1059 int wxSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3;
1060 int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap );
1061 #else
1062 #define wxSnprintf wxSnprintf_
1063 #define wxVsnprintf wxVsnprintf_
1064 #endif
1065
1066 /*
1067 various functions which might not be available in libc and for which we
1068 provide our own replacements in wxchar.cpp
1069 */
1070
1071 /* ctype.h functions */
1072
1073 /* RN: Used only under OSX <= 10.2 currently */
1074 #ifdef wxNEED_WX_CTYPE_H
1075 WXDLLIMPEXP_BASE int wxIsalnum(wxChar ch);
1076 WXDLLIMPEXP_BASE int wxIsalpha(wxChar ch);
1077 WXDLLIMPEXP_BASE int wxIscntrl(wxChar ch);
1078 WXDLLIMPEXP_BASE int wxIsdigit(wxChar ch);
1079 WXDLLIMPEXP_BASE int wxIsgraph(wxChar ch);
1080 WXDLLIMPEXP_BASE int wxIslower(wxChar ch);
1081 WXDLLIMPEXP_BASE int wxIsprint(wxChar ch);
1082 WXDLLIMPEXP_BASE int wxIspunct(wxChar ch);
1083 WXDLLIMPEXP_BASE int wxIsspace(wxChar ch);
1084 WXDLLIMPEXP_BASE int wxIsupper(wxChar ch);
1085 WXDLLIMPEXP_BASE int wxIsxdigit(wxChar ch);
1086 WXDLLIMPEXP_BASE int wxTolower(wxChar ch);
1087 WXDLLIMPEXP_BASE int wxToupper(wxChar ch);
1088 #endif /* wxNEED_WX_CTYPE_H */
1089
1090 /* under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks */
1091 /* the file parsing -- this may be true for 5.0 as well, update #ifdef then */
1092 #if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
1093 #undef wxIsspace
1094 #define wxIsspace(c) ((((unsigned)c) < 128) && isspace(c))
1095 #endif /* VC++ */
1096
1097 /*
1098 a few compilers don't have the (non standard but common) isascii function,
1099 define it ourselves for them
1100 */
1101 #ifndef isascii
1102 #if defined(__MWERKS__)
1103 #define wxNEED_ISASCII
1104 #elif defined(_WIN32_WCE)
1105 #if _WIN32_WCE <= 211
1106 #define wxNEED_ISASCII
1107 #endif
1108 #endif
1109 #endif /* isascii */
1110
1111 #ifdef wxNEED_ISASCII
1112 inline int isascii(int c) { return (unsigned)c < 0x80; }
1113 #endif
1114
1115 #ifdef _WIN32_WCE
1116 #if _WIN32_WCE <= 211
1117 #define isspace(c) ((c) == _T(' ') || (c) == _T('\t'))
1118 #endif
1119 #endif /* _WIN32_WCE */
1120
1121 /*
1122 we had goofed and defined wxIsctrl() instead of (correct) wxIscntrl() in the
1123 initial versions of this header -- now it is too late to remove it so
1124 although we fixed the function/macro name above, still provide the
1125 backwards-compatible synonym.
1126 */
1127 #define wxIsctrl wxIscntrl
1128
1129 /* string.h functions */
1130 #ifndef strdup
1131 #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
1132 #define wxNEED_STRDUP
1133 #elif defined(__WXWINCE__)
1134 #if _WIN32_WCE <= 211
1135 #define wxNEED_STRDUP
1136 #endif
1137 #endif
1138 #endif /* strdup */
1139
1140 #ifdef wxNEED_STRDUP
1141 WXDLLIMPEXP_BASE char *strdup(const char* s);
1142 #endif
1143
1144 /* RN: Used only under OSX <= 10.2 currently
1145 The __cplusplus ifdefs are messy, but they are required to build
1146 the regex library, since c does not support function overloading
1147 */
1148 #ifdef wxNEED_WX_STRING_H
1149 # ifdef __cplusplus
1150 extern "C" {
1151 # endif
1152 WXDLLIMPEXP_BASE wxChar * wxStrcat(wxChar *dest, const wxChar *src);
1153 WXDLLIMPEXP_BASE const wxChar * wxStrchr(const wxChar *s, wxChar c);
1154 WXDLLIMPEXP_BASE int wxStrcmp(const wxChar *s1, const wxChar *s2);
1155 WXDLLIMPEXP_BASE int wxStrcoll(const wxChar *s1, const wxChar *s2);
1156 WXDLLIMPEXP_BASE wxChar * wxStrcpy(wxChar *dest, const wxChar *src);
1157 WXDLLIMPEXP_BASE size_t wxStrcspn(const wxChar *s, const wxChar *reject);
1158 WXDLLIMPEXP_BASE wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n);
1159 WXDLLIMPEXP_BASE int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n);
1160 WXDLLIMPEXP_BASE wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n);
1161 WXDLLIMPEXP_BASE const wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept);
1162 WXDLLIMPEXP_BASE const wxChar * wxStrrchr(const wxChar *s, wxChar c);
1163 WXDLLIMPEXP_BASE size_t wxStrspn(const wxChar *s, const wxChar *accept);
1164 WXDLLIMPEXP_BASE const wxChar * wxStrstr(const wxChar *haystack, const wxChar *needle);
1165 # ifdef __cplusplus
1166 }
1167 # endif
1168
1169 /* These functions use C++, so we can't c extern them */
1170 WXDLLIMPEXP_BASE double wxStrtod(const wxChar *nptr, wxChar **endptr);
1171 WXDLLIMPEXP_BASE long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
1172 WXDLLIMPEXP_BASE unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base);
1173 WXDLLIMPEXP_BASE size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n);
1174
1175 /* inlined versions */
1176 #ifdef __cplusplus
1177 inline wxChar * wxStrchr(wxChar *s, wxChar c)
1178 { return (wxChar *)wxStrchr((const wxChar *)s, c); }
1179 inline wxChar * wxStrpbrk(wxChar *s, const wxChar *accept)
1180 { return (wxChar *)wxStrpbrk((const wxChar *)s, accept); }
1181 inline wxChar * wxStrrchr(wxChar *s, wxChar c)
1182 { return (wxChar *)wxStrrchr((const wxChar *)s, c); }
1183 inline wxChar *wxStrstr(wxChar *haystack, const wxChar *needle)
1184 { return (wxChar *)wxStrstr((const wxChar *)haystack, needle); }
1185 #endif
1186
1187 #endif /* wxNEED_WX_STRING_H */
1188
1189 #ifndef wxStrdupA
1190 WXDLLIMPEXP_BASE char *wxStrdupA(const char *psz);
1191 #endif
1192
1193 #ifndef wxStrdupW
1194 WXDLLIMPEXP_BASE wchar_t *wxStrdupW(const wchar_t *pwz);
1195 #endif
1196
1197 #ifndef wxStricmp
1198 WXDLLIMPEXP_BASE int wxStricmp(const wxChar *psz1, const wxChar *psz2);
1199 #endif
1200
1201 #ifndef wxStrnicmp
1202 WXDLLIMPEXP_BASE int wxStrnicmp(const wxChar *psz1, const wxChar *psz2, size_t len);
1203 #endif
1204
1205 #ifndef wxStrtok
1206 WXDLLIMPEXP_BASE wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr);
1207 #endif
1208
1209 #ifdef __cplusplus
1210 #ifndef wxSetlocale
1211 class WXDLLIMPEXP_BASE wxWCharBuffer;
1212 WXDLLIMPEXP_BASE wxWCharBuffer wxSetlocale(int category, const wxChar *locale);
1213 #endif
1214 #endif
1215
1216 /* stdio.h functions */
1217 #ifdef wxNEED_WX_STDIO_H
1218 #include <stdio.h>
1219 WXDLLIMPEXP_BASE FILE * wxFopen(const wxChar *path, const wxChar *mode);
1220 WXDLLIMPEXP_BASE FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream);
1221 WXDLLIMPEXP_BASE int wxRemove(const wxChar *path);
1222 WXDLLIMPEXP_BASE int wxRename(const wxChar *oldpath, const wxChar *newpath);
1223
1224 /* *printf() family is handled separately */
1225 #endif /* wxNEED_WX_STDIO_H */
1226
1227
1228 /* stdlib.h functions */
1229 #ifndef wxAtof
1230 WXDLLIMPEXP_BASE double wxAtof(const wxChar *psz);
1231 #endif
1232
1233 /*
1234 mingw32 doesn't provide _tsystem() even though it does provide all the other
1235 stdlib.h functions wrappers so check for it separately:
1236 */
1237 #if defined(__MINGW32__) && wxUSE_UNICODE && !defined(_tsystem)
1238 #define wxNEED_WXSYSTEM
1239 #endif
1240
1241 #ifdef wxNEED_WX_STDLIB_H
1242 WXDLLIMPEXP_BASE int wxAtoi(const wxChar *psz);
1243 WXDLLIMPEXP_BASE long wxAtol(const wxChar *psz);
1244 WXDLLIMPEXP_BASE wxChar * wxGetenv(const wxChar *name);
1245 #define wxNEED_WXSYSTEM
1246 #endif
1247
1248 #ifdef wxNEED_WXSYSTEM
1249 WXDLLIMPEXP_BASE int wxSystem(const wxChar *psz);
1250 #endif
1251
1252
1253 /* time.h functions */
1254 #ifdef wxNEED_WX_TIME_H
1255 #if defined(__MWERKS__) && defined(macintosh)
1256 #include <time.h>
1257 #endif
1258 /*silent gabby compilers*/
1259 struct tm;
1260 WXDLLIMPEXP_BASE size_t wxStrftime(wxChar *s, size_t max,
1261 const wxChar *fmt, const struct tm *tm);
1262 #endif /* wxNEED_WX_TIME_H */
1263
1264 #ifndef wxCtime
1265 #include <time.h>
1266 WXDLLIMPEXP_BASE wxChar *wxCtime(const time_t *timep);
1267 #endif
1268
1269
1270 /* missing functions in some WinCE versions */
1271 #ifdef _WIN32_WCE
1272 #if (_WIN32_WCE < 300)
1273 WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
1274 #endif
1275 #endif /* _WIN32_WCE */
1276
1277 /* multibyte to wide char conversion functions and macros */
1278
1279 #if wxUSE_WCHAR_T
1280 /* multibyte<->widechar conversion */
1281 WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n);
1282 WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n);
1283
1284 #if wxUSE_UNICODE
1285 #define wxMB2WX wxMB2WC
1286 #define wxWX2MB wxWC2MB
1287 #define wxWC2WX wxStrncpy
1288 #define wxWX2WC wxStrncpy
1289 #else
1290 #define wxMB2WX wxStrncpy
1291 #define wxWX2MB wxStrncpy
1292 #define wxWC2WX wxWC2MB
1293 #define wxWX2WC wxMB2WC
1294 #endif
1295 #else /* !wxUSE_UNICODE */
1296 /* Why is this here?
1297 #error ha */
1298 /* No wxUSE_WCHAR_T: we have to do something (JACS) */
1299 #define wxMB2WC wxStrncpy
1300 #define wxWC2MB wxStrncpy
1301 #define wxMB2WX wxStrncpy
1302 #define wxWX2MB wxStrncpy
1303 #define wxWC2WX wxWC2MB
1304 #define wxWX2WC wxMB2WC
1305 #endif
1306
1307 /*
1308 RN: The following are not normal versions of memcpy et al., rather
1309 these are either char or widechar versions depending on
1310 if unicode is used or not.
1311 */
1312
1313 #ifdef __cplusplus
1314
1315 //
1316 // RN: We could do the usual tricky compiler detection here,
1317 // and use their variant (such as wmemchr, etc.). The problem
1318 // is that these functions are quite rare, even though they are
1319 // part of the current POSIX standard. In addition, most compilers
1320 // (including even MSC) inline them just like we do right in their
1321 // headers.
1322 //
1323 #include <string.h>
1324 #if wxUSE_UNICODE
1325 //implement our own wmem variants
1326 inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l)
1327 {
1328 for(;l && *s != c;--l, ++s) {}
1329
1330 if(l)
1331 return (wxChar*)s;
1332 return NULL;
1333 }
1334
1335 inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len)
1336 {
1337 for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {}
1338
1339 if(len)
1340 return *sz1 < *sz2 ? -1 : *sz1 > *sz2;
1341 else
1342 return 0;
1343 }
1344
1345 inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len)
1346 {
1347 return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar));
1348 }
1349
1350 inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len)
1351 {
1352 return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar));
1353 }
1354
1355 inline wxChar* wxTmemset(wxChar* szOut, const wxChar cIn, size_t len)
1356 {
1357 wxChar* szRet = szOut;
1358
1359 while (len--)
1360 *szOut++ = cIn;
1361
1362 return szRet;
1363 }
1364 #else /* !wxUSE_UNICODE */
1365 #if wxABI_VERSION >= 20805
1366 // for compatibility with earlier versions, these functions take
1367 // "void *" but in the next wx version they will take "char *" so
1368 // don't use them with void pointers (use the standard memxxx()
1369 // with them)
1370 inline char* wxTmemchr(const void* s, int c, size_t len)
1371 { return (char*)memchr(s, c, len); }
1372 inline int wxTmemcmp(const void* sz1, const void* sz2, size_t len)
1373 { return memcmp(sz1, sz2, len); }
1374 inline char* wxTmemcpy(void* szOut, const void* szIn, size_t len)
1375 { return (char*)memcpy(szOut, szIn, len); }
1376 inline char* wxTmemmove(void* szOut, const void* szIn, size_t len)
1377 { return (char*)memmove(szOut, szIn, len); }
1378 inline char* wxTmemset(void* szOut, int c, size_t len)
1379 { return (char*)memset(szOut, c, len); }
1380 #else
1381 # define wxTmemchr memchr
1382 # define wxTmemcmp memcmp
1383 # define wxTmemcpy memcpy
1384 # define wxTmemmove memmove
1385 # define wxTmemset memset
1386 #endif
1387 #endif /* wxUSE_UNICODE/!wxUSE_UNICODE */
1388
1389 #endif /*__cplusplus*/
1390
1391
1392 #endif /* _WX_WXCHAR_H_ */
1393

  ViewVC Help
Powered by ViewVC 1.1.22