Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • sip/common
1 result
Select Git revision
Loading items
Show changes

Commits on Source 1

#include "guid.h"
#include <cstdio>
#ifdef _WINDOWS
#include <objbase.h>
void XCreateGUID(XGUID *pOut)
{
GUID newId;
CoCreateGuid(&newId);
memcpy(pOut, &newId, sizeof(XGUID));
}
#define snprintf _snprintf
#elif defined(_LINUX)
#include <uuid/uuid.h>
void XCreateGUID(XGUID *pOut)
{
uuid_generate((unsigned char*)pOut);
}
#elif defined(_MAC)
#include <CoreFoundation/CFUUID.h>
void XCreateGUID(XGUID *pOut)
{
auto newId = CFUUIDCreate(NULL);
auto bytes = CFUUIDGetUUIDBytes(newId);
CFRelease(newId);
memcpy(pOut, &bytes, sizeof(XGUID));
}
#else
#error Unknown platform!
#endif
void XGUIDToSting(const XGUID &guid, char *dst, int nBufSize)
{
// {34D5ED67-D3D1-4ACE-9CE7-AAB5C4F9E2FD}
snprintf(dst, nBufSize, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", guid.Data1, guid.Data2, guid.Data3,
guid.Data40, guid.Data41, guid.Data42, guid.Data43, guid.Data44, guid.Data45, guid.Data46, guid.Data47);
}
bool XGUIDFromString(XGUID *pGUID, const char *szGUID)
{
return(11 == sscanf(szGUID, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", &pGUID->Data1, &pGUID->Data2, &pGUID->Data3,
&pGUID->Data40, &pGUID->Data41, &pGUID->Data42, &pGUID->Data43, &pGUID->Data44, &pGUID->Data45, &pGUID->Data46, &pGUID->Data47));
}
#ifndef __COMMON_GUID_H
#define __COMMON_GUID_H
#include <memory.h>
typedef struct _XGUID
{
_XGUID()
{
}
_XGUID(unsigned long l, unsigned short w1, unsigned short w2,
unsigned char b1, unsigned char b2, unsigned char b3, unsigned char b4,
unsigned char b5, unsigned char b6, unsigned char b7, unsigned char b8):
Data1(l), Data2(w1), Data3(w2), Data40(b1), Data41(b2), Data42(b3), Data43(b4), Data44(b5),
Data45(b6), Data46(b7), Data47(b8)
{
}
unsigned long Data1 = 0;
unsigned short Data2 = 0;
unsigned short Data3 = 0;
unsigned char Data40 = 0;
unsigned char Data41 = 0;
unsigned char Data42 = 0;
unsigned char Data43 = 0;
unsigned char Data44 = 0;
unsigned char Data45 = 0;
unsigned char Data46 = 0;
unsigned char Data47 = 0;
} XGUID;
#define DEFINE_XGUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
XGUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
inline bool operator<(const XGUID &a, const XGUID &b)
{
return(memcmp(&a, &b, sizeof(XGUID)) < 0);
}
inline bool operator==(const XGUID &a, const XGUID &b)
{
return(memcmp(&a, &b, sizeof(XGUID)) == 0);
}
void XCreateGUID(XGUID *pOut);
void XGUIDToSting(const XGUID &guid, char *dst, int nBufSize);
bool XGUIDFromString(XGUID *pGUID, const char *szGUID);
#endif
......@@ -19,6 +19,7 @@ See the license in LICENSE
#include <mutex>
#include <atomic>
#include "spinlock.h"
#include "guid.h"
#include "enum_flags.h"
......@@ -149,45 +150,6 @@ inline const char* strcasestr(const char *haystack, const char *needle)
# error "unsupported compiler"
#endif
typedef struct _XGUID
{
_XGUID()
{
}
_XGUID(unsigned long l, unsigned short w1, unsigned short w2,
unsigned char b1, unsigned char b2, unsigned char b3, unsigned char b4,
unsigned char b5, unsigned char b6, unsigned char b7, unsigned char b8):
Data1(l), Data2(w1), Data3(w2), Data40(b1), Data41(b2), Data43(b3), Data44(b4),
Data45(b5), Data46(b6), Data47(b7)
{
}
unsigned long Data1 = 0;
unsigned short Data2 = 0;
unsigned short Data3 = 0;
unsigned char Data40 = 0;
unsigned char Data41 = 0;
unsigned char Data42 = 0;
unsigned char Data43 = 0;
unsigned char Data44 = 0;
unsigned char Data45 = 0;
unsigned char Data46 = 0;
unsigned char Data47 = 0;
} XGUID;
#define DEFINE_XGUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
XGUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
inline bool operator<(const XGUID &a, const XGUID &b)
{
return(memcmp(&a, &b, sizeof(XGUID)) < 0);
}
inline bool operator==(const XGUID &a, const XGUID &b)
{
return(memcmp(&a, &b, sizeof(XGUID)) == 0);
}
class IXUnknown
{
public:
......