Changeset ed3d605 in mainline for uspace/lib/c/generic/uuid.c
- Timestamp:
- 2019-02-09T18:31:41Z (6 years ago)
- Children:
- d55abe8b
- Parents:
- a508e82
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/uuid.c
ra508e82 red3d605 39 39 #include <stddef.h> 40 40 #include <str.h> 41 #include <stdio.h> 41 42 42 43 /** Generate UUID. … … 176 177 * @return EOK on success, ENOMEM if out of memory 177 178 */ 178 errno_t uuid_format(uuid_t *uuid, char **rstr) 179 { 180 return ENOTSUP; 179 errno_t uuid_format(uuid_t *uuid, char **rstr, bool uppercase) 180 { 181 size_t size = 37; 182 char *str = malloc(sizeof(char) * size); 183 if (str == NULL) 184 return ENOMEM; 185 186 const char *format = "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"; 187 if(uppercase) 188 format = "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X"; 189 190 int ret = snprintf(str, size, format, uuid->b[0], uuid->b[1], uuid->b[2], uuid->b[3], uuid->b[4], uuid->b[5], uuid->b[6], uuid->b[7], uuid->b[8], uuid->b[9], uuid->b[10], uuid->b[11], uuid->b[12], uuid->b[13], uuid->b[14], uuid->b[15]); 191 192 if (ret != 36) 193 return EINVAL; 194 195 *rstr = str; 196 return EOK; 181 197 } 182 198
Note:
See TracChangeset
for help on using the changeset viewer.