diff --git a/src/pEpEngine.c b/src/pEpEngine.c index 6931be7f..9ee5b89a 100644 --- a/src/pEpEngine.c +++ b/src/pEpEngine.c @@ -158,6 +158,7 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session) int_result = sqlite3_exec( _session->db, + "PRAGMA application_id = 0x23423423;\n" "create table if not exists log (\n" " timestamp integer default (datetime('now')) ,\n" " title text not null,\n" @@ -260,6 +261,7 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session) if (version < 2) { int_result = sqlite3_exec( _session->db, + "PRAGMA application_id = 0x23423423;\n" "alter table pgp_keypair\n" " add column flags integer default (0);", NULL, diff --git a/src/platform_unix.h b/src/platform_unix.h index 4b1262f4..a41d439e 100644 --- a/src/platform_unix.h +++ b/src/platform_unix.h @@ -5,6 +5,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -45,6 +46,15 @@ size_t strlcpy(char* dst, const char* src, size_t size); size_t strlcat(char* dst, const char* src, size_t size); #endif +#ifndef _UUID_STRING_T +#define _UUID_STRING_T +typedef char uuid_string_t[37]; +#endif +#ifdef UUID +// on *nix, uuid_t is an array and already implements pointer semantics +#define UUID uuid_t +#endif + #ifdef __cplusplus } #endif diff --git a/src/platform_windows.cpp b/src/platform_windows.cpp index bb7009c2..59b2904d 100644 --- a/src/platform_windows.cpp +++ b/src/platform_windows.cpp @@ -267,4 +267,36 @@ int mkstemp(char *templ) return _open(pathname, _O_RDWR | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE); } +void uuid_generate_random(uuid_t out) +{ + RPC_STATUS rpc_status = UuidCreate(out); + assert(rpc_status == RPC_S_OK); +} + +int uuid_parse(char *in, uuid_t uu) +{ + unsigned char *_in = (unsigned char *) in; + RPC_STATUS rpc_status = UuidFromString(_in, &uu); + assert(rpc_status == RPC_S_OK); + if (rpc_status == RPC_S_INVALID_STRING_UUID) + return -1; + return 0; +} + +void uuid_unparse_upper(uuid_t uu, uuid_string_t out) +{ + unsigned char *_out = out; + RPC_CSTR str; + RPC_STATUS rpc_status = UuidToString(uu, &str); + assert(rpc_status == RPC_S_OK); + if (rpc_status == RPC_S_OK) { + memcpy(out, str, 36); + out[36] = 0; + RpcStringFree(str); + } + else { // if (rpc_status == RPC_S_OUT_OF_MEMORY) + memset(out, 0, 37); + } +} + } // "C" diff --git a/src/platform_windows.h b/src/platform_windows.h index 731b7361..8fb3b9e3 100644 --- a/src/platform_windows.h +++ b/src/platform_windows.h @@ -4,6 +4,7 @@ #pragma warning(disable : 4996) +#include #include #include #include @@ -58,6 +59,15 @@ const char *gpg_conf(void); long random(void); +// on Windoze, uuid_t needs pointer semantics +typedef UUID *uuid_t; +#define _UUID_STRING_T +typedef char uuid_string_t[37]; + +void uuid_generate_random(uuid_t out); +int uuid_parse(char *in, uuid_t uu); +void uuid_unparse_upper(uuid_t uu, uuid_string_t out); + #ifndef inline #define inline __inline #endif