VxWorks Reference Manual : Libraries

ansiString

NAME

ansiString - ANSI string documentation

ROUTINES

memchr( ) - search a block of memory for a character (ANSI)
memcmp( ) - compare two blocks of memory (ANSI)
memcpy( ) - copy memory from one location to another (ANSI)
memmove( ) - copy memory from one location to another (ANSI)
memset( ) - set a block of memory (ANSI)
strcat( ) - concatenate one string to another (ANSI)
strchr( ) - find the first occurrence of a character in a string (ANSI)
strcmp( ) - compare two strings lexicographically (ANSI)
strcoll( ) - compare two strings as appropriate to LC_COLLATE (ANSI)
strcpy( ) - copy one string to another (ANSI)
strcspn( ) - return the string length up to the first character from a given set (ANSI)
strerror_r( ) - map an error number to an error string (POSIX)
strerror( ) - map an error number to an error string (ANSI)
strlen( ) - determine the length of a string (ANSI)
strncat( ) - concatenate characters from one string to another (ANSI)
strncmp( ) - compare the first n characters of two strings (ANSI)
strncpy( ) - copy characters from one string to another (ANSI)
strpbrk( ) - find the first occurrence in a string of a character from a given set (ANSI)
strrchr( ) - find the last occurrence of a character in a string (ANSI)
strspn( ) - return the string length up to the first character not in a given set (ANSI)
strstr( ) - find the first occurrence of a substring in a string (ANSI)
strtok( ) - break down a string into tokens (ANSI)
strtok_r( ) - break down a string into tokens (reentrant) (POSIX)
strxfrm( ) - transform up to n characters of s2 into s1 (ANSI)

DESCRIPTION

This library includes several standard ANSI routines. Note that where there is a pair of routines, such as div( ) and div_r( ), only the routine xxx_r( ) is reentrant. The xxx( ) routine is not reentrant.

The header string.h declares one type and several functions, and defines one macro useful for manipulating arrays of character type and other objects treated as array of character type. The type is size_t and the macro NULL. Various methods are used for determining the lengths of the arrays, but in all cases a char * or void * argument points to the initial (lowest addressed) character of the array. If an array is accessed beyond the end of an object, the behavior is undefined.

SEE ALSO

ansiString, American National Standard X3.159-1989


Libraries : Routines

memchr( )

NAME

memchr( ) - search a block of memory for a character (ANSI)

SYNOPSIS

void * memchr
    (
    const void * m, /* block of memory */
    int          c, /* character to search for */
    size_t       n  /* size of memory to search */
    )

DESCRIPTION

This routine searches for the first element of an array of unsigned char, beginning at the address m with size n, that equals c converted to an unsigned char.

INCLUDE FILES

string.h

RETURNS

If successful, it returns the address of the matching element; otherwise, it returns a null pointer.

SEE ALSO

ansiString


Libraries : Routines

memcmp( )

NAME

memcmp( ) - compare two blocks of memory (ANSI)

SYNOPSIS

int memcmp
    (
    const void * s1, /* array 1 */
    const void * s2, /* array 2 */
    size_t       n   /* size of memory to compare */
    )

DESCRIPTION

This routine compares successive elements from two arrays of unsigned char, beginning at the addresses s1 and s2 (both of size n), until it finds elements that are not equal.

INCLUDE FILES

string.h

RETURNS

If all elements are equal, zero. If elements differ and the differing element from s1 is greater than the element from s2, the routine returns a positive number; otherwise, it returns a negative number.

SEE ALSO

ansiString


Libraries : Routines

memcpy( )

NAME

memcpy( ) - copy memory from one location to another (ANSI)

SYNOPSIS

void * memcpy
    (
    void *       destination, /* destination of copy */
    const void * source,      /* source of copy */
    size_t       size         /* size of memory to copy */
    )

DESCRIPTION

This routine copies size characters from the object pointed to by source into the object pointed to by destination. If copying takes place between objects that overlap, the behavior is undefined.

INCLUDE FILES

string.h

RETURNS

A pointer to destination.

SEE ALSO

ansiString


Libraries : Routines

memmove( )

NAME

memmove( ) - copy memory from one location to another (ANSI)

SYNOPSIS

