Changeset ac02aaa in mainline
- Timestamp:
- 2008-09-14T11:00:31Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 693f614
- Parents:
- 9f3363e
- Location:
- boot/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/generic/string.c
r9f3363e rac02aaa 40 40 /** Return number of characters in a string. 41 41 * 42 * @param str 43 * 44 * @return 42 * @param str NULL terminated string. 43 * 44 * @return Number of characters in str. 45 45 */ 46 46 size_t strlen(const char *str) … … 54 54 } 55 55 56 /** Compare two NULL terminated strings 56 /** Compare two NULL terminated strings. 57 57 * 58 58 * Do a char-by-char comparison of two NULL terminated strings. … … 60 60 * characters on the minimum of their lengths. 61 61 * 62 * @param src First string to compare. 63 * @param dst Second string to compare. 64 * 65 * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller. 62 * @param src First string to compare. 63 * @param dst Second string to compare. 64 * 65 * @return 0 if the strings are equal, -1 if first is smaller, 66 * 1 if second smaller. 66 67 * 67 68 */ … … 82 83 83 84 84 /** Compare two NULL terminated strings 85 /** Compare two NULL terminated strings. 85 86 * 86 87 * Do a char-by-char comparison of two NULL terminated strings. … … 89 90 * length. 90 91 * 91 * @param src First string to compare. 92 * @param dst Second string to compare. 93 * @param len Maximal length for comparison. 94 * 95 * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller. 92 * @param src First string to compare. 93 * @param dst Second string to compare. 94 * @param len Maximal length for comparison. 95 * 96 * @return 0 if the strings are equal, -1 if first is smaller, 97 * 1 if second smaller. 96 98 * 97 99 */ … … 119 121 * last copied character. 120 122 * 121 * @param src 122 * @param dest 123 * @param len 123 * @param src Source string. 124 * @param dest Destination buffer. 125 * @param len Size of destination buffer. 124 126 */ 125 127 void strncpy(char *dest, const char *src, size_t len) … … 133 135 } 134 136 135 /** Convert ascii representation to unative_t 137 /** Convert ascii representation to unative_t. 136 138 * 137 139 * Supports 0x for hexa & 0 for octal notation. 138 140 * Does not check for overflows, does not support negative numbers 139 141 * 140 * @param text Textual representation of number141 * @return Converted number or 0 if no valid number ofund142 * @param text Textual representation of number. 143 * @return Converted number or 0 if no valid number found. 142 144 */ 143 145 unative_t atoi(const char *text) … … 153 155 154 156 while (*text) { 155 if (base != 16 && \156 ((*text >= 'A' && *text <= 'F' )157 ||(*text >='a' && *text <='f')))157 if (base != 16 && 158 ((*text >= 'A' && *text <= 'F') || 159 (*text >='a' && *text <='f'))) 158 160 break; 159 161 if (base == 8 && *text >='8') … … 177 179 } 178 180 181 /** Move piece of memory to another, possibly overlapping, location. 182 * 183 * @param dst Destination address. 184 * @param src Source address. 185 * @param len Number of bytes to move. 186 * 187 * @return Destination address. 188 */ 189 void *memmove(void *dst, const void *src, size_t len) 190 { 191 char *d = dst; 192 const char *s = src; 193 if (s < d) { 194 while (len--) 195 *(d + len) = *(s + len); 196 } else { 197 while (len--) 198 *d++ = *s++; 199 } 200 201 return dst; 202 } 203 179 204 /** @} 180 205 */ -
boot/generic/string.h
r9f3363e rac02aaa 43 43 extern void strncpy(char *dest, const char *src, size_t len); 44 44 extern unative_t atoi(const char *text); 45 extern void *memmove(void *dst, const void *src, size_t len); 45 46 46 47 #endif
Note:
See TracChangeset
for help on using the changeset viewer.