gethostuuid使用sqlite / sqlcipher折旧 - iOS

时间:2014-02-23 14:51:50

标签: ios sqlite

发现此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中已经deprecated
  • 并且API gethostuuid()已被删除,并且不会被接受提交到商店,无论目标操作系统如何。对于在iOS 7上运行的现有应用程序,该函数将返回供应商标识符的uuid_t表示形式( - [UIDevice identifierForVendor])。

如何替换gethostuuid中的sqlite3.c来电?

1 个答案:

答案 0 :(得分:3)

找到它。用以下内容替换sqlite3.c中的上述代码spinet:

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