00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #if defined (ACE_HAS_GNU_CSTRING_H)
00014
00015 # include <cstring>
00016 #else
00017 # if !defined (ACE_LACKS_MEMORY_H)
00018 # include <memory.h>
00019 # endif
00020 #endif
00021
00022 #if !defined (ACE_PSOS_DIAB_MIPS)
00023 # include <stdlib.h>
00024 # include <string.h>
00025 #endif
00026
00027
00028
00029 #if defined (ACE_HAS_STRINGS)
00030 # include <strings.h>
00031 #endif
00032
00033 #include <ctype.h>
00034
00035 ACE_INLINE const void *
00036 ACE_OS_String::memchr (const void *s, int c, size_t len)
00037 {
00038 #if defined (ACE_HAS_MEMCHR)
00039 return ::memchr (s, c, len);
00040 #else
00041 return ACE_OS_String::memchr_emulation (s, c, len);
00042 #endif
00043 }
00044
00045 ACE_INLINE void *
00046 ACE_OS_String::memchr (void *s, int c, size_t len)
00047 {
00048 return ACE_const_cast (void *,
00049 ACE_OS_String::memchr (ACE_static_cast (const void *, s), c, len));
00050 }
00051
00052
00053 ACE_INLINE int
00054 ACE_OS_String::memcmp (const void *t, const void *s, size_t len)
00055 {
00056 return ::memcmp (t, s, len);
00057 }
00058
00059
00060 ACE_INLINE void *
00061 ACE_OS_String::memcpy (void *t, const void *s, size_t len)
00062 {
00063 return ::memcpy (t, s, len);
00064 }
00065
00066 ACE_INLINE void *
00067 ACE_OS_String::memmove (void *t, const void *s, size_t len)
00068 {
00069 return ::memmove (t, s, len);
00070 }
00071
00072 ACE_INLINE void *
00073 ACE_OS_String::memset (void *s, int c, size_t len)
00074 {
00075 return ::memset (s, c, len);
00076 }
00077
00078 ACE_INLINE char *
00079 ACE_OS_String::strcat (char *s, const char *t)
00080 {
00081 return ::strcat (s, t);
00082 }
00083
00084 #if defined (ACE_HAS_WCHAR)
00085 ACE_INLINE wchar_t *
00086 ACE_OS_String::strcat (wchar_t *s, const wchar_t *t)
00087 {
00088 # if defined (ACE_LACKS_WCSCAT)
00089 return ACE_OS_String::wcscat_emulation (s, t);
00090 # else
00091 return ::wcscat (s, t);
00092 # endif
00093 }
00094 #endif
00095
00096 ACE_INLINE const char *
00097 ACE_OS_String::strchr (const char *s, int c)
00098 {
00099 #if defined (ACE_LACKS_STRCHR)
00100 return ACE_OS_String::strchr_emulation (s, c);
00101 #else
00102 return (const char *) ::strchr (s, c);
00103 #endif
00104 }
00105
00106 #if defined (ACE_HAS_WCHAR)
00107 ACE_INLINE const wchar_t *
00108 ACE_OS_String::strchr (const wchar_t *s, wint_t c)
00109 {
00110 # if defined (ACE_LACKS_WCSCHR)
00111 return ACE_OS_String::wcschr_emulation (s, c);
00112 # else
00113 return ::wcschr (s, c);
00114 # endif
00115 }
00116 #endif
00117
00118 ACE_INLINE char *
00119 ACE_OS_String::strchr (char *s, int c)
00120 {
00121 #if defined (ACE_LACKS_STRCHR)
00122 return ACE_OS_String::strchr_emulation (s, c);
00123 #else
00124 return ::strchr (s, c);
00125 #endif
00126 }
00127
00128 #if defined (ACE_HAS_WCHAR)
00129 ACE_INLINE wchar_t *
00130 ACE_OS_String::strchr (wchar_t *s, wint_t c)
00131 {
00132 return ACE_const_cast (wchar_t *,
00133 ACE_OS_String::strchr (ACE_static_cast (const wchar_t *, s), c));
00134 }
00135 #endif
00136
00137 ACE_INLINE int
00138 ACE_OS_String::strcmp (const char *s, const char *t)
00139 {
00140 return ::strcmp (s, t);
00141 }
00142
00143 ACE_INLINE int
00144 ACE_OS_String::strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t)
00145 {
00146 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSCMP)
00147 return ACE_OS_String::wcscmp_emulation (s, t);
00148 # else
00149 return ::wcscmp (s, t);
00150 # endif
00151 }
00152
00153 ACE_INLINE char *
00154 ACE_OS_String::strcpy (char *s, const char *t)
00155 {
00156 return ::strcpy (s, t);
00157 }
00158
00159 #if defined (ACE_HAS_WCHAR)
00160 ACE_INLINE wchar_t *
00161 ACE_OS_String::strcpy (wchar_t *s, const wchar_t *t)
00162 {
00163 # if defined (ACE_LACKS_WCSCPY)
00164 return ACE_OS_String::wcscpy_emulation (s, t);
00165 # else
00166 return ::wcscpy (s, t);
00167 # endif
00168 }
00169 #endif
00170
00171 ACE_INLINE size_t
00172 ACE_OS_String::strcspn (const char *s, const char *reject)
00173 {
00174 #if defined (ACE_LACKS_STRCSPN)
00175 return ACE_OS_String::strcspn_emulation (s, reject);
00176 #else
00177 return ::strcspn (s, reject);
00178 #endif
00179 }
00180
00181 #if defined (ACE_HAS_WCHAR)
00182 ACE_INLINE size_t
00183 ACE_OS_String::strcspn (const wchar_t *s, const wchar_t *reject)
00184 {
00185 # if defined (ACE_LACKS_WCSCSPN)
00186 return ACE_OS_String::wcscspn_emulation (s, reject);
00187 # else
00188 return ::wcscspn (s, reject);
00189 # endif
00190 }
00191 #endif
00192
00193 ACE_INLINE char *
00194 ACE_OS_String::strerror (int errnum)
00195 {
00196 #if defined (ACE_LACKS_STRERROR)
00197 return ACE_OS_String::strerror_emulation (errnum);
00198 #else
00199 return ::strerror (errnum);
00200 #endif
00201 }
00202
00203 ACE_INLINE size_t
00204 ACE_OS_String::strlen (const char *s)
00205 {
00206 return ::strlen (s);
00207 }
00208
00209 ACE_INLINE size_t
00210 ACE_OS_String::strlen (const ACE_WCHAR_T *s)
00211 {
00212 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSLEN)
00213 return ACE_OS_String::wcslen_emulation (s);
00214 # else
00215 return ::wcslen (s);
00216 # endif
00217 }
00218
00219 ACE_INLINE size_t
00220 ACE_OS_String::strnlen (const char *s, size_t maxlen)
00221 {
00222 #if defined (ACE_HAS_STRNLEN)
00223 return ::strnlen (s, maxlen);
00224 #else
00225 size_t i;
00226 for (i = 0; i < maxlen; ++i)
00227 if (s[i] == '\0')
00228 break;
00229 return i;
00230 #endif
00231 }
00232
00233 ACE_INLINE size_t
00234 ACE_OS_String::strnlen (const ACE_WCHAR_T *s, size_t maxlen)
00235 {
00236 #if defined (ACE_HAS_WCHAR) && defined (ACE_HAS_WCSNLEN)
00237 return wcsnlen (s, maxlen);
00238 #else
00239 size_t i;
00240 for (i = 0; i < maxlen; ++i)
00241 if (s[i] == '\0')
00242 break;
00243 return i;
00244 #endif
00245 }
00246
00247 ACE_INLINE char *
00248 ACE_OS_String::strncat (char *s, const char *t, size_t len)
00249 {
00250 return ::strncat (s, t, len);
00251 }
00252
00253 ACE_INLINE ACE_WCHAR_T *
00254 ACE_OS_String::strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00255 {
00256 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCAT)
00257 return ACE_OS_String::wcsncat_emulation (s, t, len);
00258 # else
00259 return ::wcsncat (s, t, len);
00260 # endif
00261 }
00262
00263 ACE_INLINE int
00264 ACE_OS_String::strncmp (const char *s, const char *t, size_t len)
00265 {
00266 return ::strncmp (s, t, len);
00267 }
00268
00269 ACE_INLINE int
00270 ACE_OS_String::strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00271 {
00272 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCMP)
00273 return ACE_OS_String::wcsncmp_emulation (s, t, len);
00274 # else
00275 return ::wcsncmp (s, t, len);
00276 # endif
00277 }
00278
00279 ACE_INLINE char *
00280 ACE_OS_String::strncpy (char *s, const char *t, size_t len)
00281 {
00282 return ::strncpy (s, t, len);
00283 }
00284
00285 ACE_INLINE ACE_WCHAR_T *
00286 ACE_OS_String::strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00287 {
00288 # if !defined (ACE_HAS_WCHAR) || defined (ACE_LACKS_WCSNCPY)
00289 return ACE_OS_String::wcsncpy_emulation (s, t, len);
00290 # else
00291 return ::wcsncpy (s, t, len);
00292 # endif
00293 }
00294
00295 ACE_INLINE const char *
00296 ACE_OS_String::strpbrk (const char *s1, const char *s2)
00297 {
00298 #if defined (ACE_LACKS_STRPBRK)
00299 return ACE_OS_String::strpbrk_emulation (s1, s2);
00300 #else
00301 return (const char *) ::strpbrk (s1, s2);
00302 #endif
00303 }
00304
00305 #if defined (ACE_HAS_WCHAR)
00306 ACE_INLINE const wchar_t *
00307 ACE_OS_String::strpbrk (const wchar_t *s, const wchar_t *t)
00308 {
00309 # if defined (ACE_LACKS_WCSPBRK)
00310 return ACE_OS_String::wcspbrk_emulation (s, t);
00311 # else
00312 return ::wcspbrk (s, t);
00313 # endif
00314 }
00315 #endif
00316
00317 ACE_INLINE char *
00318 ACE_OS_String::strpbrk (char *s1, const char *s2)
00319 {
00320 #if defined (ACE_LACKS_STRPBRK)
00321 return ACE_OS_String::strpbrk_emulation (s1, s2);
00322 #else
00323 return ::strpbrk (s1, s2);
00324 #endif
00325 }
00326
00327 #if defined (ACE_HAS_WCHAR)
00328 ACE_INLINE wchar_t *
00329 ACE_OS_String::strpbrk (wchar_t *s, const wchar_t *t)
00330 {
00331 return ACE_const_cast (wchar_t *,
00332 ACE_OS_String::strpbrk (ACE_static_cast (const wchar_t *, s), t));
00333 }
00334 #endif
00335
00336 ACE_INLINE const char *
00337 ACE_OS_String::strrchr (const char *s, int c)
00338 {
00339 #if defined (ACE_LACKS_STRRCHR)
00340 return ACE_OS_String::strrchr_emulation (s, c);
00341 #else
00342 return (const char *) ::strrchr (s, c);
00343 #endif
00344 }
00345
00346 #if defined (ACE_HAS_WCHAR)
00347 ACE_INLINE const wchar_t *
00348 ACE_OS_String::strrchr (const wchar_t *s, wint_t c)
00349 {
00350 #if defined (ACE_LACKS_WCSRCHR)
00351 return ACE_OS_String::wcsrchr_emulation (s, c);
00352 #else
00353 return (const wchar_t *) ::wcsrchr (s, c);
00354 #endif
00355 }
00356 #endif
00357
00358 ACE_INLINE char *
00359 ACE_OS_String::strrchr (char *s, int c)
00360 {
00361 #if defined (ACE_LACKS_STRRCHR)
00362 return ACE_OS_String::strrchr_emulation (s, c);
00363 #else
00364 return ::strrchr (s, c);
00365 #endif
00366 }
00367
00368 #if defined (ACE_HAS_WCHAR)
00369 ACE_INLINE wchar_t *
00370 ACE_OS_String::strrchr (wchar_t *s, wint_t c)
00371 {
00372 return ACE_const_cast (wchar_t *,
00373 ACE_OS_String::strrchr (ACE_static_cast (const wchar_t *, s), c));
00374 }
00375 #endif
00376
00377 ACE_INLINE size_t
00378 ACE_OS_String::strspn (const char *s, const char *t)
00379 {
00380 #if defined (ACE_LACKS_STRSPN)
00381 return ACE_OS_String::strspn_emulation (s, t);
00382 #else
00383 return ::strspn (s, t);
00384 #endif
00385 }
00386
00387 #if defined (ACE_HAS_WCHAR)
00388 ACE_INLINE size_t
00389 ACE_OS_String::strspn (const wchar_t *s, const wchar_t *t)
00390 {
00391 # if defined (ACE_LACKS_WCSSPN)
00392 return ACE_OS_String::wcsspn_emulation (s, t);
00393 # else
00394 return ::wcsspn (s, t);
00395 # endif
00396 }
00397 #endif
00398
00399 ACE_INLINE const char *
00400 ACE_OS_String::strstr (const char *s, const char *t)
00401 {
00402 return (const char *) ::strstr (s, t);
00403 }
00404
00405 #if defined (ACE_HAS_WCHAR)
00406 ACE_INLINE const wchar_t *
00407 ACE_OS_String::strstr (const wchar_t *s, const wchar_t *t)
00408 {
00409 # if defined (ACE_LACKS_WCSSTR)
00410 return ACE_OS_String::wcsstr_emulation (s, t);
00411 # elif defined (HPUX)
00412 return (const wchar_t *) ::wcswcs (s, t);
00413 # else
00414 return (const wchar_t *) ::wcsstr (s, t);
00415 # endif
00416 }
00417 #endif
00418
00419 ACE_INLINE char *
00420 ACE_OS_String::strstr (char *s, const char *t)
00421 {
00422 return ::strstr (s, t);
00423 }
00424
00425 #if defined (ACE_HAS_WCHAR)
00426 ACE_INLINE wchar_t *
00427 ACE_OS_String::strstr (wchar_t *s, const wchar_t *t)
00428 {
00429 # if defined (ACE_LACKS_WCSSTR)
00430 return ACE_OS_String::wcsstr_emulation (s, t);
00431 # elif defined (HPUX)
00432 return ::wcswcs (s, t);
00433 # else
00434 return ::wcsstr (s, t);
00435 # endif
00436 }
00437 #endif
00438
00439 ACE_INLINE char *
00440 ACE_OS_String::strtok (char *s, const char *tokens)
00441 {
00442 return ::strtok (s, tokens);
00443 }
00444
00445 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK)
00446 ACE_INLINE wchar_t *
00447 ACE_OS_String::strtok (wchar_t *s, const wchar_t *tokens)
00448 {
00449 #if defined (ACE_HAS_3_PARAM_WCSTOK)
00450 static wchar_t *lasts;
00451 return ::wcstok (s, tokens, &lasts);
00452 #else
00453 return ::wcstok (s, tokens);
00454 #endif
00455 }
00456 #endif
00457
00458 ACE_INLINE int
00459 ACE_OS_String::ace_isprint (const ACE_TCHAR c)
00460 {
00461 #if defined (ACE_USES_WCHAR)
00462 return iswprint (c);
00463 #else
00464 return isprint ((unsigned char) c);
00465 #endif
00466 }
00467
00468 ACE_INLINE int
00469 ACE_OS_String::ace_isspace (const ACE_TCHAR c)
00470 {
00471 #if defined (ACE_USES_WCHAR)
00472 return iswspace (c);
00473 #else
00474 return isspace ((unsigned char) c);
00475 #endif
00476 }
00477
00478 ACE_INLINE int
00479 ACE_OS_String::to_lower (int c)
00480 {
00481 return tolower (c);
00482 }
00483
00484 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_TOWLOWER)
00485 ACE_INLINE wint_t
00486 ACE_OS_String::to_lower (wint_t c)
00487 {
00488 return towlower (c);
00489 }
00490 #endif
00491
00492 ACE_INLINE char *
00493 ACE_OS_String::itoa (int value, char *string, int radix)
00494 {
00495 #if !defined (ACE_HAS_ITOA)
00496 return ACE_OS_String::itoa_emulation (value, string, radix);
00497 #elif defined (ACE_ITOA_EQUIVALENT)
00498 return ACE_ITOA_EQUIVALENT (value, string, radix);
00499 #else
00500 return ::itoa (value, string, radix);
00501 #endif
00502 }
00503
00504 #if defined (ACE_HAS_WCHAR)
00505 ACE_INLINE wchar_t *
00506 ACE_OS_String::itoa (int value, wchar_t *string, int radix)
00507 {
00508 #if defined (ACE_LACKS_ITOW)
00509 return ACE_OS_String::itow_emulation (value, string, radix);
00510 #else
00511 return ::_itow (value, string, radix);
00512 #endif
00513 }
00514 #endif
00515
00516 ACE_INLINE int
00517 ACE_OS_String::strcasecmp (const char *s, const char *t)
00518 {
00519 #if defined (ACE_LACKS_STRCASECMP)
00520 return ACE_OS_String::strcasecmp_emulation (s, t);
00521 #elif defined (ACE_STRCASECMP_EQUIVALENT)
00522 return ACE_STRCASECMP_EQUIVALENT (s, t);
00523 #else
00524 return ::strcasecmp (s, t);
00525 #endif
00526 }
00527
00528 #if defined (ACE_HAS_WCHAR)
00529 ACE_INLINE int
00530 ACE_OS_String::strcasecmp (const wchar_t *s, const wchar_t *t)
00531 {
00532 # if defined (ACE_LACKS_WCSICMP)
00533 return ACE_OS_String::wcsicmp_emulation (s, t);
00534 # else
00535 return ::_wcsicmp (s, t);
00536 # endif
00537 }
00538 #endif
00539
00540 ACE_INLINE char *
00541 ACE_OS_String::strnchr (char *s, int c, size_t len)
00542 {
00543 #if defined ACE_PSOS_DIAB_PPC
00544 const char *const_char_s = s;
00545 return ACE_const_cast (char *,
00546 ACE_OS_String::strnchr (const_char_s, c, len));
00547 #else
00548 return ACE_const_cast (char *,
00549 ACE_OS_String::strnchr (ACE_static_cast (const char *, s), c, len));
00550 #endif
00551 }
00552
00553 ACE_INLINE ACE_WCHAR_T *
00554 ACE_OS_String::strnchr (ACE_WCHAR_T *s, ACE_WINT_T c, size_t len)
00555 {
00556 return ACE_const_cast (ACE_WCHAR_T *,
00557 ACE_OS_String::strnchr (ACE_static_cast (const ACE_WCHAR_T *, s), c, len));
00558 }
00559
00560 ACE_INLINE int
00561 ACE_OS_String::strncasecmp (const char *s, const char *t, size_t len)
00562 {
00563 #if defined (ACE_LACKS_STRCASECMP)
00564 return ACE_OS_String::strncasecmp_emulation (s, t, len);
00565 #elif defined (ACE_STRNCASECMP_EQUIVALENT)
00566 return ACE_STRNCASECMP_EQUIVALENT (s, t, len);
00567 #else
00568 return ::strncasecmp (s, t, len);
00569 #endif
00570 }
00571
00572 #if defined (ACE_HAS_WCHAR)
00573 ACE_INLINE int
00574 ACE_OS_String::strncasecmp (const wchar_t *s, const wchar_t *t, size_t len)
00575 {
00576 #if defined (ACE_LACKS_WCSNICMP)
00577 return ACE_OS_String::wcsnicmp_emulation (s, t, len);
00578 #else
00579 return ::_wcsnicmp (s, t, len);
00580 #endif
00581 }
00582 #endif
00583
00584 ACE_INLINE char *
00585 ACE_OS_String::strnstr (char *s, const char *t, size_t len)
00586 {
00587 #if defined ACE_PSOS_DIAB_PPC
00588 const char *const_char_s=s;
00589 return (char *) ACE_OS_String::strnstr (const_char_s, t, len);
00590 #else
00591 return (char *) ACE_OS_String::strnstr ((const char *) s, t, len);
00592 #endif
00593 }
00594
00595 ACE_INLINE ACE_WCHAR_T *
00596 ACE_OS_String::strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
00597 {
00598 return ACE_const_cast (ACE_WCHAR_T *,
00599 ACE_OS_String::strnstr (ACE_static_cast (const ACE_WCHAR_T *, s), t, len));
00600 }
00601
00602 ACE_INLINE char *
00603 ACE_OS_String::strtok_r (char *s, const char *tokens, char **lasts)
00604 {
00605 #if defined (ACE_HAS_REENTRANT_FUNCTIONS)
00606 return ::strtok_r (s, tokens, lasts);
00607 #else
00608 return ACE_OS_String::strtok_r_emulation (s, tokens, lasts);
00609 #endif
00610 }
00611
00612 #if defined (ACE_HAS_WCHAR)
00613 ACE_INLINE wchar_t*
00614 ACE_OS_String::strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts)
00615 {
00616 #if defined (ACE_LACKS_WCSTOK)
00617 return ACE_OS_String::strtok_r_emulation (s, tokens, lasts);
00618 #else
00619 # if defined (ACE_HAS_3_PARAM_WCSTOK)
00620 return ::wcstok (s, tokens, lasts);
00621 # else
00622 *lasts = ::wcstok (s, tokens);
00623 return *lasts;
00624 # endif
00625 #endif
00626 }
00627 #endif // ACE_HAS_WCHAR
00628
00629 #if !defined (ACE_LACKS_STRTOD)
00630 ACE_INLINE double
00631 ACE_OS_String::strtod (const char *s, char **endptr)
00632 {
00633 return ::strtod (s, endptr);
00634 }
00635 #endif
00636
00637 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD)
00638 ACE_INLINE double
00639 ACE_OS_String::strtod (const wchar_t *s, wchar_t **endptr)
00640 {
00641 return ::wcstod (s, endptr);
00642 }
00643 #endif
00644
00645 ACE_INLINE long
00646 ACE_OS_String::strtol (const char *s, char **ptr, int base)
00647 {
00648 #if defined (ACE_LACKS_STRTOL)
00649 return ACE_OS_String::strtol_emulation (s, ptr, base);
00650 #else
00651 return ::strtol (s, ptr, base);
00652 #endif
00653 }
00654
00655 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOL)
00656 ACE_INLINE long
00657 ACE_OS_String::strtol (const wchar_t *s, wchar_t **ptr, int base)
00658 {
00659 return ::wcstol (s, ptr, base);
00660 }
00661 #endif
00662
00663 ACE_INLINE unsigned long
00664 ACE_OS_String::strtoul (const char *s, char **ptr, int base)
00665 {
00666 #if defined (ACE_LACKS_STRTOUL)
00667 return ACE_OS_String::strtoul_emulation (s, ptr, base);
00668 #else
00669 return ::strtoul (s, ptr, base);
00670 #endif
00671 }
00672
00673 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOUL)
00674
00675 #if defined (ACE_HAS_STD_WCSTOUL)
00676 using std::wcstoul;
00677 #endif
00678
00679 ACE_INLINE unsigned long
00680 ACE_OS_String::strtoul (const wchar_t *s, wchar_t **ptr, int base)
00681 {
00682 return ::wcstoul (s, ptr, base);
00683 }
00684 #endif