00001
00002
00003
00004
00005
00006
00007 #include "ace/OS_NS_wchar.h"
00008 #include "ace/os_include/os_string.h"
00009
00010 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00011
00012 ACE_INLINE const void *
00013 ACE_OS::memchr (const void *s, int c, size_t len)
00014 {
00015 #if defined (ACE_HAS_MEMCHR)
00016 return ::memchr (s, c, len);
00017 #else
00018 return ACE_OS::memchr_emulation (s, c, len);
00019 #endif
00020 }
00021
00022 ACE_INLINE void *
00023 ACE_OS::memchr (void *s, int c, size_t len)
00024 {
00025 return const_cast<void *> (ACE_OS::memchr (static_cast<const void *> (s),
00026 c,
00027 len));
00028 }
00029
00030 ACE_INLINE int
00031 ACE_OS::memcmp (const void *t, const void *s, size_t len)
00032 {
00033 return ::memcmp (t, s, len);
00034 }
00035
00036 ACE_INLINE void *
00037 ACE_OS::memcpy (void *t, const void *s, size_t len)
00038 {
00039 #if defined (ACE_HAS_MEMCPY_LOOP_UNROLL)
00040 return fast_memcpy (t, s, len);
00041 #else
00042 return ::memcpy (t, s, len);
00043 #endif
00044 }
00045
00046 ACE_INLINE void *
00047 ACE_OS::memmove (void *t, const void *s, size_t len)
00048 {
00049 return ::memmove (t, s, len);
00050 }
00051
00052 ACE_INLINE void *
00053 ACE_OS::memset (void *s, int c, size_t len)
00054 {
00055 return ::memset (s, c, len);
00056 }
00057
00058 ACE_INLINE char *
00059 ACE_OS::strcat (char *s, const char *t)
00060 {
00061 return ::strcat (s, t);
00062 }
00063
00064 #if defined (ACE_HAS_WCHAR)
00065 ACE_INLINE wchar_t *
00066 ACE_OS::strcat (wchar_t *s, const wchar_t *t)
00067 {
00068 # if defined (ACE_LACKS_WCSCAT)
00069 return ACE_OS::wcscat_emulation (s, t);
00070 # else
00071 return ::wcscat (s, t);
00072 # endif
00073 }
00074 #endif
00075
00076 ACE_INLINE const char *
00077 ACE_OS::strchr (const char *s, int c)
00078 {
00079 #if defined (ACE_LACKS_STRCHR)
00080 return ACE_OS::strchr_emulation (s, c);
00081 #else
00082 return (const char *) ::strchr (s, c);
00083 #endif
00084 }
00085
00086 #if defined (ACE_HAS_WCHAR)
00087 ACE_INLINE const wchar_t *
00088 ACE_OS::strchr (const wchar_t *s, wchar_t c)
00089 {
00090 # if defined (ACE_LACKS_WCSCHR)
00091 return ACE_OS::wcschr_emulation (s, c);
00092 # else
00093 return ::wcschr (s, c);
00094 # endif
00095 }
00096 #endif
00097
00098 ACE_INLINE char *
00099 ACE_OS::strchr (char *s, int c)
00100 {
00101 return ::strchr (s, c);
00102 }
00103
00104 #if defined (ACE_HAS_WCHAR)
00105 ACE_INLINE wchar_t *
00106 ACE_OS::strchr (wchar_t *s, wchar_t c)
00107 {
00108 return
00109 const_cast<wchar_t *> (ACE_OS::strchr (const_cast<const wchar_t *> (s),
00110 c));
00111 }
00112 #endif
00113
00114 ACE_INLINE int
00115 ACE_OS::strcmp (const char *s, const char *t)
00116 {
00117 return ::strcmp (s, t);
00118 }
00119
00120 ACE_INLINE int
00121 ACE_OS::strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t)
00122 {
00123 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP)
00124 return ACE_OS::wcscmp_emulation (s, t);
00125 # else
00126 return ::wcscmp (s, t);
00127 # endif
00128 }
00129
00130 ACE_INLINE char *
00131 ACE_OS::strcpy (char *s, const char *t)
00132 {
00133 return ::strcpy (s, t);
00134 }
00135
00136 #if defined (ACE_HAS_WCHAR)
00137 ACE_INLINE wchar_t *
00138 ACE_OS::strcpy (wchar_t *s, const wchar_t *t)
00139 {
00140 # if defined (ACE_LACKS_WCSCPY)
00141 return ACE_OS::wcscpy_emulation (s, t);
00142 # else
00143 return ::wcscpy (s, t);
00144 # endif
00145 }
00146 #endif
00147
00148 ACE_INLINE size_t
00149 ACE_OS::strcspn (const char *s, const char *reject)
00150 {
00151 return ::strcspn (s, reject);
00152 }
00153
00154 #if defined (ACE_HAS_WCHAR)
00155 ACE_INLINE size_t
00156 ACE_OS::strcspn (const wchar_t *s, const wchar_t *reject)
00157 {
00158 # if defined (ACE_LACKS_WCSCSPN)
00159 return ACE_OS::wcscspn_emulation (s, reject);
00160 # else
00161 return ::wcscspn (s, reject);
00162 # endif
00163 }
00164 #endif
00165
00166 ACE_INLINE char *
00167 ACE_OS::strdup (const char *s)
00168 {
00169 # if (defined (ACE_LACKS_STRDUP) && !defined(ACE_STRDUP_EQUIVALENT)) \
00170 || defined (ACE_HAS_STRDUP_EMULATION)
00171 return ACE_OS::strdup_emulation (s);
00172 # elif defined (ACE_STRDUP_EQUIVALENT)
00173 return ACE_STRDUP_EQUIVALENT (s);
00174 # elif defined (ACE_HAS_NONCONST_STRDUP)
00175 return ::strdup (const_cast<char *> (s));
00176 #else
00177 return ::strdup (s);
00178 # endif
00179 }
00180
00181 #if defined (ACE_HAS_WCHAR)
00182 ACE_INLINE wchar_t *
00183 ACE_OS::strdup (const wchar_t *s)
00184 {
00185 # if (defined (ACE_LACKS_WCSDUP) && !defined (ACE_WCSDUP_EQUIVALENT)) \
00186 || defined (ACE_HAS_WCSDUMP_EMULATION)
00187 return ACE_OS::strdup_emulation (s);
00188 # elif defined (ACE_WCSDUP_EQUIVALENT)
00189 return ACE_WCSDUP_EQUIVALENT (s);
00190 # elif defined (ACE_HAS_NONCONST_WCSDUP)
00191 return ::wcsdup (const_cast<wchar_t*> (s));
00192 # else
00193 return ::wcsdup (s);
00194 # endif
00195 }
00196 #endif
00197
00198 ACE_INLINE size_t
00199 ACE_OS::strlen (const char *s)
00200 {
00201 return ::strlen (s);
00202 }
00203
00204 ACE_INLINE size_t
00205 ACE_OS::strlen (const ACE_WCHAR_T *s)
00206 {
00207 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN)
00208 return ACE_OS::wcslen_emulation (s);
00209 # else
00210 return ::wcslen (s);
00211 # endif
00212 }
00213
00214 ACE_INLINE char *
00215 ACE_OS::strncat (char *s, const char *t, size_t len)
00216 {
00217 return ::strncat (s, t, len);
00218 }
00219
00220 ACE_INLINE ACE_WCHAR_T *
00221 ACE_OS::strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00222 {
00223 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT)
00224 return ACE_OS::wcsncat_emulation (s, t, len);
00225 # else
00226 return ::wcsncat (s, t, len);
00227 # endif
00228 }
00229
00230 ACE_INLINE char *
00231 ACE_OS::strnchr (char *s, int c, size_t len)
00232 {
00233 return const_cast<char *> (ACE_OS::strnchr (static_cast<const char *> (s),
00234 c,
00235 len));
00236 }
00237
00238 ACE_INLINE ACE_WCHAR_T *
00239 ACE_OS::strnchr (ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
00240 {
00241 return
00242 const_cast<ACE_WCHAR_T *> (ACE_OS::strnchr (
00243 const_cast<const ACE_WCHAR_T *> (s),
00244 c,
00245 len));
00246 }
00247
00248 ACE_INLINE int
00249 ACE_OS::strncmp (const char *s, const char *t, size_t len)
00250 {
00251 return ::strncmp (s, t, len);
00252 }
00253
00254 ACE_INLINE int
00255 ACE_OS::strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00256 {
00257 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP)
00258 return ACE_OS::wcsncmp_emulation (s, t, len);
00259 # else
00260 return ::wcsncmp (s, t, len);
00261 # endif
00262 }
00263
00264 ACE_INLINE char *
00265 ACE_OS::strncpy (char *s, const char *t, size_t len)
00266 {
00267 return ::strncpy (s, t, len);
00268 }
00269
00270 ACE_INLINE ACE_WCHAR_T *
00271 ACE_OS::strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00272 {
00273 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY)
00274 return ACE_OS::wcsncpy_emulation (s, t, len);
00275 # else
00276 return ::wcsncpy (s, t, len);
00277 # endif
00278 }
00279
00280 ACE_INLINE size_t
00281 ACE_OS::strnlen (const char *s, size_t maxlen)
00282 {
00283 #if defined (ACE_HAS_STRNLEN)
00284 return ::strnlen (s, maxlen);
00285 #else
00286 size_t i;
00287 for (i = 0; i < maxlen; ++i)
00288 if (s[i] == '\0')
00289 break;
00290 return i;
00291 #endif
00292 }
00293
00294 ACE_INLINE size_t
00295 ACE_OS::strnlen (const ACE_WCHAR_T *s, size_t maxlen)
00296 {
00297 #if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN)
00298 return wcsnlen (s, maxlen);
00299 #else
00300 size_t i;
00301 for (i = 0; i < maxlen; ++i)
00302 if (s[i] == '\0')
00303 break;
00304 return i;
00305 #endif
00306 }
00307
00308 ACE_INLINE char *
00309 ACE_OS::strnstr (char *s, const char *t, size_t len)
00310 {
00311 return (char *) ACE_OS::strnstr ((const char *) s, t, len);
00312 }
00313
00314 ACE_INLINE ACE_WCHAR_T *
00315 ACE_OS::strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00316 {
00317 return
00318 const_cast<ACE_WCHAR_T *> (ACE_OS::strnstr (
00319 static_cast<const ACE_WCHAR_T *> (s),
00320 t,
00321 len));
00322 }
00323
00324 ACE_INLINE const char *
00325 ACE_OS::strpbrk (const char *s1, const char *s2)
00326 {
00327 #if defined (ACE_LACKS_STRPBRK)
00328 return ACE_OS::strpbrk_emulation (s1, s2);
00329 #else
00330 return (const char *) ::strpbrk (s1, s2);
00331 #endif
00332 }
00333
00334 #if defined (ACE_HAS_WCHAR)
00335 ACE_INLINE const wchar_t *
00336 ACE_OS::strpbrk (const wchar_t *s, const wchar_t *t)
00337 {
00338 # if defined (ACE_LACKS_WCSPBRK)
00339 return ACE_OS::wcspbrk_emulation (s, t);
00340 # else
00341 return ::wcspbrk (s, t);
00342 # endif
00343 }
00344 #endif
00345
00346 ACE_INLINE char *
00347 ACE_OS::strpbrk (char *s1, const char *s2)
00348 {
00349 #if defined (ACE_LACKS_STRPBRK)
00350 return ACE_OS::strpbrk_emulation (s1, s2);
00351 #else
00352 return ::strpbrk (s1, s2);
00353 #endif
00354 }
00355
00356 #if defined (ACE_HAS_WCHAR)
00357 ACE_INLINE wchar_t *
00358 ACE_OS::strpbrk (wchar_t *s, const wchar_t *t)
00359 {
00360 return const_cast<wchar_t *> (ACE_OS::strpbrk (
00361 const_cast<const wchar_t *> (s), t));
00362 }
00363 #endif
00364
00365 ACE_INLINE const char *
00366 ACE_OS::strrchr (const char *s, int c)
00367 {
00368 #if defined (ACE_LACKS_STRRCHR)
00369 return ACE_OS::strrchr_emulation (s, c);
00370 #else
00371 return (const char *) ::strrchr (s, c);
00372 #endif
00373 }
00374
00375 #if defined (ACE_HAS_WCHAR)
00376 ACE_INLINE const wchar_t *
00377 ACE_OS::strrchr (const wchar_t *s, wchar_t c)
00378 {
00379 #if defined (ACE_LACKS_WCSRCHR)
00380 return ACE_OS::wcsrchr_emulation (s, c);
00381 #else
00382 return const_cast <const wchar_t *> (::wcsrchr (s, c));
00383 #endif
00384 }
00385 #endif
00386
00387 ACE_INLINE char *
00388 ACE_OS::strrchr (char *s, int c)
00389 {
00390 #if defined (ACE_LACKS_STRRCHR)
00391 return ACE_OS::strrchr_emulation (s, c);
00392 #else
00393 return ::strrchr (s, c);
00394 #endif
00395 }
00396
00397 #if defined (ACE_HAS_WCHAR)
00398 ACE_INLINE wchar_t *
00399 ACE_OS::strrchr (wchar_t *s, wchar_t c)
00400 {
00401 return const_cast<wchar_t *> (ACE_OS::strrchr (
00402 const_cast<const wchar_t *> (s), c));
00403 }
00404 #endif
00405
00406 ACE_INLINE size_t
00407 ACE_OS::strspn (const char *s, const char *t)
00408 {
00409 #if defined (ACE_LACKS_STRSPN)
00410 return ACE_OS::strspn_emulation (s, t);
00411 #else
00412 return ::strspn (s, t);
00413 #endif
00414 }
00415
00416 #if defined (ACE_HAS_WCHAR)
00417 ACE_INLINE size_t
00418 ACE_OS::strspn (const wchar_t *s, const wchar_t *t)
00419 {
00420 # if defined (ACE_LACKS_WCSSPN)
00421 return ACE_OS::wcsspn_emulation (s, t);
00422 # else
00423 return ::wcsspn (s, t);
00424 # endif
00425 }
00426 #endif
00427
00428 ACE_INLINE const char *
00429 ACE_OS::strstr (const char *s, const char *t)
00430 {
00431 return (const char *) ::strstr (s, t);
00432 }
00433
00434 #if defined (ACE_HAS_WCHAR)
00435 ACE_INLINE const wchar_t *
00436 ACE_OS::strstr (const wchar_t *s, const wchar_t *t)
00437 {
00438 # if defined (ACE_LACKS_WCSSTR)
00439 return ACE_OS::wcsstr_emulation (s, t);
00440 # elif defined (HPUX)
00441 return const_cast <const wchar_t *> (::wcswcs (s, t));
00442 # else
00443 return const_cast <const wchar_t *> (::wcsstr (s, t));
00444 # endif
00445 }
00446 #endif
00447
00448 ACE_INLINE char *
00449 ACE_OS::strstr (char *s, const char *t)
00450 {
00451 return ::strstr (s, t);
00452 }
00453
00454 #if defined (ACE_HAS_WCHAR)
00455 ACE_INLINE wchar_t *
00456 ACE_OS::strstr (wchar_t *s, const wchar_t *t)
00457 {
00458 # if defined (ACE_LACKS_WCSSTR)
00459 return ACE_OS::wcsstr_emulation (s, t);
00460 # elif defined (HPUX)
00461 return ::wcswcs (s, t);
00462 # else
00463 return ::wcsstr (s, t);
00464 # endif
00465 }
00466 #endif
00467
00468 ACE_INLINE char *
00469 ACE_OS::strtok (char *s, const char *tokens)
00470 {
00471 return ::strtok (s, tokens);
00472 }
00473
00474 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK)
00475 ACE_INLINE wchar_t *
00476 ACE_OS::strtok (wchar_t *s, const wchar_t *tokens)
00477 {
00478 #if defined (ACE_HAS_3_PARAM_WCSTOK)
00479 static wchar_t *lasts;
00480 return ::wcstok (s, tokens, &lasts);
00481 #else
00482 return ::wcstok (s, tokens);
00483 #endif
00484 }
00485 #endif
00486
00487 ACE_INLINE char *
00488 ACE_OS::strtok_r (char *s, const char *tokens, char **lasts)
00489 {
00490 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00491 return ::strtok_r (s, tokens, lasts);
00492 #else
00493 return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00494 #endif
00495 }
00496
00497 #if defined (ACE_HAS_WCHAR)
00498 ACE_INLINE wchar_t*
00499 ACE_OS::strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts)
00500 {
00501 #if defined (ACE_LACKS_WCSTOK)
00502 return ACE_OS::strtok_r_emulation (s, tokens, lasts);
00503 #else
00504 # if defined (ACE_HAS_3_PARAM_WCSTOK)
00505 return ::wcstok (s, tokens, lasts);
00506 # else
00507 *lasts = ::wcstok (s, tokens);
00508 return *lasts;
00509 # endif
00510 #endif
00511 }
00512 #endif // ACE_HAS_WCHAR
00513
00514 ACE_END_VERSIONED_NAMESPACE_DECL