您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sqlite3StrNICmp函数代码示例

51自学网 2021-06-03 08:14:33
  C++
这篇教程C++ sqlite3StrNICmp函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中sqlite3StrNICmp函数的典型用法代码示例。如果您正苦于以下问题:C++ sqlite3StrNICmp函数的具体用法?C++ sqlite3StrNICmp怎么用?C++ sqlite3StrNICmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了sqlite3StrNICmp函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sqlite3_compileoption_used

/*** Given the name of a compile-time option, return true if that option** was used and false if not.**** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix** is not required for a match.*/int sqlite3_compileoption_used(const char *zOptName){  int i, n;  if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;  n = sqlite3Strlen30(zOptName);  /* Since ArraySize(azCompileOpt) is normally in single digits, a  ** linear search is adequate.  No need for a binary search. */  for(i=0; i<ArraySize(azCompileOpt); i++){    if(   (sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0)       && ( (azCompileOpt[i][n]==0) || (azCompileOpt[i][n]=='=') ) ) return 1;  }  return 0;}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:20,


示例2: key

/* This function (for internal use only) locates an element in an** hash table that matches the given key.  The hash for this key has** already been computed and is passed as the 4th parameter.*/static HashElem *findElementGivenHash(  const Hash *pH,     /* The pH to be searched */  const char *pKey,   /* The key we are searching for */  int nKey,           /* Bytes in key (not counting zero terminator) */  unsigned int h      /* The hash for this key. */){  HashElem *elem;                /* Used to loop thru the element list */  int count;                     /* Number of elements left to test */  if( pH->ht ){    struct _ht *pEntry = &pH->ht[h];    elem = pEntry->chain;    count = pEntry->count;  }else{    elem = pH->first;    count = pH->count;  }  while( count-- && ALWAYS(elem) ){    if( elem->nKey==nKey && sqlite3StrNICmp(elem->pKey,pKey,nKey)==0 ){       return elem;    }    elem = elem->next;  }  return 0;}
开发者ID:0x7678,项目名称:owasp-igoat,代码行数:29,


示例3: sqlite3KeywordCode

/*** This function looks up an identifier to determine if it is a** keyword.  If it is a keyword, the token code of that keyword is ** returned.  If the input is not a keyword, TK_ID is returned.*/int sqlite3KeywordCode(const char *z, int n){  int h, i;  Keyword *p;  static char needInit = 1;  if( needInit ){    /* Initialize the keyword hash table */    sqlite3OsEnterMutex();    if( needInit ){      int nk;      nk = sizeof(aKeywordTable)/sizeof(aKeywordTable[0]);      for(i=0; i<nk; i++){        aKeywordTable[i].len = strlen(aKeywordTable[i].zName);        h = sqlite3HashNoCase(aKeywordTable[i].zName, aKeywordTable[i].len);        h %= KEY_HASH_SIZE;        aKeywordTable[i].iNext = aiHashTable[h];        aiHashTable[h] = i+1;      }      needInit = 0;    }    sqlite3OsLeaveMutex();  }  h = sqlite3HashNoCase(z, n) % KEY_HASH_SIZE;  for(i=aiHashTable[h]; i; i=p->iNext){    p = &aKeywordTable[i-1];    if( p->len==n && sqlite3StrNICmp(p->zName, z, n)==0 ){      return p->tokenType;    }  }  return TK_ID;}
开发者ID:kanbang,项目名称:Colt,代码行数:35,


示例4: isSystemTable

/*** Parameter zName is the name of a table that is about to be altered** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).** If the table is a system table, this function leaves an error message** in pParse->zErr (system tables may not be altered) and returns non-zero.**** Or, if zName is not a system table, zero is returned.*/static int isSystemTable(Parse *pParse, const char *zName){  if( sqlite3Strlen30(zName)>6 && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){    sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);    return 1;  }  return 0;}
开发者ID:arizwanp,项目名称:intel_sgx,代码行数:15,


示例5: sqlcipher_codec_add_random

int sqlcipher_codec_add_random(codec_ctx *ctx, const char *zRight, int random_sz){  const char *suffix = &zRight[random_sz-1];  int n = random_sz - 3; /* adjust for leading x' and tailing ' */  if (n > 0 &&      sqlite3StrNICmp((const char *)zRight ,"x'", 2) == 0 &&      sqlite3StrNICmp(suffix, "'", 1) == 0 &&      n % 2 == 0) {    int rc = 0;    int buffer_sz = n / 2;    unsigned char *random;    const unsigned char *z = (const unsigned char *)zRight + 2; /* adjust lead offset of x' */    CODEC_TRACE(("sqlcipher_codec_add_random: using raw random blob from hex/n"));    random = sqlcipher_malloc(buffer_sz);    memset(random, 0, buffer_sz);    cipher_hex2bin(z, n, random);    rc = ctx->read_ctx->provider->add_random(ctx->read_ctx->provider_ctx, random, buffer_sz);    sqlcipher_free(random, buffer_sz);    return rc;  }  return SQLITE_ERROR;}
开发者ID:CoderXL,项目名称:sqlcipher,代码行数:21,


示例6: sqlite3MatchSpanName

/*** Subqueries stores the original database, table and column names for their** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN".** Check to see if the zSpan given to this routine matches the zDb, zTab,** and zCol.  If any of zDb, zTab, and zCol are NULL then those fields will** match anything.*/int sqlite3MatchSpanName(  const char *zSpan,  const char *zCol,  const char *zTab,  const char *zDb){  int n;  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}  if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){    return 0;  }  zSpan += n+1;  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}  if( zTab && (sqlite3StrNICmp(zSpan, zTab, n)!=0 || zTab[n]!=0) ){    return 0;  }  zSpan += n+1;  if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){    return 0;  }  return 1;}
开发者ID:Oceanwings,项目名称:sqlcipher,代码行数:29,


示例7:

/*** Search a FuncDefHash for a function with the given name.  Return** a pointer to the matching FuncDef if found, or 0 if there is no match.*/static FuncDef *functionSearch(  FuncDefHash *pHash,  /* Hash table to search */  int h,               /* Hash of the name */  const char *zFunc,   /* Name of function */  int nFunc            /* Number of bytes in zFunc */){  FuncDef *p;  for(p=pHash->a[h]; p; p=p->pHash){    if( sqlite3StrNICmp(p->zName, zFunc, nFunc)==0 && p->zName[nFunc]==0 ){      return p;    }  }  return 0;}
开发者ID:DoganA,项目名称:nightingale-deps,代码行数:18,


示例8: sqlite3_compileoption_used

