Lines Matching defs:pCur
3433 series_cursor *pCur;
3435 pCur = sqlite3_malloc( sizeof(*pCur) );
3436 if( pCur==0 ) return SQLITE_NOMEM;
3437 memset(pCur, 0, sizeof(*pCur));
3438 *ppCursor = &pCur->base;
3455 series_cursor *pCur = (series_cursor*)cur;
3456 if( pCur->isDesc ){
3457 pCur->iValue -= pCur->iStep;
3459 pCur->iValue += pCur->iStep;
3461 pCur->iRowid++;
3474 series_cursor *pCur = (series_cursor*)cur;
3477 case SERIES_COLUMN_START: x = pCur->mnValue; break;
3478 case SERIES_COLUMN_STOP: x = pCur->mxValue; break;
3479 case SERIES_COLUMN_STEP: x = pCur->iStep; break;
3480 default: x = pCur->iValue; break;
3492 series_cursor *pCur = (series_cursor*)cur;
3493 *pRowid = pCur->iRowid;
3502 series_cursor *pCur = (series_cursor*)cur;
3503 if( pCur->isDesc ){
3504 return pCur->iValue < pCur->mnValue;
3506 return pCur->iValue > pCur->mxValue;
3545 series_cursor *pCur = (series_cursor *)pVtabCursor;
3549 pCur->mnValue = sqlite3_value_int64(argv[i++]);
3551 pCur->mnValue = 0;
3554 pCur->mxValue = sqlite3_value_int64(argv[i++]);
3556 pCur->mxValue = 0xffffffff;
3559 pCur->iStep = sqlite3_value_int64(argv[i++]);
3560 if( pCur->iStep==0 ){
3561 pCur->iStep = 1;
3562 }else if( pCur->iStep<0 ){
3563 pCur->iStep = -pCur->iStep;
3567 pCur->iStep = 1;
3573 pCur->mnValue = 1;
3574 pCur->mxValue = 0;
3579 pCur->isDesc = 1;
3580 pCur->iValue = pCur->mxValue;
3581 if( pCur->iStep>0 ){
3582 pCur->iValue -= (pCur->mxValue - pCur->mnValue)%pCur->iStep;
3585 pCur->isDesc = 0;
3586 pCur->iValue = pCur->mnValue;
3588 pCur->iRowid = 1;
5259 fsdir_cursor *pCur;
5261 pCur = sqlite3_malloc( sizeof(*pCur) );
5262 if( pCur==0 ) return SQLITE_NOMEM;
5263 memset(pCur, 0, sizeof(*pCur));
5264 pCur->iLvl = -1;
5265 *ppCursor = &pCur->base;
5273 static void fsdirResetCursor(fsdir_cursor *pCur){
5275 for(i=0; i<=pCur->iLvl; i++){
5276 FsdirLevel *pLvl = &pCur->aLvl[i];
5280 sqlite3_free(pCur->zPath);
5281 sqlite3_free(pCur->aLvl);
5282 pCur->aLvl = 0;
5283 pCur->zPath = 0;
5284 pCur->zBase = 0;
5285 pCur->nBase = 0;
5286 pCur->nLvl = 0;
5287 pCur->iLvl = -1;
5288 pCur->iRowid = 1;
5295 fsdir_cursor *pCur = (fsdir_cursor*)cur;
5297 fsdirResetCursor(pCur);
5298 sqlite3_free(pCur);
5304 ** pCur to the results of vprintf(zFmt, ...).
5306 static void fsdirSetErrmsg(fsdir_cursor *pCur, const char *zFmt, ...){
5309 pCur->base.pVtab->zErrMsg = sqlite3_vmprintf(zFmt, ap);
5318 fsdir_cursor *pCur = (fsdir_cursor*)cur;
5319 mode_t m = pCur->sStat.st_mode;
5321 pCur->iRowid++;
5324 int iNew = pCur->iLvl + 1;
5326 if( iNew>=pCur->nLvl ){
5329 FsdirLevel *aNew = (FsdirLevel*)sqlite3_realloc64(pCur->aLvl, nByte);
5331 memset(&aNew[pCur->nLvl], 0, sizeof(FsdirLevel)*(nNew-pCur->nLvl));
5332 pCur->aLvl = aNew;
5333 pCur->nLvl = nNew;
5335 pCur->iLvl = iNew;
5336 pLvl = &pCur->aLvl[iNew];
5338 pLvl->zDir = pCur->zPath;
5339 pCur->zPath = 0;
5342 fsdirSetErrmsg(pCur, "cannot read directory: %s", pCur->zPath);
5347 while( pCur->iLvl>=0 ){
5348 FsdirLevel *pLvl = &pCur->aLvl[pCur->iLvl];
5355 sqlite3_free(pCur->zPath);
5356 pCur->zPath = sqlite3_mprintf("%s/%s", pLvl->zDir, pEntry->d_name);
5357 if( pCur->zPath==0 ) return SQLITE_NOMEM;
5358 if( fileLinkStat(pCur->zPath, &pCur->sStat) ){
5359 fsdirSetErrmsg(pCur, "cannot stat file: %s", pCur->zPath);
5368 pCur->iLvl--;
5372 sqlite3_free(pCur->zPath);
5373 pCur->zPath = 0;
5386 fsdir_cursor *pCur = (fsdir_cursor*)cur;
5389 sqlite3_result_text(ctx, &pCur->zPath[pCur->nBase], -1, SQLITE_TRANSIENT);
5394 sqlite3_result_int64(ctx, pCur->sStat.st_mode);
5398 sqlite3_result_int64(ctx, pCur->sStat.st_mtime);
5402 mode_t m = pCur->sStat.st_mode;
5413 n = readlink(pCur->zPath, aBuf, nBuf);
5428 readFileContents(ctx, pCur->zPath);
5447 fsdir_cursor *pCur = (fsdir_cursor*)cur;
5448 *pRowid = pCur->iRowid;
5457 fsdir_cursor *pCur = (fsdir_cursor*)cur;
5458 return (pCur->zPath==0);
5473 fsdir_cursor *pCur = (fsdir_cursor*)cur;
5475 fsdirResetCursor(pCur);
5478 fsdirSetErrmsg(pCur, "table function fsdir requires an argument");
5485 fsdirSetErrmsg(pCur, "table function fsdir requires a non-NULL argument");
5489 pCur->zBase = (const char*)sqlite3_value_text(argv[1]);
5491 if( pCur->zBase ){
5492 pCur->nBase = (int)strlen(pCur->zBase)+1;
5493 pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zBase, zDir);
5495 pCur->zPath = sqlite3_mprintf("%s", zDir);
5498 if( pCur->zPath==0 ){
5501 if( fileLinkStat(pCur->zPath, &pCur->sStat) ){
5502 fsdirSetErrmsg(pCur, "cannot stat file: %s", pCur->zPath);
5813 completion_cursor *pCur;
5814 pCur = sqlite3_malloc( sizeof(*pCur) );
5815 if( pCur==0 ) return SQLITE_NOMEM;
5816 memset(pCur, 0, sizeof(*pCur));
5817 pCur->db = ((completion_vtab*)p)->db;
5818 *ppCursor = &pCur->base;
5825 static void completionCursorReset(completion_cursor *pCur){
5826 sqlite3_free(pCur->zPrefix); pCur->zPrefix = 0; pCur->nPrefix = 0;
5827 sqlite3_free(pCur->zLine); pCur->zLine = 0; pCur->nLine = 0;
5828 sqlite3_finalize(pCur->pStmt); pCur->pStmt = 0;
5829 pCur->j = 0;
5856 completion_cursor *pCur = (completion_cursor*)cur;
5858 int iCol = -1; /* If >=0, step pCur->pStmt and use the i-th column */
5859 pCur->iRowid++;
5860 while( pCur->ePhase!=COMPLETION_EOF ){
5861 switch( pCur->ePhase ){
5863 if( pCur->j >= sqlite3_keyword_count() ){
5864 pCur->zCurrentRow = 0;
5865 pCur->ePhase = COMPLETION_DATABASES;
5867 sqlite3_keyword_name(pCur->j++, &pCur->zCurrentRow, &pCur->szRow);
5873 if( pCur->pStmt==0 ){
5874 sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1,
5875 &pCur->pStmt, 0);
5882 if( pCur->pStmt==0 ){
5886 sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
5898 sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
5906 if( pCur->pStmt==0 ){
5910 sqlite3_prepare_v2(pCur->db, "PRAGMA database_list", -1, &pS2, 0);
5924 sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);
5934 if( pCur->zCurrentRow==0 ) continue;
5936 if( sqlite3_step(pCur->pStmt)==SQLITE_ROW ){
5938 pCur->zCurrentRow = (const char*)sqlite3_column_text(pCur->pStmt, iCol);
5939 pCur->szRow = sqlite3_column_bytes(pCur->pStmt, iCol);
5942 sqlite3_finalize(pCur->pStmt);
5943 pCur->pStmt = 0;
5944 pCur->ePhase = eNextPhase;
5948 if( pCur->nPrefix==0 ) break;
5949 if( pCur->nPrefix<=pCur->szRow
5950 && sqlite3_strnicmp(pCur->zPrefix, pCur->zCurrentRow, pCur->nPrefix)==0
5968 completion_cursor *pCur = (completion_cursor*)cur;
5971 sqlite3_result_text(ctx, pCur->zCurrentRow, pCur->szRow,SQLITE_TRANSIENT);
5975 sqlite3_result_text(ctx, pCur->zPrefix, -1, SQLITE_TRANSIENT);
5979 sqlite3_result_text(ctx, pCur->zLine, -1, SQLITE_TRANSIENT);
5983 sqlite3_result_int(ctx, pCur->ePhase);
5995 completion_cursor *pCur = (completion_cursor*)cur;
5996 *pRowid = pCur->iRowid;
6005 completion_cursor *pCur = (completion_cursor*)cur;
6006 return pCur->ePhase >= COMPLETION_EOF;
6020 completion_cursor *pCur = (completion_cursor *)pVtabCursor;
6024 completionCursorReset(pCur);
6026 pCur->nPrefix = sqlite3_value_bytes(argv[iArg]);
6027 if( pCur->nPrefix>0 ){
6028 pCur->zPrefix = sqlite3_mprintf("%s", sqlite3_value_text(argv[iArg]));
6029 if( pCur->zPrefix==0 ) return SQLITE_NOMEM;
6034 pCur->nLine = sqlite3_value_bytes(argv[iArg]);
6035 if( pCur->nLine>0 ){
6036 pCur->zLine = sqlite3_mprintf("%s", sqlite3_value_text(argv[iArg]));
6037 if( pCur->zLine==0 ) return SQLITE_NOMEM;
6040 if( pCur->zLine!=0 && pCur->zPrefix==0 ){
6041 int i = pCur->nLine;
6042 while( i>0 && (isalnum(pCur->zLine[i-1]) || pCur->zLine[i-1]=='_') ){
6045 pCur->nPrefix = pCur->nLine - i;
6046 if( pCur->nPrefix>0 ){
6047 pCur->zPrefix = sqlite3_mprintf("%.*s", pCur->nPrefix, pCur->zLine + i);
6048 if( pCur->zPrefix==0 ) return SQLITE_NOMEM;
6051 pCur->iRowid = 0;
6052 pCur->ePhase = COMPLETION_FIRST_PHASE;