OpenVAS Libraries  9.0.3
openvas_uuid.c File Reference
#include "openvas_uuid.h"
#include <glib.h>
#include <stdlib.h>
#include <uuid/uuid.h>
Include dependency graph for openvas_uuid.c:

Go to the source code of this file.

Functions

char * openvas_uuid_make (void)
 Make a new universal identifier. More...
 

Function Documentation

◆ openvas_uuid_make()

char* openvas_uuid_make ( void  )

Make a new universal identifier.

Returns
A newly allocated string holding the identifier, which the caller must free, or NULL on failure.

Definition at line 43 of file openvas_uuid.c.

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 }