MicrOS
string.h File Reference
#include "stdint.h"
#include "stddef.h"

Go to the source code of this file.

Typedefs

typedef size_t uint32_t
 Unsigned integral type. More...
 

Functions

void * memcpy (void *destination, const void *source, size_t size)
 Copy block of memory. More...
 
void * memmove (void *destination, const void *source, size_t size)
 Move block of memory. More...
 
char * strcpy (char *destination, const char *source)
 Copy string. More...
 
char * strncpy (char *destination, const char *source, size_t num)
 Copy characters from string. More...
 
char * strcat (char *destination, const char *source)
 Concatenate strings. More...
 
char * strncat (char *destination, const char *source, size_t num)
 Append characters from string. More...
 
int memcmp (const void *buffer1, const void *buffer2, size_t size)
 Compare two blocks of memory. More...
 
int strcmp (const char *str1, const char *str2)
 Compare two strings. More...
 
int strcoll (const char *str1, const char *str2)
 Compare two strings using locale. More...
 
int strncmp (const char *str1, const char *str2, size_t num)
 Compare two strings using locale. More...
 
size_t strxfrm (char *destination, const char *source, size_t num)
 Transform string using locale. More...
 
void * memchr (void *ptr, int value, size_t num)
 Locate character in block of memory. More...
 
char * strchr (const char *str, int character)
 Locate first occurrence of character in string. More...
 
size_t strcspn (const char *str1, const char *str2)
 Get span until character in string. More...
 
char * strpbrk (char *str1, const char *str2)
 Locate characters in string. More...
 
char * strrchr (char *str, int character)
 Locate last occurrence of character in string. More...
 
size_t strspn (const char *str1, const char *str2)
 Get span of character set in string. More...
 
char * strstr (const char *str1, const char *str2)
 Locate substring. More...
 
char * strtok (char *str, const char *delimiters)
 Split string into tokens. More...
 
void * memset (void *buffer, int value, size_t size)
 Fill block of memory. More...
 
char * strerror (int errnum)
 Get pointer to error message string. More...
 
size_t strlen (const char *str)
 Get string length. More...
 

Typedef Documentation

◆ uint32_t

typedef size_t uint32_t

Unsigned integral type.

Function Documentation

◆ memchr()

void* memchr ( void *  ptr,
int  value,
size_t  num 
)

Locate character in block of memory.

Searches within the first num bytes of the block of memory pointed by ptr for the first occurrence of value (interpreted as an unsigned char), and returns a pointer to it.

Parameters
ptrPointer to the block of memory where the search is performed.
valueValue to be located. The value is passed as an int, but the function performs a byte per byte search using the unsigned char conversion of this value.
numNumber of bytes to be analyzed.
Returns
A pointer to the first occurrence of value in the block of memory pointed by ptr. If the value is not found, the function returns a null pointer.

◆ memcmp()

int memcmp ( const void *  buffer1,
const void *  buffer2,
size_t  size 
)

Compare two blocks of memory.

Compares the first num bytes of the block of memory pointed by ptr1 to the first num bytes pointed by ptr2, returning zero if they all match or a value different from zero representing which is greater if they do not.

Parameters
ptr1Pointer to block of memory.
ptr2Pointer to block of memory.
numNumber of bytes to compare.
Returns
Returns an integral value indicating the relationship between the content of the memory blocks (<0: value in ptr1 was lower than in ptr2, 0: both are equals, >0: value in ptr2 was greater than in ptr2).

◆ memcpy()

void* memcpy ( void *  destination,
const void *  source,
size_t  size 
)

Copy block of memory.

Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.

Parameters
destinationPointer to the destination array where the content is to be copied, type-casted to a pointer of type void*.
sourcePointer to the source of data to be copied, type-casted to a pointer of type const void*.
numNumber of bytes to copy.
Returns
Destination is returned.

◆ memmove()

void* memmove ( void *  destination,
const void *  source,
size_t  size 
)

Move block of memory.

Copies the values of num bytes from the location pointed by source to the memory block pointed by destination. Copying takes place as if an intermediate buffer were used, allowing the destination and source to overlap.

Parameters
destinationPointer to the destination array where the content is to be copied, type-casted to a pointer of type void*.
sourcePointer to the source of data to be copied, type-casted to a pointer of type const void*.
numNumber of bytes to copy.
Returns
Destination is returned.

◆ memset()

void* memset ( void *  buffer,
int  value,
size_t  size 
)

Fill block of memory.

Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).

Parameters
bufferPointer to the block of memory to fill.
valueValue to be set. The value is passed as an int, but the function fills the block of memory using the unsigned char conversion of this value.
sizeNumber of bytes to be set to the value.
Returns
Ptr is returned.

◆ strcat()

char* strcat ( char *  destination,
const char *  source 
)

Concatenate strings.

Appends a copy of the source string to the destination string. The terminating null character in destination is overwritten by the first character of source, and a null-character is included at the end of the new string formed by the concatenation of both in destination.

Parameters
destinationPointer to the destination array, which should contain a C string, and be large enough to contain the concatenated resulting string.
sourceC string to be appended. This should not overlap destination.
Returns
Destination is returned.

◆ strchr()

char* strchr ( const char *  str,
int  character 
)

Locate first occurrence of character in string.

Returns a pointer to the first occurrence of character in the C string str.

Parameters
strC string.
characterCharacter to be located. It is passed as its int promotion, but it is internally converted back to char for the comparison.
Returns
A pointer to the first occurrence of value in the block of memory pointed by ptr. If the value is not found, the function returns a null pointer.

◆ strcmp()

int strcmp ( const char *  str1,
const char *  str2 
)

Compare two strings.

Compares the C string str1 to the C string str2. This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ or until a terminating null-character is reached.

