Changeset c065743 in mainline
- Timestamp:
- 2011-08-24T21:16:13Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a5454cf
- Parents:
- ace588a
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
race588a rc065743 1160 1160 str_ncpy(dest, size + 1, src, size); 1161 1161 return dest; 1162 }1163 1164 void str_reverse(char* begin, char* end)1165 {1166 char aux;1167 while(end>begin)1168 aux=*end, *end--=*begin, *begin++=aux;1169 }1170 1171 int size_t_str(size_t value, int base, char* str, size_t size)1172 {1173 static char num[] = "0123456789abcdefghijklmnopqrstuvwxyz";1174 char* wstr=str;1175 1176 if (size == 0)1177 return EINVAL;1178 if (base<2 || base>35) {1179 *str='\0';1180 return EINVAL;1181 }1182 1183 do {1184 *wstr++ = num[value % base];1185 if (--size == 0)1186 return EOVERFLOW;1187 } while(value /= base);1188 *wstr='\0';1189 1190 // Reverse string1191 str_reverse(str,wstr-1);1192 return EOK;1193 1162 } 1194 1163 -
uspace/lib/c/include/str.h
race588a rc065743 99 99 extern char *str_ndup(const char *, size_t max_size); 100 100 101 extern void str_reverse(char* begin, char* end);102 extern int size_t_str(size_t value, int base, char* str, size_t size);103 104 101 extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *); 105 102 extern int str_size_t(const char *, char **, unsigned int, bool, size_t *); -
uspace/srv/fs/fat/fat_directory.c
race588a rc065743 44 44 #include <str.h> 45 45 #include <align.h> 46 #include <stdio.h> 46 47 47 48 int fat_directory_block_load(fat_directory_t *); … … 347 348 str_to_ascii(name, lname, name_len, FAT_SFN_CHAR); 348 349 349 size_tidx;350 unsigned idx; 350 351 for (idx=1; idx <= FAT_MAX_SFN; idx++) { 351 if (size_t_str(idx, 10, number, FAT_NAME_LEN-2)!=EOK) 352 return EOVERFLOW; 352 snprintf(number, sizeof(number), "%u", idx); 353 353 354 354 /* Fill de->name with FAT_PAD */
Note:
See TracChangeset
for help on using the changeset viewer.