/*** Given the name of a compile-time option, return true if that option** was used and false if not.**** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix** is not required for a match.*/int sqlite3_compileoption_used(const char *zOptName){  int i, n;#if SQLITE_ENABLE_API_ARMOR  if( zOptName==0 ){    (void)SQLITE_MISUSE_BKPT;    return 0;  }#endif  if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;  n = sqlite3Strlen30(zOptName);  /* Since ArraySize(azCompileOpt) is normally in single digits, a  ** linear search is adequate.  No need for a binary search. */  for(i=0; i<ArraySize(azCompileOpt); i++){    if( sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0     && sqlite3IsIdChar((unsigned char)azCompileOpt[i][n])==0    ){      return 1;    }  }  return 0;}
开发者ID:blastmann,项目名称:wxSqlite3-WinRT-Project,代码行数:30,


示例9: codec_prepare_key

static void codec_prepare_key(sqlite3 *db, const void *zKey, int nKey, void *salt, int nSalt, void *out, int *nOut) {  /* if key data lenth is exactly 256 bits / 32 bytes use the data directly */  if (nKey == 67 && sqlite3StrNICmp(zKey ,"x'", 2) == 0) {     int n = nKey - 3; /* adjust for leading x' and tailing ' */    int half_n = n/2;    const char *z = zKey + 2; /* adjust lead offset of x' */     void *key = sqlite3HexToBlob(db, z, n);    memcpy(out, key, half_n);    *nOut = half_n;    memset(key, 0, half_n); /* cleanup temporary key data */    sqlite3DbFree(db, key);  /* otherwise the key is provided as a string so hash it to get key data */  } else {    *nOut = KEY_LENGTH;    PKCS5_PBKDF2_HMAC_SHA1(zKey, nKey, salt, nSalt, PBKDF2_ITER, KEY_LENGTH, out);  }}
开发者ID:qianwang,项目名称:sqlcipher,代码行数:17,


示例10: getSafetyLevel

/*** Interpret the given string as a safety level.  Return 0 for OFF,** 1 for ON or NORMAL and 2 for FULL.  Return 1 for an empty or ** unrecognized string argument.**** Note that the values returned are one less that the values that** should be passed into sqlite3BtreeSetSafetyLevel().  The is done** to support legacy SQL code.  The safety level used to be boolean** and older scripts may have used numbers 0 for OFF and 1 for ON.*/static int getSafetyLevel(const char *z){                             /* 123456789 123456789 */  static const char zText[] = "onoffalseyestruefull";  static const u8 iOffset[] = {0, 1, 2, 4, 9, 12, 16};  static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4};  static const u8 iValue[] =  {1, 0, 0, 0, 1, 1, 2};  int i, n;  if( isdigit(*z) ){    return atoi(z);  }  n = strlen(z);  for(i=0; i<sizeof(iLength); i++){    if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0 ){      return iValue[i];    }  }  return 1;}
开发者ID:tmarques,项目名称:waheela,代码行数:28,


示例11: codec_key_derive

/**  * Derive an encryption key for a cipher contex key based on the raw password.  *  * If the raw key data is formated as x'hex' and there are exactly enough hex chars to fill  * the key space (i.e 64 hex chars for a 256 bit key) then the key data will be used directly.   *   * Otherwise, a key data will be derived using PBKDF2  *   * returns SQLITE_OK if initialization was successful  * returns SQLITE_NOMEM if the key could't be derived (for instance if pass is NULL or pass_sz is 0)  */static int codec_key_derive(codec_ctx *ctx, cipher_ctx *c_ctx) {   CODEC_TRACE(("codec_key_derive: entered c_ctx->pass=%s, c_ctx->pass_sz=%d ctx->kdf_salt=%d ctx->kdf_salt_sz=%d c_ctx->kdf_iter=%d c_ctx->key_sz=%d/n",     c_ctx->pass, c_ctx->pass_sz, ctx->kdf_salt, ctx->kdf_salt_sz, c_ctx->kdf_iter, c_ctx->key_sz));  if(c_ctx->pass && c_ctx->pass_sz) { // if pass is not null    if (c_ctx->pass_sz == ((c_ctx->key_sz*2)+3) && sqlite3StrNICmp(c_ctx->pass ,"x'", 2) == 0) {       int n = c_ctx->pass_sz - 3; /* adjust for leading x' and tailing ' */      const char *z = c_ctx->pass + 2; /* adjust lead offset of x' */       CODEC_TRACE(("codec_key_derive: deriving key from hex/n"));       cipher_hex2bin(z, n, c_ctx->key);    } else {       CODEC_TRACE(("codec_key_derive: deriving key using PBKDF2/n"));       PKCS5_PBKDF2_HMAC_SHA1(c_ctx->pass, c_ctx->pass_sz, ctx->kdf_salt, ctx->kdf_salt_sz, c_ctx->kdf_iter, c_ctx->key_sz, c_ctx->key);    }    return SQLITE_OK;  };  return SQLITE_ERROR;}
开发者ID:TheDleo,项目名称:ocRosa,代码行数:29,


示例12: sqlite3Detach

/*** This routine is called by the parser to process a DETACH statement:****    DETACH DATABASE dbname**** The pDbname argument is the name of the database in the DETACH statement.*/void sqlite3Detach(Parse *pParse, Token *pDbname){  int i;  sqlite3 *db;  Vdbe *v;  Db *pDb = 0;  v = sqlite3GetVdbe(pParse);  if( !v ) return;  sqlite3VdbeAddOp(v, OP_Halt, 0, 0);  if( pParse->explain ) return;  db = pParse->db;  for(i=0; i<db->nDb; i++){    pDb = &db->aDb[i];    if( pDb->pBt==0 || pDb->zName==0 ) continue;    if( strlen(pDb->zName)!=pDbname->n ) continue;    if( sqlite3StrNICmp(pDb->zName, pDbname->z, pDbname->n)==0 ) break;  }  if( i>=db->nDb ){    sqlite3ErrorMsg(pParse, "no such database: %T", pDbname);    return;  }  if( i<2 ){    sqlite3ErrorMsg(pParse, "cannot detach database %T", pDbname);    return;  }  if( !db->autoCommit ){    sqlite3ErrorMsg(pParse, "cannot DETACH database within transaction");    pParse->rc = SQLITE_ERROR;    return;  }#ifndef SQLITE_OMIT_AUTHORIZATION  if( sqlite3AuthCheck(pParse,SQLITE_DETACH,db->aDb[i].zName,0,0)!=SQLITE_OK ){    return;  }#endif /* SQLITE_OMIT_AUTHORIZATION */  sqlite3BtreeClose(pDb->pBt);  pDb->pBt = 0;  sqlite3ResetInternalSchema(db, 0);}
开发者ID:kanbang,项目名称:Colt,代码行数:46,


示例13: vtabCallConstructor

/*** Invoke a virtual table constructor (either xCreate or xConnect). The** pointer to the function to invoke is passed as the fourth parameter** to this procedure.*/static int vtabCallConstructor(  sqlite3 *db,   Table *pTab,  Module *pMod,  int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),  char **pzErr){  VTable *pVTable;  int rc;  const char *const*azArg = (const char *const*)pTab->azModuleArg;  int nArg = pTab->nModuleArg;  char *zErr = 0;  char *zModuleName = sqlite3MPrintf(db, "%s", pTab->zName);  if( !zModuleName ){    return SQLITE_NOMEM;  }  pVTable = sqlite3DbMallocZero(db, sizeof(VTable));  if( !pVTable ){    sqlite3DbFree(db, zModuleName);    return SQLITE_NOMEM;  }  pVTable->db = db;  pVTable->pMod = pMod;  assert( !db->pVTab );  assert( xConstruct );  db->pVTab = pTab;  /* Invoke the virtual table constructor */  rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);  if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;  if( SQLITE_OK!=rc ){    if( zErr==0 ){      *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);    }else {      *pzErr = sqlite3MPrintf(db, "%s", zErr);      sqlite3DbFree(db, zErr);    }    sqlite3DbFree(db, pVTable);  }else if( ALWAYS(pVTable->pVtab) ){    /* Justification of ALWAYS():  A correct vtab constructor must allocate    ** the sqlite3_vtab object if successful.  */    pVTable->pVtab->pModule = pMod->pModule;    pVTable->nRef = 1;    if( db->pVTab ){      const char *zFormat = "vtable constructor did not declare schema: %s";      *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);      sqlite3VtabUnlock(pVTable);      rc = SQLITE_ERROR;    }else{      int iCol;      /* If everything went according to plan, link the new VTable structure      ** into the linked list headed by pTab->pVTable. Then loop through the       ** columns of the table to see if any of them contain the token "hidden".      ** If so, set the Column.isHidden flag and remove the token from      ** the type string.  */      pVTable->pNext = pTab->pVTable;      pTab->pVTable = pVTable;      for(iCol=0; iCol<pTab->nCol; iCol++){        char *zType = pTab->aCol[iCol].zType;        int nType;        int i = 0;        if( !zType ) continue;        nType = sqlite3Strlen30(zType);        if( sqlite3StrNICmp("hidden", zType, 6)||(zType[6] && zType[6]!=' ') ){          for(i=0; i<nType; i++){            if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))             && (zType[i+7]=='/0' || zType[i+7]==' ')            ){              i++;              break;            }          }        }        if( i<nType ){          int j;          int nDel = 6 + (zType[i+6] ? 1 : 0);          for(j=i; (j+nDel)<=nType; j++){            zType[j] = zType[j+nDel];          }          if( zType[i]=='/0' && i>0 ){            assert(zType[i-1]==' ');            zType[i-1] = '/0';          }          pTab->aCol[iCol].isHidden = 1;        }      }    }  }  sqlite3DbFree(db, zModuleName);//.........这里部分代码省略.........
开发者ID:sukantoguha,项目名称:INET-Vagrant-Demos,代码行数:101,


