2014-02-23 88 views
2

發現這個SOgethostuuid depreciated,但它在這種情況下幫助不大。gethostuuid用sqlite/sqlcipher折舊 - iOS

目標是iOS6.0,在compil時間sqlite3.c(v3.7.2):

static int proxyGetHostID(unsigned char *pHostID, int *pError){ 
struct timespec timeout = {1, 0}; /* 1 sec timeout */ 

assert(PROXY_HOSTIDLEN == sizeof(uuid_t)); 
memset(pHostID, 0, PROXY_HOSTIDLEN); 

if(gethostuuid(pHostID, &timeout)){  

= >>警告:'gethostuuid' is deprecated: first deprecated in iOS 5.0 - gethostuuid() is no longer supported

int err = errno; 
    if(pError){ 
     *pError = err; 
    } 
    return SQLITE_IOERR; 
    } 
#ifdef SQLITE_TEST 
    /* simulate multiple hosts by creating unique hostid file paths */ 
    if(sqlite3_hostid_num != 0){ 
    pHostID[0] = (char)(pHostID[0] + (char)(sqlite3_hostid_num & 0xFF)); 
    } 
#endif 

    return SQLITE_OK; 
} 
  • 我明白gethostuuid有在iOS 5.0中已經deprecated
  • 而且,API gethostuuid()已被刪除,不會被接受提交給商店,無論目標操作系統如何。對於在iOS 7上運行的現有應用程序,該函數將返回供應商標識的uuid_t表示( - [UIDevice identifierForVendor])。

如何將呼叫替換爲gethostuuidsqlite3.c

回答

3

找到它。用以下替換sqlite3.c上面的代碼尖晶石:

static int proxyGetHostID(unsigned char *pHostID, int *pError){ 
    assert(PROXY_HOSTIDLEN == sizeof(uuid_t)); 
    memset(pHostID, 0, PROXY_HOSTIDLEN); 

#if defined(__MAX_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED<1050 
    { 
     static const struct timespec timeout = {1, 0}; /* 1 sec timeout */ 
     if(gethostuuid(pHostID, &timeout)){ 
      int err = errno; 
      if(pError){ 
       *pError = err; 
      } 
      return SQLITE_IOERR; 
     } 
    } 
#else 
    UNUSED_PARAMETER(pError); 
#endif 

#ifdef SQLITE_TEST 
    /* simulate multiple hosts by creating unique hostid file paths */ 
    if(sqlite3_hostid_num != 0){ 
     pHostID[0] = (char)(pHostID[0] + (char)(sqlite3_hostid_num & 0xFF)); 
    } 
#endif 
    return SQLITE_OK; 
} 

來源:https://groups.google.com/forum/#!topic/sqlcipher/_ji0WbDH88s

+1

更好地爲sqlite3.c文件被通過化妝覆蓋改變它放在src/os_unix.c。 –