簡體   English   中英

使用sqlite / sqlcipher折舊的gethostuuid-iOS

[英]gethostuuid depreciated with sqlite/sqlcipher - iOS

發現這個SO大約gethostuuid depreciated ,但它不是在這種情況下,幫助我很多。

目標是iOS6.0,在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中已被棄用
  • 而且該API gethostuuid()已被刪除,無論目標操作系統是什么,都將不接受該API提交到商店。 對於在iOS 7上運行的現有應用,該函數將返回供應商標識符(-[UIDevice identifierForVendor])的uuid_t表示形式。

如何替換sqlite3.cgethostuuid的調用?

找到了。 用以下代碼將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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM