Update contrib.
1 /** @file ../include/strings.h
5 /** @fn bcmp(const void *b1, const void *b2, size_t length)
9 @return bcmp function returns 0 if the byte sequences are equal and non-zero
12 The bcmp function compares byte string b1 against byte string b2, returning zero if they are identical and non-zero otherwise. Both
13 strings are assumed to be length bytes long. Zero-length strings are always identical.
15 The strings may overlap.
24 ret = bcmp("a","a",1);
25 printf("bcmp(\"a\",\"a\",1) is %d",ret);
26 ret = bcmp("abcd","abce",4);
28 bcmp(\"abcd\",\"abce\",1) is %d",ret);
29 ret = bcmp("abc","xyz",0);
31 bcmp(\"abc\",\"xyz\",0) is %d",ret);
39 bcmp("abcd","abce",1) is -1
40 bcmp("abc","xyz",0) is 0
56 /** @fn bcopy(const void *src0, void *dst0, size_t length)
61 The bcopy function copies length bytes from string src0 to string dst0 . The two strings may overlap. If length is zero no bytes are copied.
70 bcopy("Hello World",dst,12);
71 printf("Destination string after bcopy = %s
79 Destination string after bcopy = Hello World
94 /** @fn bzero(void *b, size_t len)
99 writes len zero bytes to the string b. If len is zero, bzero does nothing.
107 char dst[50] = "abcdef";
109 if(!strcmp(dst, "ab")) printf("dst = %s
111 if(!strcmp(dst+3, "")) printf("zeros added to dst string
113 if(!strcmp(dst + 4, "ef")) printf("dst + 4 = %s
122 zeros added to dst string
133 @externallyDefinedApi
136 /** @fn ffs(int mask)
139 Note: This description also covers the following functions -
144 The ffs and ffsl functions find the first bit set in mask and return the index of that bit.
146 The fls and flsl functions find the last bit set in mask and return the index of that bit.
148 Bits are numbered starting from 1, starting at the right-most
149 (least significant) bit.
150 A return value of zero from any of these functions means that the
161 if(j == 5) printf("First bit position in 0x10 is %d
169 First bit position in 0x10 is 5
175 @externallyDefinedApi
178 /** @fn index(const char *p, int ch)
181 Note: This description also covers the following functions -
184 @return The functions index and rindex return a pointer to the located character, or NULL if the character does not appear in the string.
186 The index function locates the first occurrence of ch (converted to a char ) in the string pointed to by p. The terminating null character is considered part of the string; therefore if ch is ‘\\0,’ the functions locate the terminating ‘\\0.’
188 The rindex function is identical to index, except it locates the last occurrence of ch.
199 ret = index(one, ’c’);
200 if(!strncmp(one+2,ret,1)) printf("index of \ ’c\ ’ in string \"abcd\" is %d \n",2);
201 ret = index(one, ’z’);
202 if(ret == NULL) printf("\ ’z\ ’ not found in string \"abcd\"\n");
203 ret = index(one, ’\0’);
204 if(!strncmp(one+4,ret,1)) printf("index of \ ’\ \0\ ’ in string \"abcd\" is %d\n",4);
206 ret = rindex(one, ’c’);
207 if(!strncmp(one+2,ret,1)) printf("rindex of \ ’c\ ’ in string \"cscab\" is %d\n",2);
209 ret = rindex(one, ’\0’);
210 if(!strncmp(one+4,ret,1)) printf("index of \ ’\ \0\ ’ in string \"dcab\" is %d\n",4);
217 index of ’c’ in string "abcd" is 2
218 ’z’ not found in string "abcd"
219 index of ’\0’ in string "abcd" is 4
220 rindex of ’c’ in string "cscab" is 2
221 index of ’\0’ in string "dcab" is 4
236 @externallyDefinedApi
239 /** @fn rindex(const char *p, int ch)
243 Refer to index() for the documentation
257 @externallyDefinedApi
260 /** @fn strcasecmp(const char *s1, const char *s2)
264 Note: This description also covers the following functions -
267 @return The strcasecmp and strncasecmp return an integer greater than, equal to, or less than 0,
268 according to whether s1 is lexicographically greater than, equal to, or less than s2 after translation of each corresponding character to lower-case. The
269 strings themselves are not modified.
271 The strcasecmp and strncasecmp functions
272 compare the null-terminated strings s1 and s2. The strcasecmp() function compares the two strings s1 and s2 , ignoring
273 the case of the characters.
275 The strncasecmp compares at most len characters.
284 ret = strcasecmp("ABC","abc");
285 printf("strcasecmp of \"ABC\" \"abc\" is %d
287 ret = strcasecmp("abc","abc");
288 printf("strcasecmp of \"abc\" \"abc\" is %d
296 strcasecmp of "ABC" "abc" is 0
297 strcasecmp of "abc" "abc" is 0
311 @externallyDefinedApi
314 /** @fn strncasecmp(const char *s1, const char *s2, size_t n)
319 Refer to strcasecmp() for the documentation
331 @externallyDefinedApi