2 // OS_NS_wchar.h is only needed to get the emulation methods.
3 // Perhaps they should be moved. dhinton
4 #include "ace/OS_NS_wchar.h"
5 #include "ace/os_include/os_string.h"
7 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
9 ACE_INLINE const void *
10 ACE_OS::memchr (const void *s, int c, size_t len)
12 return ::memchr (s, c, len);
16 ACE_OS::memchr (void *s, int c, size_t len)
18 return const_cast<void *> (ACE_OS::memchr (static_cast<const void *> (s),
24 ACE_OS::memcmp (const void *t, const void *s, size_t len)
26 return ::memcmp (t, s, len);
30 ACE_OS::memcpy (void *t, const void *s, size_t len)
32 return ::memcpy (t, s, len);
36 ACE_OS::memmove (void *t, const void *s, size_t len)
38 return ::memmove (t, s, len);
42 ACE_OS::memset (void *s, int c, size_t len)
44 return ::memset (s, c, len);
48 ACE_OS::strcat (char *s, const char *t)
50 return ::strcat (s, t);
53 #if defined (ACE_HAS_WCHAR)
55 ACE_OS::strcat (wchar_t *s, const wchar_t *t)
57 # if defined (ACE_LACKS_WCSCAT)
58 return ACE_OS::wcscat_emulation (s, t);
59 # else /* ACE_LACKS_WCSCAT */
60 return ::wcscat (s, t);
61 # endif /* ACE_LACKS_WCSCAT */
63 #endif /* ACE_HAS_WCHAR */
65 ACE_INLINE const char *
66 ACE_OS::strchr (const char *s, int c)
68 return ::strchr (s, c);
71 #if defined (ACE_HAS_WCHAR)
72 ACE_INLINE const wchar_t *
73 ACE_OS::strchr (const wchar_t *s, wchar_t c)
75 # if defined (ACE_LACKS_WCSCHR)
76 return ACE_OS::wcschr_emulation (s, c);
77 # else /* ACE_LACKS_WCSCHR */
78 return ::wcschr (s, c);
79 # endif /* ACE_LACKS_WCSCHR */
81 #endif /* ACE_HAS_WCHAR */
84 ACE_OS::strchr (char *s, int c)
86 return ::strchr (s, c);
89 #if defined (ACE_HAS_WCHAR)
91 ACE_OS::strchr (wchar_t *s, wchar_t c)
93 return const_cast<wchar_t *> (ACE_OS::strchr (const_cast<const wchar_t *> (s), c));
95 #endif /* ACE_HAS_WCHAR */
98 ACE_OS::strcmp (const char *s, const char *t)
100 return ::strcmp (s, t);
104 ACE_OS::strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t)
106 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP)
107 return ACE_OS::wcscmp_emulation (s, t);
108 # else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
109 return ::wcscmp (s, t);
110 # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSCMP */
114 ACE_OS::strcpy (char *s, const char *t)
116 return ::strcpy (s, t);
119 #if defined (ACE_HAS_WCHAR)
121 ACE_OS::strcpy (wchar_t *s, const wchar_t *t)
123 # if defined (ACE_LACKS_WCSCPY)
124 return ACE_OS::wcscpy_emulation (s, t);
125 # else /* ACE_LACKS_WCSCPY */
126 return ::wcscpy (s, t);
127 # endif /* ACE_LACKS_WCSCPY */
129 #endif /* ACE_HAS_WCHAR */
132 ACE_OS::strcspn (const char *s, const char *reject)
134 return ::strcspn (s, reject);
137 #if defined (ACE_HAS_WCHAR)
139 ACE_OS::strcspn (const wchar_t *s, const wchar_t *reject)
141 # if defined (ACE_LACKS_WCSCSPN)
142 return ACE_OS::wcscspn_emulation (s, reject);
143 # else /* ACE_LACKS_WCSCSPN */
144 return ::wcscspn (s, reject);
145 # endif /* ACE_LACKS_WCSCSPN */
147 #endif /* ACE_HAS_WCHAR */
150 ACE_OS::strdup (const char *s)
152 # if (defined (ACE_LACKS_STRDUP) && !defined(ACE_STRDUP_EQUIVALENT)) \
153 || defined (ACE_HAS_STRDUP_EMULATION)
154 return ACE_OS::strdup_emulation (s);
155 # elif defined (ACE_STRDUP_EQUIVALENT)
156 return ACE_STRDUP_EQUIVALENT (s);
157 # elif defined (ACE_HAS_NONCONST_STRDUP)
158 return ::strdup (const_cast<char *> (s));
161 # endif /* (ACE_LACKS_STRDUP && !ACE_STRDUP_EQUIVALENT) || ... */
164 #if defined (ACE_HAS_WCHAR)
166 ACE_OS::strdup (const wchar_t *s)
168 # if (defined (ACE_LACKS_WCSDUP) && !defined (ACE_WCSDUP_EQUIVALENT)) \
169 || defined (ACE_HAS_WCSDUMP_EMULATION)
170 return ACE_OS::strdup_emulation (s);
171 # elif defined (ACE_WCSDUP_EQUIVALENT)
172 return ACE_WCSDUP_EQUIVALENT (s);
173 # elif defined (ACE_HAS_NONCONST_WCSDUP)
174 return ::wcsdup (const_cast<wchar_t*> (s));
177 # endif /* (ACE_LACKS_WCSDUP && !ACE_WCSDUP_EQUIVALENT) || ... */
179 #endif /* ACE_HAS_WCHAR */
182 ACE_OS::strlen (const char *s)
188 ACE_OS::strlen (const ACE_WCHAR_T *s)
190 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN)
191 return ACE_OS::wcslen_emulation (s);
192 # else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
194 # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSLEN */
198 ACE_OS::strncat (char *s, const char *t, size_t len)
200 return ::strncat (s, t, len);
203 ACE_INLINE ACE_WCHAR_T *
204 ACE_OS::strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
206 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT)
207 return ACE_OS::wcsncat_emulation (s, t, len);
208 # elif 0 /* defined (ACE_HAS_TR24731_2005_CRT) */
209 wcsncat_s (s, len + 1, t, _TRUNCATE);
211 # else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
212 return ::wcsncat (s, t, len);
213 # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCAT */
217 ACE_OS::strnchr (char *s, int c, size_t len)
219 return const_cast<char *> (ACE_OS::strnchr (static_cast<const char *> (s),
224 ACE_INLINE ACE_WCHAR_T *
225 ACE_OS::strnchr (ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
228 const_cast<ACE_WCHAR_T *> (ACE_OS::strnchr (
229 const_cast<const ACE_WCHAR_T *> (s),
235 ACE_OS::strncmp (const char *s, const char *t, size_t len)
237 return ::strncmp (s, t, len);
241 ACE_OS::strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
243 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP)
244 return ACE_OS::wcsncmp_emulation (s, t, len);
245 # else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
246 return ::wcsncmp (s, t, len);
247 # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCMP */
251 ACE_OS::strncpy (char *s, const char *t, size_t len)
253 return ::strncpy (s, t, len);
256 ACE_INLINE ACE_WCHAR_T *
257 ACE_OS::strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
259 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY)
260 return ACE_OS::wcsncpy_emulation (s, t, len);
261 # else /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
262 return ::wcsncpy (s, t, len);
263 # endif /* !ACE_HAS_WCHAR || ACE_LACKS_WCSNCPY */
267 ACE_OS::strnlen (const char *s, size_t maxlen)
269 #if defined (ACE_HAS_STRNLEN)
270 return ::strnlen (s, maxlen);
271 #else /* ACE_HAS_STRNLEN */
273 for (i = 0; i < maxlen; ++i)
277 #endif /* ACE_HAS_STRNLEN */
281 ACE_OS::strnlen (const ACE_WCHAR_T *s, size_t maxlen)
283 #if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN)
284 return wcsnlen (s, maxlen);
285 #else /* ACE_HAS_WCSNLEN */
287 for (i = 0; i < maxlen; ++i)
291 #endif /* ACE_HAS_WCSNLEN */
295 ACE_OS::strnstr (char *s, const char *t, size_t len)
298 const_cast <char *> (ACE_OS::strnstr (const_cast <const char *> (s), t, len));
301 ACE_INLINE ACE_WCHAR_T *
302 ACE_OS::strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
305 const_cast<ACE_WCHAR_T *> (ACE_OS::strnstr (
306 static_cast<const ACE_WCHAR_T *> (s),
311 ACE_INLINE const char *
312 ACE_OS::strpbrk (const char *s1, const char *s2)
314 return const_cast <const char *> (::strpbrk (s1, s2));
317 #if defined (ACE_HAS_WCHAR)
318 ACE_INLINE const wchar_t *
319 ACE_OS::strpbrk (const wchar_t *s, const wchar_t *t)
321 # if defined (ACE_LACKS_WCSPBRK)
322 return ACE_OS::wcspbrk_emulation (s, t);
323 # else /* ACE_LACKS_WCSPBRK */
324 return ::wcspbrk (s, t);
325 # endif /* ACE_LACKS_WCSPBRK */
327 #endif /* ACE_HAS_WCHAR */
330 ACE_OS::strpbrk (char *s1, const char *s2)
332 return ::strpbrk (s1, s2);
335 #if defined (ACE_HAS_WCHAR)
337 ACE_OS::strpbrk (wchar_t *s, const wchar_t *t)
339 return const_cast<wchar_t *> (ACE_OS::strpbrk (const_cast<const wchar_t *> (s), t));
341 #endif /* ACE_HAS_WCHAR */
343 ACE_INLINE const char *
344 ACE_OS::strrchr (const char *s, int c)
346 return (const char *) ::strrchr (s, c);
349 #if defined (ACE_HAS_WCHAR)
350 ACE_INLINE const wchar_t *
351 ACE_OS::strrchr (const wchar_t *s, wchar_t c)
353 #if defined (ACE_LACKS_WCSRCHR)
354 return ACE_OS::wcsrchr_emulation (s, c);
355 #else /* ! ACE_LACKS_WCSRCHR */
356 return const_cast <const wchar_t *> (::wcsrchr (s, c));
357 #endif /* ! ACE_LACKS_WCSRCHR */
359 #endif /* ACE_HAS_WCHAR */
362 ACE_OS::strrchr (char *s, int c)
364 return ::strrchr (s, c);
367 #if defined (ACE_HAS_WCHAR)
369 ACE_OS::strrchr (wchar_t *s, wchar_t c)
371 return const_cast<wchar_t *> (ACE_OS::strrchr (
372 const_cast<const wchar_t *> (s), c));
374 #endif /* ACE_HAS_WCHAR */
377 ACE_OS::strspn (const char *s, const char *t)
379 return ::strspn (s, t);
382 #if defined (ACE_HAS_WCHAR)
384 ACE_OS::strspn (const wchar_t *s, const wchar_t *t)
386 # if defined (ACE_LACKS_WCSSPN)
387 return ACE_OS::wcsspn_emulation (s, t);
388 # else /* ACE_LACKS_WCSSPN */
389 return ::wcsspn (s, t);
390 # endif /* ACE_LACKS_WCSSPN */
392 #endif /* ACE_HAS_WCHAR */
394 ACE_INLINE const char *
395 ACE_OS::strstr (const char *s, const char *t)
397 return (const char *) ::strstr (s, t);
400 #if defined (ACE_HAS_WCHAR)
401 ACE_INLINE const wchar_t *
402 ACE_OS::strstr (const wchar_t *s, const wchar_t *t)
404 # if defined (ACE_LACKS_WCSSTR)
405 return ACE_OS::wcsstr_emulation (s, t);
406 # else /* ACE_LACKS_WCSSTR */
407 return const_cast <const wchar_t *> (::wcsstr (s, t));
408 # endif /* ACE_LACKS_WCSSTR */
410 #endif /* ACE_HAS_WCHAR */
413 ACE_OS::strstr (char *s, const char *t)
415 return ::strstr (s, t);
418 #if defined (ACE_HAS_WCHAR)
420 ACE_OS::strstr (wchar_t *s, const wchar_t *t)
422 # if defined (ACE_LACKS_WCSSTR)
423 return ACE_OS::wcsstr_emulation (s, t);
424 # else /* ACE_LACKS_WCSSTR */
425 return ::wcsstr (s, t);
426 # endif /* ACE_LACKS_WCSSTR */
428 #endif /* ACE_HAS_WCHAR */
431 ACE_OS::strtok (char *s, const char *tokens)
433 #if !defined (ACE_LACKS_STRTOK)
434 return ::strtok (s, tokens);
437 ACE_UNUSED_ARG (tokens);
438 ACE_NOTSUP_RETURN (0);
439 #endif /* ACE_LACKS_STRTOK */
442 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK)
444 ACE_OS::strtok (wchar_t *s, const wchar_t *tokens)
446 #if defined (ACE_HAS_3_PARAM_WCSTOK)
447 static wchar_t *lasts = 0;
448 return ::wcstok (s, tokens, &lasts);
450 return ::wcstok (s, tokens);
451 #endif /* ACE_HAS_3_PARAM_WCSTOK */
453 #endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOK */
456 ACE_OS::strtok_r (char *s, const char *tokens, char **lasts)
458 #if defined (ACE_HAS_TR24731_2005_CRT)
459 return strtok_s (s, tokens, lasts);
460 #elif defined (ACE_LACKS_STRTOK_R)
461 return ACE_OS::strtok_r_emulation (s, tokens, lasts);
463 return ::strtok_r (s, tokens, lasts);
464 #endif /* ACE_HAS_TR24731_2005_CRT */
467 #if defined (ACE_HAS_WCHAR)
469 ACE_OS::strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts)
471 #if defined (ACE_HAS_TR24731_2005_CRT)
472 return wcstok_s (s, tokens, lasts);
473 #elif defined (ACE_LACKS_WCSTOK)
474 return ACE_OS::strtok_r_emulation (s, tokens, lasts);
476 # if defined (ACE_HAS_3_PARAM_WCSTOK)
477 return ::wcstok (s, tokens, lasts);
478 # else /* ACE_HAS_3_PARAM_WCSTOK */
479 *lasts = ::wcstok (s, tokens);
481 # endif /* ACE_HAS_3_PARAM_WCSTOK */
482 #endif /* ACE_LACKS_WCSTOK */
484 #endif // ACE_HAS_WCHAR
486 ACE_END_VERSIONED_NAMESPACE_DECL