aboutsummaryrefslogtreecommitdiff
path: root/src/unstable
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/unstable/uuid.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/unstable/uuid.cpp b/src/unstable/uuid.cpp
index fb237d8..4ac90a5 100644
--- a/src/unstable/uuid.cpp
+++ b/src/unstable/uuid.cpp
@@ -11,6 +11,11 @@
11#include "bu/membuf.h" 11#include "bu/membuf.h"
12#include <string.h> 12#include <string.h>
13 13
14#ifdef WIN32
15#include <rpc.h>
16#include <Rpcdce.h>
17#endif
18
14Bu::Uuid::Uuid() 19Bu::Uuid::Uuid()
15{ 20{
16 clear(); 21 clear();
@@ -77,12 +82,31 @@ void Bu::Uuid::clear()
77 82
78Bu::Uuid Bu::Uuid::gen() 83Bu::Uuid Bu::Uuid::gen()
79{ 84{
85#ifdef linux
80 Bu::File fIn( "/proc/sys/kernel/random/uuid", Bu::File::Read ); 86 Bu::File fIn( "/proc/sys/kernel/random/uuid", Bu::File::Read );
81 char dat[36]; 87 char dat[36];
82 fIn.read( dat, 36 ); 88 fIn.read( dat, 36 );
83 Uuid id; 89 Uuid id;
84 id.set( dat ); 90 id.set( dat );
85 return id; 91 return id;
92#elif WIN32
93 UUID uuid;
94 UuidCreate( &uuid );
95 Uuid id;
96 id.data[0] = ((unsigned char *)&uuid.Data1)[3];
97 id.data[1] = ((unsigned char *)&uuid.Data1)[2];
98 id.data[2] = ((unsigned char *)&uuid.Data1)[1];
99 id.data[3] = ((unsigned char *)&uuid.Data1)[0];
100 id.data[4] = ((unsigned char *)&uuid.Data2)[1];
101 id.data[5] = ((unsigned char *)&uuid.Data2)[0];
102 id.data[6] = ((unsigned char *)&uuid.Data3)[1];
103 id.data[7] = ((unsigned char *)&uuid.Data3)[0];
104 memcpy( id.data+8, uuid.Data4, 8 );
105
106 return id;
107#else
108# error We should be using one of the other fallbacks, but your platform is not supported yet. Sorry.
109#endif
86} 110}
87 111
88void Bu::Uuid::set( const Bu::String &sSrc ) 112void Bu::Uuid::set( const Bu::String &sSrc )