3 * Copyright (C) 2007 David Cohen <dacohen@gmail.com>
4 * Copyright (C) 2007 Felipe Balbi <me@felipebalbi.com>
6 * This file is part of Tinyx Nanokernel Project.
8 * Tinyx is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * Tinyx is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Tinyx. If not, see <http://www.gnu.org/licenses/>.
22 #include <libc/string.h>
25 * memset - Fill a memory region with data
26 * @mem: Pointer to the start of the area.
27 * @data: The byte to fill the area with
28 * @count: The size of the area.
30 void *memset(void *mem
, int data
, size_t count
)
40 * memcpy - Copy memory areas
41 * @dest: Destination of copy task
42 * @src: Where the data to copy from is
43 * @count: The size of the area.
45 void *memcpy(void *dest
, const void *src
, size_t count
)
56 * strcat - Apend one string to another
57 * @str1: The destination string
58 * @str2: The source string
60 char *strcat(char *str1
, const char *str2
)
66 while ((*str1
++ = *str2
++) != '\0')
72 * strchr - Find the first ocurrence of a character in a string
73 * @str: The string to search into
74 * @ch: The character to find
76 char *strchr(const char *str
, int ch
)
78 for (; *str
!= (char)ch
; ++str
)
85 * strcoll - Compare two strings
87 * @str2: Second string
89 int strcoll(const char *str1
, const char *str2
)
91 while ((*str1
) == (*str2
)) {
96 while ((*str1
++) && (*str2
++));
98 return (*str1
) ? 1 : -1;
102 * strcmp - Lex comparation of two strings
103 * @str1: First string
104 * @str2: Second string
106 int strcmp(const char *str1
, const char *str2
)
111 if ((ret
= *str1
- *str2
++) != 0 || !*str1
++)
118 * strcpy - Copy the contents of str2 into str1
119 * @str1: The destination string
120 * @str2: The source string
122 char *strcpy(char *str1
, const char *str2
)
126 while ((*str1
++ = *str2
++) != '\0');
132 * strlen - Find the length of a string
133 * @str: The string to be sized
135 size_t strlen(const char *str
)
139 for (tmp
= str
; *tmp
!= '\0'; ++tmp
);
145 * strncat - Append count characters of str2 into str1
146 * @str1: The destination string
147 * @str2: The source string
148 * @count: The number of characters to append
150 char *strncat(char *str1
, const char *str2
, size_t count
)
157 while ((*str1
++ = *str2
++) != 0) {
168 * strncmp - Comparison of count characters
169 * @str1: The destination string
170 * @str2: The source string
171 * @count: The number of characters
173 int strncmp(const char *str1
, const char *str2
, size_t count
)
178 if ((ret
= *str1
- *str2
++) != 0 || !*str1
++)
186 * strncpy - Copy count characters from str2 into str1
187 * @str1: The destination string
188 * @str2: The source string
189 * @count: The number of characters
191 char *strncpy(char *str1
, const char *str2
, size_t count
)
196 if ((*tmp
= *str2
) != 0)