comparison Core/Toolbox.cpp @ 2172:84d1d392a9ab

GenerateUuid() not available in sandboxed environments
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Nov 2016 12:06:00 +0100
parents fd5875662670
children 1c42860097fc
comparison
equal deleted inserted replaced
2171:35febe19e874 2172:84d1d392a9ab
76 } 76 }
77 #endif 77 #endif
78 78
79 79
80 80
81 // Inclusions for UUID
82 // http://stackoverflow.com/a/1626302
83
84 extern "C"
85 {
86 #ifdef WIN32
87 # include <rpc.h>
88 #else
89 # include <uuid/uuid.h>
90 #endif
91 }
92
93
94 #if ORTHANC_ENABLE_PUGIXML == 1 81 #if ORTHANC_ENABLE_PUGIXML == 1
95 # include "ChunkedBuffer.h" 82 # include "ChunkedBuffer.h"
96 # include <pugixml.hpp> 83 # include <pugixml.hpp>
97 #endif 84 #endif
98 85
1224 return static_cast<unsigned int>(v); 1211 return static_cast<unsigned int>(v);
1225 } 1212 }
1226 } 1213 }
1227 1214
1228 1215
1229 std::string Toolbox::GenerateUuid()
1230 {
1231 #ifdef WIN32
1232 UUID uuid;
1233 UuidCreate ( &uuid );
1234
1235 unsigned char * str;
1236 UuidToStringA ( &uuid, &str );
1237
1238 std::string s( ( char* ) str );
1239
1240 RpcStringFreeA ( &str );
1241 #else
1242 uuid_t uuid;
1243 uuid_generate_random ( uuid );
1244 char s[37];
1245 uuid_unparse ( uuid, s );
1246 #endif
1247 return s;
1248 }
1249
1250
1251 bool Toolbox::IsUuid(const std::string& str) 1216 bool Toolbox::IsUuid(const std::string& str)
1252 { 1217 {
1253 if (str.size() != 36) 1218 if (str.size() != 36)
1254 { 1219 {
1255 return false; 1220 return false;