]> git.saurik.com Git - wxWidgets.git/blob - include/wx/wxcrtbase.h
compilation fix if wxLongLong_t is not available
[wxWidgets.git] / include / wx / wxcrtbase.h
1 /*
2 * Name: wx/wxcrtbase.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_WXCRTBASE_H_
16 #define _WX_WXCRTBASE_H_
17
18 /* -------------------------------------------------------------------------
19 headers and missing declarations
20 ------------------------------------------------------------------------- */
21
22 #include "wx/chartype.h"
23
24 /*
25 Standard headers we need here.
26
27 NB: don't include any wxWidgets headers here because almost all of them
28 include this one!
29 */
30
31 #include <stdio.h>
32 #include <string.h>
33 #include <ctype.h>
34 #include <wctype.h>
35 #include <time.h>
36
37
38 #if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
39 char *strtok_r(char *, const char *, char **);
40 #endif
41
42 /*
43 a few compilers don't have the (non standard but common) isascii function,
44 define it ourselves for them
45 */
46 #ifndef isascii
47 #if defined(__MWERKS__)
48 #define wxNEED_ISASCII
49 #elif defined(_WIN32_WCE)
50 #if _WIN32_WCE <= 211
51 #define wxNEED_ISASCII
52 #endif
53 #endif
54 #endif /* isascii */
55
56 #ifdef wxNEED_ISASCII
57 inline int isascii(int c) { return (unsigned)c < 0x80; }
58 #endif
59
60 #ifdef _WIN32_WCE
61 #if _WIN32_WCE <= 211
62 #define isspace(c) ((c) == _T(' ') || (c) == _T('\t'))
63 #endif
64 #endif /* _WIN32_WCE */
65
66 /* string.h functions */
67 #ifndef strdup
68 #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
69 #define wxNEED_STRDUP
70 #elif defined(__WXWINCE__)
71 #if _WIN32_WCE <= 211
72 #define wxNEED_STRDUP
73 #endif
74 #endif
75 #endif /* strdup */
76
77 #ifdef wxNEED_STRDUP
78 WXDLLIMPEXP_BASE char *strdup(const char* s);
79 #endif
80
81 /* missing functions in some WinCE versions */
82 #ifdef _WIN32_WCE
83 #if (_WIN32_WCE < 300)
84 WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
85 #endif
86 #endif /* _WIN32_WCE */
87
88
89 #if defined(__MWERKS__)
90 /* Metrowerks only has wide char support for OS X >= 10.3 */
91 #if !defined(__DARWIN__) || \
92 (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
93 #define wxHAVE_MWERKS_UNICODE
94 #endif
95
96 #ifdef wxHAVE_MWERKS_UNICODE
97 #define HAVE_WPRINTF 1
98 #define HAVE_WCSRTOMBS 1
99 #define HAVE_VSWPRINTF 1
100 #endif
101 #endif /* __MWERKS__ */
102
103
104 /* -------------------------------------------------------------------------
105 UTF-8 locale handling
106 ------------------------------------------------------------------------- */
107
108 #ifdef __cplusplus
109 #if wxUSE_UNICODE_UTF8
110 /* flag indicating whether the current locale uses UTF-8 or not; must be
111 updated every time the locale is changed! */
112 #if wxUSE_UTF8_LOCALE_ONLY
113 #define wxLocaleIsUtf8 true
114 #else
115 extern WXDLLIMPEXP_BASE bool wxLocaleIsUtf8;
116 #endif
117 /* function used to update the flag: */
118 extern WXDLLIMPEXP_BASE void wxUpdateLocaleIsUtf8();
119 #else /* !wxUSE_UNICODE_UTF8 */
120 inline void wxUpdateLocaleIsUtf8() {}
121 #endif /* wxUSE_UNICODE_UTF8/!wxUSE_UNICODE_UTF8 */
122 #endif /* __cplusplus */
123
124
125 /* -------------------------------------------------------------------------
126 string.h
127 ------------------------------------------------------------------------- */
128
129 #define wxCRT_StrcatA strcat
130 #define wxCRT_StrchrA strchr
131 #define wxCRT_StrcmpA strcmp
132 #define wxCRT_StrcollA strcoll
133 #define wxCRT_StrcpyA strcpy
134 #define wxCRT_StrcspnA strcspn
135 #define wxCRT_StrlenA strlen
136 #define wxCRT_StrncatA strncat
137 #define wxCRT_StrncmpA strncmp
138 #define wxCRT_StrncpyA strncpy
139 #define wxCRT_StrpbrkA strpbrk
140 #define wxCRT_StrrchrA strrchr
141 #define wxCRT_StrspnA strspn
142 #define wxCRT_StrstrA strstr
143 #define wxCRT_StrxfrmA strxfrm
144
145 #define wxCRT_StrcatW wcscat
146 #define wxCRT_StrchrW wcschr
147 #define wxCRT_StrcmpW wcscmp
148 #define wxCRT_StrcollW wcscoll
149 #define wxCRT_StrcpyW wcscpy
150 #define wxCRT_StrcspnW wcscspn
151 #define wxCRT_StrncatW wcsncat
152 #define wxCRT_StrncmpW wcsncmp
153 #define wxCRT_StrncpyW wcsncpy
154 #define wxCRT_StrpbrkW wcspbrk
155 #define wxCRT_StrrchrW wcsrchr
156 #define wxCRT_StrspnW wcsspn
157 #define wxCRT_StrstrW wcsstr
158 #define wxCRT_StrxfrmW wcsxfrm
159
160 /* Almost all compiler have strdup(), but not quite all: CodeWarrior under
161 Mac and VC++ for Windows CE don't provide it; additionally, gcc under
162 Mac and OpenVMS do not have wcsdup: */
163 #if defined(__VISUALC__) && __VISUALC__ >= 1400
164 #define wxCRT_StrdupA _strdup
165 #elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
166 #define wxCRT_StrdupA strdup
167 #endif
168 #if defined(__WINDOWS__)
169 #define wxCRT_StrdupW _wcsdup
170 #elif !defined(__DARWIN__) && !defined( __VMS )
171 #define wxCRT_StrdupW wcsdup
172 #endif
173
174 #ifdef wxHAVE_TCHAR_SUPPORT
175 /* we surely have wchar_t if we have TCHAR have wcslen() */
176 #ifndef HAVE_WCSLEN
177 #define HAVE_WCSLEN
178 #endif
179 #endif /* wxHAVE_TCHAR_SUPPORT */
180
181 #ifdef HAVE_WCSLEN
182 #define wxCRT_StrlenW wcslen
183 #endif
184
185 #define wxCRT_StrtodA strtod
186 #define wxCRT_StrtolA strtol
187 #define wxCRT_StrtoulA strtoul
188 #define wxCRT_StrtodW wcstod
189 #define wxCRT_StrtolW wcstol
190 #define wxCRT_StrtoulW wcstoul
191
192 #ifdef __VISUALC__
193 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
194 #define wxCRT_StrtollA _strtoi64
195 #define wxCRT_StrtoullA _strtoui64
196 #define wxCRT_StrtollW _wcstoi64
197 #define wxCRT_StrtoullW _wcstoui64
198 #endif /* VC++ 7+ */
199 #else
200 #ifdef HAVE_STRTOULL
201 #define wxCRT_StrtollA strtoll
202 #define wxCRT_StrtoullA strtoull
203 #endif /* HAVE_STRTOULL */
204 #ifdef HAVE_WCSTOULL
205 /* assume that we have wcstoull(), which is also C99, too */
206 #define wxCRT_StrtollW wcstoll
207 #define wxCRT_StrtoullW wcstoull
208 #endif /* HAVE_WCSTOULL */
209 #endif
210
211
212 /* define wxCRT_StricmpA/W and wxCRT_StrnicmpA/W for various compilers */
213
214 /* note that we definitely are going to need our own version for widechar
215 * versions */
216 #if !defined(wxCRT_StricmpA)
217 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
218 defined(__SALFORDC__) || defined(__VISAGECPP__) || \
219 defined(__EMX__) || defined(__DJGPP__)
220 #define wxCRT_StricmpA stricmp
221 #define wxCRT_StrnicmpA strnicmp
222 #elif defined(__WXPALMOS__)
223 /* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
224 * quick hack should do until one can be written.
225 */
226 #define wxCRT_StricmpA StrCaselessCompare
227 #define wxCRT_StrnicmpA strnicmp
228 #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
229 (defined(__MWERKS__) && defined(__INTEL__))
230 #define wxCRT_StricmpA _stricmp
231 #define wxCRT_StrnicmpA _strnicmp
232 #elif defined(__UNIX__) || defined(__GNUWIN32__)
233 #define wxCRT_StricmpA strcasecmp
234 #define wxCRT_StrnicmpA strncasecmp
235 /* #else -- use wxWidgets implementation */
236 #endif
237 #endif /* !defined(wxCRT_StricmpA) */
238 /* FIXME-UTF8: use wcs(n)casecmp if available for *W versions */
239
240 #ifdef HAVE_STRTOK_R
241 #define wxCRT_StrtokA(str, sep, last) strtok_r(str, sep, last)
242 #endif
243 /* FIXME-UTF8: detect and use wcstok() if available for wxCRT_StrtokW */
244
245 /* these are extern "C" because they are used by regex lib: */
246 #ifdef __cplusplus
247 extern "C" {
248 #endif
249
250 #ifndef wxCRT_StrlenW
251 WXDLLIMPEXP_BASE size_t wxCRT_StrlenW(const wchar_t *s);
252 #endif
253
254 #ifndef wxCRT_StrncmpW
255 WXDLLIMPEXP_BASE int wxCRT_StrncmpW(const wchar_t *s1, const wchar_t *s2, size_t n);
256 #endif
257
258 #ifdef __cplusplus
259 }
260 #endif
261
262 /* FIXME-UTF8: remove this once we are Unicode only */
263 #if wxUSE_UNICODE
264 #define wxCRT_StrlenNative wxCRT_StrlenW
265 #define wxCRT_StrncmpNative wxCRT_StrncmpW
266 #define wxCRT_ToupperNative wxCRT_ToupperW
267 #define wxCRT_TolowerNative wxCRT_TolowerW
268 #else
269 #define wxCRT_StrlenNative wxCRT_StrlenA
270 #define wxCRT_StrncmpNative wxCRT_StrncmpA
271 #define wxCRT_ToupperNative toupper
272 #define wxCRT_TolowerNative tolower
273 #endif
274
275 #ifndef wxCRT_StrcatW
276 WXDLLIMPEXP_BASE wchar_t *wxCRT_StrcatW(wchar_t *dest, const wchar_t *src);
277 #endif
278
279 #ifndef wxCRT_StrchrW
280 WXDLLIMPEXP_BASE const wchar_t *wxCRT_StrchrW(const wchar_t *s, wchar_t c);
281 #endif
282
283 #ifndef wxCRT_StrcmpW
284 WXDLLIMPEXP_BASE int wxCRT_StrcmpW(const wchar_t *s1, const wchar_t *s2);
285 #endif
286
287 #ifndef wxCRT_StrcollW
288 WXDLLIMPEXP_BASE int wxCRT_StrcollW(const wchar_t *s1, const wchar_t *s2);
289 #endif
290
291 #ifndef wxCRT_StrcpyW
292 WXDLLIMPEXP_BASE wchar_t *wxCRT_StrcpyW(wchar_t *dest, const wchar_t *src);
293 #endif
294
295 #ifndef wxCRT_StrcspnW
296 WXDLLIMPEXP_BASE size_t wxCRT_StrcspnW(const wchar_t *s, const wchar_t *reject);
297 #endif
298
299 #ifndef wxCRT_StrncatW
300 WXDLLIMPEXP_BASE wchar_t *wxCRT_StrncatW(wchar_t *dest, const wchar_t *src, size_t n);
301 #endif
302
303 #ifndef wxCRT_StrncpyW
304 WXDLLIMPEXP_BASE wchar_t *wxCRT_StrncpyW(wchar_t *dest, const wchar_t *src, size_t n);
305 #endif
306
307 #ifndef wxCRT_StrpbrkW
308 WXDLLIMPEXP_BASE const wchar_t *wxCRT_StrpbrkW(const wchar_t *s, const wchar_t *accept);
309 #endif
310
311 #ifndef wxCRT_StrrchrW
312 WXDLLIMPEXP_BASE const wchar_t *wxCRT_StrrchrW(const wchar_t *s, wchar_t c);
313 #endif
314
315 #ifndef wxCRT_StrspnW
316 WXDLLIMPEXP_BASE size_t wxCRT_StrspnW(const wchar_t *s, const wchar_t *accept);
317 #endif
318
319 #ifndef wxCRT_StrstrW
320 WXDLLIMPEXP_BASE const wchar_t *wxCRT_StrstrW(const wchar_t *haystack, const wchar_t *needle);
321 #endif
322
323 #ifndef wxCRT_StrtodW
324 WXDLLIMPEXP_BASE double wxCRT_StrtodW(const wchar_t *nptr, wchar_t **endptr);
325 #endif
326
327 #ifndef wxCRT_StrtolW
328 WXDLLIMPEXP_BASE long int wxCRT_StrtolW(const wchar_t *nptr, wchar_t **endptr, int base);
329 #endif
330
331 #ifndef wxCRT_StrtoulW
332 WXDLLIMPEXP_BASE unsigned long int wxCRT_StrtoulW(const wchar_t *nptr, wchar_t **endptr, int base);
333 #endif
334
335 #ifndef wxCRT_StrxfrmW
336 WXDLLIMPEXP_BASE size_t wxCRT_StrxfrmW(wchar_t *dest, const wchar_t *src, size_t n);
337 #endif
338
339 #ifndef wxCRT_StrdupA
340 WXDLLIMPEXP_BASE char *wxCRT_StrdupA(const char *psz);
341 #endif
342
343 #ifndef wxCRT_StrdupW
344 WXDLLIMPEXP_BASE wchar_t *wxCRT_StrdupW(const wchar_t *pwz);
345 #endif
346
347 #ifndef wxCRT_StricmpA
348 WXDLLIMPEXP_BASE int wxCRT_StricmpA(const char *psz1, const char *psz2);
349 #endif
350
351 #ifndef wxCRT_StricmpW
352 WXDLLIMPEXP_BASE int wxCRT_StricmpW(const wchar_t *psz1, const wchar_t *psz2);
353 #endif
354
355 #ifndef wxCRT_StrnicmpA
356 WXDLLIMPEXP_BASE int wxCRT_StrnicmpA(const char *psz1, const char *psz2, size_t len);
357 #endif
358
359 #ifndef wxCRT_StrnicmpW
360 WXDLLIMPEXP_BASE int wxCRT_StrnicmpW(const wchar_t *psz1, const wchar_t *psz2, size_t len);
361 #endif
362
363 #ifndef wxCRT_StrtokA
364 WXDLLIMPEXP_BASE char *wxCRT_StrtokA(char *psz, const char *delim, char **save_ptr);
365 #endif
366
367 #ifndef wxCRT_StrtokW
368 WXDLLIMPEXP_BASE wchar_t *wxCRT_StrtokW(wchar_t *psz, const wchar_t *delim, wchar_t **save_ptr);
369 #endif
370
371 /* supply strtoll and strtoull, if needed */
372 #ifdef wxLongLong_t
373 #ifndef wxCRT_StrtollA
374 WXDLLIMPEXP_BASE wxLongLong_t wxCRT_StrtollA(const char* nptr,
375 char** endptr,
376 int base);
377 WXDLLIMPEXP_BASE wxULongLong_t wxCRT_StrtoullA(const char* nptr,
378 char** endptr,
379 int base);
380 #endif
381 #ifndef wxCRT_StrtollW
382 WXDLLIMPEXP_BASE wxLongLong_t wxCRT_StrtollW(const wchar_t* nptr,
383 wchar_t** endptr,
384 int base);
385 WXDLLIMPEXP_BASE wxULongLong_t wxCRT_StrtoullW(const wchar_t* nptr,
386 wchar_t** endptr,
387 int base);
388 #endif
389 #endif // wxLongLong_t
390
391
392 /* -------------------------------------------------------------------------
393 stdio.h
394 ------------------------------------------------------------------------- */
395
396 #if defined(__UNIX__) || defined(__WXMAC__)
397 #define wxMBFILES 1
398 #else
399 #define wxMBFILES 0
400 #endif
401
402
403 /* these functions are only needed in the form used for filenames (i.e. char*
404 on Unix, wchar_t* on Windows), so we don't need to use A/W suffix: */
405 #if wxMBFILES || !wxUSE_UNICODE /* ANSI filenames */
406
407 #define wxCRT_Fopen fopen
408 #define wxCRT_Freopen freopen
409 #define wxCRT_Remove remove
410 #define wxCRT_Rename rename
411
412 #else /* Unicode filenames */
413
414 /* special case: these functions are missing under Win9x with Unicows so we
415 have to implement them ourselves */
416 #if wxUSE_UNICODE_MSLU
417 WXDLLIMPEXP_BASE FILE* wxMSLU__wfopen(const wchar_t *name, const wchar_t *mode);
418 WXDLLIMPEXP_BASE FILE* wxMSLU__wfreopen(const wchar_t *name, const wchar_t *mode, FILE *stream);
419 WXDLLIMPEXP_BASE int wxMSLU__wrename(const wchar_t *oldname, const wchar_t *newname);
420 WXDLLIMPEXP_BASE int wxMSLU__wremove(const wchar_t *name);
421 #define wxCRT_Fopen wxMSLU__wfopen
422 #define wxCRT_Freopen wxMSLU__wfreopen
423 #define wxCRT_Remove wxMSLU__wremove
424 #define wxCRT_Rename wxMSLU__wrename
425 #else
426 #define wxCRT_Rename _wrename
427 #define wxCRT_Fopen _wfopen
428 #define wxCRT_Freopen _wfreopen
429 #ifdef __WXWINCE__
430 /* carefully: wxCRT_Remove() must return 0 on success while
431 DeleteFile() returns 0 on error, so don't just define one as
432 the other */
433 int wxCRT_Remove(const wchar_t *path);
434 #else
435 #define wxCRT_Remove _wremove
436 #endif
437 #endif
438
439 #endif /* wxMBFILES/!wxMBFILES */
440
441 #define wxCRT_PutsA puts
442 #define wxCRT_FputsA fputs
443 #define wxCRT_FgetsA fgets
444 #define wxCRT_FputcA fputc
445 #define wxCRT_FgetcA fgetc
446 #define wxCRT_UngetcA ungetc
447
448 #ifdef wxHAVE_TCHAR_SUPPORT
449 #define wxCRT_PutsW _putws
450 #define wxCRT_FputsW fputws
451 #define wxCRT_FputcW fputwc
452 #endif
453 #ifdef HAVE_FPUTWS
454 #define wxCRT_FputsW fputws
455 #endif
456 #ifdef HAVE_PUTWS
457 #define wxCRT_PutsW putws
458 #endif
459 #ifdef HAVE_FPUTWC
460 #define wxCRT_FputcW fputwc
461 #endif
462 #define wxCRT_FgetsW fgetws
463
464 #ifndef wxCRT_PutsW
465 WXDLLIMPEXP_BASE int wxCRT_PutsW(const wchar_t *ws);
466 #endif
467
468 #ifndef wxCRT_FputsW
469 WXDLLIMPEXP_BASE int wxCRT_FputsW(const wchar_t *ch, FILE *stream);
470 #endif
471
472 #ifndef wxCRT_FputcW
473 WXDLLIMPEXP_BASE int wxCRT_FputcW(wchar_t wc, FILE *stream);
474 #endif
475
476 #define wxCRT_TmpnamA tmpnam
477 #ifdef _ttmpnam
478 #define wxCRT_TmpnamW _wtmpnam
479 #endif
480
481 #ifndef wxCRT_TmpnamW
482 WXDLLIMPEXP_BASE wchar_t *wxCRT_TmpnamW(wchar_t *s);
483 #endif
484
485 #define wxCRT_PerrorA perror
486 #ifdef wxHAVE_TCHAR_SUPPORT
487 #define wxCRT_PerrorW _wperror
488 #endif
489
490 /* -------------------------------------------------------------------------
491 stdlib.h
492 ------------------------------------------------------------------------- */
493
494 /* there are no env vars at all under CE, so no _tgetenv neither */
495 #ifdef __WXWINCE__
496 /* can't define as inline function as this is a C file... */
497 #define wxCRT_GetenvA(name) ((char*)NULL)
498 #define wxCRT_GetenvW(name) ((wchar_t*)NULL)
499 #else
500 #define wxCRT_GetenvA getenv
501 #ifdef _tgetenv
502 #define wxCRT_GetenvW _wgetenv
503 #endif
504 #endif
505
506 #ifndef wxCRT_GetenvW
507 WXDLLIMPEXP_BASE wchar_t * wxCRT_GetenvW(const wchar_t *name);
508 #endif
509
510
511 #define wxCRT_SystemA system
512 /* mingw32 doesn't provide _tsystem() or _wsystem(): */
513 #if defined(_tsystem)
514 #define wxCRT_SystemW _wsystem
515 #endif
516
517 #define wxCRT_AtofA atof
518 #define wxCRT_AtoiA atoi
519 #define wxCRT_AtolA atol
520
521 #if defined(__MWERKS__)
522 #if defined(__MSL__)
523 #define wxCRT_AtofW watof
524 #define wxCRT_AtoiW watoi
525 #define wxCRT_AtolW watol
526 /* else: use ANSI versions */
527 #endif
528 #elif defined(wxHAVE_TCHAR_SUPPORT)
529 #define wxCRT_AtoiW _wtoi
530 #define wxCRT_AtolW _wtol
531 /* _wtof doesn't exist */
532 #else
533 #ifndef __VMS
534 #define wxCRT_AtofW(s) wcstof(s, NULL)
535 #endif
536 #define wxCRT_AtolW(s) wcstol(s, NULL, 10)
537 /* wcstoi doesn't exist */
538 #endif
539
540 /*
541 There are 2 unrelated problems with these functions under Mac:
542 a) Metrowerks MSL CRT implements them strictly in C99 sense and
543 doesn't support (very common) extension of allowing to call
544 mbstowcs(NULL, ...) which makes it pretty useless as you can't
545 know the size of the needed buffer
546 b) OS X <= 10.2 declares and even defined these functions but
547 doesn't really implement them -- they always return an error
548
549 So use our own replacements in both cases.
550 */
551 #if defined(__MWERKS__) && defined(__MSL__)
552 #define wxNEED_WX_MBSTOWCS
553 #endif
554
555 #ifdef __DARWIN__
556 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
557 #define wxNEED_WX_MBSTOWCS
558 #endif
559 #endif
560
561 #ifdef wxNEED_WX_MBSTOWCS
562 /* even though they are defined and "implemented", they are bad and just
563 stubs so we need our own - we need these even in ANSI builds!! */
564 WXDLLIMPEXP_BASE size_t wxMbstowcs(wchar_t *, const char *, size_t);
565 WXDLLIMPEXP_BASE size_t wxWcstombs(char *, const wchar_t *, size_t);
566 #else
567 #define wxMbstowcs mbstowcs
568 #define wxWcstombs wcstombs
569 #endif
570
571
572
573 /* -------------------------------------------------------------------------
574 time.h
575 ------------------------------------------------------------------------- */
576
577 #define wxCRT_StrftimeA strftime
578 /* FIXME-UTF8: when is this available? */
579 #define wxCRT_StrftimeW wcsftime
580
581 #ifndef wxCRT_StrftimeW
582 WXDLLIMPEXP_BASE size_t wxCRT_StrftimeW(wchar_t *s, size_t max,
583 const wchar_t *fmt,
584 const struct tm *tm);
585 #endif
586
587
588
589 /* -------------------------------------------------------------------------
590 ctype.h
591 ------------------------------------------------------------------------- */
592
593 #ifdef __WATCOMC__
594 #define WXWCHAR_T_CAST(c) (wint_t)(c)
595 #else
596 #define WXWCHAR_T_CAST(c) c
597 #endif
598
599 #define wxCRT_IsalnumW(c) iswalnum(WXWCHAR_T_CAST(c))
600 #define wxCRT_IsalphaW(c) iswalpha(WXWCHAR_T_CAST(c))
601 #define wxCRT_IscntrlW(c) iswcntrl(WXWCHAR_T_CAST(c))
602 #define wxCRT_IsdigitW(c) iswdigit(WXWCHAR_T_CAST(c))
603 #define wxCRT_IsgraphW(c) iswgraph(WXWCHAR_T_CAST(c))
604 #define wxCRT_IslowerW(c) iswlower(WXWCHAR_T_CAST(c))
605 #define wxCRT_IsprintW(c) iswprint(WXWCHAR_T_CAST(c))
606 #define wxCRT_IspunctW(c) iswpunct(WXWCHAR_T_CAST(c))
607 #define wxCRT_IsspaceW(c) iswspace(WXWCHAR_T_CAST(c))
608 #define wxCRT_IsupperW(c) iswupper(WXWCHAR_T_CAST(c))
609 #define wxCRT_IsxdigitW(c) iswxdigit(WXWCHAR_T_CAST(c))
610
611 #ifdef __GLIBC__
612 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
613 /* /usr/include/wctype.h incorrectly declares translations */
614 /* tables which provokes tons of compile-time warnings -- try */
615 /* to correct this */
616 #define wxCRT_TolowerW(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
617 #define wxCRT_ToupperW(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
618 #else /* !glibc 2.0 */
619 #define wxCRT_TolowerW towlower
620 #define wxCRT_ToupperW towupper
621 #endif
622 #else /* !__GLIBC__ */
623 /* There is a bug in VC6 C RTL: toxxx() functions dosn't do anything
624 with signed chars < 0, so "fix" it here. */
625 #define wxCRT_TolowerW(c) towlower((wxUChar)(wxChar)(c))
626 #define wxCRT_ToupperW(c) towupper((wxUChar)(wxChar)(c))
627 #endif /* __GLIBC__/!__GLIBC__ */
628
629
630
631
632
633 /* -------------------------------------------------------------------------
634 wx wrappers for CRT functions in both char* and wchar_t* versions
635 ------------------------------------------------------------------------- */
636
637 #ifdef __cplusplus
638
639 /* NB: this belongs to wxcrt.h and not this header, but it makes life easier
640 * for buffer.h and stringimpl.h (both of which must be included before
641 * string.h, which is required by wxcrt.h) to have them here: */
642
643 /* safe version of strlen() (returns 0 if passed NULL pointer) */
644 inline size_t wxStrlen(const char *s) { return s ? wxCRT_StrlenA(s) : 0; }
645 inline size_t wxStrlen(const wchar_t *s) { return s ? wxCRT_StrlenW(s) : 0; }
646 #define wxWcslen wxCRT_StrlenW
647
648 #define wxStrdupA wxCRT_StrdupA
649 #define wxStrdupW wxCRT_StrdupW
650 inline char* wxStrdup(const char *s) { return wxCRT_StrdupA(s); }
651 inline wchar_t* wxStrdup(const wchar_t *s) { return wxCRT_StrdupW(s); }
652
653 #endif /* __cplusplus */
654
655 #endif /* _WX_WXCRTBASE_H_ */