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