[英]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;
}
如何替換sqlite3.c
對gethostuuid
的調用?
找到了。 用以下代碼將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.