#include <stdint.h>#include <stdlib.h>#include <string.h>#include <ctype.h>Go to the source code of this file.
Functions | |
| int | strnicmp (const char *s1, const char *s2, size_t len) |
| strnicmp - Case insensitive, length-limited string comparison : One string : The other string : the maximum number of characters to compare | |
| char * | strncat (char *dest, const char *src, size_t count) |
| strncat - Append a length-limited, NUL-terminated string to another : The string to be appended to : The string to append to it : The maximum numbers of bytes to copy | |
| size_t | strspn (const char *s, const char *accept) |
| strspn - Calculate the length of the initial substring of which only contain letters in : The string to be searched : The string to search for | |
| size_t | strcspn (const char *s, const char *reject) |
| strcspn - Calculate the length of the initial substring of which only contain letters not in : The string to be searched : The string to search for | |
| char * | strpbrk (const char *cs, const char *ct) |
| strpbrk - Find the first occurrence of a set of characters : The string to be searched : The characters to search for | |
| char * | strtok (char *s, const char *ct) |
| strtok - Split a string into tokens : The string to be searched : The characters to search for | |
| char * | strsep (char **s, const char *ct) |
| strsep - Split a string into tokens : The string to be searched : The characters to search for | |
| char * | bcopy (const char *src, char *dest, int count) |
| bcopy - Copy one area of memory to another : Where to copy from : Where to copy to : The size of the area. | |
| void * | memscan (const void *addr, int c, size_t size) |
| memscan - Find a character in an area of memory. | |
Variables | |
| char * | ___strtok |
| int strnicmp | ( | const char * | s1, | |
| const char * | s2, | |||
| size_t | len | |||
| ) |
strnicmp - Case insensitive, length-limited string comparison : One string : The other string : the maximum number of characters to compare
Definition at line 46 of file stringextra.c.
References tolower().
00047 { 00048 /* Yes, Virginia, it had better be unsigned */ 00049 unsigned char c1, c2; 00050 00051 c1 = 0; c2 = 0; 00052 if (len) { 00053 do { 00054 c1 = *s1; c2 = *s2; 00055 s1++; s2++; 00056 if (!c1) 00057 break; 00058 if (!c2) 00059 break; 00060 if (c1 == c2) 00061 continue; 00062 c1 = tolower(c1); 00063 c2 = tolower(c2); 00064 if (c1 != c2) 00065 break; 00066 } while (--len); 00067 } 00068 return (int)c1 - (int)c2; 00069 }
| char* strncat | ( | char * | dest, | |
| const char * | src, | |||
| size_t | count | |||
| ) |
strncat - Append a length-limited, NUL-terminated string to another : The string to be appended to : The string to append to it : The maximum numbers of bytes to copy
Note that in contrast to strncpy, strncat ensures the result is terminated.
Definition at line 84 of file stringextra.c.
00085 { 00086 char *tmp = dest; 00087 00088 if (count) { 00089 while (*dest) 00090 dest++; 00091 while ((*dest++ = *src++)) { 00092 if (--count == 0) { 00093 *dest = '\0'; 00094 break; 00095 } 00096 } 00097 } 00098 00099 return tmp; 00100 }
| size_t strspn | ( | const char * | s, | |
| const char * | accept | |||
| ) |
strspn - Calculate the length of the initial substring of which only contain letters in : The string to be searched : The string to search for
Definition at line 110 of file stringextra.c.
Referenced by strtok().
00111 { 00112 const char *p; 00113 const char *a; 00114 size_t count = 0; 00115 00116 for (p = s; *p != '\0'; ++p) { 00117 for (a = accept; *a != '\0'; ++a) { 00118 if (*p == *a) 00119 break; 00120 } 00121 if (*a == '\0') 00122 return count; 00123 ++count; 00124 } 00125 00126 return count; 00127 }
| size_t strcspn | ( | const char * | s, | |
| const char * | reject | |||
| ) |
strcspn - Calculate the length of the initial substring of which only contain letters not in : The string to be searched : The string to search for
Definition at line 137 of file stringextra.c.
References r.
00138 { 00139 const char *p; 00140 const char *r; 00141 size_t count = 0; 00142 00143 for (p = s; *p != '\0'; ++p) { 00144 for (r = reject; *r != '\0'; ++r) { 00145 if (*p == *r) 00146 return count; 00147 } 00148 ++count; 00149 } 00150 00151 return count; 00152 }
| char* strpbrk | ( | const char * | cs, | |
| const char * | ct | |||
| ) |
strpbrk - Find the first occurrence of a set of characters : The string to be searched : The characters to search for
Definition at line 161 of file stringextra.c.
References NULL.
Referenced by strsep(), and strtok().
00162 { 00163 const char *sc1,*sc2; 00164 00165 for( sc1 = cs; *sc1 != '\0'; ++sc1) { 00166 for( sc2 = ct; *sc2 != '\0'; ++sc2) { 00167 if (*sc1 == *sc2) 00168 return (char *) sc1; 00169 } 00170 } 00171 return NULL; 00172 }
| char* strtok | ( | char * | s, | |
| const char * | ct | |||
| ) |
strtok - Split a string into tokens : The string to be searched : The characters to search for
WARNING: strtok is deprecated, use strsep instead.
Definition at line 183 of file stringextra.c.
References ___strtok, NULL, strpbrk(), and strspn().
00184 { 00185 char *sbegin, *send; 00186 00187 sbegin = s ? s : ___strtok; 00188 if (!sbegin) { 00189 return NULL; 00190 } 00191 sbegin += strspn(sbegin,ct); 00192 if (*sbegin == '\0') { 00193 ___strtok = NULL; 00194 return( NULL ); 00195 } 00196 send = strpbrk( sbegin, ct); 00197 if (send && *send != '\0') 00198 *send++ = '\0'; 00199 ___strtok = send; 00200 return (sbegin); 00201 }
| char* strsep | ( | char ** | s, | |
| const char * | ct | |||
| ) |
strsep - Split a string into tokens : The string to be searched : The characters to search for
strsep() updates to point after the token, ready for the next call.
It returns empty tokens, too, behaving exactly like the libc function of that name. In fact, it was stolen from glibc2 and de-fancy-fied. Same semantics, slimmer shape. ;)
Definition at line 216 of file stringextra.c.
References NULL, and strpbrk().
00217 { 00218 char *sbegin = *s, *end; 00219 00220 if (sbegin == NULL) 00221 return NULL; 00222 00223 end = strpbrk(sbegin, ct); 00224 if (end) 00225 *end++ = '\0'; 00226 *s = end; 00227 00228 return sbegin; 00229 }
| char* bcopy | ( | const char * | src, | |
| char * | dest, | |||
| int | count | |||
| ) |
bcopy - Copy one area of memory to another : Where to copy from : Where to copy to : The size of the area.
Note that this is the same as memcpy(), with the arguments reversed. memcpy() is the standard, bcopy() is a legacy BSD function.
You should not use this function to access IO space, use memcpy_toio() or memcpy_fromio() instead.
Definition at line 245 of file stringextra.c.
References memmove().
| void* memscan | ( | const void * | addr, | |
| int | c, | |||
| size_t | size | |||
| ) |
memscan - Find a character in an area of memory.
: The memory area : The byte to search for : The size of the area.
returns the address of the first occurrence of , or 1 byte past the area if is not found
Definition at line 261 of file stringextra.c.
00262 { 00263 unsigned char * p = (unsigned char *) addr; 00264 00265 while (size) { 00266 if (*p == c) 00267 return (void *) p; 00268 p++; 00269 size--; 00270 } 00271 return (void *) p; 00272 }
| char* ___strtok |
1.5.7.1