UUID functions renamed to avoid conflict with Mac OS X system functions
authorVictor Kirhenshtein <victor@netxms.org>
Mon, 13 Jul 2015 08:30:16 +0000 (11:30 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Mon, 13 Jul 2015 08:30:47 +0000 (11:30 +0300)
16 files changed:
include/nxconfig.h
include/uuid.h
src/agent/core/policy.cpp
src/libnetxms/config.cpp
src/libnetxms/uuid.cpp
src/server/core/dcst.cpp
src/server/core/events.cpp
src/server/core/objtools.cpp
src/server/core/session.cpp
src/server/tools/nxap/nxap.cpp
src/server/tools/nxconfig/WizardWorker.cpp
src/server/tools/nxdbmgr/check.cpp
src/server/tools/nxdbmgr/init.cpp
src/server/tools/nxdbmgr/mm.cpp
src/server/tools/nxdbmgr/upgrade.cpp
src/tools/nxgenguid/nxgenguid.cpp

index e5f8402..d5ea4b4 100644 (file)
@@ -66,7 +66,7 @@ public:
        INT64 getValueAsInt64(int index = 0, INT64 defaultValue = 0);
        UINT64 getValueAsUInt64(int index = 0, UINT64 defaultValue = 0);
        bool getValueAsBoolean(int index = 0, bool defaultValue = false);
-       bool getValueAsUUID(int index, uuid_t uuid);
+       uuid getValueAsUUID(int index);
 
        void addValue(const TCHAR *value);
        void addValuePreallocated(TCHAR *value);
@@ -151,7 +151,7 @@ public:
        INT64 getValueAsInt64(const TCHAR *path, INT64 defaultValue);
        UINT64 getValueAsUInt64(const TCHAR *path, UINT64 defaultValue);
        bool getValueAsBoolean(const TCHAR *path, bool defaultValue);
-       bool getValueAsUUID(const TCHAR *path, uuid_t uuid);
+       uuid getValueAsUUID(const TCHAR *path);
        ObjectArray<ConfigEntry> *getSubEntries(const TCHAR *path, const TCHAR *mask);
        ObjectArray<ConfigEntry> *getOrderedSubEntries(const TCHAR *path, const TCHAR *mask);
 
@@ -161,7 +161,7 @@ public:
        bool setValue(const TCHAR *path, INT64 value);
        bool setValue(const TCHAR *path, UINT64 value);
        bool setValue(const TCHAR *path, double value);
-       bool setValue(const TCHAR *path, uuid_t value);
+       bool setValue(const TCHAR *path, const uuid& value);
 
        bool parseTemplate(const TCHAR *section, NX_CFG_TEMPLATE *cfgTemplate);
 
index 73f8168..10b78e0 100644 (file)
@@ -25,12 +25,12 @@ typedef unsigned char uuid_t[UUID_LENGTH];
 #define UUID_VARIANT_MICROSOFT   2
 #define UUID_VARIANT_OTHER       3
 
-void LIBNETXMS_EXPORTABLE uuid_clear(uuid_t uu);
-int LIBNETXMS_EXPORTABLE uuid_compare(const uuid_t uu1, const uuid_t uu2);
-void LIBNETXMS_EXPORTABLE uuid_generate(uuid_t out);
-bool LIBNETXMS_EXPORTABLE uuid_is_null(const uuid_t uu);
-int LIBNETXMS_EXPORTABLE uuid_parse(const TCHAR *in, uuid_t uu);
-TCHAR LIBNETXMS_EXPORTABLE *uuid_to_string(const uuid_t uu, TCHAR *out);
+void LIBNETXMS_EXPORTABLE _uuid_clear(uuid_t uu);
+int LIBNETXMS_EXPORTABLE _uuid_compare(const uuid_t uu1, const uuid_t uu2);
+void LIBNETXMS_EXPORTABLE _uuid_generate(uuid_t out);
+bool LIBNETXMS_EXPORTABLE _uuid_is_null(const uuid_t uu);
+int LIBNETXMS_EXPORTABLE _uuid_parse(const TCHAR *in, uuid_t uu);
+TCHAR LIBNETXMS_EXPORTABLE *_uuid_to_string(const uuid_t uu, TCHAR *out);
 
 #ifdef __cplusplus
 
@@ -44,15 +44,15 @@ private:
    uuid_t m_value;
 
 public:
-   uuid() { uuid_clear(m_value); }
+   uuid() { _uuid_clear(m_value); }
    uuid(const uuid_t v) { memcpy(m_value, v, UUID_LENGTH); }
 
-   int compare(const uuid& u) const { return uuid_compare(m_value, u.m_value); }
-   bool equals(const uuid& u) const { return uuid_compare(m_value, u.m_value) == 0; }
+   int compare(const uuid& u) const { return _uuid_compare(m_value, u.m_value); }
+   bool equals(const uuid& u) const { return _uuid_compare(m_value, u.m_value) == 0; }
    const uuid_t& getValue() const { return m_value; }
-   bool isNull() const { return uuid_is_null(m_value); }
-   TCHAR *toString(TCHAR *buffer) const { return uuid_to_string(m_value, buffer); }
-   String toString() const { TCHAR buffer[64]; return String(uuid_to_string(m_value, buffer)); }
+   bool isNull() const { return _uuid_is_null(m_value); }
+   TCHAR *toString(TCHAR *buffer) const { return _uuid_to_string(m_value, buffer); }
+   String toString() const { TCHAR buffer[64]; return String(_uuid_to_string(m_value, buffer)); }
 
    /**
     * Generate new UUID
@@ -60,7 +60,7 @@ public:
    static uuid generate() 
    { 
       uuid_t u;
-      uuid_generate(u);
+      _uuid_generate(u);
       return uuid(u);
    }
 
@@ -70,7 +70,7 @@ public:
    static uuid parse(const TCHAR *s)
    {
       uuid_t u;
-      if (uuid_parse(s, u) != 0)
+      if (_uuid_parse(s, u) != 0)
          return NULL_UUID;
       return uuid(u);
    }
index 772bdad..4c29240 100644 (file)
 /**
  * Register policy in persistent storage
  */
-static void RegisterPolicy(CommSession *session, UINT32 type, uuid_t guid)
+static void RegisterPolicy(CommSession *session, UINT32 type, const uuid& guid)
 {
        TCHAR path[256], buffer[64];
        int tail;
 
-       _sntprintf(path, 256, POLICY_REGISTRY_PATH _T("/policy-%s/"), uuid_to_string(guid, buffer));
+   _sntprintf(path, 256, POLICY_REGISTRY_PATH _T("/policy-%s/"), guid.toString(buffer));
        tail = (int)_tcslen(path);
 
        Config *registry = AgentOpenRegistry();
@@ -54,11 +54,11 @@ static void RegisterPolicy(CommSession *session, UINT32 type, uuid_t guid)
 /**
  * Register policy in persistent storage
  */
-static void UnregisterPolicy(uuid_t guid)
+static void UnregisterPolicy(const uuid& guid)
 {
        TCHAR path[256], buffer[64];
 
-       _sntprintf(path, 256, POLICY_REGISTRY_PATH _T("/policy-%s"), uuid_to_string(guid, buffer));
+   _sntprintf(path, 256, POLICY_REGISTRY_PATH _T("/policy-%s"), guid.toString(buffer));
        Config *registry = AgentOpenRegistry();
        registry->deleteEntry(path);
        AgentCloseRegistry(true);
@@ -67,12 +67,12 @@ static void UnregisterPolicy(uuid_t guid)
 /**
  * Get policy type by GUID
  */
-static int GetPolicyType(uuid_t guid)
+static int GetPolicyType(const uuid& guid)
 {
        TCHAR path[256], buffer[64];
        int type;
 
-       _sntprintf(path, 256, POLICY_REGISTRY_PATH _T("/policy-%s/type"), uuid_to_string(guid, buffer));
+   _sntprintf(path, 256, POLICY_REGISTRY_PATH _T("/policy-%s/type"), guid.toString(buffer));
        Config *registry = AgentOpenRegistry();
        type = registry->getValueAsInt(path, -1);
        AgentCloseRegistry(false);
@@ -82,7 +82,7 @@ static int GetPolicyType(uuid_t guid)
 /**
  * Deploy configuration file
  */
-static UINT32 DeployConfig(UINT32 session, uuid_t guid, NXCPMessage *msg)
+static UINT32 DeployConfig(UINT32 session, const uuid& guid, NXCPMessage *msg)
 {
        TCHAR path[MAX_PATH], name[64], tail;
        int fh;
@@ -91,7 +91,7 @@ static UINT32 DeployConfig(UINT32 session, uuid_t guid, NXCPMessage *msg)
        tail = g_szConfigIncludeDir[_tcslen(g_szConfigIncludeDir) - 1];
        _sntprintf(path, MAX_PATH, _T("%s%s%s.conf"), g_szConfigIncludeDir,
                   ((tail != '\\') && (tail != '/')) ? FS_PATH_SEPARATOR : _T(""),
-                                 uuid_to_string(guid, name));
+              guid.toString(name));
 
        fh = _topen(path, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, S_IRUSR | S_IWUSR);
        if (fh != -1)
@@ -130,7 +130,7 @@ static UINT32 DeployConfig(UINT32 session, uuid_t guid, NXCPMessage *msg)
 /**
  * Deploy log parser policy
  */
-static UINT32 DeployLogParser(UINT32 session, uuid_t guid, NXCPMessage *msg)
+static UINT32 DeployLogParser(UINT32 session, const uuid& guid, NXCPMessage *msg)
 {
        return ERR_NOT_IMPLEMENTED;
 }
@@ -141,10 +141,9 @@ static UINT32 DeployLogParser(UINT32 session, uuid_t guid, NXCPMessage *msg)
 UINT32 DeployPolicy(CommSession *session, NXCPMessage *request)
 {
        UINT32 type, rcc;
-       uuid_t guid;
 
        type = request->getFieldAsUInt16(VID_POLICY_TYPE);
-       request->getFieldAsBinary(VID_GUID, guid, UUID_LENGTH);
+       uuid guid = request->getFieldAsGUID(VID_GUID);
 
        switch(type)
        {
@@ -169,7 +168,7 @@ UINT32 DeployPolicy(CommSession *session, NXCPMessage *request)
 /**
  * Remove configuration file
  */
-static UINT32 RemoveConfig(UINT32 session, uuid_t guid,  NXCPMessage *msg)
+static UINT32 RemoveConfig(UINT32 session, const uuid& guid, NXCPMessage *msg)
 {
        TCHAR path[MAX_PATH], name[64], tail;
        UINT32 rcc;
@@ -177,7 +176,7 @@ static UINT32 RemoveConfig(UINT32 session, uuid_t guid,  NXCPMessage *msg)
        tail = g_szConfigIncludeDir[_tcslen(g_szConfigIncludeDir) - 1];
        _sntprintf(path, MAX_PATH, _T("%s%s%s.conf"), g_szConfigIncludeDir,
                   ((tail != '\\') && (tail != '/')) ? FS_PATH_SEPARATOR : _T(""),
-                                 uuid_to_string(guid, name));
+              guid.toString(name));
 
        if (_tremove(path) != 0)
        {
@@ -193,7 +192,7 @@ static UINT32 RemoveConfig(UINT32 session, uuid_t guid,  NXCPMessage *msg)
 /**
  * Remove log parser file
  */
-static UINT32 RemoveLogParser(UINT32 session, uuid_t guid,  NXCPMessage *msg)
+static UINT32 RemoveLogParser(UINT32 session, const uuid& guid,  NXCPMessage *msg)
 {
        TCHAR path[MAX_PATH], name[64], tail;
        UINT32 rcc;
@@ -201,7 +200,7 @@ static UINT32 RemoveLogParser(UINT32 session, uuid_t guid,  NXCPMessage *msg)
        tail = g_szConfigIncludeDir[_tcslen(g_szConfigIncludeDir) - 1];
        _sntprintf(path, MAX_PATH, _T("%s%s%s.conf"), g_szConfigIncludeDir,
                   ((tail != '\\') && (tail != '/')) ? FS_PATH_SEPARATOR : _T(""),
-                                 uuid_to_string(guid, name));
+              guid.toString(name));
 
        if (_tremove(path) != 0)
        {
@@ -221,10 +220,9 @@ UINT32 UninstallPolicy(CommSession *session, NXCPMessage *request)
 {
        UINT32 rcc;
        int type;
-       uuid_t guid;
        TCHAR buffer[64];
 
-       request->getFieldAsBinary(VID_GUID, guid, UUID_LENGTH);
+       uuid guid = request->getFieldAsGUID(VID_GUID);
        type = GetPolicyType(guid);
 
        switch(type)
@@ -243,7 +241,7 @@ UINT32 UninstallPolicy(CommSession *session, NXCPMessage *request)
        if (rcc == RCC_SUCCESS)
                UnregisterPolicy(guid);
 
-       DebugPrintf(session->getIndex(), 3, _T("Policy uninstall: GUID=%s TYPE=%d RCC=%d"), uuid_to_string(guid, buffer), type, rcc);
+   DebugPrintf(session->getIndex(), 3, _T("Policy uninstall: GUID=%s TYPE=%d RCC=%d"), guid.toString(buffer), type, rcc);
        return rcc;
 }
 
@@ -266,7 +264,7 @@ UINT32 GetPolicyInventory(CommSession *session, NXCPMessage *msg)
 
                        if (MatchString(_T("policy-*"), e->getName(), TRUE))
                        {
-                               uuid_parse(&(e->getName()[7]), guid);
+                               _uuid_parse(&(e->getName()[7]), guid);
                                msg->setField(varId++, guid, UUID_LENGTH);
                                msg->setField(varId++, (WORD)e->getSubEntryValueAsInt(_T("type")));
                                msg->setField(varId++, e->getSubEntryValue(_T("server")));
index d6a6425..302eca1 100644 (file)
@@ -341,14 +341,14 @@ bool ConfigEntry::getValueAsBoolean(int index, bool defaultValue)
 /**
  * Get entry value as GUID
  */
-bool ConfigEntry::getValueAsUUID(int index, uuid_t uuid)
+uuid ConfigEntry::getValueAsUUID(int index)
 {
    const TCHAR *value = getValue(index);
    if (value != NULL)
    {
-      return uuid_parse(value, uuid) == 0;
+      return uuid::parse(value);
    }
-   return false;
+   return uuid::NULL_UUID;
 }
 
 /**
@@ -876,16 +876,16 @@ bool Config::getValueAsBoolean(const TCHAR *path, bool defaultValue)
 /**
  * Get value at given path as UUID
  */
-bool Config::getValueAsUUID(const TCHAR *path, uuid_t uuid)
+uuid Config::getValueAsUUID(const TCHAR *path)
 {
    const TCHAR *value = getValue(path);
    if (value != NULL)
    {
-      return uuid_parse(value, uuid) == 0;
+      return uuid::parse(value);
    }
    else
    {
-      return false;
+      return uuid::NULL_UUID;
    }
 }
 
@@ -1074,10 +1074,10 @@ bool Config::setValue(const TCHAR *path, double value)
  * Set value
  * Returns false on error (usually caused by incorrect path)
  */
-bool Config::setValue(const TCHAR *path, uuid_t value)
+bool Config::setValue(const TCHAR *path, const uuid& value)
 {
    TCHAR buffer[64];
-   uuid_to_string(value, buffer);
+   value.toString(buffer);
    return setValue(path, buffer);
 }
 
index 9e5ec8a..c90da16 100644 (file)
@@ -143,7 +143,7 @@ static void uuid_unpack(const uuid_t in, struct __uuid *uu)
 /**
  * Clear a UUID
  */
-void LIBNETXMS_EXPORTABLE uuid_clear(uuid_t uu)
+void LIBNETXMS_EXPORTABLE _uuid_clear(uuid_t uu)
 {
        memset(uu, 0, 16);
 }
@@ -155,7 +155,7 @@ void LIBNETXMS_EXPORTABLE uuid_clear(uuid_t uu)
  *
  * Returns 1/-1 if the two UUID's are different, and 0 if they are the same.
  */
-int LIBNETXMS_EXPORTABLE uuid_compare(const uuid_t uu1, const uuid_t uu2)
+int LIBNETXMS_EXPORTABLE _uuid_compare(const uuid_t uu1, const uuid_t uu2)
 {
        struct __uuid   uuid1, uuid2;
 
@@ -173,7 +173,7 @@ int LIBNETXMS_EXPORTABLE uuid_compare(const uuid_t uu1, const uuid_t uu2)
  * isnull.c --- Check whether or not the UUID is null
  * Returns true if the uuid is the NULL uuid
  */
-bool LIBNETXMS_EXPORTABLE uuid_is_null(const uuid_t uu)
+bool LIBNETXMS_EXPORTABLE _uuid_is_null(const uuid_t uu)
 {
        const unsigned char *cp;
        int i;
@@ -187,7 +187,7 @@ bool LIBNETXMS_EXPORTABLE uuid_is_null(const uuid_t uu)
 /**
  * Parse UUID
  */
-int LIBNETXMS_EXPORTABLE uuid_parse(const TCHAR *in, uuid_t uu)
+int LIBNETXMS_EXPORTABLE _uuid_parse(const TCHAR *in, uuid_t uu)
 {
        struct __uuid uuid;
        int i;
@@ -227,7 +227,7 @@ int LIBNETXMS_EXPORTABLE uuid_parse(const TCHAR *in, uuid_t uu)
 /**
  * Convert packed UUID to string
  */
-TCHAR LIBNETXMS_EXPORTABLE *uuid_to_string(const uuid_t uu, TCHAR *out)
+TCHAR LIBNETXMS_EXPORTABLE *_uuid_to_string(const uuid_t uu, TCHAR *out)
 {
        struct __uuid uuid;
 
@@ -510,7 +510,7 @@ static void uuid_generate_random(uuid_t out)
  * /dev/urandom is available, since otherwise we won't have
  * high-quality randomness.
  */
-void LIBNETXMS_EXPORTABLE uuid_generate(uuid_t out)
+void LIBNETXMS_EXPORTABLE _uuid_generate(uuid_t out)
 {
 #ifdef _WIN32
        UUID uuid;
index 2961ed6..554f957 100644 (file)
@@ -61,11 +61,7 @@ UINT32 ModifySummaryTable(NXCPMessage *msg, LONG *newId)
 
       if (isNew)
       {
-         uuid_t guid;
-         TCHAR guidText[64];
-         uuid_generate(guid);
-         uuid_to_string(guid, guidText);
-         DBBind(hStmt, 7, DB_SQLTYPE_VARCHAR, guidText, DB_BIND_TRANSIENT);
+         DBBind(hStmt, 7, DB_SQLTYPE_VARCHAR, uuid::generate());
       }
 
       rcc = DBExecute(hStmt) ? RCC_SUCCESS : RCC_DB_FAILURE;
@@ -493,7 +489,7 @@ bool ImportSummaryTable(ConfigEntry *config)
    }
 
    uuid_t temp;
-   if (uuid_parse(guid, temp) == -1)
+   if (_uuid_parse(guid, temp) == -1)
    {
       DbgPrintf(4, _T("ImportSummaryTable: GUID (%s) is invalid"), guid);
       return false;
index 7aaa326..f5665c9 100644 (file)
@@ -234,7 +234,6 @@ TCHAR *Event::expandText(Event *event, UINT32 sourceObject, const TCHAR *textTem
    struct tm *lt;
    TCHAR *pText, szBuffer[4], scriptName[256];
        int i;
-       uuid_t guid;
 
        DbgPrintf(8, _T("Event::expandText(event=%p sourceObject=%d template='%s' alarmMsg='%s' alarmKey='%s')"),
                  event, (int)sourceObject, CHECK_NULL(textTemplate), CHECK_NULL(alarmMsg), CHECK_NULL(alarmKey));
index fbf84b6..050d39e 100644 (file)
@@ -709,10 +709,7 @@ UINT32 UpdateObjectToolFromMessage(NXCPMessage *pMsg)
    DBBind(hStmt, 11, DB_SQLTYPE_INTEGER, dwToolId);
    if (newTool)
    {
-      uuid_t guid;
-      uuid_generate(guid);
-      TCHAR guidText[64];
-      DBBind(hStmt, 12, DB_SQLTYPE_VARCHAR, uuid_to_string(guid, guidText), DB_BIND_TRANSIENT);
+      DBBind(hStmt, 12, DB_SQLTYPE_VARCHAR, uuid::generate());
    }
 
    if (!DBExecute(hStmt))
@@ -820,7 +817,7 @@ bool ImportObjectTool(ConfigEntry *config)
    }
 
    uuid_t temp;
-   if (uuid_parse(guid, temp) == -1)
+   if (_uuid_parse(guid, temp) == -1)
    {
       DbgPrintf(4, _T("ImportObjectTool: GUID (%s) is invalid"), guid);
       return false;
index 5498c95..97e8a67 100644 (file)
@@ -12003,7 +12003,7 @@ void ClientSession::sendLibraryImage(NXCPMessage *request)
 
        uuid_t guid;
        request->getFieldAsBinary(VID_GUID, guid, UUID_LENGTH);
-       uuid_to_string(guid, guidText);
+       _uuid_to_string(guid, guidText);
        debugPrintf(5, _T("sendLibraryImage: guid=%s"), guidText);
 
        if (rcc == RCC_SUCCESS)
@@ -12101,7 +12101,7 @@ void ClientSession::updateLibraryImage(NXCPMessage *request)
    }
 
        uuid_t guid;
-       uuid_clear(guid);
+       _uuid_clear(guid);
 
        msg.setId(request->getId());
        msg.setCode(CMD_REQUEST_COMPLETED);
@@ -12116,13 +12116,13 @@ void ClientSession::updateLibraryImage(NXCPMessage *request)
                request->getFieldAsBinary(VID_GUID, guid, UUID_LENGTH);
        }
 
-       if (uuid_is_null(guid))
+       if (_uuid_is_null(guid))
        {
-               uuid_generate(guid);
+               _uuid_generate(guid);
        }
 
        TCHAR guidText[64];
-       uuid_to_string(guid, guidText);
+       _uuid_to_string(guid, guidText);
 
        request->getFieldAsString(VID_NAME, name, MAX_OBJECT_NAME);
        request->getFieldAsString(VID_CATEGORY, category, MAX_OBJECT_NAME);
@@ -12259,7 +12259,7 @@ void ClientSession::deleteLibraryImage(NXCPMessage *request)
    }
 
        request->getFieldAsBinary(VID_GUID, guid, UUID_LENGTH);
-       uuid_to_string(guid, guidText);
+       _uuid_to_string(guid, guidText);
        debugPrintf(5, _T("deleteLibraryImage: guid=%s"), guidText);
 
    DB_HANDLE hdb = DBConnectionPoolAcquireConnection();
index 61991f4..c4371a3 100644 (file)
@@ -232,9 +232,9 @@ int main(int argc, char *argv[])
                                WCHAR wguid[256];
                                MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, optarg, -1, wguid, 256);
                                wguid[255] = 0;
-                               uuid_parse(wguid, guid);
+                               _uuid_parse(wguid, guid);
 #else
-                               uuid_parse(optarg, guid);
+                               _uuid_parse(optarg, guid);
 #endif
                                break;
          case '?':
index 64473f3..439673e 100644 (file)
@@ -533,18 +533,18 @@ static DWORD __stdcall WorkerThread(void *pArg)
       // Generate GUID for user "admin"
       if (bResult)
       {
-         uuid_generate(guid);
+         _uuid_generate(guid);
          _sntprintf(szQuery, 256, _T("UPDATE users SET guid='%s' WHERE id=0"),
-                    uuid_to_string(guid, szGUID));
+                    _uuid_to_string(guid, szGUID));
          bResult = DBQueryEx(hConn, szQuery);
       }
 
       // Generate GUID for "everyone" group
       if (bResult)
       {
-         uuid_generate(guid);
+         _uuid_generate(guid);
          _sntprintf(szQuery, 256, _T("UPDATE user_groups SET guid='%s' WHERE id=%d"),
-                    uuid_to_string(guid, szGUID), GROUP_EVERYONE);
+                    _uuid_to_string(guid, szGUID), GROUP_EVERYONE);
          bResult = DBQueryEx(hConn, szQuery);
       }
 
index ea42639..b85f271 100644 (file)
@@ -225,7 +225,7 @@ static void CheckZones()
                                                uuid_t guid;
                                                TCHAR guidText[128];
 
-                                               uuid_generate(guid);
+                                               _uuid_generate(guid);
                   _sntprintf(szQuery, 1024, 
                              _T("INSERT INTO object_properties (object_id,guid,name,")
                              _T("status,is_deleted,is_system,inherit_access_rights,")
@@ -235,7 +235,7 @@ static void CheckZones()
                                                                          _T("latitude,longitude,image) VALUES ")
                              _T("(%d,'%s','lost_zone_%d',5,0,0,1,") TIME_T_FMT _T(",0,0,0,0,0,0,'00000000',0,")
                                                                          _T("'0.000000','0.000000','00000000-0000-0000-0000-000000000000')"),
-                                                                         (int)dwId, uuid_to_string(guid, guidText), (int)dwId, TIME_T_FCAST(time(NULL)));
+                                                                         (int)dwId, _uuid_to_string(guid, guidText), (int)dwId, TIME_T_FCAST(time(NULL)));
                   if (SQLQuery(szQuery))
                      m_iNumFixes++;
                }
@@ -285,7 +285,7 @@ static void CheckNodes()
                                                uuid_t guid;
                                                TCHAR guidText[128];
 
-                                               uuid_generate(guid);
+                                               _uuid_generate(guid);
                   _sntprintf(szQuery, 1024, 
                              _T("INSERT INTO object_properties (object_id,guid,name,")
                              _T("status,is_deleted,is_system,inherit_access_rights,")
@@ -295,7 +295,7 @@ static void CheckNodes()
                                                                          _T("latitude,longitude,location_accuracy,location_timestamp,image,submap_id) VALUES ")
                              _T("(%d,'%s','lost_node_%d',5,0,0,1,") TIME_T_FMT _T(",0,0,0,0,0,0,'00000000',0,")
                                                                          _T("'0.000000','0.000000',0,0,'00000000-0000-0000-0000-000000000000',0)"),
-                                                                         (int)dwId, uuid_to_string(guid, guidText), (int)dwId, TIME_T_FCAST(time(NULL)));
+                                                                         (int)dwId, _uuid_to_string(guid, guidText), (int)dwId, TIME_T_FCAST(time(NULL)));
                   if (SQLQuery(szQuery))
                      m_iNumFixes++;
                }
@@ -375,7 +375,7 @@ static void CheckComponents(const TCHAR *pszDisplayName, const TCHAR *pszTable)
                                                uuid_t guid;
                                                TCHAR guidText[128];
 
-                                               uuid_generate(guid);
+                                               _uuid_generate(guid);
                   _sntprintf(szQuery, 1024, 
                              _T("INSERT INTO object_properties (object_id,guid,name,")
                              _T("status,is_deleted,is_system,inherit_access_rights,")
@@ -385,7 +385,7 @@ static void CheckComponents(const TCHAR *pszDisplayName, const TCHAR *pszTable)
                                                                          _T("latitude,longitude,image) VALUES ")
                              _T("(%d,'%s','lost_%s_%d',5,0,0,1,") TIME_T_FMT _T(",0,0,0,0,0,0,'00000000',0,")
                                                                          _T("'0.000000','0.000000','00000000-0000-0000-0000-000000000000')"),
-                                                                         (int)dwId, uuid_to_string(guid, guidText), pszDisplayName, (int)dwId, TIME_T_FCAST(time(NULL)));
+                                                                         (int)dwId, _uuid_to_string(guid, guidText), pszDisplayName, (int)dwId, TIME_T_FCAST(time(NULL)));
                   if (SQLQuery(szQuery))
                      m_iNumFixes++;
                   szName[0] = 0;
index 141f52b..16fcfa1 100644 (file)
@@ -163,16 +163,16 @@ void InitDatabase(const char *pszInitFile)
       goto init_failed;
 
    // Generate GUID for user "admin"
-   uuid_generate(guid);
+   _uuid_generate(guid);
    _sntprintf(szQuery, 256, _T("UPDATE users SET guid='%s' WHERE id=0"),
-              uuid_to_string(guid, szGUID));
+              _uuid_to_string(guid, szGUID));
    if (!SQLQuery(szQuery))
       goto init_failed;
 
    // Generate GUID for "everyone" group
-   uuid_generate(guid);
+   _uuid_generate(guid);
    _sntprintf(szQuery, 256, _T("UPDATE user_groups SET guid='%s' WHERE id=%d"),
-              uuid_to_string(guid, szGUID), GROUP_EVERYONE);
+              _uuid_to_string(guid, szGUID), GROUP_EVERYONE);
    if (!SQLQuery(szQuery))
       goto init_failed;
 
index 3d21ae7..032aac1 100644 (file)
@@ -62,10 +62,6 @@ static DWORD CreateMapObject(const TCHAR *name, const TCHAR *description)
        if (!SQLQuery(query))
                return FALSE;
 
-       uuid_t guid;
-       TCHAR guidText[128];
-
-       uuid_generate(guid);
    _sntprintf(query, 4096, 
               _T("INSERT INTO object_properties (object_id,guid,name,")
               _T("status,is_deleted,is_system,inherit_access_rights,")
@@ -75,7 +71,7 @@ static DWORD CreateMapObject(const TCHAR *name, const TCHAR *description)
                                  _T("latitude,longitude,image,comments) VALUES ")
               _T("(%d,'%s',%s,0,0,0,1,") TIME_T_FMT _T(",0,0,0,0,0,0,'00000000',0,")
                                  _T("'0.000000','0.000000','00000000-0000-0000-0000-000000000000',%s)"),
-                                 (int)id, uuid_to_string(guid, guidText), 
+              (int)id, (const TCHAR *)uuid::generate().toString(),
                                  (const TCHAR *)DBPrepareString(g_hCoreDB, name), 
                                  TIME_T_FCAST(time(NULL)),
                                  (const TCHAR *)DBPrepareString(g_hCoreDB, description, 2048));
index bc48310..2a87f7e 100644 (file)
@@ -45,9 +45,9 @@ static bool GenerateGUID(const TCHAR *table, const TCHAR *idColumn, const TCHAR
                uuid_t guid;
                TCHAR buffer[64];
 
-               uuid_generate(guid);
+               _uuid_generate(guid);
                _sntprintf(query, 256, _T("UPDATE %s SET %s='%s' WHERE %s=%d"),
-                          table, guidColumn, uuid_to_string(guid, buffer), idColumn, DBGetFieldULong(hResult, i, 0));
+                          table, guidColumn, _uuid_to_string(guid, buffer), idColumn, DBGetFieldULong(hResult, i, 0));
                if (!SQLQuery(query))
       {
        DBFreeResult(hResult);
@@ -3967,9 +3967,9 @@ static BOOL H_UpgradeFromV215(int currVersion, int newVersion)
                        uuid_t guid;
                        TCHAR query[256], buffer[64];
 
-                       uuid_generate(guid);
+                       _uuid_generate(guid);
                        _sntprintf(query, 256, _T("UPDATE object_properties SET guid='%s' WHERE object_id=%d"),
-                                  uuid_to_string(guid, buffer), DBGetFieldULong(hResult, i, 0));
+                                  _uuid_to_string(guid, buffer), DBGetFieldULong(hResult, i, 0));
                        CHK_EXEC(SQLQuery(query));
                }
                DBFreeResult(hResult);
@@ -6797,9 +6797,9 @@ static BOOL H_UpgradeFromV40(int currVersion, int newVersion)
       for(i = 0; i < nCount; i++)
       {
          dwId = DBGetFieldULong(hResult, i, 0);
-         uuid_generate(guid);
+         _uuid_generate(guid);
          _sntprintf(szQuery, 256, _T("UPDATE users SET guid='%s' WHERE id=%d"),
-                    uuid_to_string(guid, szGUID), dwId);
+                    _uuid_to_string(guid, szGUID), dwId);
          if (!SQLQuery(szQuery))
             if (!g_bIgnoreErrors)
             {
@@ -6817,9 +6817,9 @@ static BOOL H_UpgradeFromV40(int currVersion, int newVersion)
       for(i = 0; i < nCount; i++)
       {
          dwId = DBGetFieldULong(hResult, i, 0);
-         uuid_generate(guid);
+         _uuid_generate(guid);
          _sntprintf(szQuery, 256, _T("UPDATE user_groups SET guid='%s' WHERE id=%d"),
-                    uuid_to_string(guid, szGUID), dwId);
+                    _uuid_to_string(guid, szGUID), dwId);
          if (!SQLQuery(szQuery))
             if (!g_bIgnoreErrors)
             {
index 2f70caa..8886c8d 100644 (file)
@@ -53,12 +53,6 @@ int main(int argc, char *argv[])
       }
    }
 
-   uuid_t guid;
-   uuid_generate(guid);
-
-   TCHAR guidText[64];
-   uuid_to_string(guid, guidText);
-       _putts(guidText);
-
+   _putts(uuid::generate().toString());
        return 0;
 }