| 1 |
uuid requirements |
| 2 |
================= |
| 3 |
|
| 4 |
## Overview |
| 5 |
The UUID module provides functions to create and convert UUID values. |
| 6 |
|
| 7 |
## Exposed API |
| 8 |
```c |
| 9 |
typedef unsigned char UUID_T[16]; |
| 10 |
|
| 11 |
extern int UUID_generate(UUID_T* uuid); |
| 12 |
extern int UUID_from_string(char* uuid_string, UUID_T* uuid); |
| 13 |
extern char* UUID_to_string(UUID_T* uuid); |
| 14 |
``` |
| 15 |
|
| 16 |
### UUID_generate |
| 17 |
```c |
| 18 |
extern int UUID_generate(UUID_T* uuid); |
| 19 |
``` |
| 20 |
**SRS_UUID_09_001: [** If `uuid` is NULL, UUID_generate shall return a non-zero value **]** |
| 21 |
|
| 22 |
**SRS_UUID_09_002: [** UUID_generate shall obtain an UUID string from UniqueId_Generate **]** |
| 23 |
|
| 24 |
**SRS_UUID_09_003: [** If the UUID string fails to be obtained, UUID_generate shall fail and return a non-zero value **]** |
| 25 |
|
| 26 |
**SRS_UUID_09_004: [** The UUID string shall be parsed into an UUID_T type (16 unsigned char array) and filled in `uuid` **]** |
| 27 |
|
| 28 |
**SRS_UUID_09_005: [** If `uuid` fails to be set, UUID_generate shall fail and return a non-zero value **]** |
| 29 |
|
| 30 |
**SRS_UUID_09_006: [** If no failures occur, UUID_generate shall return zero **]** |
| 31 |
|
| 32 |
|
| 33 |
### UUID_from_string |
| 34 |
```c |
| 35 |
extern int UUID_from_string(char* uuid_string, UUID_T* uuid); |
| 36 |
``` |
| 37 |
**SRS_UUID_09_007: [** If `uuid_string` or `uuid` are NULL, UUID_from_string shall return a non-zero value **]** |
| 38 |
|
| 39 |
**SRS_UUID_09_008: [** Each pair of digits in `uuid_string`, excluding dashes, shall be read as a single HEX value and saved on the respective position in `uuid` **]** |
| 40 |
|
| 41 |
**SRS_UUID_09_009: [** If `uuid` fails to be generated, UUID_from_string shall return a non-zero value **]** |
| 42 |
|
| 43 |
**SRS_UUID_09_010: [** If no failures occur, UUID_from_string shall return zero **]** |
| 44 |
|
| 45 |
|
| 46 |
### UUID_to_string |
| 47 |
```c |
| 48 |
extern char* UUID_to_string(UUID_T* uuid); |
| 49 |
``` |
| 50 |
**SRS_UUID_09_011: [** If `uuid` is NULL, UUID_to_string shall return a non-zero value **]** |
| 51 |
|
| 52 |
**SRS_UUID_09_012: [** UUID_to_string shall allocate a valid UUID string (`uuid_string`) as per RFC 4122 **]** |
| 53 |
|
| 54 |
**SRS_UUID_09_013: [** If `uuid_string` fails to be allocated, UUID_to_string shall return NULL **]** |
| 55 |
|
| 56 |
**SRS_UUID_09_014: [** Each character in `uuid` shall be written in the respective positions of `uuid_string` as a 2-digit HEX value **]** |
| 57 |
|
| 58 |
**SRS_UUID_09_015: [** If `uuid_string` fails to be set, UUID_to_string shall return NULL **]** |
| 59 |
|
| 60 |
**SRS_UUID_09_016: [** If no failures occur, UUID_to_string shall return `uuid_string` **]** |