2 * uuid.c: Utilities for Virtualized Super Computer Management
4 * Copyright (C) 2009 Matthias Bolte <matthias.bolte@googlemail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 * Appends a duplicate of the given UUID to the list.
32 * Always returns a pointer to the first UUID item in the list, so that this
33 * function can be used for initialization and for appending.
35 VscMgmtUuid * /* uuid_list */
36 vsc_mgmt_uuid_list_append (VscMgmtError *error, VscMgmtUuid *uuid_list,
37 const VscMgmtUuid *uuid)
39 VscMgmtUuid *uuid_duplicate = NULL;
41 VSC_MGMT__ASSERT (error != NULL);
42 VSC_MGMT__ASSERT (! error->occured);
44 uuid_duplicate = vsc_mgmt_memdup (error, uuid, sizeof (VscMgmtUuid));
47 VSC_MGMT__APPEND_ERROR0 (error, VSC_MGMT__CODE__TRACE);
51 uuid_duplicate->next = NULL;
53 return (VscMgmtUuid *) vsc_mgmt_list_append ((VscMgmtList *) uuid_list,
54 (VscMgmtList *) uuid_duplicate);
58 * Recursively frees the given UUID list.
61 vsc_mgmt_uuid_list_free (VscMgmtUuid *uuid_list)
63 vsc_mgmt_list_free ((VscMgmtList *) uuid_list);
67 * Parses a UUID from string representation.
70 vsc_mgmt_uuid_parse (VscMgmtError *error, const char *uuid_string,
73 VSC_MGMT__ASSERT (error != NULL);
74 VSC_MGMT__ASSERT (! error->occured);
76 if (uuid_parse (uuid_string, uuid->bytes) < 0) {
77 VSC_MGMT__ERROR2 (error, VSC_MGMT__CODE__INVALID_UUID_STRING,
83 * Formats a UUID to string representation.
86 vsc_mgmt_uuid_format (const VscMgmtUuid *uuid, char *uuid_string)
88 uuid_unparse_lower (uuid->bytes, uuid_string);