Parameters
str1C string to be compared.
str2C string to be compared.
Returns
Returns an integral value indicating the relationship between the content of the memory blocks (<0: value in ptr1 was lower than in ptr2, 0: both are equals, >0: value in ptr2 was greater than in ptr2).

◆ strcoll()

int strcoll ( const char *  str1,
const char *  str2 
)

Compare two strings using locale.

Compares the C string str1 to the C string str2, both interpreted appropriately according to the LC_COLLATE category of the C locale currently selected.

Parameters
str1C string to be compared.
str2C string to be compared.
numMaximum number of characters to compare.
Returns
Returns an integral value indicating the relationship between the content of the memory blocks (<0: value in ptr1 was lower than in ptr2, 0: both are equals, >0: value in ptr2 was greater than in ptr2).

◆ strcpy()

char* strcpy ( char *  destination,
const char *  source 
)

Copy string.

Copies the C string pointed by source into the array pointed by destination, including the terminating null character (and stopping at that point).

Parameters
destinationPointer to the destination array where the content is to be copied.
sourceC string to be copied.
Returns
Destination is returned.

◆ strcspn()

size_t strcspn ( const char *  str1,
const char *  str2 
)

Get span until character in string.

Scans str1 for the first occurrence of any of the characters that are part of str2, returning the number of characters of str1 read before this first occurrence.

Parameters
str1C string to be scanned.
str2C string containing the characters to match.
Returns
The length of the initial part of str1 not containing any of the characters that are part of str2. This is the length of str1 if none of the characters in str2 are found in str1.

◆ strerror()

char* strerror ( int  errnum)

Get pointer to error message string.

Interprets the value of errnum, generating a string with a message that describes the error condition as if set to errno by a function of the library.

Parameters
errnumError number.
Returns
A pointer to the error string describing error errnum.

◆ strlen()

size_t strlen ( const char *  str)

Get string length.

Returns the length of the C string str. The length of a C string is determined by the terminating null-character.

Parameters
strC string.
Returns
The length of string.

◆ strncat()

char* strncat ( char *  destination,
const char *  source,
size_t  num 
)

Append characters from string.

Appends the first num characters of source to destination, plus a terminating null-character.

Parameters
destinationPointer to the destination array, which should contain a C string, and be large enough to contain the concatenated resulting string, including the additional null-character.
sourceC string to be appended.
numMaximum number of characters to be appended.
Returns
Destination is returned.

◆ strncmp()

int strncmp ( const char *  str1,
const char *  str2,
size_t  num 
)

Compare two strings using locale.

Compares up to num characters of the C string str1 to those of the C string str2.

Parameters
str1C string to be compared.
str2C string to be compared.
Returns
Returns an integral value indicating the relationship between the content of the memory blocks (<0: value in ptr1 was lower than in ptr2, 0: both are equals, >0: value in ptr2 was greater than in ptr2).

◆ strncpy()

char* strncpy ( char *  destination,
const char *  source,
size_t  num 
)

Copy characters from string.

Copies the first num characters of source to destination. If the end of the source C string (which is signaled by a null-character) is found before num characters have been copied, destination is padded with zeros until a total of num characters have been written to it.

Parameters
destinationPointer to the destination array where the content is to be copied.
sourceC string to be copied.
numMaximum number of characters to be copied from source.
Returns
Destination is returned.

◆ strpbrk()

char* strpbrk ( char *  str1,
const char *  str2 
)

Locate characters in string.

Returns a pointer to the first occurrence in str1 of any of the characters that are part of str2, or a null pointer if there are no matches.

Parameters
str1C string to be scanned.
str2C string containing the characters to match.
Returns
A pointer to the first occurrence in str1 of any of the characters that are part of str2, or a null pointer if none of the characters of str2 is found in str1 before the terminating null-character.

◆ strrchr()

char* strrchr ( char *  str,
int  character 
)

Locate last occurrence of character in string.

Returns a pointer to the last occurrence of character in the C string str.

Parameters
str1C string.
characterCharacter to be located. It is passed as its int promotion, but it is internally converted back to char.
Returns
A pointer to the last occurrence of character in str. If the character is not found, the function returns a null pointer.

◆ strspn()

size_t strspn ( const char *  str1,
const char *  str2 
)

Get span of character set in string.

Returns the length of the initial portion of str1 which consists only of characters that are part of str2.

Parameters
str1C string to be scanned.
str2C string containing the characters to match.
Returns
The length of the initial portion of str1 containing only characters that appear in str2.

◆ strstr()

char* strstr ( const char *  str1,
const char *  str2 
)

Locate substring.

Returns a pointer to the first occurrence of str2 in str1, or a null pointer if str2 is not part of str1.

Parameters
str1C string to be scanned.
str2C string containing the characters to match.
Returns
A pointer to the first occurrence in str1 of the entire sequence of characters specified in str2, or a null pointer if the sequence is not present in str1.

◆ strtok()

char* strtok ( char *  str,
const char *  delimiters 
)

Split string into tokens.

A sequence of calls to this function split str into tokens, which are sequences of contiguous characters separated by any of the characters that are part of delimiters.

Parameters
strC string to truncate.
delimetersC string containing the delimiter characters.
Returns
If a token is found, a pointer to the beginning of the token. Otherwise, a null pointer.

◆ strxfrm()

size_t strxfrm ( char *  destination,
const char *  source,
size_t  num 
)

Transform string using locale.

Transforms the C string pointed by source according to the current locale and copies the first num characters of the transformed string to destination, returning its length.

Parameters
destinatinoPointer to the destination array where the content is to be copied. It can be a null pointer if the argument for num is zero.
sourceC string to be transformed.
numMaximum number of characters to be copied to destination.
Returns
The length of the transformed string, not including the terminating null-character.