RichTxt& RichTxt::GetTableUpdateText(int table, const RichStyles& style, int& pi) { Invalidate(); for(int i = 0;; i++) if(IsTable(i)) { table--; RichTable& tab = part[i].Get<RichTable>(); if(table <= tab.GetTableCount()) { SetRefresh(i); if(table == 0) { pi = i; return *this; } for(int i = 0; i < tab.GetRows(); i++) for(int j = 0; j < tab.GetColumns(); j++) if(tab(i, j)) { RichTxt& txt = tab[i][j].text; if(table <= txt.GetTableCount()) { tab.InvalidateRefresh(i, j); return txt.GetTableUpdateText(table, style, pi); } table -= txt.GetTableCount(); } NEVER(); } else table -= tab.GetTableCount(); } NEVER(); }
/* Called by: */ int zxbus_login_subj_hash(struct hi_thr* hit, struct hi_io* io, unsigned long subj_hash) { struct hi_ent* ent; char* p; char* eid; char buf[1024]; if (!read_all(sizeof(buf), buf, "ClientTLS login", 1, "%s" ZXID_UID_DIR "/%lu/.bs/.at", zxbus_path, subj_hash)) { ERR("Login by ClienTLS failed subj_hash(%lu). No such uid.", subj_hash); return 0; } if (!(eid = strstr(buf, "eid: "))) { ERR("Login by ClienTLS failed subj_hash(%lu). .bs/.at file does not specify eid", subj_hash); return 0; } eid += sizeof("eid: ")-1; if (p = strchr(eid, '\n')) *p = 0; LOCK(hit->shf->ent_mut, "subj_hash"); D("LOCK ent_mut->thr=%x (%s:%d)", hit->shf->ent_mut.thr, hit->shf->ent_mut.func, hit->shf->ent_mut.line); if (!(ent = zxbus_load_ent(hit->shf, -1, eid))) { if (hit->shf->anonlogin) { ent = zxbus_new_ent(hit->shf, -1, eid); INFO("Anon login eid(%s)", ent->eid); /* *** consider persisting the newly created account */ } else { D("UNLOCK ent_mut->thr=%x (%s:%d)", hit->shf->ent_mut.thr, hit->shf->ent_mut.func, hit->shf->ent_mut.line); UNLOCK(hit->shf->ent_mut, "subj_hash-fail"); ERR("Login account(%s) does not exist and no anon login", eid); return 0; } } if (ent->io) { if (ent->io == io) { NEVER("Entity has io already set to current io_%p", io); } else { NEVER("Entity has io already set to different io_%p", ent->io); } } ent->io = io; LOCK(io->qel.mut, "subj_hash"); D("LOCK io(%x)->qel.mut->thr=%x (%s:%d)", io->qel.mut.thr, io->qel.mut.func, io->qel.mut.line); if (io->ent) { if (io->ent == ent) { NEVER("io has ent already set to current ent_%p", ent); } else { NEVER("io has ent already set to different ent_%p", ent); } } io->ent = ent; D("UNLOCK io(%x)->qel.mut->thr=%x (%s:%d)", io->qel.mut.thr, io->qel.mut.func, io->qel.mut.line); UNLOCK(io->qel.mut, "subj_hash"); D("UNLOCK ent_mut->thr=%x (%s:%d)", hit->shf->ent_mut.thr, hit->shf->ent_mut.func, hit->shf->ent_mut.line); UNLOCK(hit->shf->ent_mut, "subj_hash"); return 1; }
/* ** The first parameter (pDef) is a function implementation. The ** second parameter (pExpr) is the first argument to this function. ** If pExpr is a column in a virtual table, then let the virtual ** table implementation have an opportunity to overload the function. ** ** This routine is used to allow virtual table implementations to ** overload MATCH, LIKE, GLOB, and REGEXP operators. ** ** Return either the pDef argument (indicating no change) or a ** new FuncDef structure that is marked as ephemeral using the ** SQLITE_FUNC_EPHEM flag. */ FuncDef *sqlite3VtabOverloadFunction( sqlite3 *db, /* Database connection for reporting malloc problems */ FuncDef *pDef, /* Function to possibly overload */ int nArg, /* Number of arguments to the function */ Expr *pExpr /* First argument to the function */ ){ Table *pTab; sqlite3_vtab *pVtab; sqlite3_module *pMod; void (*xSFunc)(sqlite3_context*,int,sqlite3_value**) = 0; void *pArg = 0; FuncDef *pNew; int rc = 0; char *zLowerName; unsigned char *z; /* Check to see the left operand is a column in a virtual table */ if( NEVER(pExpr==0) ) return pDef; if( pExpr->op!=TK_COLUMN ) return pDef; pTab = pExpr->pTab; if( NEVER(pTab==0) ) return pDef; if( (pTab->tabFlags & TF_Virtual)==0 ) return pDef; pVtab = sqlite3GetVTable(db, pTab)->pVtab; assert( pVtab!=0 ); assert( pVtab->pModule!=0 ); pMod = (sqlite3_module *)pVtab->pModule; if( pMod->xFindFunction==0 ) return pDef; /* Call the xFindFunction method on the virtual table implementation ** to see if the implementation wants to overload this function */ zLowerName = sqlite3DbStrDup(db, pDef->zName); if( zLowerName ){ for(z=(unsigned char*)zLowerName; *z; z++){ *z = sqlite3UpperToLower[*z]; } rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xSFunc, &pArg); sqlite3DbFree(db, zLowerName); } if( rc==0 ){ return pDef; } /* Create a new ephemeral function definition for the overloaded ** function */ pNew = sqlite3DbMallocZero(db, sizeof(*pNew) + sqlite3Strlen30(pDef->zName) + 1); if( pNew==0 ){ return pDef; } *pNew = *pDef; pNew->zName = (const char*)&pNew[1]; memcpy((char*)&pNew[1], pDef->zName, sqlite3Strlen30(pDef->zName)+1); pNew->xSFunc = xSFunc; pNew->pUserData = pArg; pNew->funcFlags |= SQLITE_FUNC_EPHEM; return pNew; }
/* ** The following set of routines walk through the parse tree and assign ** a specific database to all table references where the database name ** was left unspecified in the original SQL statement. The pFix structure ** must have been initialized by a prior call to sqlite3FixInit(). ** ** These routines are used to make sure that an index, trigger, or ** view in one database does not refer to objects in a different database. ** (Exception: indices, triggers, and views in the TEMP database are ** allowed to refer to anything.) If a reference is explicitly made ** to an object in a different database, an error message is added to ** pParse->zErrMsg and these routines return non-zero. If everything ** checks out, these routines return 0. */ int sqlite3FixSrcList( DbFixer *pFix, /* Context of the fixation */ SrcList *pList /* The Source list to check and modify */ ){ int i; const char *zDb; struct SrcList_item *pItem; if( NEVER(pList==0) ) return 0; zDb = pFix->zDb; for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ if( pFix->bVarOnly==0 ){ if( pItem->zDatabase && sqlite3StrICmp(pItem->zDatabase, zDb) ){ sqlite3ErrorMsg(pFix->pParse, "%s %T cannot reference objects in database %s", pFix->zType, pFix->pName, pItem->zDatabase); return 1; } sqlite3DbFree(pFix->pParse->db, pItem->zDatabase); pItem->zDatabase = 0; pItem->pSchema = pFix->pSchema; } #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1; if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1; #endif if( pItem->fg.isTabFunc && sqlite3FixExprList(pFix, pItem->u1.pFuncArg) ){ return 1; } } return 0; }
IconDes::Slot& IconDes::Current() { if(ilist.IsCursor()) return slot[ilist.GetKey()]; NEVER(); return dummy; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // gets rectangular bounding box of marker Rect Marker::GetBoundingBox() const { switch(kind) { case EmptyMarker: return Rect(0, 0, 0, 0); case RectMarker: return Rect(points[0], points[1]); case PolyMarker: { int minX = INT_MAX; int maxX = INT_MIN; int minY = INT_MAX; int maxY = INT_MIN; for(int i = 0; i < points.GetCount(); i++) { Point p = points[i]; if(p.x < minX) minX = p.x; if(p.x > maxX) maxX = p.x; if(p.y < minY) minY = p.y; if(p.y > maxY) maxY = p.y; } return Rect(minX, minY, maxX, maxY); } default: NEVER(); } }
const char *StrToDate(const char *fmt, Date& d, const char *s, Date def) { if(*s == 0) { d = Null; return s; } d = Nvl(def, GetSysDate()); while(*fmt) { while(*s && !IsDigit(*s) && !IsAlpha(*s) && (byte)*s < 128) s++; int n; if(IsDigit(*s)) { char *q; n = strtoul(s, &q, 10); s = q; } else if(IsAlpha(*s) || (byte)*s >= 128) { if(*fmt != 'm') return NULL; String m; while(IsAlpha(*s) || (byte)*s >= 128) m.Cat(*s++); m = ToUpper(m); for(int i = 0; i < 12; i++) if(m == ToUpper(MonthName(i)) || m == ToUpper(MonName(i))) { n = i + 1; goto found; } return NULL; found: ; } else break; switch(*fmt) { case 'd': if(n < 1 || n > 31) return NULL; d.day = n; break; case 'm': if(n < 1 || n > 12) return NULL; d.month = n; break; case 'y': d.year = n; if(d.year < 25) d.year += 2000; // Check again in 2020.... // TODO: Make this automatic else if(d.year < 100) d.year += 1900; break; default: NEVER(); } fmt++; } return d.IsValid() ? s : NULL; }
RichTable& RichTxt::GetTable0(int table, bool update) { if(update) Invalidate(); for(int i = 0;; i++) if(IsTable(i)) { table--; RichTable& tab = part[i].Get<RichTable>(); if(table <= tab.GetTableCount()) { if(update) SetRefresh(i); if(table == 0) return tab; for(int i = 0; i < tab.GetRows(); i++) for(int j = 0; j < tab.GetColumns(); j++) if(tab(i, j)) { RichTxt& txt = tab[i][j].text; if(table <= txt.GetTableCount()) { if(update) tab.InvalidateRefresh(i, j); return txt.GetTable0(table, update); } table -= txt.GetTableCount(); } NEVER(); } else table -= tab.GetTableCount(); } }
/* ** pExpr points to an expression which implements a function. If ** it is appropriate to apply the LIKE optimization to that function ** then set aWc[0] through aWc[2] to the wildcard characters and ** return TRUE. If the function is not a LIKE-style function then ** return FALSE. */ int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){ FuncDef *pDef; if( pExpr->op!=TK_FUNCTION || !pExpr->x.pList || pExpr->x.pList->nExpr!=2 ){ return 0; } assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); pDef = sqlite3FindFunction(db, pExpr->u.zToken, sqlite3Strlen30(pExpr->u.zToken), 2, SQLITE_UTF8, 0); if( NEVER(pDef==0) || (pDef->flags & SQLITE_FUNC_LIKE)==0 ){ return 0; } /* The memcpy() statement assumes that the wildcard characters are ** the first three statements in the compareInfo structure. The ** asserts() that follow verify that assumption */ memcpy(aWc, pDef->pUserData, 3); assert( (char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll ); assert( &((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne ); assert( &((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet ); *pIsNocase = (pDef->flags & SQLITE_FUNC_CASE)==0; return 1; }
static PgHdr *pcacheSortDirtyList(PgHdr *pIn){ PgHdr *a[N_SORT_BUCKET], *p; int i; memset(a, 0, sizeof(a)); while( pIn ){ p = pIn; pIn = p->pDirty; p->pDirty = 0; for(i=0; ALWAYS(i<N_SORT_BUCKET-1); i++){ if( a[i]==0 ){ a[i] = p; break; }else{ p = pcacheMergeDirtyList(a[i], p); a[i] = 0; } } if( NEVER(i==N_SORT_BUCKET-1) ){ /* To get here, there need to be 2^(N_SORT_BUCKET) elements in ** the input list. But that is impossible. */ a[i] = pcacheMergeDirtyList(a[i], p); } } p = a[0]; for(i=1; i<N_SORT_BUCKET; i++){ p = pcacheMergeDirtyList(p, a[i]); } return p; }
static PgHdr *pcacheSortDirtyList(PgHdr *pIn){ PgHdr *a[N_SORT_BUCKET], *p; int i; memset(a, 0, sizeof(a)); while( pIn ){ p = pIn; pIn = p->pDirty; p->pDirty = 0; for(i=0; ALWAYS(i<N_SORT_BUCKET-1); i++){ if( a[i]==0 ){ a[i] = p; break; }else{ p = pcacheMergeDirtyList(a[i], p); a[i] = 0; } } if( NEVER(i==N_SORT_BUCKET-1) ){ a[i] = pcacheMergeDirtyList(a[i], p); } } p = a[0]; for(i=1; i<N_SORT_BUCKET; i++){ p = pcacheMergeDirtyList(p, a[i]); } return p; }
void XmlView::Load(int parent, XmlParser& p) { if(p.IsTag()) { String tag = p.ReadTag(); String txt = tag; for(int i = 0; i < p.GetAttrCount(); i++) txt << ' ' << p.GetAttr(i) << "=\"" << p[i] << "\""; parent = xml.Add(parent, XmlImg::Tag(), tag, txt); while(!p.End()) { if(p.IsEof()) throw XmlError(""); Load(parent, p); } } else if(p.IsText()) xml.Add(parent, XmlImg::Text(), Null, NormalizeSpaces(p.ReadText())); else if(p.IsPI()) xml.Add(parent, XmlImg::PI(), Null, NormalizeSpaces(p.ReadPI())); else if(p.IsDecl()) xml.Add(parent, XmlImg::Decl(), Null, NormalizeSpaces(p.ReadDecl())); else if(p.IsComment()) xml.Add(parent, XmlImg::Comment(), Null, NormalizeSpaces(p.ReadComment())); else NEVER(); }
bool ODBCConnection::Fetch() { if(rowi >= rowcount) return false; fetchrow.Clear(); for(int i = 0; i < info.GetCount(); i++) { Value v; switch(info[i].type) { case DOUBLE_V: v = number[number_i++]; break; case INT64_V: v = num64[num64_i++]; break; case TIME_V: v = time[time_i++]; break; case DATE_V: v = date[date_i++]; break; case STRING_V: v = text[text_i++]; break; default: NEVER(); } fetchrow.Add(v); } ++rowi; return true; }
/////////////////////////////////////////////////////////////////////////////////////// // main updater call // returns TRUE if app should continue, FALSE if should terminate // BEWARE, app MUST check for return value AND behave as needed // te SELF_UPDATE() macro does all what is needed bool Updater::Run() { // create user config path only on normal run if(state == NormalRun) RealizeDirectory(userConfigPath); // creates system config path on superuser mode if(state == InsideUpdater) RealizeDirectory(systemConfigPath); switch(state) { case NormalRun : return DO_NormalRun(); case InsideUpdater : return DO_InsideUpdater(); case UninstallFailed : return DO_UninstallFailed(); case InstallFailed : return DO_InstallFailed(); case UpdateFailed : return DO_UpdateFailed(); case UninstallSucceeded : return DO_UninstallSucceeded(); case InstallSucceeded : return DO_InstallSucceeded(); case UpdateSucceeded : return DO_UpdateSucceeded(); default: NEVER(); break; } // dummy return false; }
void Gdal::Block::GetDouble(double *out, int x, int y, int count) const { ASSERT(x >= 0 && x + count <= size.cx); ASSERT(y >= 0 && y < size.cy); int offset = (x + y * size.cx) * pixel_bytes; const byte *raw_src = &bytes[offset]; switch(type) { case GDT_Byte: CONVERT_LOOP(byte, *src); case GDT_UInt16: CONVERT_LOOP(uint16, *src); case GDT_Int16: CONVERT_LOOP(int16, *src); case GDT_UInt32: CONVERT_LOOP(uint32, (int)*src); case GDT_Int32: CONVERT_LOOP(int32, (int)*src); case GDT_Float32: CONVERT_LOOP(float, (double)*src); case GDT_Float64: CONVERT_LOOP(double, *src); case GDT_CInt16: CONVERT_LOOP(Point16, src->x); case GDT_CInt32: CONVERT_LOOP(Point, src->x); case GDT_CFloat32: CONVERT_LOOP(Point_<float>, (double)src->x); case GDT_CFloat64: CONVERT_LOOP(Pointf, src->x); default: { Fill(out, out + count, (double)Null); RLOG("unsupported GDAL data type: " << (int)type); NEVER(); break; } } }
/* ** The following set of routines walk through the parse tree and assign ** a specific database to all table references where the database name ** was left unspecified in the original SQL statement. The pFix structure ** must have been initialized by a prior call to sqlite3FixInit(). ** ** These routines are used to make sure that an index, trigger, or ** view in one database does not refer to objects in a different database. ** (Exception: indices, triggers, and views in the TEMP database are ** allowed to refer to anything.) If a reference is explicitly made ** to an object in a different database, an error message is added to ** pParse->zErrMsg and these routines return non-zero. If everything ** checks out, these routines return 0. */ int sqlite3FixSrcList( DbFixer *pFix, /* Context of the fixation */ SrcList *pList /* The Source list to check and modify */ ){ int i; const char *zDb; struct SrcList_item *pItem; if( NEVER(pList==0) ) return 0; zDb = pFix->zDb; for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ if( pItem->zDatabase==0 ){ pItem->zDatabase = sqlite3DbStrDup(pFix->pParse->db, zDb); }else if( sqlite3StrICmp(pItem->zDatabase,zDb)!=0 ){ sqlite3ErrorMsg(pFix->pParse, "%s %T cannot reference objects in database %s", pFix->zType, pFix->pName, pItem->zDatabase); return 1; } #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1; if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1; #endif } return 0; }
/* ** pEList is the SET clause of an UPDATE statement. Each entry ** in pEList is of the format <id>=<expr>. If any of the entries ** in pEList have an <id> which matches an identifier in pIdList, ** then return TRUE. If pIdList==NULL, then it is considered a ** wildcard that matches anything. Likewise if pEList==NULL then ** it matches anything so always return true. Return false only ** if there is no match. */ static int checkColumnOverlap(IdList *pIdList, ExprList *pEList){ int e; if( pIdList==0 || NEVER(pEList==0) ) return 1; for(e=0; e<pEList->nExpr; e++){ if( sqlite3IdListIndex(pIdList, pEList->a[e].zName)>=0 ) return 1; } return 0; }
MultiButton::SubButton& MultiButton::MainButton() { for(int i = 0; i < button.GetCount(); i++) if(button[i].main) return button[i]; NEVER(); return button[0]; }
void PNGEncoder::Data::Start(Stream& stream, Size size_, int bpp, ImageKind kind_, bool interlace_, const RGBA *imgpal) { size = size_; kind = kind_; interlace = interlace_; png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, png_user_error_fn, png_user_warning_fn); if(!png_ptr) { stream.SetError(); return; } /* Allocate/initialize the image information data. REQUIRED */ info_ptr = png_create_info_struct(png_ptr); if(!info_ptr) { stream.SetError(); return; } /* if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_write_struct(&png_ptr, &info_ptr); sptr -> SetError(); return; } */ png_set_write_fn(png_ptr, (void *)&stream, png_write_stream, png_flush_stream); int color_type, bit_depth; Vector<png_color> palette; do_alpha = (kind != IMAGE_OPAQUE && bpp != 1); do_mask = (do_alpha && kind == IMAGE_MASK); do_palette = (bpp <= 8); if(do_palette) { switch(bpp) { case 1: format.Set1mf(); break; case 2: format.Set2mf(); break; case 4: format.Set4mf(); break; default: NEVER(); case 8: format.Set8(); break; } bit_depth = bpp; color_type = PNG_COLOR_TYPE_PALETTE; palette.SetCount(1 << bpp); for(int i = 0; i < palette.GetCount(); i++) { png_color& c = palette[i]; c.red = imgpal[i].r; c.green = imgpal[i].g; c.blue = imgpal[i].b; } rowbytes = (size.cx * bpp + 31) >> 5 << 2; } else {
/* ** This routine is called when the extension is loaded. ** Register the new VFS. */ int sqlite3MemdbInit(void){ sqlite3_vfs *pLower = sqlite3_vfs_find(0); int sz = pLower->szOsFile; memdb_vfs.pAppData = pLower; /* In all known configurations of SQLite, the size of a default ** sqlite3_file is greater than the size of a memdb sqlite3_file. ** Should that ever change, remove the following NEVER() */ if( NEVER(sz<sizeof(MemFile)) ) sz = sizeof(MemFile); memdb_vfs.szOsFile = sz; return sqlite3_vfs_register(&memdb_vfs, 0); }
// lays toolbars inside frame void XMLToolBarFrame::Layout(void) { // don't layout if still no parent if(!parent) return; for(int iRow = 0; iRow < posMapper.GetCount(); iRow++) { int rowPos = posMapper.GetKey(iRow); VectorMap<int, int> &rowMapper = posMapper[iRow]; for(int iCol = 0; iCol < rowMapper.GetCount(); iCol++) { int colPos = rowMapper.GetKey(iCol); int idx = rowMapper[iCol]; XMLToolBarCtrl &tb = *toolBars[idx]; Ctrl::LogPos pos; Size sz; int x1, y1, x2, y2; switch(toolBarState) { case TOOLBAR_LEFT : case TOOLBAR_RIGHT : sz = tb.GetVertSize(); x1 = rowPos; y1 = colPos; break; case TOOLBAR_TOP : case TOOLBAR_BOTTOM : sz = tb.GetHorzSize(); x1 = colPos; y1 = rowPos; break; default : NEVER(); break; } x2 = x1 + sz.cx; y2 = y1 + sz.cy; // don't add last toolbar as a child if predocking if(!preDocking || &tb != toolBars.Top()) { pos = Ctrl::LogPos( Ctrl::PosLeft(x1, x2 - x1), Ctrl::PosTop(y1, y2 - y1) ); tb.SetPos(pos); } if(preDocking && &tb == toolBars.Top()) preDockRect = Rect(x1, y1, x2, y2); } } }
void Sqlite3Connection::GetColumn(int i, Ref f) const { ASSERT(NULL != current_stmt); if(i == -1) { f = Value(sqlite3_last_insert_rowid(db)); return; } ASSERT(got_row_data); String coltype; const char *s = sqlite3_column_decltype(current_stmt,i); if(s) coltype = ToLower(s); switch (sqlite3_column_type(current_stmt,i)) { case SQLITE_INTEGER: f = sqlite3_column_int64(current_stmt,i); break; case SQLITE_FLOAT: f = sqlite3_column_double(current_stmt,i); break; case SQLITE_TEXT: if(coltype == "date" || f.GetType() == DATE_V){ const char *s = (const char *)sqlite3_column_text(current_stmt, i); if(strlen(s) >= 10) f = Value(Date(atoi(s), atoi(s + 5), atoi(s + 8))); else f = Null; } else if(coltype == "datetime" || f.GetType() == TIME_V) { const char *s = (const char *)sqlite3_column_text(current_stmt, i); if(strlen(s) >= 19) f = Value(Time(atoi(s), atoi(s + 5), atoi(s + 8), atoi(s + 11), atoi(s + 14), atoi(s + 17))); else if(strlen(s) >= 10) f = Value(ToTime(Date(atoi(s), atoi(s + 5), atoi(s + 8)))); else f = Null; } else f = Value(WString((const wchar*)sqlite3_column_text16(current_stmt,i))); break; case SQLITE_NULL: f = Null; break; case SQLITE_BLOB: f = Value(String( (const byte*)sqlite3_column_blob(current_stmt,i), sqlite3_column_bytes(current_stmt,i) )); break; default: NEVER(); break; } return; }
/* ** The pExpr should be a TK_COLUMN expression. The table referred to ** is in pTabList or else it is the NEW or OLD table of a trigger. ** Check to see if it is OK to read this particular column. ** ** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN ** instruction into a TK_NULL. If the auth function returns SQLITE_DENY, ** then generate an error. */ SQLITE_PRIVATE void sqlite3AuthRead( Parse *pParse, /* The parser context */ Expr *pExpr, /* The expression to check authorization on */ Schema *pSchema, /* The schema of the expression */ SrcList *pTabList /* All table that pExpr might refer to */ ){ sqlite3 *db = pParse->db; Table *pTab = 0; /* The table being read */ const char *zCol; /* Name of the column of the table */ int iSrc; /* Index in pTabList->a[] of table being read */ int iDb; /* The index of the database the expression refers to */ int iCol; /* Index of column in table */ if( db->xAuth==0 ) return; iDb = sqlite3SchemaToIndex(pParse->db, pSchema); if( iDb<0 ){ /* An attempt to read a column out of a subquery or other ** temporary table. */ return; } assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER ); if( pExpr->op==TK_TRIGGER ){ pTab = pParse->pTriggerTab; }else{ assert( pTabList ); for(iSrc=0; ALWAYS(iSrc<pTabList->nSrc); iSrc++){ if( pExpr->iTable==pTabList->a[iSrc].iCursor ){ pTab = pTabList->a[iSrc].pTab; break; } } } iCol = pExpr->iColumn; if( NEVER(pTab==0) ) return; if( iCol>=0 ){ assert( iCol<pTab->nCol ); zCol = pTab->aCol[iCol].zName; }else if( pTab->iPKey>=0 ){ assert( pTab->iPKey<pTab->nCol ); zCol = pTab->aCol[pTab->iPKey].zName; }else{ zCol = "ROWID"; } assert( iDb>=0 && iDb<db->nDb ); if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){ pExpr->op = TK_NULL; } }
/* Get the results of the thread */ int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){ int rc; assert( ppOut!=0 ); if( NEVER(p==0) ) return SQLITE_NOMEM; if( p->done ){ *ppOut = p->pOut; rc = SQLITE_OK; }else{ rc = pthread_join(p->tid, ppOut) ? SQLITE_ERROR : SQLITE_OK; } sqlite3_free(p); return rc; }
byte GetLangStdCharset(int language) { if(IsNull(language) || language == 0) return GetDefaultCharset(); int cs = (language >> 20) & 0xFF; if(cs) return cs; switch(language) { #undef LNGITEM #define LNGITEM(lcode, charset) case lcode: return charset; LNGLIST() default: NEVER(); return CHARSET_DEFAULT; } }
void Test() { MemoryLimitKb(8000000); for(int sz = 0; sz < 2; sz++) { for(int pass = 0; pass < 2; pass++) { RLOG("--------------------"); DUMP(sz); DUMP(pass); { NanoStrings ns; Vector<dword> ws; ns.ZeroTerminated(sz); SeedRandom(); for(int i = 0; i < 140000000; i++) { if(i % 10000000 == 0) RLOG("Created " << i); String s = pass ? "x" : RandomString(Random(4) ? 5 : 50); ws.Add(ns.Add(s)); } // ns.DumpProfile(); RLOG("---- Strings " << MemoryUsedKb() << " KB used -------"); RLOG(MemoryProfile()); SeedRandom(); for(int i = 0; i < ws.GetCount(); i++) { if(i % 10000000 == 0) RLOG("Tested " << i); String s = pass ? "x" : RandomString(Random(4) ? 5 : 50); if((sz ? String(ns.GetPtr(ws[i])) : ns.Get(ws[i])) != s) { DUMP(i); DUMP(ns.Get(ws[i])); DUMP(s); NEVER(); } } RLOG("Test OK"); } RLOG("===== EMPTY " << MemoryUsedKb() << " KB used -------"); RLOG(MemoryProfile()); } } }
void RescaleImage::Create(Size _tsz, Raster& _src, const Rect& src_rc) { y = -1; src = &_src; tsz = _tsz; if(tsz.cx == 0 || tsz.cy == 0) return; size = src->GetSize(); Rect dr = tsz; horz = AAGetMap(dr.left, dr.right, dr.left, dr.right, src_rc.left, src_rc.right, 0, size.cx, 1, 0x100); if(horz.IsEmpty()) return; vert = AAGetMap(dr.top, dr.bottom, dr.top, dr.bottom, src_rc.top, src_rc.bottom, 0, size.cy, 1, 0x100); if(vert.IsEmpty()) return; switch(horz[MAP_SEGMENT]) { case 1: row_proc = BltAAMapRGBA1; break; case 2: row_proc = BltAAMapRGBA2; break; case 3: row_proc = BltAAMapRGBA3; break; case 4: row_proc = BltAAMapRGBA4; break; default: NEVER(); return; } cx4 = 4 * tsz.cx; count = vert[MAP_COUNT]; segment = vert[MAP_SEGMENT]; entry = vert[MAP_BLOCK]; step = vert[MAP_STEP]; segspan = (segment - 1) * step + 1; bigseg = (segment == MAXAA); row_buffers.Alloc(cx4 * segment); first = vert[4]; full = 0; offsets = vert.GetIter(4); offset = 0; y = 0; cii = 0; cache[0].ii = cache[1].ii = cache[2].ii = cache[3].ii = -1; }
int sqlite3FixInit( DbFixer *pFix, Parse *pParse, /* Error messages will be written here */ int iDb, const char *zType, const Token *pName ){ sqlite3 *db; if( NEVER(iDb<0) || iDb==1 ) return 0; db = pParse->db; assert( db->nDb>iDb ); pFix->pParse = pParse; pFix->zDb = db->aDb[iDb].zName; pFix->zType = zType; pFix->pName = pName; return 1; }
/* ** Initialize a DbFixer structure. This routine must be called prior ** to passing the structure to one of the sqliteFixAAAA() routines below. ** ** The return value indicates whether or not fixation is required. TRUE ** means we do need to fix the database references, FALSE means we do not. */ int sqlite3FixInit( DbFixer *pFix, /* The fixer to be initialized */ Parse *pParse, /* Error messages will be written here */ int iDb, /* This is the database that must be used */ const char *zType, /* "view", "trigger", or "index" */ const Token *pName /* Name of the view, trigger, or index */ ){ sqlite3 *db; if( NEVER(iDb<0) || iDb==1 ) return 0; db = pParse->db; assert( db->nDb>iDb ); pFix->pParse = pParse; pFix->zDb = db->aDb[iDb].zName; pFix->zType = zType; pFix->pName = pName; return 1; }
void XMLBarEditor::treeContextAddCb(int mode) { int id = barTree.GetCursor(); int parentId = 0; int childIdx; int newId = 0; XMLToolBarItem item; if(mode > 4) { item.isSeparator = true; mode -= 4; } String lbl = (item.IsSeparator() ? t_("<SEPARATOR>") : ""); Value v = RawPickToValue(item); switch(mode) { case 1: parentId = barTree.GetParent(id); childIdx = barTree.GetChildIndex(parentId, id); newId = barTree.Insert(parentId, childIdx, Null, v, lbl); break; case 2: parentId = barTree.GetParent(id); childIdx = barTree.GetChildIndex(parentId, id); newId = barTree.Insert(parentId, childIdx + 1, Null, v, lbl); break; case 3: newId = barTree.Insert(id, 0, Null, v, ""); break; case 4: newId = barTree.Add(id, Null, v, ""); break; default: NEVER(); } RefreshBar(); barTree.SetCursor(newId); itemPane.label.SetFocus(); }