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