MentOS  0.8.0
The Mentoring Operating System
string.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include "stddef.h"
9 
15 char *strncpy(char *destination, const char *source, size_t num);
16 
28 int strncmp(const char *s1, const char *s2, size_t n);
29 
40 int stricmp(const char *s1, const char *s2);
41 
53 int strnicmp(const char *s1, const char *s2, size_t n);
54 
59 char *strchr(const char *s, int ch);
60 
65 char *strrchr(const char *s, int ch);
66 
74 char *strstr(const char *s1, const char *s2);
75 
82 size_t strspn(const char *string, const char *control);
83 
90 size_t strcspn(const char *string, const char *control);
91 
100 char *strpbrk(const char *string, const char *control);
101 
106 char *strdup(const char *s);
107 
113 char *strndup(const char *s, size_t n);
114 
120 char *strcat(char *dst, const char *src);
121 
128 char *strncat(char *dst, const char *src, size_t n);
129 
134 char *strset(char *s, int c);
135 
141 char *strnset(char *s, int c, size_t n);
142 
146 char *strrev(char *s);
147 
157 char *strtok(char *str, const char *delim);
158 
171 char *strtok_r(char *str, const char *delim, char **saveptr);
172 
181 int tokenize(const char *string, const char *separators, size_t *offset, char *buffer, ssize_t buflen);
182 
191 void *memmove(void *dst, const void *src, size_t n);
192 
200 void *memchr(const void *ptr, int c, size_t n);
201 
205 char *strlwr(char *s);
206 
210 char *strupr(char *s);
211 
221 void *memccpy(void *dst, const void *src, int c, size_t n);
222 
228 void *memcpy(void *dst, const void *src, size_t num);
229 
242 int memcmp(const void *ptr1, const void *ptr2, size_t n);
243 
250 void *memset(void *ptr, int value, size_t num);
251 
256 char *strcpy(char *dst, const char *src);
257 
268 int strcmp(const char *s1, const char *s2);
269 
273 size_t strlen(const char *s);
274 
282 size_t strnlen(const char *s, size_t maxlen);
283 
287 char *trim(char *str);
288 
299 char *strsep(char **stringp, const char *delim);
300 
306 char *itoa(char *buffer, unsigned int num, unsigned int base);
307 
313 char *replace_char(char *str, char find, char replace);
314 
320 void strmode(mode_t mode, char *p);
Define basic data types.
long ssize_t
Define the generic signed size type.
Definition: stddef.h:31
unsigned int mode_t
The type of mode.
Definition: stddef.h:49
char * trim(char *str)
Removes any whitespace characters from the beginning and end of str.
Definition: string.c:581
int strncmp(const char *s1, const char *s2, size_t n)
Compares up to n characters of s1 to those of s2.
Definition: string.c:37
int strnicmp(const char *s1, const char *s2, size_t n)
Case-insensitively compare up to n characters of s1 to those of s2.
Definition: string.c:59
int strcmp(const char *s1, const char *s2)
Checks if the two strings are equal.
Definition: string.c:509
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 o...
Definition: string.c:128
char * strrev(char *s)
Reverse the string s.
Definition: string.c:350
char * strcpy(char *dst, const char *src)
Copy the string src into the array dst.
Definition: string.c:489
void strmode(mode_t mode, char *p)
Converts a file mode (the type and permission information associated with an inode) into a symbolic s...
Definition: string.c:727
char * itoa(char *buffer, unsigned int num, unsigned int base)
Move the number "num" into a string.
Definition: string.c:683
char * strupr(char *s)
Converts a given string into uppercase.
Definition: string.c:307
char * strcat(char *dst, const char *src)
Appends a copy of the string src to the string dst.
Definition: string.c:319
void * memcpy(void *dst, const void *src, size_t num)
Copy a block of memory, handling overlap.
Definition: string.c:466
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.
Definition: string.c:440
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.
Definition: string.c:332
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 c...
Definition: string.c:161
char * strpbrk(const char *string, const char *control)
Finds the first character in the string string that matches any character specified in control.
Definition: string.c:191
int stricmp(const char *s1, const char *s2)
Case insensitive string compare.
Definition: string.c:50
char * strchr(const char *s, int ch)
Returns a pointer to the first occurrence of ch in str.
Definition: string.c:75
char * strndup(const char *s, size_t n)
Make a copy of at most n bytes of the given string.
Definition: string.c:641
char * strtok(char *str, const char *delim)
Splits string into tokens.
Definition: string.c:537
char * strsep(char **stringp, const char *delim)
Separate the given string based on a given delimiter.
Definition: string.c:656
char * strrchr(const char *s, int ch)
Returns a pointer to the last occurrence of ch in str.
Definition: string.c:88
size_t strlen(const char *s)
Returns the length of the string s.
Definition: string.c:496
int memcmp(const void *ptr1, const void *ptr2, size_t n)
Compares the first n bytes of str1 and str2.
Definition: string.c:452
char * strset(char *s, int c)
Fill the string s with the character c.
Definition: string.c:519
char * strtok_r(char *str, const char *delim, char **saveptr)
This function is a reentrant version strtok().
Definition: string.c:368
char * strdup(const char *s)
Make a copy of the given string.
Definition: string.c:626
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 des...
Definition: string.c:257
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,...
Definition: string.c:479
char * strncpy(char *destination, const char *source, size_t num)
Copies the first num characters of source to destination.
Definition: string.c:16
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 s...
Definition: string.c:285
char * strnset(char *s, int c, size_t n)
Fill the string s with the character c, up to the given length n.
Definition: string.c:528
char * replace_char(char *str, char find, char replace)
Replaces the occurrences of find with replace inside str.
Definition: string.c:715
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.
Definition: string.c:103
char * strlwr(char *s)
Converts a given string into lowercase.
Definition: string.c:295
size_t strnlen(const char *s, size_t maxlen)
Returns the number of characters inside s, excluding the terminating null byte ('\0'),...
Definition: string.c:503
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....
Definition: string.c:221