MentOS
0.8.0
The Mentoring Operating System
|
String routines. More...
Functions | |
char * | strncpy (char *destination, const char *source, size_t num) |
Copies the first num characters of source to destination. More... | |
int | strncmp (const char *s1, const char *s2, size_t n) |
Compares up to n characters of s1 to those of s2. More... | |
int | stricmp (const char *s1, const char *s2) |
Case insensitive string compare. More... | |
int | strnicmp (const char *s1, const char *s2, size_t n) |
Case-insensitively compare up to n characters of s1 to those of s2. More... | |
char * | strchr (const char *s, int ch) |
Returns a pointer to the first occurrence of ch in str. More... | |
char * | strrchr (const char *s, int ch) |
Returns a pointer to the last occurrence of ch in str. More... | |
char * | strstr (const char *str1, const char *str2) |
Returns a pointer to the first occurrence of s2 in s1, or NULL if s2 is not part of s1. More... | |
size_t | strspn (const char *string, const char *control) |
Returns the length of the initial portion of string which consists only of characters that are part of control. More... | |
size_t | strcspn (const char *string, const char *control) |
Calculates the length of the initial segment of string which consists entirely of characters not in control. More... | |
char * | strpbrk (const char *string, const char *control) |
Finds the first character in the string string that matches any character specified in control. More... | |
int | tokenize (const char *string, const char *separators, size_t *offset, char *buffer, ssize_t buflen) |
Parses the string using the separator, and at each call it saves the parsed token in buffer. The pointer string will be modified. More... | |
void * | memmove (void *dst, const void *src, size_t n) |
Copies the values of num bytes from the location pointed by source to the memory block pointed by destination. More... | |
void * | memchr (const void *ptr, int ch, size_t n) |
Searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string pointed to, by the argument str. More... | |
char * | strlwr (char *s) |
Converts a given string into lowercase. More... | |
char * | strupr (char *s) |
Converts a given string into uppercase. More... | |
char * | strcat (char *dst, const char *src) |
Appends a copy of the string src to the string dst. More... | |
char * | strncat (char *s1, const char *s2, size_t n) |
Appends a copy of the string src to the string dst, up to n bytes. More... | |
char * | strrev (char *s) |
Reverse the string s. More... | |
char * | strtok_r (char *str, const char *delim, char **saveptr) |
This function is a reentrant version strtok(). More... | |
void * | memset (void *ptr, int value, size_t num) |
Sets the first num bytes of the block of memory pointed by ptr to the specified value. More... | |
int | memcmp (const void *dst, const void *src, size_t n) |
Compares the first n bytes of str1 and str2. More... | |
void * | memcpy (void *dst, const void *src, size_t num) |
Copy a block of memory, handling overlap. More... | |
void * | memccpy (void *dst, const void *src, int c, size_t n) |
The memccpy function copies no more than n bytes from memory area src to memory area dest, stopping when the character c is found. More... | |
char * | strcpy (char *dst, const char *src) |
Copy the string src into the array dst. More... | |
size_t | strlen (const char *s) |
Returns the length of the string s. More... | |
size_t | strnlen (const char *s, size_t count) |
Returns the number of characters inside s, excluding the terminating null byte ('\0'), but at most count. More... | |
int | strcmp (const char *s1, const char *s2) |
Checks if the two strings are equal. More... | |
char * | strset (char *s, int c) |
Fill the string s with the character c. More... | |
char * | strnset (char *s, int c, size_t n) |
Fill the string s with the character c, up to the given length n. More... | |
char * | strtok (char *str, const char *delim) |
Splits string into tokens. More... | |
char * | trim (char *str) |
Removes any whitespace characters from the beginning and end of str. More... | |
char * | strdup (const char *s) |
Make a copy of the given string. More... | |
char * | strndup (const char *s, size_t n) |
Make a copy of at most n bytes of the given string. More... | |
char * | strsep (char **stringp, const char *delim) |
Separate the given string based on a given delimiter. More... | |
char * | itoa (char *buffer, unsigned int num, unsigned int base) |
Move the number "num" into a string. More... | |
char * | replace_char (char *str, char find, char replace) |
Replaces the occurrences of find with replace inside str. More... | |
void | strmode (mode_t mode, char *p) |
Converts a file mode (the type and permission information associated with an inode) into a symbolic string which is stored in the location referenced by p. More... | |
String routines.
char* itoa | ( | char * | buffer, |
unsigned int | num, | ||
unsigned int | base | ||
) |
Move the number "num" into a string.
buffer | The string containing the number. |
num | The number to convert. |
base | The base used to convert. |
void* memccpy | ( | void * | dst, |
const void * | src, | ||
int | c, | ||
size_t | n | ||
) |
The memccpy function copies no more than n bytes from memory area src to memory area dest, stopping when the character c is found.
dst | Points to the destination memory area. |
src | Points to the source memory area. |
c | The delimiter used to stop. |
n | The maximum number of copied bytes. |
void* memchr | ( | const void * | ptr, |
int | c, | ||
size_t | n | ||
) |
Searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string pointed to, by the argument str.
ptr | Pointer to the block of memory where the search is performed. |
c | Value to be located. |
n | Number of bytes to be analyzed. |
int memcmp | ( | const void * | ptr1, |
const void * | ptr2, | ||
size_t | n | ||
) |
Compares the first n bytes of str1 and str2.
ptr1 | First pointer to block of memory. |
ptr2 | Second pointer to block of memory. |
n | Number of bytes to compare. |
void* memcpy | ( | void * | dst, |
const void * | src, | ||
size_t | num | ||
) |
Copy a block of memory, handling overlap.
dst | Pointer to the destination. |
src | Pointer to the source. |
num | Number of bytes to be copied. |
void* memmove | ( | void * | dst, |
const void * | src, | ||
size_t | n | ||
) |
Copies the values of num bytes from the location pointed by source to the memory block pointed by destination.
dst | Pointer to the destination array where the content is to be copied, type-casted to a pointer of type void*. |
src | Pointer to the source of data to be copied, type-casted to a pointer of type const void*. |
n | Number of bytes to copy. |
void* memset | ( | void * | ptr, |
int | value, | ||
size_t | num | ||
) |
Sets the first num bytes of the block of memory pointed by ptr to the specified value.
ptr | Pointer to the block of memory to set. |
value | Value to be set. |
num | Number of bytes to be set to the given value. |
char* replace_char | ( | char * | str, |
char | find, | ||
char | replace | ||
) |
Replaces the occurrences of find with replace inside str.
str | The string to manipulate. |
find | The character to replace. |
replace | The character used to replace. |
char* strcat | ( | char * | dst, |
const char * | src | ||
) |
Appends a copy of the string src to the string dst.
dst | Pointer to the destination array, which should be large enough to contain the concatenated resulting string. |
src | String to be appended. This should not overlap dst. |
char* strchr | ( | const char * | s, |
int | ch | ||
) |
Returns a pointer to the first occurrence of ch in str.
s | The string where the search is performed. |
ch | Character to be located. |
int strcmp | ( | const char * | s1, |
const char * | s2 | ||
) |
Checks if the two strings are equal.
s1 | First string to be compared. |
s2 | Second string to be compared. |
char* strcpy | ( | char * | dst, |
const char * | src | ||
) |
Copy the string src into the array dst.
dst | The destination array where the content is to be copied. |
src | String to be copied. |
size_t strcspn | ( | const char * | string, |
const char * | control | ||
) |
Calculates the length of the initial segment of string which consists entirely of characters not in control.
string | String to be scanned. |
control | String containing the characters to match. |
char* strdup | ( | const char * | s | ) |
Make a copy of the given string.
s | String to duplicate. |
int stricmp | ( | const char * | s1, |
const char * | s2 | ||
) |
Case insensitive string compare.
s1 | First string to be compared. |
s2 | Second string to be compared. |
size_t strlen | ( | const char * | s | ) |
Returns the length of the string s.
s | Pointer to the null-terminated byte string to be examined. |
char* strlwr | ( | char * | s | ) |
Converts a given string into lowercase.
s | String which we want to convert into lowercase. |
void strmode | ( | mode_t | mode, |
char * | p | ||
) |
Converts a file mode (the type and permission information associated with an inode) into a symbolic string which is stored in the location referenced by p.
mode | File mode that encodes access permissions and file type. |
p | Buffer used to hold the string representation of file mode m. |
char* strncat | ( | char * | dst, |
const char * | src, | ||
size_t | n | ||
) |
Appends a copy of the string src to the string dst, up to n bytes.
dst | Pointer to the destination array, which should be large enough to contain the concatenated resulting string. |
src | String to be appended. This should not overlap dst. |
n | The number of bytes to copy. |
int strncmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | n | ||
) |
Compares up to n characters of s1 to those of s2.
s1 | First string to be compared. |
s2 | Second string to be compared. |
n | Maximum number of characters to compare. |
char* strncpy | ( | char * | destination, |
const char * | source, | ||
size_t | num | ||
) |
Copies the first num characters of source to destination.
destination | Pointer to the destination array where the content is to be copied. |
source | String to be copied. |
num | Maximum number of characters to be copied from source. |
char* strndup | ( | const char * | s, |
size_t | n | ||
) |
Make a copy of at most n bytes of the given string.
s | String to duplicate. |
n | The number of character to duplicate. |
int strnicmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | n | ||
) |
Case-insensitively compare up to n characters of s1 to those of s2.
s1 | First string to be compared. |
s2 | Second string to be compared. |
n | Maximum number of characters to compare. |
Returns the number of characters inside s, excluding the terminating null byte ('\0'), but at most count.
s | Pointer to the null-terminated byte string to be examined. |
maxlen | The upperbound on the length. |
char* strnset | ( | char * | s, |
int | c, | ||
size_t | n | ||
) |
Fill the string s with the character c, up to the given length n.
s | The string that you want to fill. |
c | The character that you want to fill the string with. |
n | The maximum number of bytes to fill. |
char* strpbrk | ( | const char * | string, |
const char * | control | ||
) |
Finds the first character in the string string that matches any character specified in control.
string | String to be scanned. |
control | String containing the characters to match. |
char* strrchr | ( | const char * | s, |
int | ch | ||
) |
Returns a pointer to the last occurrence of ch in str.
s | The string where the search is performed. |
ch | Character to be located. |
char* strrev | ( | char * | s | ) |
Reverse the string s.
s | The given string which is needed to be reversed. |
char* strsep | ( | char ** | stringp, |
const char * | delim | ||
) |
Separate the given string based on a given delimiter.
stringp | The string to separate. |
delim | The delimiter used to separate the string. |
Finds the first token in stringp, that is delimited by one of the bytes in the string delim. This token is terminated by overwriting the delimiter with a null byte ('\0'), and *stringp is updated to point past the token. In case no delimiter was found, the token is taken to be the entire string *stringp, and *stringp is made NULL.
char* strset | ( | char * | s, |
int | c | ||
) |
Fill the string s with the character c.
s | The string that you want to fill. |
c | The character that you want to fill the string with. |
size_t strspn | ( | const char * | string, |
const char * | control | ||
) |
Returns the length of the initial portion of string which consists only of characters that are part of control.
string | String to be scanned. |
control | String containing the characters to match. |
char* strstr | ( | const char * | s1, |
const char * | s2 | ||
) |
Returns a pointer to the first occurrence of s2 in s1, or NULL if s2 is not part of s1.
s1 | String to be scanned |
s2 | String containing the sequence of characters to match. |
char* strtok | ( | char * | str, |
const char * | delim | ||
) |
Splits string into tokens.
str | String to truncate. |
delim | String containing the delimiter characters. |
Notice that str is modified by being broken into smaller strings (tokens). A null pointer may be specified, in which case the function continues scanning where a previous successful call to the function ended.
char* strtok_r | ( | char * | str, |
const char * | delim, | ||
char ** | saveptr | ||
) |
This function is a reentrant version strtok().
str | String to truncate. |
delim | String containing the delimiter characters. |
saveptr | Pointer used internally to maintain context between calls. |
The saveptr argument is a pointer to a char * variable that is used internally by strtok_r() in order to maintain context between successive calls that parse the same string. On the first call to strtok_r(), str should point to the string to be parsed, and the value of saveptr is ignored. In subsequent calls, str should be NULL, and saveptr should be unchanged since the previous call.
char* strupr | ( | char * | s | ) |
Converts a given string into uppercase.
s | String which we want to convert into uppercase. |
int tokenize | ( | const char * | string, |
const char * | separators, | ||
size_t * | offset, | ||
char * | buffer, | ||
ssize_t | buflen | ||
) |
Parses the string using the separator, and at each call it saves the parsed token in buffer. The pointer string
will be modified.
string | cursor used to parse the string, it will be modified. |
separators | the list of separators we are using. |
offset | the offset character from which we start extracting the next token. |
buffer | the buffer where we save the parsed token. |
buflen | the length of the buffer. |
char* trim | ( | char * | str | ) |
Removes any whitespace characters from the beginning and end of str.
str | The string to trim. |