genericopenlibs/openenvcore/include/strings.dosc
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /** @file  ../include/strings.h
       
     2 @internalComponent
       
     3 */
       
     4 
       
     5 /** @fn  bcmp(const void *b1, const void *b2, size_t length)
       
     6 @param b1
       
     7 @param b2
       
     8 @param length
       
     9 @return   bcmp function returns 0 if the byte sequences are equal and non-zero 
       
    10   otherwise.
       
    11 
       
    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.
       
    14 
       
    15  The strings may overlap.
       
    16 
       
    17 Examples:
       
    18 @code
       
    19 #include <string.h>
       
    20 #include <stdio.h>
       
    21 int main()
       
    22 {
       
    23    int ret = 0;
       
    24    ret = bcmp("a","a",1);               
       
    25    printf("bcmp(\"a\",\"a\",1) is %d",ret);
       
    26    ret = bcmp("abcd","abce",4); 
       
    27    printf("
       
    28 bcmp(\"abcd\",\"abce\",1) is %d",ret);
       
    29    ret = bcmp("abc","xyz",0);
       
    30    printf("
       
    31 bcmp(\"abc\",\"xyz\",0) is %d",ret);
       
    32    return 0;
       
    33 }
       
    34 
       
    35 @endcode
       
    36  Output
       
    37 @code
       
    38 bcmp("a","a",1) is 0
       
    39 bcmp("abcd","abce",1) is -1
       
    40 bcmp("abc","xyz",0) is 0
       
    41 
       
    42 @endcode
       
    43 @see memcmp()
       
    44 @see strcasecmp()
       
    45 @see strcmp()
       
    46 @see strcoll()
       
    47 @see strxfrm()
       
    48 
       
    49 
       
    50  
       
    51 
       
    52 @publishedAll
       
    53 @externallyDefinedApi
       
    54 */
       
    55 
       
    56 /** @fn  bcopy(const void *src0, void *dst0, size_t length)
       
    57 @param src0
       
    58 @param dst0
       
    59 @param length
       
    60 
       
    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.
       
    62 
       
    63 Examples:
       
    64 @code
       
    65 #include <string.h>
       
    66 #include <stdio.h>
       
    67 int main()
       
    68 {
       
    69     char dst[50];
       
    70     bcopy("Hello World",dst,12);        
       
    71     printf("Destination string after bcopy = %s
       
    72 ",dst);
       
    73     return 0;
       
    74 }
       
    75 
       
    76 @endcode
       
    77  Output
       
    78 @code
       
    79 Destination string after bcopy = Hello World
       
    80 
       
    81 @endcode
       
    82 @see memccpy()
       
    83 @see memcpy()
       
    84 @see memmove()
       
    85 @see strcpy()
       
    86 
       
    87 
       
    88  
       
    89 
       
    90 @publishedAll
       
    91 @externallyDefinedApi
       
    92 */
       
    93 
       
    94 /** @fn  bzero(void *b, size_t len)
       
    95 @param b
       
    96 @param len
       
    97 
       
    98   The bzero function
       
    99 writes len zero bytes to the string b. If len is zero, bzero does nothing.
       
   100 
       
   101 Examples:
       
   102 @code
       
   103 #include <string.h>
       
   104 #include <stdio.h>
       
   105 int main()
       
   106 {
       
   107     char dst[50] = "abcdef";
       
   108     bzero(dst + 2, 2);
       
   109     if(!strcmp(dst, "ab")) printf("dst =  %s
       
   110 ",dst);
       
   111     if(!strcmp(dst+3, "")) printf("zeros added to dst string
       
   112 ");
       
   113     if(!strcmp(dst + 4, "ef")) printf("dst + 4 = %s
       
   114 ",dst);
       
   115     return 0;
       
   116 }
       
   117 
       
   118 @endcode
       
   119  Output
       
   120 @code
       
   121 dst =  ab
       
   122 zeros added to dst string
       
   123 dst + 4 = ab
       
   124 
       
   125 @endcode
       
   126 @see memset()
       
   127 @see swab()
       
   128 
       
   129 
       
   130  
       
   131 
       
   132 @publishedAll
       
   133 @externallyDefinedApi
       
   134 */
       
   135 
       
   136 /** @fn  ffs(int mask)
       
   137 @param mask
       
   138 
       
   139 Note: This description also covers the following functions -
       
   140  ffsl()  fls()  flsl() 
       
   141 
       
   142 @return  
       
   143 
       
   144   The ffs and ffsl functions find the first bit set in mask and return the index of that bit.
       
   145 
       
   146  The fls and flsl functions find the last bit set in mask and return the index of that bit.
       
   147 
       
   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
       
   151 argument was zero.
       
   152 
       
   153 Examples:
       
   154 @code
       
   155 #include <string.h>
       
   156 #include <stdio.h>
       
   157 int main()
       
   158 {
       
   159     int i = 0x10;
       
   160     int j = ffs(i);
       
   161     if(j == 5) printf("First bit position in 0x10 is %d
       
   162 ",j);
       
   163     return 0;
       
   164 }
       
   165 
       
   166 @endcode
       
   167  Output
       
   168 @code
       
   169 First bit position in 0x10 is 5
       
   170 @endcode
       
   171  
       
   172  
       
   173 
       
   174 @publishedAll
       
   175 @externallyDefinedApi
       
   176 */
       
   177 
       
   178 /** @fn  index(const char *p, int ch)
       
   179 @param p
       
   180 @param ch
       
   181 Note: This description also covers the following functions -
       
   182  rindex() 
       
   183 
       
   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.
       
   185 
       
   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.’
       
   187 
       
   188 The rindex function is identical to index, except it locates the last occurrence of ch.
       
   189 
       
   190 Examples:
       
   191 @code
       
   192 #include <string.h>
       
   193 #include <stdio.h>
       
   194 int main()
       
   195 {
       
   196     char one[50];
       
   197     char* ret;
       
   198     strcpy(one,"abcd");
       
   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);
       
   205     strcpy(one,"cdcab");
       
   206     ret = rindex(one, ’c’);
       
   207     if(!strncmp(one+2,ret,1)) printf("rindex of \ ’c\ ’ in string \"cscab\" is %d\n",2);
       
   208     strcpy(one,"dcab");
       
   209     ret = rindex(one, ’\0’);
       
   210     if(!strncmp(one+4,ret,1)) printf("index of \ ’\ \0\ ’ in string \"dcab\" is %d\n",4);
       
   211     return 0;
       
   212 }
       
   213 
       
   214 @endcode
       
   215  Output
       
   216 @code
       
   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
       
   222 @endcode
       
   223 @see memchr()
       
   224 @see strchr()
       
   225 @see strcspn()
       
   226 @see strpbrk()
       
   227 @see strsep()
       
   228 @see strspn()
       
   229 @see strstr()
       
   230 @see strtok()
       
   231 
       
   232 
       
   233  
       
   234 
       
   235 @publishedAll
       
   236 @externallyDefinedApi
       
   237 */
       
   238 
       
   239 /** @fn  rindex(const char *p, int ch)
       
   240 @param p
       
   241 @param ch
       
   242 
       
   243 Refer to  index() for the documentation
       
   244 @see memchr()
       
   245 @see strchr()
       
   246 @see strcspn()
       
   247 @see strpbrk()
       
   248 @see strsep()
       
   249 @see strspn()
       
   250 @see strstr()
       
   251 @see strtok()
       
   252 
       
   253 
       
   254  
       
   255 
       
   256 @publishedAll
       
   257 @externallyDefinedApi
       
   258 */
       
   259 
       
   260 /** @fn  strcasecmp(const char *s1, const char *s2)
       
   261 @param s1
       
   262 @param s2
       
   263 
       
   264 Note: This description also covers the following functions -
       
   265  strncasecmp() 
       
   266 
       
   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.
       
   270 
       
   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.
       
   274 
       
   275  The strncasecmp compares at most len characters.
       
   276 
       
   277 Examples:
       
   278 @code
       
   279 #include <string.h>
       
   280 #include <stdio.h>
       
   281 int main()
       
   282 {
       
   283     int ret;
       
   284     ret = strcasecmp("ABC","abc");
       
   285     printf("strcasecmp of \"ABC\" \"abc\" is %d
       
   286 ",ret);
       
   287     ret = strcasecmp("abc","abc");
       
   288     printf("strcasecmp of \"abc\" \"abc\" is %d
       
   289 ",ret);
       
   290     return 0;   
       
   291 }
       
   292 
       
   293 @endcode
       
   294  Output
       
   295 @code
       
   296 strcasecmp of "ABC" "abc" is 0
       
   297 strcasecmp of "abc" "abc" is 0
       
   298 
       
   299 @endcode
       
   300 @see bcmp()
       
   301 @see memcmp()
       
   302 @see strcmp()
       
   303 @see strcoll()
       
   304 @see strxfrm()
       
   305 @see tolower()
       
   306 
       
   307 
       
   308  
       
   309 
       
   310 @publishedAll
       
   311 @externallyDefinedApi
       
   312 */
       
   313 
       
   314 /** @fn  strncasecmp(const char *s1, const char *s2, size_t n)
       
   315 @param s1
       
   316 @param s2
       
   317 @param n
       
   318 
       
   319 Refer to  strcasecmp() for the documentation
       
   320 @see bcmp()
       
   321 @see memcmp()
       
   322 @see strcmp()
       
   323 @see strcoll()
       
   324 @see strxfrm()
       
   325 @see tolower()
       
   326 
       
   327 
       
   328  
       
   329 
       
   330 @publishedAll
       
   331 @externallyDefinedApi
       
   332 */
       
   333