diff --git a/src/uuid.cpp b/src/uuid.cpp new file mode 100644 index 0000000..f389a2b --- /dev/null +++ b/src/uuid.cpp @@ -0,0 +1,31 @@ +#include "uuid.h" + +extern "C" +{ +#ifdef WIN32 +#include +#else +#include +#endif +} + +std::string newUUID() +{ +#ifdef WIN32 + UUID uuid; + UuidCreate ( &uuid ); + + unsigned char * str; + UuidToStringA ( &uuid, &str ); + + std::string s( ( char* ) str ); + + RpcStringFreeA ( &str ); +#else + uuid_t uuid; + uuid_generate_random ( uuid ); + char s[37]; + uuid_unparse ( uuid, s ); +#endif + return s; +} \ No newline at end of file diff --git a/src/uuid.h b/src/uuid.h new file mode 100644 index 0000000..952e887 --- /dev/null +++ b/src/uuid.h @@ -0,0 +1,11 @@ +#ifndef OPENALPR_UUID_H +#define OPENALPR_UUID_H + +#include +#include + + +std::string newUUID(); + + +#endif // OPENALPR_UUID_H \ No newline at end of file