示例14: sqlite3Update

/*** Process an UPDATE statement.****   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;**          /_______/ /________/     /______/       /________________/*            onError   pTabList      pChanges             pWhere*/void sqlite3Update(  Parse *pParse,         /* The parser context */  SrcList *pTabList,     /* The table in which we should change things */  ExprList *pChanges,    /* Things to be changed */  Expr *pWhere,          /* The WHERE clause.  May be null */  int onError            /* How to handle constraint errors */){  int i, j;              /* Loop counters */  Table *pTab;           /* The table to be updated */  int addrTop = 0;       /* VDBE instruction address of the start of the loop */  WhereInfo *pWInfo;     /* Information about the WHERE clause */  Vdbe *v;               /* The virtual database engine */  Index *pIdx;           /* For looping over indices */  Index *pPk;            /* The PRIMARY KEY index for WITHOUT ROWID tables */  int nIdx;              /* Number of indices that need updating */  int iBaseCur;          /* Base cursor number */  int iDataCur;          /* Cursor for the canonical data btree */  int iIdxCur;           /* Cursor for the first index */  sqlite3 *db;           /* The database structure */  int *aRegIdx = 0;      /* One register assigned to each index to be updated */  int *aXRef = 0;        /* aXRef[i] is the index in pChanges->a[] of the                         ** an expression for the i-th column of the table.                         ** aXRef[i]==-1 if the i-th column is not changed. */  u8 *aToOpen;           /* 1 for tables and indices to be opened */  u8 chngPk;             /* PRIMARY KEY changed in a WITHOUT ROWID table */  u8 chngRowid;          /* Rowid changed in a normal table */  u8 chngKey;            /* Either chngPk or chngRowid */  Expr *pRowidExpr = 0;  /* Expression defining the new record number */  AuthContext sContext;  /* The authorization context */  NameContext sNC;       /* The name-context to resolve expressions in */  int iDb;               /* Database containing the table being updated */  int okOnePass;         /* True for one-pass algorithm without the FIFO */  int hasFK;             /* True if foreign key processing is required */  int labelBreak;        /* Jump here to break out of UPDATE loop */  int labelContinue;     /* Jump here to continue next step of UPDATE loop */#ifndef SQLITE_OMIT_TRIGGER  int isView;            /* True when updating a view (INSTEAD OF trigger) */  Trigger *pTrigger;     /* List of triggers on pTab, if required */  int tmask;             /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */#endif  int newmask;           /* Mask of NEW.* columns accessed by BEFORE triggers */  int iEph = 0;          /* Ephemeral table holding all primary key values */  int nKey = 0;          /* Number of elements in regKey for WITHOUT ROWID */  int aiCurOnePass[2];   /* The write cursors opened by WHERE_ONEPASS */  /* Register Allocations */  int regRowCount = 0;   /* A count of rows changed */  int regOldRowid;       /* The old rowid */  int regNewRowid;       /* The new rowid */  int regNew;            /* Content of the NEW.* table in triggers */  int regOld = 0;        /* Content of OLD.* table in triggers */  int regRowSet = 0;     /* Rowset of rows to be updated */  int regKey = 0;        /* composite PRIMARY KEY value */  memset(&sContext, 0, sizeof(sContext));  db = pParse->db;  if( pParse->nErr || db->mallocFailed ){    goto update_cleanup;  }  assert( pTabList->nSrc==1 );  /* Locate the table which we want to update.   */  pTab = sqlite3SrcListLookup(pParse, pTabList);  if( pTab==0 ) goto update_cleanup;  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);#if defined(SQLITE_ENABLE_SELINUX)if(0!=sqlite3StrNICmp(pTab->zName, "sqlite_", 7) && 0!=sqlite3StrNICmp(pTab->zName, "selinux_", 8)) {  /* MODIFIED */  Expr *pNewWhere = NULL;  char *f_name = sqlite3MPrintf(db, "%s", "selinux_check_access");  char *f_column = sqlite3MPrintf(db, "%s", "security_context");  char *f_class = sqlite3MPrintf(db, "%s", "db_tuple");  char *f_action = sqlite3MPrintf(db, "%s", "update");  for(i = 0; i < pTabList->nAlloc; i++){      Expr *pFName = sqlite3DbMallocZero(db, sizeof(Expr) + strlen(f_name) + 1);      Expr *pFTable = sqlite3DbMallocZero(db, sizeof(Expr) + strlen(pTabList->a[i].zName) + 1);      Expr *pFColumn = sqlite3DbMallocZero(db, sizeof(Expr) + strlen(f_column) + 1);      Expr *pFClass = sqlite3DbMallocZero(db, sizeof(Expr) + strlen(f_class) + 1);      Expr *pFAction = sqlite3DbMallocZero(db, sizeof(Expr) + strlen(f_action) + 1);      Expr *pFDebug = sqlite3DbMallocZero(db, sizeof(Expr) + strlen(pTabList->a[i].zName) + 1);      Expr *pFunction = sqlite3DbMallocZero(db, sizeof(Expr));    pFName->op = (u8)153;     pFName->iAgg = -1;    pFTable->op = (u8)27;//.........这里部分代码省略.........
开发者ID:vsimple,项目名称:sesqlite,代码行数:101,


示例15: sqlcipher_cipher_ctx_key_derive

/**  * Derive an encryption key for a cipher contex key based on the raw password.  *  * If the raw key data is formated as x'hex' and there are exactly enough hex chars to fill  * the key (i.e 64 hex chars for a 256 bit key) then the key data will be used directly.   * Else, if the raw key data is formated as x'hex' and there are exactly enough hex chars to fill  * the key and the salt (i.e 92 hex chars for a 256 bit key and 16 byte salt) then it will be unpacked  * as the key followed by the salt.  *   * Otherwise, a key data will be derived using PBKDF2  *   * returns SQLITE_OK if initialization was successful  * returns SQLITE_ERROR if the key could't be derived (for instance if pass is NULL or pass_sz is 0)  */static int sqlcipher_cipher_ctx_key_derive(codec_ctx *ctx, cipher_ctx *c_ctx) {  int rc;  CODEC_TRACE(("cipher_ctx_key_derive: entered c_ctx->pass=%s, c_ctx->pass_sz=%d /                ctx->kdf_salt=%p ctx->kdf_salt_sz=%d c_ctx->kdf_iter=%d /                ctx->hmac_kdf_salt=%p, c_ctx->fast_kdf_iter=%d c_ctx->key_sz=%d/n",                 c_ctx->pass, c_ctx->pass_sz, ctx->kdf_salt, ctx->kdf_salt_sz, c_ctx->kdf_iter,                 ctx->hmac_kdf_salt, c_ctx->fast_kdf_iter, c_ctx->key_sz));                     if(c_ctx->pass && c_ctx->pass_sz) { // if pass is not null    if(ctx->need_kdf_salt) {      if(ctx->read_ctx->provider->random(ctx->read_ctx->provider_ctx, ctx->kdf_salt, FILE_HEADER_SZ) != SQLITE_OK) return SQLITE_ERROR;      ctx->need_kdf_salt = 0;    }    if (c_ctx->pass_sz == ((c_ctx->key_sz * 2) + 3) && sqlite3StrNICmp((const char *)c_ctx->pass ,"x'", 2) == 0) {       int n = c_ctx->pass_sz - 3; /* adjust for leading x' and tailing ' */      const unsigned char *z = c_ctx->pass + 2; /* adjust lead offset of x' */      CODEC_TRACE(("cipher_ctx_key_derive: using raw key from hex/n"));       cipher_hex2bin(z, n, c_ctx->key);    } else if (c_ctx->pass_sz == (((c_ctx->key_sz + ctx->kdf_salt_sz) * 2) + 3) && sqlite3StrNICmp((const char *)c_ctx->pass ,"x'", 2) == 0) {       const unsigned char *z = c_ctx->pass + 2; /* adjust lead offset of x' */      CODEC_TRACE(("cipher_ctx_key_derive: using raw key from hex/n"));       cipher_hex2bin(z, (c_ctx->key_sz * 2), c_ctx->key);      cipher_hex2bin(z + (c_ctx->key_sz * 2), (ctx->kdf_salt_sz * 2), ctx->kdf_salt);    } else {       CODEC_TRACE(("cipher_ctx_key_derive: deriving key using full PBKDF2 with %d iterations/n", c_ctx->kdf_iter));       c_ctx->provider->kdf(c_ctx->provider_ctx, c_ctx->pass, c_ctx->pass_sz,                     ctx->kdf_salt, ctx->kdf_salt_sz, c_ctx->kdf_iter,                    c_ctx->key_sz, c_ctx->key);    }    /* set the context "keyspec" containing the hex-formatted key and salt to be used when attaching databases */    if((rc = sqlcipher_cipher_ctx_set_keyspec(c_ctx, c_ctx->key, c_ctx->key_sz, ctx->kdf_salt, ctx->kdf_salt_sz)) != SQLITE_OK) return rc;    /* if this context is setup to use hmac checks, generate a seperate and different        key for HMAC. In this case, we use the output of the previous KDF as the input to        this KDF run. This ensures a distinct but predictable HMAC key. */    if(c_ctx->flags & CIPHER_FLAG_HMAC) {      int i;      /* start by copying the kdf key into the hmac salt slot         then XOR it with the fixed hmac salt defined at compile time         this ensures that the salt passed in to derive the hmac key, while          easy to derive and publically known, is not the same as the salt used          to generate the encryption key */       memcpy(ctx->hmac_kdf_salt, ctx->kdf_salt, ctx->kdf_salt_sz);      for(i = 0; i < ctx->kdf_salt_sz; i++) {        ctx->hmac_kdf_salt[i] ^= hmac_salt_mask;      }       CODEC_TRACE(("cipher_ctx_key_derive: deriving hmac key from encryption key using PBKDF2 with %d iterations/n",         c_ctx->fast_kdf_iter));             c_ctx->provider->kdf(c_ctx->provider_ctx, c_ctx->key, c_ctx->key_sz,                     ctx->hmac_kdf_salt, ctx->kdf_salt_sz, c_ctx->fast_kdf_iter,                    c_ctx->key_sz, c_ctx->hmac_key);     }    c_ctx->derive_key = 0;    return SQLITE_OK;  };  return SQLITE_ERROR;}
开发者ID:CoderXL,项目名称:sqlcipher,代码行数:80,


示例16: sqlite3_complete

//.........这里部分代码省略.........      case ' ':      case '/r':      case '/t':      case '/n':      case '/f': {  /* White space is ignored */        token = tkWS;        break;      }      case '/': {   /* C-style comments */        if( zSql[1]!='*' ){          token = tkOTHER;          break;        }        zSql += 2;        while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }        if( zSql[0]==0 ) return 0;        zSql++;        token = tkWS;        break;      }      case '-': {   /* SQL-style comments from "--" to end of line */        if( zSql[1]!='-' ){          token = tkOTHER;          break;        }        while( *zSql && *zSql!='/n' ){ zSql++; }        if( *zSql==0 ) return state==0;        token = tkWS;        break;      }      case '[': {   /* Microsoft-style identifiers in [...] */        zSql++;        while( *zSql && *zSql!=']' ){ zSql++; }        if( *zSql==0 ) return 0;        token = tkOTHER;        break;      }      case '"':     /* single- and double-quoted strings */      case '/'': {        int c = *zSql;        zSql++;        while( *zSql && *zSql!=c ){ zSql++; }        if( *zSql==0 ) return 0;        token = tkOTHER;        break;      }      default: {        if( isIdChar[(u8)*zSql] ){          /* Keywords and unquoted identifiers */          int nId;          for(nId=1; isIdChar[(u8)zSql[nId]]; nId++){}          switch( *zSql ){            case 'c': case 'C': {              if( nId==6 && sqlite3StrNICmp(zSql, "create", 6)==0 ){                token = tkCREATE;              }else{                token = tkOTHER;              }              break;            }            case 't': case 'T': {              if( nId==7 && sqlite3StrNICmp(zSql, "trigger", 7)==0 ){                token = tkTRIGGER;              }else if( nId==4 && sqlite3StrNICmp(zSql, "temp", 4)==0 ){                token = tkTEMP;              }else if( nId==9 && sqlite3StrNICmp(zSql, "temporary", 9)==0 ){                token = tkTEMP;              }else{                token = tkOTHER;              }              break;            }            case 'e':  case 'E': {              if( nId==3 && sqlite3StrNICmp(zSql, "end", 3)==0 ){                token = tkEND;              }else if( nId==7 && sqlite3StrNICmp(zSql, "explain", 7)==0 ){                token = tkEXPLAIN;              }else{                token = tkOTHER;              }              break;            }            default: {              token = tkOTHER;              break;            }          }          zSql += nId-1;        }else{          /* Operators and special symbols */          token = tkOTHER;        }        break;      }    }    state = trans[state][token];    zSql++;  }  return state==0;}
开发者ID:kanbang,项目名称:Colt,代码行数:101,


示例17: sqlite3_complete

//.........这里部分代码省略.........        if( zSql[1]!='*' ){          token = tkOTHER;          break;        }        zSql += 2;        while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }        if( zSql[0]==0 ) return 0;        zSql++;        token = tkWS;        break;      }      case '-': {   /* SQL-style comments from "--" to end of line */        if( zSql[1]!='-' ){          token = tkOTHER;          break;        }        while( *zSql && *zSql!='/n' ){ zSql++; }        if( *zSql==0 ) return state==0;        token = tkWS;        break;      }      case '[': {   /* Microsoft-style identifiers in [...] */        zSql++;        while( *zSql && *zSql!=']' ){ zSql++; }        if( *zSql==0 ) return 0;        token = tkOTHER;        break;      }      case '"':     /* single- and double-quoted strings */      case '/'': {        int c = *zSql;        zSql++;        while( *zSql && *zSql!=c ){ zSql++; }        if( *zSql==0 ) return 0;        token = tkOTHER;        break;      }      default: {        int c;        if( IdChar((u8)*zSql) ){          /* Keywords and unquoted identifiers */          int nId;          for(nId=1; IdChar(zSql[nId]); nId++){}#ifdef SQLITE_OMIT_TRIGGER          token = tkOTHER;#else          switch( *zSql ){            case 'c': case 'C': {              if( nId==6 && sqlite3StrNICmp(zSql, "create", 6)==0 ){                token = tkCREATE;              }else{                token = tkOTHER;              }              break;            }            case 't': case 'T': {              if( nId==7 && sqlite3StrNICmp(zSql, "trigger", 7)==0 ){                token = tkTRIGGER;              }else if( nId==4 && sqlite3StrNICmp(zSql, "temp", 4)==0 ){                token = tkTEMP;              }else if( nId==9 && sqlite3StrNICmp(zSql, "temporary", 9)==0 ){                token = tkTEMP;              }else{                token = tkOTHER;              }              break;            }            case 'e':  case 'E': {              if( nId==3 && sqlite3StrNICmp(zSql, "end", 3)==0 ){                token = tkEND;              }else#ifndef SQLITE_OMIT_EXPLAIN              if( nId==7 && sqlite3StrNICmp(zSql, "explain", 7)==0 ){                token = tkEXPLAIN;              }else#endif              {                token = tkOTHER;              }              break;            }            default: {              token = tkOTHER;              break;            }          }#endif /* SQLITE_OMIT_TRIGGER */          zSql += nId-1;        }else{          /* Operators and special symbols */          token = tkOTHER;        }        break;      }    }    state = trans[state][token];    zSql++;  }  return state==0;}
开发者ID:DSD-TELCEL-ESCOM,项目名称:INE-Votation-Distributed-System,代码行数:101,


示例18: sqlite3Pragma

//.........这里部分代码省略.........      };      int addr = sqlite3VdbeAddOpList(v, ArraySize(readCookie), readCookie);      sqlite3VdbeChangeP1(v, addr, iDb);      sqlite3VdbeChangeP2(v, addr, iCookie);      sqlite3VdbeSetNumCols(v, 1);      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, P3_TRANSIENT);    }  }else#endif /* SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)  /*  ** Report the current state of file logs for all databases  */  if( sqlite3StrICmp(zLeft, "lock_status")==0 ){    static const char *const azLockName[] = {      "unlocked", "shared", "reserved", "pending", "exclusive"    };    int i;    Vdbe *v = sqlite3GetVdbe(pParse);    sqlite3VdbeSetNumCols(v, 2);    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", P3_STATIC);    sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "status", P3_STATIC);    for(i=0; i<db->nDb; i++){      Btree *pBt;      Pager *pPager;      const char *zState = "unknown";      int j;      if( db->aDb[i].zName==0 ) continue;      sqlite3VdbeOp3(v, OP_String8, 0, 0, db->aDb[i].zName, P3_STATIC);      pBt = db->aDb[i].pBt;      if( pBt==0 || (pPager = sqlite3BtreePager(pBt))==0 ){        zState = "closed";      }else if( sqlite3_file_control(db, db->aDb[i].zName,                                      SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){         zState = azLockName[j];      }      sqlite3VdbeOp3(v, OP_String8, 0, 0, zState, P3_STATIC);      sqlite3VdbeAddOp(v, OP_Callback, 2, 0);    }  }else#endif#ifdef SQLITE_SSE  /*  ** Check to see if the sqlite_statements table exists.  Create it  ** if it does not.  */  if( sqlite3StrICmp(zLeft, "create_sqlite_statement_table")==0 ){    extern int sqlite3CreateStatementsTable(Parse*);    sqlite3CreateStatementsTable(pParse);  }else#endif#if SQLITE_HAS_CODEC  if( sqlite3StrICmp(zLeft, "key")==0 ){    sqlite3_key(db, zRight, strlen(zRight));  }else#endif#if SQLITE_HAS_CODEC || defined(SQLITE_ENABLE_CEROD)  if( sqlite3StrICmp(zLeft, "activate_extensions")==0 ){#if SQLITE_HAS_CODEC    if( sqlite3StrNICmp(zRight, "see-", 4)==0 ){      extern void sqlite3_activate_see(const char*);      sqlite3_activate_see(&zRight[4]);    }#endif#ifdef SQLITE_ENABLE_CEROD    if( sqlite3StrNICmp(zRight, "cerod-", 6)==0 ){      extern void sqlite3_activate_cerod(const char*);      sqlite3_activate_cerod(&zRight[6]);    }#endif  }#endif  {}  if( v ){    /* Code an OP_Expire at the end of each PRAGMA program to cause    ** the VDBE implementing the pragma to expire. Most (all?) pragmas    ** are only valid for a single execution.    */    sqlite3VdbeAddOp(v, OP_Expire, 1, 0);    /*    ** Reset the safety level, in case the fullfsync flag or synchronous    ** setting changed.    */#ifndef SQLITE_OMIT_PAGER_PRAGMAS    if( db->autoCommit ){      sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level,                 (db->flags&SQLITE_FullFSync)!=0);    }#endif  }pragma_out:  sqlite3_free(zLeft);  sqlite3_free(zRight);}
开发者ID:ChunHungLiu,项目名称:Reclass-2015,代码行数:101,


示例19: sqlite3BeginTrigger

//.........这里部分代码省略.........             ** and the table is dropped by a different database connection, the             ** trigger is not visible to the database connection that does the             ** drop so the trigger cannot be dropped.  This results in an             ** "orphaned trigger" - a trigger whose associated table is missing.             */            db->init.orphanTrigger = 1;        }        goto trigger_cleanup;    }    if( IsVirtual(pTab) ){        sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables");        goto trigger_cleanup;    }        /* Check that the trigger name is not reserved and that no trigger of the     ** specified name exists */    zName = sqlite3NameFromToken(db, pName);    if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){        goto trigger_cleanup;    }    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );    if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),                        zName, sqlite3Strlen30(zName)) ){        if( !noErr ){            sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);        }else{            assert( !db->init.busy );            sqlite3CodeVerifySchema(pParse, iDb);        }        goto trigger_cleanup;    }        /* Do not create a trigger on a system table */    if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){        sqlite3ErrorMsg(pParse, "cannot create trigger on system table");        pParse->nErr++;        goto trigger_cleanup;    }        /* INSTEAD of triggers are only for views and views only support INSTEAD     ** of triggers.     */    if( pTab->pSelect && tr_tm!=TK_INSTEAD ){        sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S",                        (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName, 0);        goto trigger_cleanup;    }    if( !pTab->pSelect && tr_tm==TK_INSTEAD ){        sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF"                        " trigger on table: %S", pTableName, 0);        goto trigger_cleanup;    }    iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);    #ifndef SQLITE_OMIT_AUTHORIZATION    {        int code = SQLITE_CREATE_TRIGGER;        const char *zDb = db->aDb[iTabDb].zName;        const char *zDbTrig = isTemp ? db->aDb[1].zName : zDb;        if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;        if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){            goto trigger_cleanup;        }        if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iTabDb),0,zDb)){            goto trigger_cleanup;        }
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:67,


示例20: sqlite3BeginTrigger

/*** This is called by the parser when it sees a CREATE TRIGGER statement** up to the point of the BEGIN before the trigger actions.  A Trigger** structure is generated based on the information available and stored** in pParse->pNewTrigger.  After the trigger actions have been parsed, the** sqlite3FinishTrigger() function is called to complete the trigger** construction process.*/void sqlite3BeginTrigger(  Parse *pParse,      /* The parse context of the CREATE TRIGGER statement */  Token *pName1,      /* The name of the trigger */  Token *pName2,      /* The name of the trigger */  int tr_tm,          /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */  int op,             /* One of TK_INSERT, TK_UPDATE, TK_DELETE */  IdList *pColumns,   /* column list if this is an UPDATE OF trigger */  SrcList *pTableName,/* The name of the table/view the trigger applies to */  Expr *pWhen,        /* WHEN clause */  int isTemp,         /* True if the TEMPORARY keyword is present */  int noErr           /* Suppress errors if the trigger already exists */){  Trigger *pTrigger = 0;  Table *pTab;  char *zName = 0;        /* Name of the trigger */  sqlite3 *db = pParse->db;  int iDb;                /* The database to store the trigger in */  Token *pName;           /* The unqualified db name */  DbFixer sFix;  int iTabDb;  assert( pName1!=0 );   /* pName1->z might be NULL, but not pName1 itself */  assert( pName2!=0 );  if( isTemp ){    /* If TEMP was specified, then the trigger name may not be qualified. */    if( pName2->n>0 ){      sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name");      goto trigger_cleanup;    }    iDb = 1;    pName = pName1;  }else{    /* Figure out the db that the the trigger will be created in */    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);    if( iDb<0 ){      goto trigger_cleanup;    }  }  /* If the trigger name was unqualified, and the table is a temp table,  ** then set iDb to 1 to create the trigger in the temporary database.  ** If sqlite3SrcListLookup() returns 0, indicating the table does not  ** exist, the error is caught by the block below.  */  if( !pTableName || db->mallocFailed ){    goto trigger_cleanup;  }  pTab = sqlite3SrcListLookup(pParse, pTableName);  if( pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){    iDb = 1;  }  /* Ensure the table name matches database name and that the table exists */  if( db->mallocFailed ) goto trigger_cleanup;  assert( pTableName->nSrc==1 );  if( sqlite3FixInit(&sFix, pParse, iDb, "trigger", pName) &&       sqlite3FixSrcList(&sFix, pTableName) ){    goto trigger_cleanup;  }  pTab = sqlite3SrcListLookup(pParse, pTableName);  if( !pTab ){    /* The table does not exist. */    goto trigger_cleanup;  }  if( IsVirtual(pTab) ){    sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables");    goto trigger_cleanup;  }  /* Check that the trigger name is not reserved and that no trigger of the  ** specified name exists */  zName = sqlite3NameFromToken(db, pName);  if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){    goto trigger_cleanup;  }  if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash), zName,strlen(zName)) ){    if( !noErr ){      sqlite3ErrorMsg(pParse, "trigger %T already exists", pName);    }    goto trigger_cleanup;  }  /* Do not create a trigger on a system table */  if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){    sqlite3ErrorMsg(pParse, "cannot create trigger on system table");    pParse->nErr++;    goto trigger_cleanup;  }  /* INSTEAD of triggers are only for views and views only support INSTEAD  ** of triggers.  *///.........这里部分代码省略.........
开发者ID:DoktahWorm,项目名称:rhodes,代码行数:101,