void * memmove
    (
    void *       destination, /* destination of copy */
    const void * source,      /* source of copy */
    size_t       size         /* size of memory to copy */
    )

DESCRIPTION

This routine copies size characters from the memory location source to the location destination. It ensures that the memory is not corrupted even if source and destination overlap.

INCLUDE FILES

string.h

RETURNS

A pointer to destination.

SEE ALSO

ansiString


Libraries : Routines

memset( )

NAME

memset( ) - set a block of memory (ANSI)

SYNOPSIS

void * memset
    (
    void * m,   /* block of memory */
    int    c,   /* character to store */
    size_t size /* size of memory */
    )

DESCRIPTION

This routine stores c converted to an unsigned char in each of the elements of the array of unsigned char beginning at m, with size size.

INCLUDE FILES

string.h

RETURNS

A pointer to m.

SEE ALSO

ansiString


Libraries : Routines

strcat( )

NAME

strcat( ) - concatenate one string to another (ANSI)

SYNOPSIS

char * strcat
    (
    char *       destination, /* string to be appended to */
    const char * append       /* string to append to destination */
    )

DESCRIPTION

This routine appends a copy of string append to the end of string destination. The resulting string is null-terminated.

INCLUDE FILES

string.h

RETURNS

A pointer to destination.

SEE ALSO

ansiString


Libraries : Routines

strchr( )

NAME

strchr( ) - find the first occurrence of a character in a string (ANSI)

SYNOPSIS

char * strchr
    (
    const char * s, /* string in which to search */
    int          c  /* character to find in string */
    )

DESCRIPTION

This routine finds the first occurrence of character c in string s. The terminating null is considered to be part of the string.

INCLUDE FILES

string.h

RETURNS

The address of the located character, or NULL if the character is not found.

SEE ALSO

ansiString


Libraries : Routines

strcmp( )

NAME

strcmp( ) - compare two strings lexicographically (ANSI)

SYNOPSIS

int strcmp
    (
    const char * s1, /* string to compare */
    const char * s2  /* string to compare s1 to */
    )

DESCRIPTION

This routine compares string s1 to string s2 lexicographically.

INCLUDE FILES

string.h

RETURNS

An integer greater than, equal to, or less than 0, according to whether s1 is lexicographically greater than, equal to, or less than s2, respectively.

SEE ALSO

ansiString


Libraries : Routines

strcoll( )

NAME

strcoll( ) - compare two strings as appropriate to LC_COLLATE (ANSI)

SYNOPSIS

int strcoll
    (
    const char * s1, /* string 1 */
    const char * s2  /* string 2 */
    )

DESCRIPTION

This routine compares two strings, both interpreted as appropriate to the LC_COLLATE category of the current locale.

INCLUDE FILES

string.h

RETURNS

An integer greater than, equal to, or less than zero, according to whether string s1 is greater than, equal to, or less than string s2 when both are interpreted as appropriate to the current locale.

SEE ALSO

ansiString


Libraries : Routines

strcpy( )

NAME

strcpy( ) - copy one string to another (ANSI)

SYNOPSIS

char * strcpy
    (
    char *       s1, /* string to copy to */
    const char * s2  /* string to copy from */
    )

DESCRIPTION

This routine copies string s2 (including EOS) to string s1.

INCLUDE FILES

string.h

RETURNS

A pointer to s1.

SEE ALSO

ansiString


Libraries : Routines

strcspn( )

NAME

strcspn( ) - return the string length up to the first character from a given set (ANSI)

SYNOPSIS

size_t strcspn
    (
    const char * s1, /* string to search */
    const char * s2  /* set of characters to look for in s1 */
    )

DESCRIPTION

This routine computes the length of the maximum initial segment of string s1 that consists entirely of characters not included in string s2.

INCLUDE FILES

string.h

RETURNS

The length of the string segment.

SEE ALSO

ansiString, strpbrk( ), strspn( )


Libraries : Routines

strerror_r( )

NAME

strerror_r( ) - map an error number to an error string (POSIX)

SYNOPSIS

STATUS strerror_r
    (
    int    errcode, /* error code */
    char * buffer   /* string buffer */
    )

DESCRIPTION

This routine maps the error number in errcode to an error message string. It stores the error string in buffer.

This routine is the POSIX reentrant version of strerror( ).

INCLUDE FILES

