Greenbone Vulnerability Management Libraries  22.8.0
uuidutils.c
Go to the documentation of this file.
1 /* SPDX-FileCopyrightText: 2009-2023 Greenbone AG
2  *
3  * SPDX-License-Identifier: GPL-2.0-or-later
4  */
5 
11 #include "uuidutils.h"
12 
13 #include <glib.h>
14 #include <stdlib.h>
15 #include <uuid/uuid.h>
16 
17 #undef G_LOG_DOMAIN
18 
21 #define G_LOG_DOMAIN "libgvm util"
22 
29 char *
31 {
32  char *id;
33  uuid_t uuid;
34 
35  /* Generate an UUID. */
36  uuid_generate (uuid);
37  if (uuid_is_null (uuid) == 1)
38  {
39  g_warning ("%s: failed to generate UUID", __func__);
40  return NULL;
41  }
42 
43  /* Allocate mem for string to hold UUID. */
44  id = g_malloc0 (sizeof (char) * 37);
45  if (id == NULL)
46  {
47  g_warning ("%s: Cannot export UUID to text: out of memory", __func__);
48  return NULL;
49  }
50 
51  /* Export the UUID to text. */
52  uuid_unparse (uuid, id);
53 
54  return id;
55 }
uuidutils.h
UUID creation.
gvm_uuid_make
char * gvm_uuid_make(void)
Make a new universal identifier.
Definition: uuidutils.c:30