• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files
6  * (the "Software"), to deal in the Software without restriction,
7  * including without limitation the rights to use, copy, modify, merge,
8  * publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #pragma once
25 
26 #include <uapi/trusty_uuid.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /* Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx */
33 #define UUID_STR_SIZE (37)
34 
35 /**
36  * uuid_to_str() - Converts from a uuid to its string representation
37  * @uuid: The uuid to convert
38  * @str: Buffer to put the string representation in. This buffer must be at
39  *       least UUID_STRT_SIZE bytes long
40  */
41 void uuid_to_str(const struct uuid* uuid, char* str);
42 
43 /**
44  * str_to_uuid() - Converts a string into a uuid
45  * @uuid_str: String representation of the uuid
46  * @uuid: &strcut uuid to fill with the converted uuid
47  *
48  * Return: 0 on success or -1 if str did not contain a valid uuid.
49  *
50  */
51 __attribute__((warn_unused_result)) int str_to_uuid(const char* str,
52                                                     struct uuid* uuid);
53 
54 #ifdef __cplusplus
55 }
56 #endif
57