string.h

RETURNS

OK or ERROR.

SEE ALSO

ansiString, strerror( )


Libraries : Routines

strerror( )

NAME

strerror( ) - map an error number to an error string (ANSI)

SYNOPSIS

char * strerror
    (
    int errcode /* error code */
    )

DESCRIPTION

This routine maps the error number in errcode to an error message string. It returns a pointer to a static buffer that holds the error string.

This routine is not reentrant. For a reentrant version, see strerror_r( ).

INCLUDE

string.h

RETURNS

A pointer to the buffer that holds the error string.

SEE ALSO

ansiString, strerror_r( )


Libraries : Routines

strlen( )

NAME

strlen( ) - determine the length of a string (ANSI)

SYNOPSIS

size_t strlen
    (
    const char * s /* string */
    )

DESCRIPTION

This routine returns the number of characters in s, not including EOS.

INCLUDE FILES

string.h

RETURNS

The number of non-null characters in the string.

SEE ALSO

ansiString


Libraries : Routines

strncat( )

NAME

strncat( ) - concatenate characters from one string to another (ANSI)

SYNOPSIS

char * strncat
    (
    char *       dst, /* string to append to */
    const char * src, /* string to append */
    size_t       n    /* max no. of characters to append */
    )

DESCRIPTION

This routine appends up to n characters from string src to the end of string dst.

INCLUDE FILES

string.h

RETURNS

A pointer to the null-terminated string s1.

SEE ALSO

ansiString


Libraries : Routines

strncmp( )

NAME

strncmp( ) - compare the first n characters of two strings (ANSI)

SYNOPSIS

int strncmp
    (
    const char * s1, /* string to compare */
    const char * s2, /* string to compare s1 to */
    size_t       n   /* max no. of characters to compare */
    )

DESCRIPTION

This routine compares up to n characters of string s1 to string s2 lexicographically.

INCLUDE FILES

string.h

RETURNS

An integer greater than, equal to, or less than 0, according to whether s1 is lexicographically greater than, equal to, or less than s2, respectively.

SEE ALSO

ansiString


Libraries : Routines

strncpy( )

NAME

strncpy( ) - copy characters from one string to another (ANSI)

SYNOPSIS

char *strncpy
    (
    char *       s1, /* string to copy to */
    const char * s2, /* string to copy from */
    size_t       n   /* max no. of characters to copy */
    )

DESCRIPTION

This routine copies n characters from string s2 to string s1. If n is greater than the length of s2, nulls are added to s1. If n is less than or equal to the length of s2, the target string will not be null-terminated.

INCLUDE FILES

string.h

RETURNS

A pointer to s1.

SEE ALSO

ansiString


Libraries : Routines

strpbrk( )

NAME

strpbrk( ) - find the first occurrence in a string of a character from a given set (ANSI)

SYNOPSIS

char * strpbrk
    (
    const char * s1, /* string to search */
    const char * s2  /* set of characters to look for in s1 */
    )

DESCRIPTION

This routine locates the first occurrence in string s1 of any character from string s2.

INCLUDE FILES

string.h

RETURNS

A pointer to the character found in s1, or NULL if no character from s2 occurs in s1.

SEE ALSO

ansiString, strcspn( )


Libraries : Routines

strrchr( )

NAME

strrchr( ) - find the last occurrence of a character in a string (ANSI)

SYNOPSIS

char * strrchr
    (
    const char * s, /* string to search */
    int          c  /* character to look for */
    )

DESCRIPTION

This routine locates the last occurrence of c in the string pointed to by s. The terminating null is considered to be part of the string.

INCLUDE FILES

string.h

RETURNS

A pointer to the last occurrence of the character, or NULL if the character is not found.

SEE ALSO

ansiString


Libraries : Routines

strspn( )

NAME

strspn( ) - return the string length up to the first character not in a given set (ANSI)

SYNOPSIS

size_t strspn
    (
    const char * s,  /* string to search */
    const char * sep /* set of characters to look for in s */
    )

DESCRIPTION

This routine computes the length of the maximum initial segment of string s that consists entirely of characters from the string sep.

INCLUDE FILES

string.h

RETURNS

The length of the string segment.

SEE ALSO

ansiString, strcspn( )


Libraries : Routines

strstr( )

