| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include <pj/guid.h> |
| 19 |
#include <pj/assert.h> |
| 20 |
#include <pj/os.h> |
| 21 |
#include <pj/string.h> |
| 22 |
#include <uuid.h> |
| 23 |
|
| 24 |
PJ_DEF_DATA(const unsigned) PJ_GUID_STRING_LENGTH = 36; |
| 25 |
|
| 26 |
PJ_DEF(unsigned) pj_GUID_STRING_LENGTH() |
| 27 |
{ |
| 28 |
return PJ_GUID_STRING_LENGTH; |
| 29 |
} |
| 30 |
|
| 31 |
PJ_DEF(pj_str_t *) pj_generate_unique_string(pj_str_t *str) |
| 32 |
{ |
| 33 |
uint32_t status; |
| 34 |
uuid_t u; |
| 35 |
char *s = NULL; |
| 36 |
pj_str_t sguid; |
| 37 |
|
| 38 |
PJ_ASSERT_RETURN(str && str->ptr, NULL); |
| 39 |
PJ_CHECK_STACK(); |
| 40 |
|
| 41 |
uuid_create(&u, &status); |
| 42 |
PJ_ASSERT_RETURN(status == uuid_s_ok, NULL); |
| 43 |
uuid_to_string(&u, &s, &status); |
| 44 |
PJ_ASSERT_RETURN(status == uuid_s_ok, NULL); |
| 45 |
sguid = pj_str(s); |
| 46 |
pj_strncpy(str, &sguid, PJ_GUID_STRING_LENGTH); |
| 47 |
free(s); |
| 48 |
|
| 49 |
return str; |
| 50 |
} |