OpenVAS Libraries  9.0.3
openvas_uuid.c
Go to the documentation of this file.
1 /* OpenVAS Libraries
2  * $Id$
3  * Description: UUID creation.
4  *
5  * Authors:
6  * Matthew Mundell <matt@mundell.ukfsn.org>
7  * Michael Wiegand <michael.wiegand@greenbone.net>
8  * Felix Wolfsteller <felix.wolfsteller@greenbone.net>
9  *
10  * Copyright:
11  * Copyright (C) 2009,2010 Greenbone Networks GmbH
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
26  * USA.
27  */
28 
29 #include "openvas_uuid.h"
30 
31 #include <glib.h>
32 #include <stdlib.h>
33 #include <uuid/uuid.h>
34 
35 
42 char *
44 {
45  char *id;
46  uuid_t uuid;
47 
48  /* Generate an UUID. */
49  uuid_generate (uuid);
50  if (uuid_is_null (uuid) == 1)
51  {
52  g_warning ("%s: failed to generate UUID", __FUNCTION__);
53  return NULL;
54  }
55 
56  /* Allocate mem for string to hold UUID. */
57  id = g_malloc0 (sizeof (char) * 37);
58  if (id == NULL)
59  {
60  g_warning ("%s: Cannot export UUID to text: out of memory", __FUNCTION__);
61  return NULL;
62  }
63 
64  /* Export the UUID to text. */
65  uuid_unparse (uuid, id);
66 
67  return id;
68 }
char * openvas_uuid_make(void)
Make a new universal identifier.
Definition: openvas_uuid.c:43