# OS_NS_string.h File Reference

`#include "ace/config-lite.h"`
`#include "ace/Basic_Types.h"`
`#include "ace/ACE_export.h"`
`#include "ace/OS_NS_string.inl"`

Include dependency graph for OS_NS_string.h:

This graph shows which files directly or indirectly include this file:

## Namespaces

namespace | ACE_OS

## Functions from <cstring>

Included are the functions defined in <cstring> and their <cwchar> equivalents.

Todo:
  To be complete, we should add strcoll, and strxfrm.

ACE_NAMESPACE_INLINE_FUNCTION const void * | memchr (const void *s, int c, size_t len)
| Finds characters in a buffer (const void version).
ACE_NAMESPACE_INLINE_FUNCTION void * | memchr (void *s, int c, size_t len)
| Finds characters in a buffer (void version).
ACE_Export const void * | memchr_emulation (const void *s, int c, size_t len)
| Emulated memchr - Finds a character in a buffer.
ACE_NAMESPACE_INLINE_FUNCTION int | memcmp (const void *t, const void *s, size_t len)
| Compares two buffers.
ACE_NAMESPACE_INLINE_FUNCTION void * | memcpy (void *t, const void *s, size_t len)
| Copies one buffer to another.
ACE_NAMESPACE_INLINE_FUNCTION void * | memmove (void *t, const void *s, size_t len)
| Moves one buffer to another.
ACE_NAMESPACE_INLINE_FUNCTION void * | memset (void *s, int c, size_t len)
| Fills a buffer with a character value.
ACE_NAMESPACE_INLINE_FUNCTION char * | strcat (char *s, const char *t)
| Appends a string to another string (char version).
ACE_NAMESPACE_INLINE_FUNCTION wchar_t * | strcat (wchar_t *s, const wchar_t *t)
| Appends a string to another string (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION const char * | strchr (const char *s, int c)
ACE_NAMESPACE_INLINE_FUNCTION const wchar_t * | strchr (const wchar_t *s, wchar_t c)
ACE_NAMESPACE_INLINE_FUNCTION char * | strchr (char *s, int c)
| Finds the first occurance of a character in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION wchar_t * | strchr (wchar_t *s, wchar_t c)
| Finds the first occurance of a character in a string (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION int | strcmp (const char *s, const char *t)
| Compares two strings (char version).
ACE_NAMESPACE_INLINE_FUNCTION int | strcmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t)
| Compares two strings (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION char * | strcpy (char *s, const char *t)
| Copies a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION wchar_t * | strcpy (wchar_t *s, const wchar_t *t)
| Copies a string (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION size_t | strcspn (const char *s, const char *reject)
ACE_NAMESPACE_INLINE_FUNCTION size_t | strcspn (const wchar_t *s, const wchar_t *reject)
ACE_NAMESPACE_INLINE_FUNCTION char * | strdup (const char *s)
| Returns a malloced duplicated string (char version).
ACE_NAMESPACE_INLINE_FUNCTION wchar_t * | strdup (const wchar_t *s)
| Returns a malloced duplicated string (wchar_t version).
ACE_Export char * | strecpy (char *des, const char *src)
ACE_Export wchar_t * | strecpy (wchar_t *s, const wchar_t *t)
ACE_Export char * | strerror (int errnum)
| Finds characters in a buffer (const void version).
ACE_NAMESPACE_INLINE_FUNCTION size_t | strlen (const char *s)
| Finds the length of a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION size_t | strlen (const ACE_WCHAR_T *s)
| Finds the length of a string (ACE_WCHAR_T version).
ACE_NAMESPACE_INLINE_FUNCTION char * | strncat (char *s, const char *t, size_t len)
| Appends part of a string to another string (char version).
ACE_NAMESPACE_INLINE_FUNCTION ACE_WCHAR_T * | strncat (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
| Appends part of a string to another string (wchar_t version).
ACE_Export const char * | strnchr (const char *s, int c, size_t len)
ACE_Export const ACE_WCHAR_T * | strnchr (const ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION char * | strnchr (char *s, int c, size_t len)
| Finds the first occurance of a character in an array (char version).
ACE_NAMESPACE_INLINE_FUNCTION ACE_WCHAR_T * | strnchr (ACE_WCHAR_T *s, ACE_WCHAR_T c, size_t len)
| Finds the first occurance of a character in an array (ACE_WCHAR_T version).
ACE_NAMESPACE_INLINE_FUNCTION int | strncmp (const char *s, const char *t, size_t len)
| Compares two arrays (char version).
ACE_NAMESPACE_INLINE_FUNCTION int | strncmp (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
| Compares two arrays (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION char * | strncpy (char *s, const char *t, size_t len)
| Copies an array (char version).
ACE_NAMESPACE_INLINE_FUNCTION ACE_WCHAR_T * | strncpy (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
| Copies an array (ACE_WCHAR_T version).
ACE_NAMESPACE_INLINE_FUNCTION size_t | strnlen (const char *s, size_t maxlen)
| Finds the length of a limited-length string (char version).
ACE_NAMESPACE_INLINE_FUNCTION size_t | strnlen (const ACE_WCHAR_T *s, size_t maxlen)
| Finds the length of a limited-length string (ACE_WCHAR_T version).
ACE_Export const char * | strnstr (const char *s, const char *t, size_t len)
ACE_Export const ACE_WCHAR_T * | strnstr (const ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
ACE_NAMESPACE_INLINE_FUNCTION char * | strnstr (char *s, const char *t, size_t len)
| Finds the first occurance of a substring in an array (char version).
ACE_NAMESPACE_INLINE_FUNCTION ACE_WCHAR_T * | strnstr (ACE_WCHAR_T *s, const ACE_WCHAR_T *t, size_t len)
| Finds the first occurance of a substring in an array (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION const char * | strpbrk (const char *s1, const char *s2)
| Searches for characters in a string (const char version).
ACE_NAMESPACE_INLINE_FUNCTION const wchar_t * | strpbrk (const wchar_t *s1, const wchar_t *s2)
| Searches for characters in a string (const wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION char * | strpbrk (char *s1, const char *s2)
| Searches for characters in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION wchar_t * | strpbrk (wchar_t *s1, const wchar_t *s2)
| Searches for characters in a string (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION const char * | strrchr (const char *s, int c)
ACE_NAMESPACE_INLINE_FUNCTION const wchar_t * | strrchr (const wchar_t *s, wchar_t c)
ACE_NAMESPACE_INLINE_FUNCTION char * | strrchr (char *s, int c)
| Finds the last occurance of a character in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION wchar_t * | strrchr (wchar_t *s, wchar_t c)
| Finds the last occurance of a character in a string (wchar_t version).
ACE_Export char * | strrchr_emulation (char *s, int c)
ACE_Export const char * | strrchr_emulation (const char *s, int c)
ACE_Export char * | strsncpy (char *dst, const char *src, size_t maxlen)
| This is a "safe" c string copy function (char version).
ACE_Export ACE_WCHAR_T * | strsncpy (ACE_WCHAR_T *dst, const ACE_WCHAR_T *src, size_t maxlen)
| This is a "safe" c string copy function (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION size_t | strspn (const char *s1, const char *s2)
ACE_NAMESPACE_INLINE_FUNCTION size_t | strspn (const wchar_t *s1, const wchar_t *s2)
ACE_NAMESPACE_INLINE_FUNCTION const char * | strstr (const char *s, const char *t)
ACE_NAMESPACE_INLINE_FUNCTION const wchar_t * | strstr (const wchar_t *s, const wchar_t *t)
ACE_NAMESPACE_INLINE_FUNCTION char * | strstr (char *s, const char *t)
| Finds the first occurance of a substring in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION wchar_t * | strstr (wchar_t *s, const wchar_t *t)
| Finds the first occurance of a substring in a string (wchar_t version).
ACE_NAMESPACE_INLINE_FUNCTION char * | strtok (char *s, const char *tokens)
| Finds the next token in a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION wchar_t * | strtok (wchar_t *s, const wchar_t *tokens)
| Finds the next token in a string (wchar_t version).

## Defines

#define | ACE_EXPORT_MACRO ACE_Export
#define | ACE_INLINE inline

## Functions

ACE_NAMESPACE_INLINE_FUNCTION char * | strtok_r (char *s, const char *tokens, char **lasts)
| Finds the next token in a string (safe char version).
ACE_NAMESPACE_INLINE_FUNCTION wchar_t * | strtok_r (ACE_WCHAR_T *s, const ACE_WCHAR_T *tokens, ACE_WCHAR_T **lasts)
| Finds the next token in a string (wchar_t version).
ACE_Export char * | strtok_r_emulation (char *s, const char *tokens, char **lasts)
| Emulated strtok_r.

## Detailed Description

Id
  OS_NS_string.h,v 1.20 2006/02/02 17:52:06 jtc Exp

Author:
  Douglas C. Schmidt <schmidt@cs.wustl.edu>

  Jesper S. M|ller<stophph@diku.dk>

  and a cast of thousands...

Originally in OS.h.

## Define Documentation

#define ACE_EXPORT_MACRO ACE_Export

#define ACE_INLINE inline

## Function Documentation

ACE_INLINE void * ACE_OS::memchr | ( | void * | s,
|  | int | c,
|  | size_t | len
| ) |

| Finds characters in a buffer (void version).

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE const void * ACE_OS::memchr | ( | const void * | s,
|  | int | c,
|  | size_t | len
| ) |

| Finds characters in a buffer (const void version).

ACE_BEGIN_VERSIONED_NAMESPACE_DECL const void * ACE_OS::memchr_emulation | ( | const void * | s,
|  | int | c,
|  | size_t | len
| ) |

| Emulated memchr - Finds a character in a buffer.

ACE_INLINE int ACE_OS::memcmp | ( | const void * | t,
|  | const void * | s,
|  | size_t | len
| ) |

| Compares two buffers.

ACE_INLINE void * ACE_OS::memcpy | ( | void * | t,
|  | const void * | s,
|  | size_t | len
| ) |

| Copies one buffer to another.

ACE_INLINE void * ACE_OS::memmove | ( | void * | t,
|  | const void * | s,
|  | size_t | len
| ) |

| Moves one buffer to another.

ACE_INLINE void * ACE_OS::memset | ( | void * | s,
|  | int | c,
|  | size_t | len
| ) |

| Fills a buffer with a character value.

ACE_INLINE wchar_t * ACE_OS::strcat | ( | wchar_t * | s,
|  | const wchar_t * | t
| ) |

| Appends a string to another string (wchar_t version).

ACE_INLINE char * ACE_OS::strcat | ( | char * | s,
|  | const char * | t
| ) |

| Appends a string to another string (char version).

ACE_INLINE wchar_t * ACE_OS::strchr | ( | wchar_t * | s,
|  | wchar_t | c
| ) |

| Finds the first occurance of a character in a string (wchar_t version).

ACE_INLINE char * ACE_OS::strchr | ( | char * | s,
|  | int | c
| ) |

| Finds the first occurance of a character in a string (char version).

ACE_INLINE const wchar_t * ACE_OS::strchr | ( | const wchar_t * | s,
|  | wchar_t | c
| ) |

| Finds the first occurance of a character in a string (const wchar_t version).

ACE_INLINE const char * ACE_OS::strchr | ( | const char * | s,
|  | int | c
| ) |

| Finds the first occurance of a character in a string (const char version).

ACE_INLINE int ACE_OS::strcmp | ( | const ACE_WCHAR_T * | s,
|  | const ACE_WCHAR_T * | t
| ) |

| Compares two strings (wchar_t version).

ACE_INLINE int ACE_OS::strcmp | ( | const char * | s,
|  | const char * | t
| ) |

| Compares two strings (char version).

ACE_INLINE wchar_t * ACE_OS::strcpy | ( | wchar_t * | s,
|  | const wchar_t * | t
| ) |

| Copies a string (wchar_t version).

ACE_INLINE char * ACE_OS::strcpy | ( | char * | s,
|  | const char * | t
| ) |

| Copies a string (char version).

ACE_INLINE size_t ACE_OS::strcspn | ( | const wchar_t * | s,
|  | const wchar_t * | reject
| ) |

| Searches for the first substring without any of the specified characters and returns the size of the substring (wchar_t version).

ACE_INLINE size_t ACE_OS::strcspn | ( | const char * | s,
|  | const char * | reject
| ) |

| Searches for the first substring without any of the specified characters and returns the size of the substring (char version).

ACE_INLINE wchar_t * ACE_OS::strdup | ( | const wchar_t * | s | ) |

| Returns a malloced duplicated string (wchar_t version).

ACE_INLINE char * ACE_OS::strdup | ( | const char * | s | ) |

| Returns a malloced duplicated string (char version).

wchar_t * ACE_OS::strecpy | ( | wchar_t * | s,
|  | const wchar_t * | t
| ) |

| Copies a string, but returns a pointer to the end of the copied region (wchar_t version).

char * ACE_OS::strecpy | ( | char * | des,
|  | const char * | src
| ) |

| Copies a string, but returns a pointer to the end of the copied region (char version).

char * ACE_OS::strerror | ( | int | errnum | ) |

| Finds characters in a buffer (const void version).

ACE_INLINE size_t ACE_OS::strlen | ( | const ACE_WCHAR_T * | s | ) |

| Finds the length of a string (ACE_WCHAR_T version).

ACE_INLINE size_t ACE_OS::strlen | ( | const char * | s | ) |

| Finds the length of a string (char version).

ACE_INLINE ACE_WCHAR_T * ACE_OS::strncat | ( | ACE_WCHAR_T * | s,
|  | const ACE_WCHAR_T * | t,
|  | size_t | len
| ) |

| Appends part of a string to another string (wchar_t version).

ACE_INLINE char * ACE_OS::strncat | ( | char * | s,
|  | const char * | t,
|  | size_t | len
| ) |

| Appends part of a string to another string (char version).

ACE_INLINE ACE_WCHAR_T * ACE_OS::strnchr | ( | ACE_WCHAR_T * | s,
|  | ACE_WCHAR_T | c,
|  | size_t | len
| ) |

| Finds the first occurance of a character in an array (ACE_WCHAR_T version).

ACE_INLINE char * ACE_OS::strnchr | ( | char * | s,
|  | int | c,
|  | size_t | len
| ) |

| Finds the first occurance of a character in an array (char version).

const ACE_WCHAR_T * ACE_OS::strnchr | ( | const ACE_WCHAR_T * | s,
|  | ACE_WCHAR_T | c,
|  | size_t | len
| ) |

| Finds the first occurance of a character in an array (const ACE_WCHAR_T version).

const char * ACE_OS::strnchr | ( | const char * | s,
|  | int | c,
|  | size_t | len
| ) |

| Finds the first occurance of a character in an array (const char version).

ACE_INLINE int ACE_OS::strncmp | ( | const ACE_WCHAR_T * | s,
|  | const ACE_WCHAR_T * | t,
|  | size_t | len
| ) |

| Compares two arrays (wchar_t version).

ACE_INLINE int ACE_OS::strncmp | ( | const char * | s,
|  | const char * | t,
|  | size_t | len
| ) |

| Compares two arrays (char version).

ACE_INLINE ACE_WCHAR_T * ACE_OS::strncpy | ( | ACE_WCHAR_T * | s,
|  | const ACE_WCHAR_T * | t,
|  | size_t | len
| ) |

| Copies an array (ACE_WCHAR_T version).

ACE_INLINE char * ACE_OS::strncpy | ( | char * | s,
|  | const char * | t,
|  | size_t | len
| ) |

| Copies an array (char version).

ACE_INLINE size_t ACE_OS::strnlen | ( | const ACE_WCHAR_T * | s,
|  | size_t | maxlen
| ) |

Finds the length of a limited-length string (ACE_WCHAR_T version).

Parameters:

  | s | The character string to find the length of.
  | maxlen | The maximum number of characters that will be scanned for the terminating nul character.

Returns:
  The length of
  - s, if the terminating nul character is located, else
  - maxlen.

ACE_INLINE size_t ACE_OS::strnlen | ( | const char * | s,
|  | size_t | maxlen
| ) |

Finds the length of a limited-length string (char version).

Parameters:

  | s | The character string to find the length of.
  | maxlen | The maximum number of characters that will be scanned for the terminating nul character.

Returns:
  The length of
  - s, if the terminating nul character is located, else
  - maxlen.

ACE_INLINE ACE_WCHAR_T * ACE_OS::strnstr | ( | ACE_WCHAR_T * | s,
|  | const ACE_WCHAR_T * | t,
|  | size_t | len
| ) |

| Finds the first occurance of a substring in an array (wchar_t version).

ACE_INLINE char * ACE_OS::strnstr | ( | char * | s,
|  | const char * | t,
|  | size_t | len
| ) |

| Finds the first occurance of a substring in an array (char version).

const ACE_WCHAR_T * ACE_OS::strnstr | ( | const ACE_WCHAR_T * | s,
|  | const ACE_WCHAR_T * | t,
|  | size_t | len
| ) |

| Finds the first occurance of a substring in an array (const wchar_t version).

const char * ACE_OS::strnstr | ( | const char * | s,
|  | const char * | t,
|  | size_t | len
| ) |

| Finds the first occurance of a substring in an array (const char version).

ACE_INLINE wchar_t * ACE_OS::strpbrk | ( | wchar_t * | s1,
|  | const wchar_t * | s2
| ) |

| Searches for characters in a string (wchar_t version).

ACE_INLINE char * ACE_OS::strpbrk | ( | char * | s1,
|  | const char * | s2
| ) |

| Searches for characters in a string (char version).

ACE_INLINE const wchar_t * ACE_OS::strpbrk | ( | const wchar_t * | s1,
|  | const wchar_t * | s2
| ) |

| Searches for characters in a string (const wchar_t version).

ACE_INLINE const char * ACE_OS::strpbrk | ( | const char * | s1,
|  | const char * | s2
| ) |

| Searches for characters in a string (const char version).

ACE_INLINE wchar_t * ACE_OS::strrchr | ( | wchar_t * | s,
|  | wchar_t | c
| ) |

| Finds the last occurance of a character in a string (wchar_t version).

ACE_INLINE char * ACE_OS::strrchr | ( | char * | s,
|  | int | c
| ) |

| Finds the last occurance of a character in a string (char version).

ACE_INLINE const wchar_t * ACE_OS::strrchr | ( | const wchar_t * | s,
|  | wchar_t | c
| ) |

| Finds the last occurance of a character in a string (const wchar_t version).

ACE_INLINE const char * ACE_OS::strrchr | ( | const char * | s,
|  | int | c
| ) |

| Finds the last occurance of a character in a string (const char version).

const char * ACE_OS::strrchr_emulation | ( | const char * | s,
|  | int | c
| ) |

| Emulated strrchr (const char version) - Finds the last occurance of a character in a string.

char * ACE_OS::strrchr_emulation | ( | char * | s,
|  | int | c
| ) |

| Emulated strrchr (char version) - Finds the last occurance of a character in a string.

ACE_WCHAR_T * ACE_OS::strsncpy | ( | ACE_WCHAR_T * | dst,
|  | const ACE_WCHAR_T * | src,
|  | size_t | maxlen
| ) |

This is a "safe" c string copy function (wchar_t version).

Unlike strncpy() this function will always add a terminating '' char if maxlen > 0. So the user doesn't has to provide an extra '' if the user wants a '' terminated dst. The function doesn't check for a 0 dst, because this will give problems anyway. When src is 0 an empty string is made. We do not "touch" * dst if maxlen is 0. Returns dst. Care should be taken when replacing strncpy() calls, because in some cases a strncpy() user is using the "not '\0' terminating" feature from strncpy(). This happens most when the call to strncpy() was optimized by using a maxlen which is 1 smaller than the size because there's always written a '' inside this last position. Very seldom it's possible that the '' padding feature from strncpy() is needed.

char * ACE_OS::strsncpy | ( | char * | dst,
|  | const char * | src,
|  | size_t | maxlen
| ) |

This is a "safe" c string copy function (char version).

Unlike strncpy() this function will always add a terminating '' char if maxlen > 0. So the user doesn't has to provide an extra '' if the user wants a '' terminated dst. The function doesn't check for a 0 dst, because this will give problems anyway. When src is 0 an empty string is made. We do not "touch" * dst if maxlen is 0. Returns dst. Care should be taken when replacing strncpy() calls, because in some cases a strncpy() user is using the "not '\0' terminating" feature from strncpy(). This happens most when the call to strncpy() was optimized by using a maxlen which is 1 smaller than the size because there's always written a '' inside this last position. Very seldom it's possible that the '' padding feature from strncpy() is needed.

ACE_INLINE size_t ACE_OS::strspn | ( | const wchar_t * | s1,
|  | const wchar_t * | s2
| ) |

| Searches for the first substring containing only the specified characters and returns the size of the substring (wchar_t version).

ACE_INLINE size_t ACE_OS::strspn | ( | const char * | s1,
|  | const char * | s2
| ) |

| Searches for the first substring containing only the specified characters and returns the size of the substring (char version).

ACE_INLINE wchar_t * ACE_OS::strstr | ( | wchar_t * | s,
|  | const wchar_t * | t
| ) |

| Finds the first occurance of a substring in a string (wchar_t version).

ACE_INLINE char * ACE_OS::strstr | ( | char * | s,
|  | const char * | t
| ) |

| Finds the first occurance of a substring in a string (char version).

ACE_INLINE const wchar_t * ACE_OS::strstr | ( | const wchar_t * | s,
|  | const wchar_t * | t
| ) |

| Finds the first occurance of a substring in a string (const wchar_t version).

ACE_INLINE const char * ACE_OS::strstr | ( | const char * | s,
|  | const char * | t
| ) |

| Finds the first occurance of a substring in a string (const char version).

ACE_INLINE wchar_t * ACE_OS::strtok | ( | wchar_t * | s,
|  | const wchar_t * | tokens
| ) |

| Finds the next token in a string (wchar_t version).

ACE_INLINE char * ACE_OS::strtok | ( | char * | s,
|  | const char * | tokens
| ) |

| Finds the next token in a string (char version).

ACE_INLINE wchar_t * ACE_OS::strtok_r | ( | ACE_WCHAR_T * | s,
|  | const ACE_WCHAR_T * | tokens,
|  | ACE_WCHAR_T ** | lasts
| ) |

| Finds the next token in a string (wchar_t version).

ACE_INLINE char * ACE_OS::strtok_r | ( | char * | s,
|  | const char * | tokens,
|  | char ** | lasts
| ) |

| Finds the next token in a string (safe char version).

char * ACE_OS::strtok_r_emulation | ( | char * | s,
|  | const char * | tokens,
|  | char ** | lasts
| ) |

| Emulated strtok_r.