1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/include/strings.dosc Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,333 @@
1.4 +/** @file ../include/strings.h
1.5 +@internalComponent
1.6 +*/
1.7 +
1.8 +/** @fn bcmp(const void *b1, const void *b2, size_t length)
1.9 +@param b1
1.10 +@param b2
1.11 +@param length
1.12 +@return bcmp function returns 0 if the byte sequences are equal and non-zero
1.13 + otherwise.
1.14 +
1.15 + The bcmp function compares byte string b1 against byte string b2, returning zero if they are identical and non-zero otherwise. Both
1.16 +strings are assumed to be length bytes long. Zero-length strings are always identical.
1.17 +
1.18 + The strings may overlap.
1.19 +
1.20 +Examples:
1.21 +@code
1.22 +#include <string.h>
1.23 +#include <stdio.h>
1.24 +int main()
1.25 +{
1.26 + int ret = 0;
1.27 + ret = bcmp("a","a",1);
1.28 + printf("bcmp(\"a\",\"a\",1) is %d",ret);
1.29 + ret = bcmp("abcd","abce",4);
1.30 + printf("
1.31 +bcmp(\"abcd\",\"abce\",1) is %d",ret);
1.32 + ret = bcmp("abc","xyz",0);
1.33 + printf("
1.34 +bcmp(\"abc\",\"xyz\",0) is %d",ret);
1.35 + return 0;
1.36 +}
1.37 +
1.38 +@endcode
1.39 + Output
1.40 +@code
1.41 +bcmp("a","a",1) is 0
1.42 +bcmp("abcd","abce",1) is -1
1.43 +bcmp("abc","xyz",0) is 0
1.44 +
1.45 +@endcode
1.46 +@see memcmp()
1.47 +@see strcasecmp()
1.48 +@see strcmp()
1.49 +@see strcoll()
1.50 +@see strxfrm()
1.51 +
1.52 +
1.53 +
1.54 +
1.55 +@publishedAll
1.56 +@externallyDefinedApi
1.57 +*/
1.58 +
1.59 +/** @fn bcopy(const void *src0, void *dst0, size_t length)
1.60 +@param src0
1.61 +@param dst0
1.62 +@param length
1.63 +
1.64 + 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.
1.65 +
1.66 +Examples:
1.67 +@code
1.68 +#include <string.h>
1.69 +#include <stdio.h>
1.70 +int main()
1.71 +{
1.72 + char dst[50];
1.73 + bcopy("Hello World",dst,12);
1.74 + printf("Destination string after bcopy = %s
1.75 +",dst);
1.76 + return 0;
1.77 +}
1.78 +
1.79 +@endcode
1.80 + Output
1.81 +@code
1.82 +Destination string after bcopy = Hello World
1.83 +
1.84 +@endcode
1.85 +@see memccpy()
1.86 +@see memcpy()
1.87 +@see memmove()
1.88 +@see strcpy()
1.89 +
1.90 +
1.91 +
1.92 +
1.93 +@publishedAll
1.94 +@externallyDefinedApi
1.95 +*/
1.96 +
1.97 +/** @fn bzero(void *b, size_t len)
1.98 +@param b
1.99 +@param len
1.100 +
1.101 + The bzero function
1.102 +writes len zero bytes to the string b. If len is zero, bzero does nothing.
1.103 +
1.104 +Examples:
1.105 +@code
1.106 +#include <string.h>
1.107 +#include <stdio.h>
1.108 +int main()
1.109 +{
1.110 + char dst[50] = "abcdef";
1.111 + bzero(dst + 2, 2);
1.112 + if(!strcmp(dst, "ab")) printf("dst = %s
1.113 +",dst);
1.114 + if(!strcmp(dst+3, "")) printf("zeros added to dst string
1.115 +");
1.116 + if(!strcmp(dst + 4, "ef")) printf("dst + 4 = %s
1.117 +",dst);
1.118 + return 0;
1.119 +}
1.120 +
1.121 +@endcode
1.122 + Output
1.123 +@code
1.124 +dst = ab
1.125 +zeros added to dst string
1.126 +dst + 4 = ab
1.127 +
1.128 +@endcode
1.129 +@see memset()
1.130 +@see swab()
1.131 +
1.132 +
1.133 +
1.134 +
1.135 +@publishedAll
1.136 +@externallyDefinedApi
1.137 +*/
1.138 +
1.139 +/** @fn ffs(int mask)
1.140 +@param mask
1.141 +
1.142 +Note: This description also covers the following functions -
1.143 + ffsl() fls() flsl()
1.144 +
1.145 +@return
1.146 +
1.147 + The ffs and ffsl functions find the first bit set in mask and return the index of that bit.
1.148 +
1.149 + The fls and flsl functions find the last bit set in mask and return the index of that bit.
1.150 +
1.151 + Bits are numbered starting from 1, starting at the right-most
1.152 +(least significant) bit.
1.153 +A return value of zero from any of these functions means that the
1.154 +argument was zero.
1.155 +
1.156 +Examples:
1.157 +@code
1.158 +#include <string.h>
1.159 +#include <stdio.h>
1.160 +int main()
1.161 +{
1.162 + int i = 0x10;
1.163 + int j = ffs(i);
1.164 + if(j == 5) printf("First bit position in 0x10 is %d
1.165 +",j);
1.166 + return 0;
1.167 +}
1.168 +
1.169 +@endcode
1.170 + Output
1.171 +@code
1.172 +First bit position in 0x10 is 5
1.173 +@endcode
1.174 +
1.175 +
1.176 +
1.177 +@publishedAll
1.178 +@externallyDefinedApi
1.179 +*/
1.180 +
1.181 +/** @fn index(const char *p, int ch)
1.182 +@param p
1.183 +@param ch
1.184 +Note: This description also covers the following functions -
1.185 + rindex()
1.186 +
1.187 +@return The functions index and rindex return a pointer to the located character, or NULL if the character does not appear in the string.
1.188 +
1.189 +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.’
1.190 +
1.191 +The rindex function is identical to index, except it locates the last occurrence of ch.
1.192 +
1.193 +Examples:
1.194 +@code
1.195 +#include <string.h>
1.196 +#include <stdio.h>
1.197 +int main()
1.198 +{
1.199 + char one[50];
1.200 + char* ret;
1.201 + strcpy(one,"abcd");
1.202 + ret = index(one, ’c’);
1.203 + if(!strncmp(one+2,ret,1)) printf("index of \ ’c\ ’ in string \"abcd\" is %d \n",2);
1.204 + ret = index(one, ’z’);
1.205 + if(ret == NULL) printf("\ ’z\ ’ not found in string \"abcd\"\n");
1.206 + ret = index(one, ’\0’);
1.207 + if(!strncmp(one+4,ret,1)) printf("index of \ ’\ \0\ ’ in string \"abcd\" is %d\n",4);
1.208 + strcpy(one,"cdcab");
1.209 + ret = rindex(one, ’c’);
1.210 + if(!strncmp(one+2,ret,1)) printf("rindex of \ ’c\ ’ in string \"cscab\" is %d\n",2);
1.211 + strcpy(one,"dcab");
1.212 + ret = rindex(one, ’\0’);
1.213 + if(!strncmp(one+4,ret,1)) printf("index of \ ’\ \0\ ’ in string \"dcab\" is %d\n",4);
1.214 + return 0;
1.215 +}
1.216 +
1.217 +@endcode
1.218 + Output
1.219 +@code
1.220 +index of ’c’ in string "abcd" is 2
1.221 + ’z’ not found in string "abcd"
1.222 +index of ’\0’ in string "abcd" is 4
1.223 +rindex of ’c’ in string "cscab" is 2
1.224 +index of ’\0’ in string "dcab" is 4
1.225 +@endcode
1.226 +@see memchr()
1.227 +@see strchr()
1.228 +@see strcspn()
1.229 +@see strpbrk()
1.230 +@see strsep()
1.231 +@see strspn()
1.232 +@see strstr()
1.233 +@see strtok()
1.234 +
1.235 +
1.236 +
1.237 +
1.238 +@publishedAll
1.239 +@externallyDefinedApi
1.240 +*/
1.241 +
1.242 +/** @fn rindex(const char *p, int ch)
1.243 +@param p
1.244 +@param ch
1.245 +
1.246 +Refer to index() for the documentation
1.247 +@see memchr()
1.248 +@see strchr()
1.249 +@see strcspn()
1.250 +@see strpbrk()
1.251 +@see strsep()
1.252 +@see strspn()
1.253 +@see strstr()
1.254 +@see strtok()
1.255 +
1.256 +
1.257 +
1.258 +
1.259 +@publishedAll
1.260 +@externallyDefinedApi
1.261 +*/
1.262 +
1.263 +/** @fn strcasecmp(const char *s1, const char *s2)
1.264 +@param s1
1.265 +@param s2
1.266 +
1.267 +Note: This description also covers the following functions -
1.268 + strncasecmp()
1.269 +
1.270 +@return The strcasecmp and strncasecmp return an integer greater than, equal to, or less than 0,
1.271 +according to whether s1 is lexicographically greater than, equal to, or less than s2 after translation of each corresponding character to lower-case. The
1.272 +strings themselves are not modified.
1.273 +
1.274 + The strcasecmp and strncasecmp functions
1.275 +compare the null-terminated strings s1 and s2. The strcasecmp() function compares the two strings s1 and s2 , ignoring
1.276 +the case of the characters.
1.277 +
1.278 + The strncasecmp compares at most len characters.
1.279 +
1.280 +Examples:
1.281 +@code
1.282 +#include <string.h>
1.283 +#include <stdio.h>
1.284 +int main()
1.285 +{
1.286 + int ret;
1.287 + ret = strcasecmp("ABC","abc");
1.288 + printf("strcasecmp of \"ABC\" \"abc\" is %d
1.289 +",ret);
1.290 + ret = strcasecmp("abc","abc");
1.291 + printf("strcasecmp of \"abc\" \"abc\" is %d
1.292 +",ret);
1.293 + return 0;
1.294 +}
1.295 +
1.296 +@endcode
1.297 + Output
1.298 +@code
1.299 +strcasecmp of "ABC" "abc" is 0
1.300 +strcasecmp of "abc" "abc" is 0
1.301 +
1.302 +@endcode
1.303 +@see bcmp()
1.304 +@see memcmp()
1.305 +@see strcmp()
1.306 +@see strcoll()
1.307 +@see strxfrm()
1.308 +@see tolower()
1.309 +
1.310 +
1.311 +
1.312 +
1.313 +@publishedAll
1.314 +@externallyDefinedApi
1.315 +*/
1.316 +
1.317 +/** @fn strncasecmp(const char *s1, const char *s2, size_t n)
1.318 +@param s1
1.319 +@param s2
1.320 +@param n
1.321 +
1.322 +Refer to strcasecmp() for the documentation
1.323 +@see bcmp()
1.324 +@see memcmp()
1.325 +@see strcmp()
1.326 +@see strcoll()
1.327 +@see strxfrm()
1.328 +@see tolower()
1.329 +
1.330 +
1.331 +
1.332 +
1.333 +@publishedAll
1.334 +@externallyDefinedApi
1.335 +*/
1.336 +