NAME

strstr( ) - find the first occurrence of a substring in a string (ANSI)

SYNOPSIS

char * strstr
    (
    const char * s,   /* string to search */
    const char * find /* substring to look for */
    )

DESCRIPTION

This routine locates the first occurrence in string s of the sequence of characters (excluding the terminating null character) in the string find.

INCLUDE FILES

string.h

RETURNS

A pointer to the located substring, or s if find points to a zero-length string, or NULL if the string is not found.

SEE ALSO

ansiString


Libraries : Routines

strtok( )

NAME

strtok( ) - break down a string into tokens (ANSI)

SYNOPSIS

char * strtok
    (
    char *       string,   /* string */
    const char * separator /* separator indicator */
    )

DESCRIPTION

A sequence of calls to this routine breaks the string string into a sequence of tokens, each of which is delimited by a character from the string separator. The first call in the sequence has string as its first argument, and is followed by calls with a null pointer as their first argument. The separator string may be different from call to call.

The first call in the sequence searches string for the first character that is not contained in the current separator string. If the character is not found, there are no tokens in string and strtok( ) returns a null pointer. If the character is found, it is the start of the first token.

strtok( ) then searches from there for a character that is contained in the current separator string. If the character is not found, the current token expands to the end of the string pointed to by string, and subsequent searches for a token will return a null pointer. If the character is found, it is overwritten by a null character, which terminates the current token. strtok( ) saves a pointer to the following character, from which the next search for a token will start. (Note that because the separator character is overwritten by a null character, the input string is modified as a result of this call.)

Each subsequent call, with a null pointer as the value of the first argument, starts searching from the saved pointer and behaves as described above.

The implementation behaves as if strtok( ) is called by no library functions.

REENTRANCY

This routine is not reentrant; the reentrant form is strtok_r( ).

INCLUDE FILES

string.h

RETURNS

A pointer to the first character of a token, or a NULL pointer if there is no token.

SEE ALSO

ansiString, strtok_r( )


Libraries : Routines

strtok_r( )

NAME

strtok_r( ) - break down a string into tokens (reentrant) (POSIX)

SYNOPSIS

char * strtok_r
    (
    char *       string,     /* string to break into tokens */
    const char * separators, /* the separators */
    char * *     ppLast      /* pointer to serve as string index */
    )

DESCRIPTION

This routine considers the null-terminated string string as a sequence of zero or more text tokens separated by spans of one or more characters from the separator string separators. The argument ppLast points to a user-provided pointer which in turn points to the position within string at which scanning should begin.

In the first call to this routine, string points to a null-terminated string; separators points to a null-terminated string of separator characters; and ppLast points to a NULL pointer. The function returns a pointer to the first character of the first token, writes a null character into string immediately following the returned token, and updates the pointer to which ppLast points so that it points to the first character following the null written into string. (Note that because the separator character is overwritten by a null character, the input string is modified as a result of this call.)

In subsequent calls string must be a NULL pointer and ppLast must be unchanged so that subsequent calls will move through the string string, returning successive tokens until no tokens remain. The separator string separators may be different from call to call. When no token remains in string, a NULL pointer is returned.

INCLUDE FILES

string.h

RETURNS

A pointer to the first character of a token, or a NULL pointer if there is no token.

SEE ALSO

ansiString, strtok( )


Libraries : Routines

strxfrm( )

NAME

strxfrm( ) - transform up to n characters of s2 into s1 (ANSI)

SYNOPSIS

size_t strxfrm
    (
    char *       s1, /* string out */
    const char * s2, /* string in */
    size_t       n   /* size of buffer */
    )

DESCRIPTION

This routine transforms string s2 and places the resulting string in s1. The transformation is such that if strcmp( ) is applied to two transformed strings, it returns a value greater than, equal to, or less than zero, corresponding to the result of the strcoll( ) function applied to the same two original strings. No more than n characters are placed into the resulting s1, including the terminating null character. If n is zero, s1 is permitted to be a NULL pointer. If copying takes place between objects that overlap, the behavior is undefined.

INCLUDE FILES

string.h

RETURNS

The length of the transformed string, not including the terminating null character. If the value is n or more, the contents of s1 are indeterminate.

SEE ALSO

ansiString, strcmp( ), strcoll( )