Go to the source code of this file.
|
int | memcmp (const void *b1, const void *b2, size_t len) |
|
void * | memcpy (void *dst, const void *src, size_t len) |
|
void * | memset (void *dst, int c, size_t len) |
|
char * | strchr (const char *s, int c) |
|
int | strcmp (const char *s1, const char *s2) |
|
char * | strcpy (char *to, const char *from) |
|
size_t | strlen (const char *str) |
|
int | strncmp (const char *s1, const char *s2, size_t len) |
|
char * | strncpy (char *to, const char *from, size_t len) |
|
char * | strcat (char *s, const char *append) |
|
char * | strncat (char *s, const char *append, size_t count) |
|
char * | strtok (char *str, const char *delim) |
|
char * | strtok_r (char *str, const char *delim, char **last) |
|
◆ memcmp()
int memcmp |
( |
const void * |
b1, |
|
|
const void * |
b2, |
|
|
size_t |
len |
|
) |
| |
Definition at line 192 of file string.c.
193{
194 int i;
195 const char *c1 = (const char *)b1;
196 const char *c2 = (const char *)b2;
197
198 for (i = 0; i < length; i++)
199 {
200 if (*c1 != *c2)
201 return *c2 - *c1;
202 c1++;
203 c2++;
204 }
205
206 return 0;
207}
◆ memcpy()
void * memcpy |
( |
void * |
dst, |
|
|
const void * |
src, |
|
|
size_t |
len |
|
) |
| |
Definition at line 177 of file string.c.
178{
181
182 while (length-- != 0) {
183 *d = *s;
184 d += 1;
185 s += 1;
186 };
187
188 return dst;
189}
◆ memset()
void * memset |
( |
void * |
dst, |
|
|
int |
c, |
|
|
size_t |
len |
|
) |
| |
Definition at line 164 of file string.c.
165{
167
168 while (length-- != 0) {
169 *p = c;
170 p += 1;
171 };
172
173 return dst;
174}
◆ strcat()
char * strcat |
( |
char * |
s, |
|
|
const char * |
append |
|
) |
| |
Definition at line 46 of file string.c.
47{
48 char *save = s;
49
50 for (; *s; ++s);
51 while ((*s++ = *append++));
52
53 return save;
54}
◆ strchr()
char * strchr |
( |
const char * |
s, |
|
|
int |
c |
|
) |
| |
Definition at line 11 of file string.c.
12{
13 int i;
14 for (i = 0; ; i++)
15 {
16 if (s[i] == c)
17 return (char *)s + i;
18 if (s[i] == '\0')
20 }
21}
◆ strcmp()
int strcmp |
( |
const char * |
s1, |
|
|
const char * |
s2 |
|
) |
| |
Definition at line 81 of file string.c.
82{
83 while (*s1 == *s2++)
84 if (*s1++ == 0)
85 return 0;
86
88}
◆ strcpy()
char * strcpy |
( |
char * |
to, |
|
|
const char * |
from |
|
) |
| |
Definition at line 24 of file string.c.
25{
26 char *save = to;
27
28 for (; (*to = *from); ++from, ++to);
29
30 return save;
31}
◆ strlen()
size_t strlen |
( |
const char * |
str | ) |
|
Definition at line 112 of file string.c.
113{
114 const char *s;
115
116 for (s = str; *s; ++s);
117
118 return (s - str);
119}
◆ strncat()
char * strncat |
( |
char * |
s, |
|
|
const char * |
append, |
|
|
size_t |
count |
|
) |
| |
Definition at line 58 of file string.c.
59{
60 if (n != 0) {
61 char *d = dst;
62 const char *s = src;
63
64 while (*d != 0)
65 d++;
66
67 do {
68 if ((*d = *s++) == 0)
69 break;
70
71 d++;
72 } while (--n != 0);
73
74 *d = 0;
75 }
76
77 return dst;
78}
◆ strncmp()
int strncmp |
( |
const char * |
s1, |
|
|
const char * |
s2, |
|
|
size_t |
len |
|
) |
| |
Definition at line 91 of file string.c.
92{
94 return 0;
95
96 while (*s1 == *s2) {
97 if (*s1 == 0)
98 return 0;
99
100 s1++;
101 s2++;
102
105 return 0;
106 }
107
109}
◆ strncpy()
char * strncpy |
( |
char * |
to, |
|
|
const char * |
from, |
|
|
size_t |
len |
|
) |
| |
Definition at line 34 of file string.c.
35{
36 char *save = to;
37
38 for (; (*to = *from) != '\0' && length > 0; ++from, ++to, length--);
39
40 *to = '\0';
41
42 return save;
43}
◆ strtok()
char * strtok |
( |
char * |
str, |
|
|
const char * |
delim |
|
) |
| |
Definition at line 156 of file string.c.
157{
158 static char *last;
159
161}
char * strtok_r(char *str, const char *delim, char **last)
◆ strtok_r()
char * strtok_r |
( |
char * |
str, |
|
|
const char * |
delim, |
|
|
char ** |
last |
|
) |
| |
Definition at line 122 of file string.c.
123{
124 char *rval;
125
127 str = *last;
128
129
130 while ((str[0] !=
'\0') &&
strchr(delim, str[0])) {
131 str++;
132 }
133
134
135 if (str[0] == '\0')
137
138
139 rval = str;
140
141
142 while ((str[0] !=
'\0') && !
strchr(delim, str[0])) {
143 str++;
144 }
145
146 if (str[0] != '\0') {
147 str[0] = '\0';
148 str++;
149 }
150 *last = str;
151
152 return rval;
153}
char * strchr(const char *s, int c)