示例21: sqlite3AlterRenameTable

/*** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" ** command. */void sqlite3AlterRenameTable(  Parse *pParse,            /* Parser context. */  SrcList *pSrc,            /* The table to rename. */  Token *pName              /* The new table name. */){  int iDb;                  /* Database that contains the table */  char *zDb;                /* Name of database iDb */  Table *pTab;              /* Table being renamed */  char *zName = 0;          /* NULL-terminated version of pName */   sqlite3 *db = pParse->db; /* Database connection */  Vdbe *v;#ifndef SQLITE_OMIT_TRIGGER  char *zWhere = 0;         /* Where clause to locate temp triggers */#endif    if( sqlite3_malloc_failed ) goto exit_rename_table;  assert( pSrc->nSrc==1 );  pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);  if( !pTab ) goto exit_rename_table;  iDb = pTab->iDb;  zDb = db->aDb[iDb].zName;  /* Get a NULL terminated version of the new table name. */  zName = sqlite3NameFromToken(pName);  if( !zName ) goto exit_rename_table;  /* Check that a table or index named 'zName' does not already exist  ** in database iDb. If so, this is an error.  */  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){    sqlite3ErrorMsg(pParse,         "there is already another table or index with this name: %s", zName);    goto exit_rename_table;  }  /* Make sure it is not a system table being altered, or a reserved name  ** that the table is being renamed to.  */  if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){    sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);    goto exit_rename_table;  }  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){    goto exit_rename_table;  }#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    goto exit_rename_table;  }#endif  /* Begin a transaction and code the VerifyCookie for database iDb.   ** Then modify the schema cookie (since the ALTER TABLE modifies the  ** schema).  */  v = sqlite3GetVdbe(pParse);  if( v==0 ){    goto exit_rename_table;  }  sqlite3BeginWriteOperation(pParse, 0, iDb);  sqlite3ChangeCookie(db, v, iDb);  /* Modify the sqlite_master table to use the new table name. */  sqlite3NestedParse(pParse,      "UPDATE %Q.%s SET "#ifdef SQLITE_OMIT_TRIGGER          "sql = sqlite_rename_table(sql, %Q), "#else          "sql = CASE "            "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)"            "ELSE sqlite_rename_table(sql, %Q) END, "#endif          "tbl_name = %Q, "          "name = CASE "            "WHEN type='table' THEN %Q "            "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN "              "'sqlite_autoindex_' || %Q || substr(name, %d+18,10) "            "ELSE name END "      "WHERE tbl_name=%Q AND "          "(type='table' OR type='index' OR type='trigger');",       zDb, SCHEMA_TABLE(iDb), zName, zName, zName, #ifndef SQLITE_OMIT_TRIGGER      zName,#endif      zName, strlen(pTab->zName), pTab->zName  );#ifndef SQLITE_OMIT_AUTOINCREMENT  /* If the sqlite_sequence table exists in this database, then update   ** it with the new table name.  */  if( sqlite3FindTable(db, "sqlite_sequence", zDb) ){    sqlite3NestedParse(pParse,//.........这里部分代码省略.........
开发者ID:stephen-hill,项目名称:musicCube,代码行数:101,


示例22: sqlcipher_codec_pragma

//.........这里部分代码省略.........    }  }else  if( sqlite3StrICmp(zLeft, "fast_kdf_iter")==0){    if(ctx) {      if( zRight ) {        sqlcipher_codec_ctx_set_fast_kdf_iter(ctx, atoi(zRight), 2); // change of RW PBKDF2 iteration       } else {        char *fast_kdf_iter = sqlite3_mprintf("%d", sqlcipher_codec_ctx_get_fast_kdf_iter(ctx, 2));        codec_vdbe_return_static_string(pParse, "fast_kdf_iter", fast_kdf_iter);        sqlite3_free(fast_kdf_iter);      }    }  }else  if( sqlite3StrICmp(zLeft, "rekey_kdf_iter")==0 && zRight ){    if(ctx) sqlcipher_codec_ctx_set_kdf_iter(ctx, atoi(zRight), 1); // write iterations only  }else  if( sqlite3StrICmp(zLeft,"cipher_page_size")==0 ){    if(ctx) {      if( zRight ) {        int size = atoi(zRight);        rc = sqlcipher_codec_ctx_set_pagesize(ctx, size);        if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);        rc = codec_set_btree_to_codec_pagesize(db, pDb, ctx);        if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);      } else {        char * page_size = sqlite3_mprintf("%d", sqlcipher_codec_ctx_get_pagesize(ctx));        codec_vdbe_return_static_string(pParse, "cipher_page_size", page_size);        sqlite3_free(page_size);      }    }  }else  if( sqlite3StrICmp(zLeft,"cipher_default_use_hmac")==0 ){    if( zRight ) {      sqlcipher_set_default_use_hmac(sqlite3GetBoolean(zRight,1));    } else {      char *default_use_hmac = sqlite3_mprintf("%d", sqlcipher_get_default_use_hmac());      codec_vdbe_return_static_string(pParse, "cipher_default_use_hmac", default_use_hmac);      sqlite3_free(default_use_hmac);    }  }else  if( sqlite3StrICmp(zLeft,"cipher_use_hmac")==0 ){    if(ctx) {      if( zRight ) {        rc = sqlcipher_codec_ctx_set_use_hmac(ctx, sqlite3GetBoolean(zRight,1));        if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);        /* since the use of hmac has changed, the page size may also change */        rc = codec_set_btree_to_codec_pagesize(db, pDb, ctx);        if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);      } else {        char *hmac_flag = sqlite3_mprintf("%d", sqlcipher_codec_ctx_get_use_hmac(ctx, 2));        codec_vdbe_return_static_string(pParse, "cipher_use_hmac", hmac_flag);        sqlite3_free(hmac_flag);      }    }  }else  if( sqlite3StrICmp(zLeft,"cipher_hmac_pgno")==0 ){    if(ctx) {      if(zRight) {        // clear both pgno endian flags        if(sqlite3StrICmp(zRight, "le") == 0) {          sqlcipher_codec_ctx_unset_flag(ctx, CIPHER_FLAG_BE_PGNO);          sqlcipher_codec_ctx_set_flag(ctx, CIPHER_FLAG_LE_PGNO);        } else if(sqlite3StrICmp(zRight, "be") == 0) {          sqlcipher_codec_ctx_unset_flag(ctx, CIPHER_FLAG_LE_PGNO);          sqlcipher_codec_ctx_set_flag(ctx, CIPHER_FLAG_BE_PGNO);        } else if(sqlite3StrICmp(zRight, "native") == 0) {          sqlcipher_codec_ctx_unset_flag(ctx, CIPHER_FLAG_LE_PGNO);          sqlcipher_codec_ctx_unset_flag(ctx, CIPHER_FLAG_BE_PGNO);        }      } else {        if(sqlcipher_codec_ctx_get_flag(ctx, CIPHER_FLAG_LE_PGNO, 2)) {          codec_vdbe_return_static_string(pParse, "cipher_hmac_pgno", "le");        } else if(sqlcipher_codec_ctx_get_flag(ctx, CIPHER_FLAG_BE_PGNO, 2)) {          codec_vdbe_return_static_string(pParse, "cipher_hmac_pgno", "be");        } else {          codec_vdbe_return_static_string(pParse, "cipher_hmac_pgno", "native");        }      }    }  }else  if( sqlite3StrICmp(zLeft,"cipher_hmac_salt_mask")==0 ){    if(ctx) {      if(zRight) {        if (sqlite3StrNICmp(zRight ,"x'", 2) == 0 && sqlite3Strlen30(zRight) == 5) {          unsigned char mask = 0;          const unsigned char *hex = (const unsigned char *)zRight+2;          cipher_hex2bin(hex,2,&mask);          sqlcipher_set_hmac_salt_mask(mask);        }      } else {          char *hmac_salt_mask = sqlite3_mprintf("%02x", sqlcipher_get_hmac_salt_mask());          codec_vdbe_return_static_string(pParse, "cipher_hmac_salt_mask", hmac_salt_mask);          sqlite3_free(hmac_salt_mask);      }    }  }else {    return 0;  }  return 1;}
开发者ID:CoderXL,项目名称:sqlcipher,代码行数:101,


示例23: sqlite3AlterRenameTable

/*** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy" ** command. */void sqlite3AlterRenameTable(  Parse *pParse,            /* Parser context. */  SrcList *pSrc,            /* The table to rename. */  Token *pName              /* The new table name. */){  int iDb;                  /* Database that contains the table */  char *zDb;                /* Name of database iDb */  Table *pTab;              /* Table being renamed */  char *zName = 0;          /* NULL-terminated version of pName */   sqlite3 *db = pParse->db; /* Database connection */  int nTabName;             /* Number of UTF-8 characters in zTabName */  const char *zTabName;     /* Original name of the table */  Vdbe *v;#ifndef SQLITE_OMIT_TRIGGER  char *zWhere = 0;         /* Where clause to locate temp triggers */#endif  int isVirtualRename = 0;  /* True if this is a v-table with an xRename() */    if( sqlite3MallocFailed() ) goto exit_rename_table;  assert( pSrc->nSrc==1 );  pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);  if( !pTab ) goto exit_rename_table;  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);  zDb = db->aDb[iDb].zName;  /* Get a NULL terminated version of the new table name. */  zName = sqlite3NameFromToken(pName);  if( !zName ) goto exit_rename_table;  /* Check that a table or index named 'zName' does not already exist  ** in database iDb. If so, this is an error.  */  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){    sqlite3ErrorMsg(pParse,         "there is already another table or index with this name: %s", zName);    goto exit_rename_table;  }  /* Make sure it is not a system table being altered, or a reserved name  ** that the table is being renamed to.  */  if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){    sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);    goto exit_rename_table;  }  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){    goto exit_rename_table;  }#ifndef SQLITE_OMIT_AUTHORIZATION  /* Invoke the authorization callback. */  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){    goto exit_rename_table;  }#endif#ifndef SQLITE_OMIT_VIRTUALTABLE  if( sqlite3ViewGetColumnNames(pParse, pTab) ){    goto exit_rename_table;  }  if( IsVirtual(pTab) && pTab->pMod->pModule->xRename ){    isVirtualRename = 1;  }#endif  /* Begin a transaction and code the VerifyCookie for database iDb.   ** Then modify the schema cookie (since the ALTER TABLE modifies the  ** schema). Open a statement transaction if the table is a virtual  ** table.  */  v = sqlite3GetVdbe(pParse);  if( v==0 ){    goto exit_rename_table;  }  sqlite3BeginWriteOperation(pParse, isVirtualRename, iDb);  sqlite3ChangeCookie(db, v, iDb);  /* If this is a virtual table, invoke the xRename() function if  ** one is defined. The xRename() callback will modify the names  ** of any resources used by the v-table implementation (including other  ** SQLite tables) that are identified by the name of the virtual table.  */#ifndef SQLITE_OMIT_VIRTUALTABLE  if( isVirtualRename ){    sqlite3VdbeOp3(v, OP_String8, 0, 0, zName, 0);    sqlite3VdbeOp3(v, OP_VRename, 0, 0, (const char*)pTab->pVtab, P3_VTAB);  }#endif  /* figure out how many UTF-8 characters are in zName */  zTabName = pTab->zName;  nTabName = sqlite3Utf8CharLen(zTabName, -1);  /* Modify the sqlite_master table to use the new table name. */  sqlite3NestedParse(pParse,//.........这里部分代码省略.........
开发者ID:3rdexp,项目名称:jezzitest,代码行数:101,


示例24: strCompare

static int strCompare(const void *pKey1, int n1, const void *pKey2, int n2){  if( n1!=n2 ) return 1;  return sqlite3StrNICmp((const char*)pKey1,(const char*)pKey2,n1);}
开发者ID:kfengbest,项目名称:GenericDB,代码行数:4,


示例25: vtabCallConstructor

/*** Invoke a virtual table constructor (either xCreate or xConnect). The** pointer to the function to invoke is passed as the fourth parameter** to this procedure.*/static int vtabCallConstructor(  sqlite3 *db,   Table *pTab,  Module *pMod,  int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),  char **pzErr){  VtabCtx sCtx;  VTable *pVTable;  int rc;  const char *const*azArg = (const char *const*)pTab->azModuleArg;  int nArg = pTab->nModuleArg;  char *zErr = 0;  char *zModuleName;  int iDb;  VtabCtx *pCtx;  /* Check that the virtual-table is not already being initialized */  for(pCtx=db->pVtabCtx; pCtx; pCtx=pCtx->pPrior){    if( pCtx->pTab==pTab ){      *pzErr = sqlite3MPrintf(db,           "vtable constructor called recursively: %s", pTab->zName      );      return SQLITE_LOCKED;    }  }  zModuleName = sqlite3MPrintf(db, "%s", pTab->zName);  if( !zModuleName ){    return SQLITE_NOMEM_BKPT;  }  pVTable = sqlite3DbMallocZero(db, sizeof(VTable));  if( !pVTable ){    sqlite3DbFree(db, zModuleName);    return SQLITE_NOMEM_BKPT;  }  pVTable->db = db;  pVTable->pMod = pMod;  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);  pTab->azModuleArg[1] = db->aDb[iDb].zDbSName;  /* Invoke the virtual table constructor */  assert( &db->pVtabCtx );  assert( xConstruct );  sCtx.pTab = pTab;  sCtx.pVTable = pVTable;  sCtx.pPrior = db->pVtabCtx;  sCtx.bDeclared = 0;  db->pVtabCtx = &sCtx;  rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);  db->pVtabCtx = sCtx.pPrior;  if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);  assert( sCtx.pTab==pTab );  if( SQLITE_OK!=rc ){    if( zErr==0 ){      *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);    }else {      *pzErr = sqlite3MPrintf(db, "%s", zErr);      sqlite3_free(zErr);    }    sqlite3DbFree(db, pVTable);  }else if( ALWAYS(pVTable->pVtab) ){    /* Justification of ALWAYS():  A correct vtab constructor must allocate    ** the sqlite3_vtab object if successful.  */    memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));    pVTable->pVtab->pModule = pMod->pModule;    pVTable->nRef = 1;    if( sCtx.bDeclared==0 ){      const char *zFormat = "vtable constructor did not declare schema: %s";      *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);      sqlite3VtabUnlock(pVTable);      rc = SQLITE_ERROR;    }else{      int iCol;      u8 oooHidden = 0;      /* If everything went according to plan, link the new VTable structure      ** into the linked list headed by pTab->pVTable. Then loop through the       ** columns of the table to see if any of them contain the token "hidden".      ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from      ** the type string.  */      pVTable->pNext = pTab->pVTable;      pTab->pVTable = pVTable;      for(iCol=0; iCol<pTab->nCol; iCol++){        char *zType = sqlite3ColumnType(&pTab->aCol[iCol], "");        int nType;        int i = 0;        nType = sqlite3Strlen30(zType);        for(i=0; i<nType; i++){          if( 0==sqlite3StrNICmp("hidden", &zType[i], 6)           && (i==0 || zType[i-1]==' ')           && (zType[i+6]=='/0' || zType[i+6]==' ')//.........这里部分代码省略.........
开发者ID:wangyiran126,项目名称:sqlite,代码行数:101,


示例26: vtabCallConstructor

/*** Invoke a virtual table constructor (either xCreate or xConnect). The** pointer to the function to invoke is passed as the fourth parameter** to this procedure.*/static int vtabCallConstructor(  sqlite3 *db,   Table *pTab,  Module *pMod,  int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),  char **pzErr){  int rc;  int rc2;  sqlite3_vtab *pVtab = 0;  const char *const*azArg = (const char *const*)pTab->azModuleArg;  int nArg = pTab->nModuleArg;  char *zErr = 0;  char *zModuleName = sqlite3MPrintf(db, "%s", pTab->zName);  if( !zModuleName ){    return SQLITE_NOMEM;  }  assert( !db->pVTab );  assert( xConstruct );  db->pVTab = pTab;  rc = sqlite3SafetyOff(db);  assert( rc==SQLITE_OK );  rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVtab, &zErr);  rc2 = sqlite3SafetyOn(db);  if( rc==SQLITE_OK && pVtab ){    pVtab->pModule = pMod->pModule;    pVtab->nRef = 1;    pTab->pVtab = pVtab;  }  if( SQLITE_OK!=rc ){    if( zErr==0 ){      *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);    }else {      *pzErr = sqlite3MPrintf(db, "%s", zErr);      sqlite3_free(zErr);    }  }else if( db->pVTab ){    const char *zFormat = "vtable constructor did not declare schema: %s";    *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);    rc = SQLITE_ERROR;  }   if( rc==SQLITE_OK ){    rc = rc2;  }  db->pVTab = 0;  sqlite3_free(zModuleName);  /* If everything went according to plan, loop through the columns  ** of the table to see if any of them contain the token "hidden".  ** If so, set the Column.isHidden flag and remove the token from  ** the type string.  */  if( rc==SQLITE_OK ){    int iCol;    for(iCol=0; iCol<pTab->nCol; iCol++){      char *zType = pTab->aCol[iCol].zType;      int nType;      int i = 0;      if( !zType ) continue;      nType = strlen(zType);      if( sqlite3StrNICmp("hidden", zType, 6) || (zType[6] && zType[6]!=' ') ){        for(i=0; i<nType; i++){          if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))           && (zType[i+7]=='/0' || zType[i+7]==' ')          ){            i++;            break;          }        }      }      if( i<nType ){        int j;        int nDel = 6 + (zType[i+6] ? 1 : 0);        for(j=i; (j+nDel)<=nType; j++){          zType[j] = zType[j+nDel];        }        if( zType[i]=='/0' && i>0 ){          assert(zType[i-1]==' ');          zType[i-1] = '/0';        }        pTab->aCol[iCol].isHidden = 1;      }    }  }  return rc;}
开发者ID:berte,项目名称:mediaplayer,代码行数:95,



注:本文中的sqlite3StrNICmp函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ sqlite3Strlen30函数代码示例
C++ sqlite3StrICmp函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。