AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
guid.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #include "guid.h"
9 
10 std::string CreateGuid (void)
11 {
12  #if defined (AJA_WINDOWS)
13  UUID uuid;
14  UuidCreate (&uuid);
15 
16  unsigned char * str (NULL);
17  UuidToStringA (&uuid, &str);
18 
19  std::string result (reinterpret_cast <char *> (str));
20  RpcStringFreeA (&str);
21  #elif defined (AJA_LINUX)
22  #include <stdio.h>
23  #define GUID_LENGTH 36
24 
25  std::string result ("");
26 
27  FILE *fp = fopen ("/proc/sys/kernel/random/uuid", "r");
28  if (fp)
29  {
30  char guid[GUID_LENGTH + 1];
31 
32  size_t readSize = fread (guid, 1, GUID_LENGTH, fp);
33  if (readSize == GUID_LENGTH)
34  {
35  guid [GUID_LENGTH] = '\0';
36  result = std::string((const char *) guid);
37  }
38  fclose (fp);
39  }
40  #else
41  uuid_t uuid;
42  uuid_generate_random (uuid);
43  char result [37];
44  uuid_unparse (uuid, result);
45  #endif
46  return result;
47 }
NULL
#define NULL
Definition: ntv2caption608types.h:19
guid.h
Generates a new, unique UUID as an STL string.
CreateGuid
std::string CreateGuid(void)
Definition: guid.cpp:10