亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? test6.c

?? sqlite庫
?? C
字號:
/*** 2004 May 22**** The author disclaims copyright to this source code.  In place of** a legal notice, here is a blessing:****    May you do good and not evil.**    May you find forgiveness for yourself and forgive others.**    May you share freely, never taking more than you give.************************************************************************************ This file contains code that modified the OS layer in order to simulate** the effect on the database file of an OS crash or power failure.  This** is used to test the ability of SQLite to recover from those situations.*/#if SQLITE_TEST          /* This file is used for the testing only */#include "sqliteInt.h"#include "os.h"#include "tcl.h"#ifndef SQLITE_OMIT_DISKIO  /* This file is a no-op if disk I/O is disabled *//*** crashFile is a subclass of OsFile that is taylored for the** crash test module.*/typedef struct crashFile crashFile;struct crashFile {  IoMethod const *pMethod; /* Must be first */  u8 **apBlk;              /* Array of blocks that have been written to. */  int nBlk;                /* Size of apBlock. */  i64 offset;              /* Next character to be read from the file */  int nMaxWrite;           /* Largest offset written to. */  char *zName;             /* File name */  OsFile *pBase;           /* The real file */  crashFile *pNext;        /* Next in a list of them all */};/*** Size of a simulated disk block*/#define BLOCKSIZE 512#define BLOCK_OFFSET(x) ((x) * BLOCKSIZE)/*** The following variables control when a simulated crash occurs.**** If iCrashDelay is non-zero, then zCrashFile contains (full path) name of** a file that SQLite will call sqlite3OsSync() on. Each time this happens** iCrashDelay is decremented. If iCrashDelay is zero after being** decremented, a "crash" occurs during the sync() operation.**** In other words, a crash occurs the iCrashDelay'th time zCrashFile is** synced.*/static int iCrashDelay = 0;static char zCrashFile[500];/*** Set the value of the two crash parameters.*/static void setCrashParams(int iDelay, char const *zFile){  sqlite3OsEnterMutex();  assert( strlen(zFile)<sizeof(zCrashFile) );  strcpy(zCrashFile, zFile);  iCrashDelay = iDelay;  sqlite3OsLeaveMutex();}/*** File zPath is being sync()ed. Return non-zero if this should** cause a crash.*/static int crashRequired(char const *zPath){  int r;  int n;  sqlite3OsEnterMutex();  n = strlen(zCrashFile);  if( zCrashFile[n-1]=='*' ){    n--;  }else if( strlen(zPath)>n ){    n = strlen(zPath);  }  r = 0;  if( iCrashDelay>0 && strncmp(zPath, zCrashFile, n)==0 ){    iCrashDelay--;    if( iCrashDelay<=0 ){      r = 1;    }  }  sqlite3OsLeaveMutex();  return r;}/*** A list of all open files.*/static crashFile *pAllFiles = 0;/* Forward reference */static void initFile(OsFile **pId, char const *zName, OsFile *pBase);/*** Undo the work done by initFile. Delete the OsFile structure** and unlink the structure from the pAllFiles list.*/static void closeFile(crashFile **pId){  crashFile *pFile = *pId;  if( pFile==pAllFiles ){    pAllFiles = pFile->pNext;  }else{    crashFile *p;    for(p=pAllFiles; p->pNext!=pFile; p=p->pNext ){      assert( p );    }    p->pNext = pFile->pNext;  }  sqliteFree(*pId);  *pId = 0;}/*** Read block 'blk' off of the real disk file and into the cache of pFile.*/static int readBlockIntoCache(crashFile *pFile, int blk){  if( blk>=pFile->nBlk ){    int n = ((pFile->nBlk * 2) + 100 + blk);    /* if( pFile->nBlk==0 ){ printf("DIRTY %s\n", pFile->zName); } */    pFile->apBlk = (u8 **)sqliteRealloc(pFile->apBlk, n * sizeof(u8*));    if( !pFile->apBlk ) return SQLITE_NOMEM;    memset(&pFile->apBlk[pFile->nBlk], 0, (n - pFile->nBlk)*sizeof(u8*));    pFile->nBlk = n;  }  if( !pFile->apBlk[blk] ){    i64 filesize;    int rc;    u8 *p = sqliteMalloc(BLOCKSIZE);    if( !p ) return SQLITE_NOMEM;    pFile->apBlk[blk] = p;    rc = sqlite3OsFileSize(pFile->pBase, &filesize);    if( rc!=SQLITE_OK ) return rc;    if( BLOCK_OFFSET(blk)<filesize ){      int len = BLOCKSIZE;      rc = sqlite3OsSeek(pFile->pBase, blk*BLOCKSIZE);      if( BLOCK_OFFSET(blk+1)>filesize ){        len = filesize - BLOCK_OFFSET(blk);      }      if( rc!=SQLITE_OK ) return rc;      rc = sqlite3OsRead(pFile->pBase, p, len);      if( rc!=SQLITE_OK ) return rc;    }  }  return SQLITE_OK;}/*** Write the cache of pFile to disk. If crash is non-zero, randomly** skip blocks when writing. The cache is deleted before returning.*/static int writeCache2(crashFile *pFile, int crash){  int i;  int nMax = pFile->nMaxWrite;  int rc = SQLITE_OK;  for(i=0; i<pFile->nBlk; i++){    u8 *p = pFile->apBlk[i];    if( p ){      int skip = 0;      int trash = 0;      if( crash ){        char random;        sqlite3Randomness(1, &random);        if( random & 0x01 ){          if( random & 0x02 ){            trash = 1;#ifdef TRACE_WRITECACHEprintf("Trashing block %d of %s\n", i, pFile->zName); #endif          }else{            skip = 1;#ifdef TRACE_WRITECACHEprintf("Skiping block %d of %s\n", i, pFile->zName); #endif          }        }else{#ifdef TRACE_WRITECACHEprintf("Writing block %d of %s\n", i, pFile->zName); #endif        }      }      if( rc==SQLITE_OK ){        rc = sqlite3OsSeek(pFile->pBase, BLOCK_OFFSET(i));      }      if( rc==SQLITE_OK && !skip ){        int len = BLOCKSIZE;        if( BLOCK_OFFSET(i+1)>nMax ){          len = nMax-BLOCK_OFFSET(i);        }        if( len>0 ){          if( trash ){            sqlite3Randomness(len, p);          }          rc = sqlite3OsWrite(pFile->pBase, p, len);        }      }      sqliteFree(p);    }  }  sqliteFree(pFile->apBlk);  pFile->nBlk = 0;  pFile->apBlk = 0;  pFile->nMaxWrite = 0;  return rc;}/*** Write the cache to disk.*/static int writeCache(crashFile *pFile){  if( pFile->apBlk ){    int c = crashRequired(pFile->zName);    if( c ){      crashFile *p;#ifdef TRACE_WRITECACHE      printf("\nCrash during sync of %s\n", pFile->zName);#endif      for(p=pAllFiles; p; p=p->pNext){        writeCache2(p, 1);      }      exit(-1);    }else{      return writeCache2(pFile, 0);    }  }  return SQLITE_OK;}/*** Close the file.*/static int crashClose(OsFile **pId){  crashFile *pFile = (crashFile*)*pId;  if( pFile ){    /* printf("CLOSE %s (%d blocks)\n", pFile->zName, pFile->nBlk); */    writeCache(pFile);    sqlite3OsClose(&pFile->pBase);  }  closeFile(&pFile);  *pId = 0;  return SQLITE_OK;}static int crashSeek(OsFile *id, i64 offset){  ((crashFile*)id)->offset = offset;  return SQLITE_OK;}static int crashRead(OsFile *id, void *pBuf, int amt){  i64 offset;       /* The current offset from the start of the file */  i64 end;          /* The byte just past the last byte read */  int blk;            /* Block number the read starts on */  int i;  u8 *zCsr;  int rc = SQLITE_OK;  crashFile *pFile = (crashFile*)id;  offset = pFile->offset;  end = offset+amt;  blk = (offset/BLOCKSIZE);  zCsr = (u8 *)pBuf;  for(i=blk; i*BLOCKSIZE<end; i++){    int off = 0;    int len = 0;    if( BLOCK_OFFSET(i) < offset ){      off = offset-BLOCK_OFFSET(i);    }    len = BLOCKSIZE - off;    if( BLOCK_OFFSET(i+1) > end ){      len = len - (BLOCK_OFFSET(i+1)-end);    }    if( i<pFile->nBlk && pFile->apBlk[i]){      u8 *pBlk = pFile->apBlk[i];      memcpy(zCsr, &pBlk[off], len);    }else{      rc = sqlite3OsSeek(pFile->pBase, BLOCK_OFFSET(i) + off);      if( rc!=SQLITE_OK ) return rc;      rc = sqlite3OsRead(pFile->pBase, zCsr, len);      if( rc!=SQLITE_OK ) return rc;    }    zCsr += len;  }  assert( zCsr==&((u8 *)pBuf)[amt] );  pFile->offset = end;  return rc;}static int crashWrite(OsFile *id, const void *pBuf, int amt){  i64 offset;       /* The current offset from the start of the file */  i64 end;          /* The byte just past the last byte written */  int blk;            /* Block number the write starts on */  int i;  const u8 *zCsr;  int rc = SQLITE_OK;  crashFile *pFile = (crashFile*)id;  offset = pFile->offset;  end = offset+amt;  blk = (offset/BLOCKSIZE);  zCsr = (u8 *)pBuf;  for(i=blk; i*BLOCKSIZE<end; i++){    u8 *pBlk;    int off = 0;    int len = 0;    /* Make sure the block is in the cache */    rc = readBlockIntoCache(pFile, i);    if( rc!=SQLITE_OK ) return rc;    /* Write into the cache */    pBlk = pFile->apBlk[i];    assert( pBlk );    if( BLOCK_OFFSET(i) < offset ){      off = offset-BLOCK_OFFSET(i);    }    len = BLOCKSIZE - off;    if( BLOCK_OFFSET(i+1) > end ){      len = len - (BLOCK_OFFSET(i+1)-end);    }    memcpy(&pBlk[off], zCsr, len);    zCsr += len;  }  if( pFile->nMaxWrite<end ){    pFile->nMaxWrite = end;  }  assert( zCsr==&((u8 *)pBuf)[amt] );  pFile->offset = end;  return rc;}/*** Sync the file. First flush the write-cache to disk, then call the** real sync() function.*/static int crashSync(OsFile *id, int dataOnly){  return writeCache((crashFile*)id);}/*** Truncate the file. Set the internal OsFile.nMaxWrite variable to the new** file size to ensure that nothing in the write-cache past this point** is written to disk.*/static int crashTruncate(OsFile *id, i64 nByte){  crashFile *pFile = (crashFile*)id;  pFile->nMaxWrite = nByte;  return sqlite3OsTruncate(pFile->pBase, nByte);}/*** Return the size of the file. If the cache contains a write that extended** the file, then return this size instead of the on-disk size.*/static int crashFileSize(OsFile *id, i64 *pSize){  crashFile *pFile = (crashFile*)id;  int rc = sqlite3OsFileSize(pFile->pBase, pSize);  if( rc==SQLITE_OK && pSize && *pSize<pFile->nMaxWrite ){    *pSize = pFile->nMaxWrite;  }  return rc;}/*** Set this global variable to 1 to enable crash testing.*/int sqlite3CrashTestEnable = 0;/*** The three functions used to open files. All that is required is to** initialise the os_test.c specific fields and then call the corresponding** os_unix.c function to really open the file.*/int sqlite3CrashOpenReadWrite(const char *zFilename, OsFile **pId,int *pRdonly){  OsFile *pBase = 0;  int rc;  sqlite3CrashTestEnable = 0;  rc = sqlite3OsOpenReadWrite(zFilename, &pBase, pRdonly);  sqlite3CrashTestEnable = 1;  if( !rc ){    initFile(pId, zFilename, pBase);  }  return rc;}int sqlite3CrashOpenExclusive(const char *zFilename, OsFile **pId, int delFlag){  OsFile *pBase = 0;  int rc;  sqlite3CrashTestEnable = 0;  rc = sqlite3OsOpenExclusive(zFilename, &pBase, delFlag);  sqlite3CrashTestEnable = 1;  if( !rc ){    initFile(pId, zFilename, pBase);  }  return rc;}int sqlite3CrashOpenReadOnly(const char *zFilename, OsFile **pId, int NotUsed){  OsFile *pBase = 0;  int rc;  sqlite3CrashTestEnable = 0;  rc = sqlite3OsOpenReadOnly(zFilename, &pBase);  sqlite3CrashTestEnable = 1;  if( !rc ){    initFile(pId, zFilename, pBase);  }  return rc;}/*** OpenDirectory is a no-op*/static int crashOpenDir(OsFile *id, const char *zName){  return SQLITE_OK;}/*** Locking primitives are passed through into the underlying** file descriptor.*/int crashLock(OsFile *id, int lockType){  return sqlite3OsLock(((crashFile*)id)->pBase, lockType);}int crashUnlock(OsFile *id, int lockType){  return sqlite3OsUnlock(((crashFile*)id)->pBase, lockType);}int crashCheckReservedLock(OsFile *id){  return sqlite3OsCheckReservedLock(((crashFile*)id)->pBase);}void crashSetFullSync(OsFile *id, int setting){  return;  /* This is a no-op */}int crashLockState(OsFile *id){  return sqlite3OsLockState(((crashFile*)id)->pBase);}/*** Return the underlying file handle.*/int crashFileHandle(OsFile *id){#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)  return sqlite3OsFileHandle(((crashFile*)id)->pBase);#endif  return 0;}/*** This vector defines all the methods that can operate on an OsFile** for the crash tester.*/static const IoMethod crashIoMethod = {  crashClose,  crashOpenDir,  crashRead,  crashWrite,  crashSeek,  crashTruncate,  crashSync,  crashSetFullSync,  crashFileHandle,  crashFileSize,  crashLock,  crashUnlock,  crashLockState,  crashCheckReservedLock,};/*** Initialise the os_test.c specific fields of pFile.*/static void initFile(OsFile **pId, char const *zName, OsFile *pBase){  crashFile *pFile = sqliteMalloc(sizeof(crashFile) + strlen(zName)+1);  pFile->pMethod = &crashIoMethod;  pFile->nMaxWrite = 0;   pFile->offset = 0;  pFile->nBlk = 0;   pFile->apBlk = 0;   pFile->zName = (char *)(&pFile[1]);  strcpy(pFile->zName, zName);  pFile->pBase = pBase;  pFile->pNext = pAllFiles;  pAllFiles = pFile;  *pId = (OsFile*)pFile;}/*** tclcmd:   sqlite_crashparams DELAY CRASHFILE**** This procedure implements a TCL command that enables crash testing** in testfixture.  Once enabled, crash testing cannot be disabled.*/static int crashParamsObjCmd(  void * clientData,  Tcl_Interp *interp,  int objc,  Tcl_Obj *CONST objv[]){  int delay;  const char *zFile;  int nFile;  if( objc!=3 ){    Tcl_WrongNumArgs(interp, 1, objv, "DELAY CRASHFILE");    return TCL_ERROR;  }  if( Tcl_GetIntFromObj(interp, objv[1], &delay) ) return TCL_ERROR;  zFile = Tcl_GetStringFromObj(objv[2], &nFile);  if( nFile>=sizeof(zCrashFile)-1 ){    Tcl_AppendResult(interp, "crash file name too big", 0);    return TCL_ERROR;  }  setCrashParams(delay, zFile);  sqlite3CrashTestEnable = 1;  return TCL_OK;}#endif /* SQLITE_OMIT_DISKIO *//*** This procedure registers the TCL procedures defined in this file.*/int Sqlitetest6_Init(Tcl_Interp *interp){#ifndef SQLITE_OMIT_DISKIO  Tcl_CreateObjCommand(interp, "sqlite3_crashparams", crashParamsObjCmd, 0, 0);#endif  return TCL_OK;}#endif /* SQLITE_TEST */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日日骚欧美日韩| 欧美系列一区二区| 在线精品视频一区二区三四| 666欧美在线视频| 久久午夜电影网| 亚洲国产美女搞黄色| 国产成人午夜精品影院观看视频| 欧美午夜精品免费| 国产女主播视频一区二区| 亚洲成a人v欧美综合天堂| 99综合电影在线视频| 欧美成人免费网站| 亚洲444eee在线观看| 91在线免费看| 久久久国产精品麻豆| 裸体歌舞表演一区二区| 欧美色倩网站大全免费| 亚洲日穴在线视频| 成人黄色小视频| 久久综合999| 久久电影网电视剧免费观看| 欧美精品一二三区| 亚洲妇女屁股眼交7| 在线亚洲人成电影网站色www| 国产日产精品一区| 狠狠色狠狠色综合| 欧美mv日韩mv国产网站app| 日韩激情av在线| 欧美精品在欧美一区二区少妇| 亚洲综合一区在线| 在线观看中文字幕不卡| 一区二区三区视频在线看| 91丨porny丨首页| 国产精品理论片| 97se亚洲国产综合自在线| 亚洲色图欧美偷拍| 色婷婷综合久色| 一区二区三区国产精华| 在线免费观看日本一区| 亚洲一二三区不卡| 欧美电影影音先锋| 久久精品av麻豆的观看方式| 欧美变态tickling挠脚心| 国产综合久久久久影院| 久久久久久久久久电影| 成人午夜激情在线| 中文字幕日本不卡| 欧美制服丝袜第一页| 亚洲成在线观看| 欧美一卡二卡在线观看| 国产一区二区三区国产| 国产精品毛片大码女人| 日本韩国一区二区| 亚洲福利视频导航| 91精品久久久久久久91蜜桃| 精品一区二区三区免费观看| 国产人成亚洲第一网站在线播放| www.欧美日韩国产在线| 一区二区三区不卡视频在线观看| 欧美日韩在线播| 另类小说欧美激情| 国产精品久久久久久久久搜平片 | 欧美日韩三级一区二区| 日韩国产精品91| 国产女同性恋一区二区| 欧美亚洲精品一区| 精品一区二区在线免费观看| 国产精品免费久久久久| 欧美丝袜自拍制服另类| 国产呦精品一区二区三区网站| 国产精品美女久久久久久久| 欧美在线观看视频一区二区三区| 看国产成人h片视频| 国产精品激情偷乱一区二区∴| 欧美伊人久久久久久久久影院| 久久机这里只有精品| 亚洲精品菠萝久久久久久久| 日韩免费电影一区| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 欧美高清dvd| av亚洲产国偷v产偷v自拍| 亚洲va欧美va天堂v国产综合| 国产欧美一区二区精品性| 精品污污网站免费看| 懂色av中文一区二区三区 | 日韩一卡二卡三卡| 色婷婷亚洲精品| 国产成人高清视频| 激情偷乱视频一区二区三区| 洋洋成人永久网站入口| 欧美国产视频在线| 久久久综合九色合综国产精品| 91精品国产美女浴室洗澡无遮挡| 91麻豆免费观看| k8久久久一区二区三区| 国产在线日韩欧美| 全国精品久久少妇| 图片区小说区国产精品视频| 亚洲视频在线观看三级| 国产亚洲一二三区| 精品久久久久久久久久久久久久久久久 | 成人高清视频免费观看| 国产综合久久久久久久久久久久 | 久久品道一品道久久精品| 国产精品久久久久久久蜜臀| 一区二区三区在线不卡| 日本一区二区在线不卡| 日韩久久精品一区| 欧美剧在线免费观看网站 | 久久中文娱乐网| 日韩一区二区视频| 日韩视频在线永久播放| 在线综合视频播放| 欧美精品aⅴ在线视频| 欧美喷水一区二区| 欧美日韩精品一区二区| 欧美伦理电影网| 欧美军同video69gay| 日韩小视频在线观看专区| 日韩三级视频在线观看| 日韩欧美国产电影| 久久女同互慰一区二区三区| 欧美国产日本韩| 亚洲美女淫视频| 无吗不卡中文字幕| 麻豆成人在线观看| 久久99精品久久只有精品| 国产精品888| av电影在线观看一区| 日本韩国欧美国产| 欧美一区二区福利在线| 精品少妇一区二区| 国产精品免费视频观看| 亚洲精品亚洲人成人网在线播放| 亚洲国产精品一区二区久久恐怖片| 日韩在线卡一卡二| 久草精品在线观看| 色欧美片视频在线观看在线视频| 91无套直看片红桃| 欧美写真视频网站| 精品久久久久香蕉网| 国产日韩av一区| 一区二区三区在线视频免费| 人人精品人人爱| 国产宾馆实践打屁股91| 色伊人久久综合中文字幕| 欧美精品久久99久久在免费线 | 蜜臀91精品一区二区三区| 国产又黄又大久久| 在线影视一区二区三区| 亚洲精品一线二线三线无人区| 国产目拍亚洲精品99久久精品| 一区二区三区在线观看欧美| 蜜桃精品在线观看| 成人动漫视频在线| 在线播放欧美女士性生活| 国产欧美视频一区二区| 香港成人在线视频| 国产精品一区二区免费不卡| 欧美在线视频日韩| 国产99久久久国产精品潘金 | 国产精品一级片在线观看| 暴力调教一区二区三区| 宅男在线国产精品| 亚洲欧美激情小说另类| 久久99热狠狠色一区二区| 91麻豆精品一区二区三区| 精品欧美一区二区三区精品久久| 一区二区日韩av| 国产精品系列在线播放| 4438x亚洲最大成人网| 国产日韩欧美一区二区三区乱码 | 欧美色精品在线视频| 国产目拍亚洲精品99久久精品| 奇米影视一区二区三区小说| 色伊人久久综合中文字幕| 国产亚洲综合在线| 久久9热精品视频| 欧美喷潮久久久xxxxx| 亚洲黄色片在线观看| 99视频精品全部免费在线| 日韩色视频在线观看| 亚洲欧美一区二区在线观看| 久久超级碰视频| 欧美日韩亚洲综合一区二区三区| 中国av一区二区三区| 蜜臀精品久久久久久蜜臀| 欧美日韩激情在线| 亚洲精品国产a| 91美女在线看| 亚洲天堂免费看| av网站免费线看精品| 成人免费视频在线观看| 成人av在线资源| 亚洲国产精品黑人久久久| 国产精品一二三| 国产精品天天看| 风流少妇一区二区| 国产精品精品国产色婷婷| 丁香婷婷深情五月亚洲|