/************************************************************************* * @ [SHLWAPI.21] * * Remove an item from a DataBlock list. * * PARAMS * lppList [O] List to remove the item from * ulId [I] Id of item to remove * * RETURNS * Success: TRUE. * Failure: FALSE, If any parameters are invalid, or the item was not found. * * NOTES * See SHWriteDataBlockList. */ BOOL WINAPI SHRemoveDataBlock(LPSHLWAPI_CLIST* lppList, ULONG ulId) { LPSHLWAPI_CLIST lpList = 0; LPSHLWAPI_CLIST lpItem = NULL; LPSHLWAPI_CLIST lpNext; ULONG ulNewSize; TRACE("(%p,%ld)\n", lppList, ulId); if(lppList && (lpList = *lppList)) { /* Search for item in list */ while (lpList->ulSize) { if(lpList->ulId == ulId || (lpList->ulId == CLIST_ID_CONTAINER && lpList[1].ulId == ulId)) { lpItem = lpList; /* Found */ break; } lpList = NextItem(lpList); } } if(!lpItem) return FALSE; lpList = lpNext = NextItem(lpItem); /* Locate the end of the list */ while (lpList->ulSize) lpList = NextItem(lpList); /* Resize the list */ ulNewSize = LocalSize((HLOCAL)*lppList) - lpItem->ulSize; /* Copy following elements over lpItem */ memmove(lpItem, lpNext, (char *)lpList - (char *)lpNext + sizeof(ULONG)); if(ulNewSize <= sizeof(ULONG)) { LocalFree((HLOCAL)*lppList); *lppList = NULL; /* Removed the last element */ } else { lpList = (LPSHLWAPI_CLIST)LocalReAlloc((HLOCAL)*lppList, ulNewSize, LMEM_ZEROINIT|LMEM_MOVEABLE); if(lpList) *lppList = lpList; } return TRUE; }
void DBVPolyIF::FourColoring () { char nameStr [DBStringLength]; DBInt symbol, maxSymbol = 0, line, index; DBObjRecord *polyRec,*searchPoly, *neighborPolyRec, *lineRec, *symRec; for (polyRec = FirstItem ();polyRec != (DBObjRecord *) NULL;polyRec = NextItem ()) SymbolFLD->Record (polyRec,(DBObjRecord *) NULL); ListSort (LineNumFLD); for (searchPoly = FirstItem ();searchPoly != (DBObjRecord *) NULL;searchPoly = NextItem ()) { if (((DBInt) (SymbolFLD->Record (searchPoly) - (DBObjRecord *) NULL)) != 0) continue; DBPause (searchPoly->RowID () * 100 / ItemNum ()); symbol = 1; Restart: for (polyRec = ItemTable->First (&index);polyRec != (DBObjRecord *) NULL;polyRec = ItemTable->Next (&index)) { if (strcmp (polyRec->Name (),searchPoly->Name ()) != 0) continue; lineRec = FirstLine (polyRec); for (line = 0;line <= LineNum (polyRec);++line) { if (LineRightPoly (lineRec) == polyRec) { neighborPolyRec = LineLeftPoly (lineRec); lineRec = LineNextLine (lineRec); } else { neighborPolyRec = LineRightPoly (lineRec); lineRec = LinePrevLine (lineRec); } if (neighborPolyRec == (DBObjRecord *) NULL) continue; if (SymbolFLD->Record (neighborPolyRec) == (DBObjRecord *) symbol) { symbol++; goto Restart; } } } for (polyRec = ItemTable->First (&index);polyRec != (DBObjRecord *) NULL;polyRec = ItemTable->Next (&index)) if (strcmp (polyRec->Name (),searchPoly->Name ()) == 0) SymbolFLD->Record (polyRec,(DBObjRecord *) symbol); maxSymbol = maxSymbol > symbol ? maxSymbol : symbol; } while (maxSymbol < SymbolTable->ItemNum ()) SymbolTable->Remove (SymbolTable->ItemNum () - 1); while (maxSymbol > SymbolTable->ItemNum ()) SymbolTable->Add (); for (symbol = 0;symbol < SymbolTable->ItemNum ();++symbol) { symRec = SymbolTable->Item (symbol); sprintf (nameStr,"Symbol:%2d",symbol); symRec->Name (nameStr); StyleFLD->Int (symRec,0); ForegroundFLD->Int (symRec,1); BackgroundFLD->Int (symRec,0); } for (polyRec = FirstItem ();polyRec != (DBObjRecord *) NULL;polyRec = NextItem ()) SymbolFLD->Record (polyRec,SymbolTable->Item ((DBInt) (SymbolFLD->Record (polyRec) - (DBObjRecord *) NULL) - 1)); ListReset (); }
/************************************************************************* * @ [SHLWAPI.21] * * Remove an item from a DataBlock list. * * PARAMS * lppList [O] List to remove the item from * dwSignature [I] Id of item to remove * * RETURNS * Success: TRUE. * Failure: FALSE, If any parameters are invalid, or the item was not found. * * NOTES * See SHWriteDataBlockList. */ BOOL WINAPI SHRemoveDataBlock(LPDBLIST* lppList, DWORD dwSignature) { LPDATABLOCK_HEADER lpList = 0; LPDATABLOCK_HEADER lpItem = NULL; LPDATABLOCK_HEADER lpNext; ULONG ulNewSize; TRACE("(%p,%d)\n", lppList, dwSignature); if(lppList && (lpList = *lppList)) { /* Search for item in list */ while (lpList->cbSize) { if(lpList->dwSignature == dwSignature || (lpList->dwSignature == CLIST_ID_CONTAINER && lpList[1].dwSignature == dwSignature)) { lpItem = lpList; /* Found */ break; } lpList = NextItem(lpList); } } if(!lpItem) return FALSE; lpList = lpNext = NextItem(lpItem); /* Locate the end of the list */ while (lpList->cbSize) lpList = NextItem(lpList); /* Resize the list */ ulNewSize = LocalSize(*lppList) - lpItem->cbSize; /* Copy following elements over lpItem */ memmove(lpItem, lpNext, (char *)lpList - (char *)lpNext + sizeof(ULONG)); if(ulNewSize <= sizeof(ULONG)) { LocalFree(*lppList); *lppList = NULL; /* Removed the last element */ } else { lpList = LocalReAlloc(*lppList, ulNewSize, LMEM_ZEROINIT|LMEM_MOVEABLE); if(lpList) *lppList = lpList; } return TRUE; }
uint32 mhmakefileparser::CreateEnvMd5_32() const { md5_context ctx; string Md5; string EnvVars=ExpandVar(USED_ENVVARS); const char *pTmp=EnvVars.c_str(); // Now create the md5 string md5_starts( &ctx ); DBGOUT(cout << "MD5 of " << m_MakeDir->GetQuotedFullFileName() << endl); while (*pTmp) { string Var; pTmp=NextItem(pTmp,Var,";"); if (!SkipVar(Var)) { string Val=ExpandVar(Var); transform(Val.begin(),Val.end(),Val.begin(),(int(__CDECL *)(int))toupper); DBGOUT(cout << GetMakeDir()->GetQuotedFullFileName() << " -> Setting GetFromEnv var " << Var << " to " << Val << endl); md5_update( &ctx, (uint8 *) Var.c_str(), (unsigned long)Var.size()); md5_update( &ctx, (uint8 *) "=", 1); md5_update( &ctx, (uint8 *) Val.c_str(), (unsigned long)Val.size()); } } return md5_finish32( &ctx); }
bool mhmakefileparser::SkipHeaderFile(const string &FileName) { if (!m_SkipHeadersInitialized) { m_SkipHeadersInitialized=true; string HeadersToSkip=ExpandVar(SKIPHEADERS); const char *pTmp=HeadersToSkip.c_str(); while (*pTmp) { string Item; pTmp=NextItem(pTmp,Item); if (Item.find('%')==string::npos) { m_SkipHeaders.insert(Item); } else { m_PercentHeaders.push_back(Item); } } } if (m_SkipHeaders.find(FileName)!=m_SkipHeaders.end()) return true; vector<string>::const_iterator It=m_PercentHeaders.begin(); vector<string>::const_iterator ItEnd=m_PercentHeaders.end(); while (It!=ItEnd) { if (PercentMatch(FileName,*It++)) return true; } return false; }
DBObjRecord *DBVectorIF::Item (DBCoordinate coord) const { DBObjRecord *record, *retRecord = (DBObjRecord *) NULL; switch (DataPTR->Type ()) { case DBTypeVectorPoint: { DBFloat dist, minDist = DBHugeVal; DBObjTableField *coordFLD = ItemTable->Field (DBrNCoord); DBMathDistanceFunction distFunc = DBMathGetDistanceFunction (DataPTR); for (record = FirstItem ();record != (DBObjRecord *) NULL;record = NextItem ()) { dist = DBMathCoordinateDistance (distFunc,coord,coordFLD->Coordinate (record)); if (dist < minDist) { minDist = dist; retRecord = record; } } } break; case DBTypeVectorLine: break; case DBTypeVectorPolygon: break; default: CMmsgPrint (CMmsgAppError, "Unknown Vector Data Type in: %s %d",__FILE__,__LINE__); break; } return (retRecord); }
bool OnKey(IInputProvider* pprovider, const KeyState& ks, bool& fForceTranslate) { VerifyScrollPos(); if (ks.bDown) { switch (ks.vk) { case VK_DOWN: NextItem(); SelectionChanged(); return true; case VK_UP: PreviousItem(); SelectionChanged(); return true; case VK_PRIOR: // page up PageUp(); SelectionChanged(); return true; case VK_NEXT: // page down PageDown(); SelectionChanged(); return true; } } return false; }
void CMenuState::HandleEvents(CGameEngine* game) { ALLEGRO_EVENT ev; // wait for an event (mouse movement, key press, etc.) al_wait_for_event(game->event_queue, &ev); switch(ev.type) { case ALLEGRO_EVENT_DISPLAY_CLOSE: game->Quit(); break; case ALLEGRO_EVENT_KEY_DOWN: if(ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE) game->Quit(); else if(ev.keyboard.keycode == ALLEGRO_KEY_RIGHT) NextItem(); else if(ev.keyboard.keycode == ALLEGRO_KEY_LEFT) PrevItem(); else if(ev.keyboard.keycode == ALLEGRO_KEY_ENTER || ev.keyboard.keycode == ALLEGRO_KEY_SPACE) items[menuIndex]->Activate(game); break; } }
void mhmakefileparser::SetvPath(const string &Pattern, const string &Path) { // First create the array of directory from the Path parameter. For now all entries need to // be valid directories (extra checking). This could be improved by checking if there // is a rule for creating the directory entry, but like first said, not for now. refptr<fileinfoarray> pDirArray=new fileinfoarray; const char *pTmp=Path.c_str(); while (*pTmp) { string Item; pTmp=NextItem(pTmp,Item," \t:;"); if (!Item.empty()) { fileinfo *pDir=GetFileInfo(Item,m_MakeDir); if (!pDir->IsDir()) { #ifdef WIN32 // On windows this could happen if a full pathname was specified, so we try together // with the next item to check if this is not a valid directories // but only if the the length of the item was 1 namely the driver letter if (Item.length()==1) { string Rest; pTmp=NextItem(pTmp,Rest," \t:;"); pDir=GetFileInfo(Item+":"+Rest,m_MakeDir); #ifdef _DEBUG if (g_PrintAdditionalInfo && !pDir->IsDir()) throw(pDir->GetFullFileName()+" is not a valid directory."); #endif } #ifdef _DEBUG else if (g_PrintAdditionalInfo) cout << pDir->GetFullFileName() << " is not a valid directory.\n"; #endif #else #ifdef _DEBUG if (g_PrintAdditionalInfo) cout << pDir->GetFullFileName() << " is not a valid directory.\n"; #endif #endif } pDirArray->push_back(pDir); } } m_vPath.push_back(pair<string, refptr<fileinfoarray> >(Pattern,pDirArray)); }
void PageDown() { int delta = GetSignificantSize() / GetSignificantSize(*m_ppainter); while (delta > 0) { NextItem(); delta--; } }
static bool Next( playlist_t *p_playlist ) { playlist_item_t *p_item = NextItem( p_playlist ); if( p_item == NULL ) return false; msg_Dbg( p_playlist, "starting playback of new item" ); ResyncCurrentIndex( p_playlist, p_item ); return PlayItem( p_playlist, p_item ); }
static void LoopRequest( playlist_t *p_playlist ) { playlist_private_t *p_sys = pl_priv(p_playlist); assert( !p_sys->p_input ); /* No input. Several cases * - No request, running status -> start new item * - No request, stopped status -> collect garbage * - Request, running requested -> start new item * - Request, stopped requested -> collect garbage */ const int i_status = p_sys->request.b_request ? p_sys->request.i_status : p_sys->status.i_status; if( i_status == PLAYLIST_STOPPED || !vlc_object_alive( p_playlist ) ) { p_sys->status.i_status = PLAYLIST_STOPPED; if( p_sys->p_input_resource && input_resource_HasVout( p_sys->p_input_resource ) ) { /* XXX We can unlock if we don't issue the wait as we will be * call again without anything else done between the calls */ PL_UNLOCK; /* input_resource_t must be manipulated without playlist lock */ input_resource_TerminateVout( p_sys->p_input_resource ); PL_LOCK; } else { if( vlc_object_alive( p_playlist ) ) vlc_cond_wait( &p_sys->signal, &p_sys->lock ); } return; } playlist_item_t *p_item = NextItem( p_playlist ); if( p_item ) { msg_Dbg( p_playlist, "starting playback of the new playlist item" ); PlayItem( p_playlist, p_item ); return; } msg_Dbg( p_playlist, "nothing to play" ); p_sys->status.i_status = PLAYLIST_STOPPED; if( var_GetBool( p_playlist, "play-and-exit" ) ) { msg_Info( p_playlist, "end of playlist, exiting" ); libvlc_Quit( p_playlist->p_libvlc ); } }
MouseResult Button( IInputProvider* pprovider, const Point& point, int button, bool bCaptured, bool bInside, bool bDown ) { VerifyScrollPos(); if (button == 0 && bDown) { int nSize = GetSignificantSize(*m_ppainter); int nSignificantMouseDim = (int)(m_bHorizontal ? point.X(): point.Y()); SetSelection(m_plist->GetItem((nSignificantMouseDim + GetScrollPos()) / nSize)); NeedPaint(); SelectionChanged(); if (pprovider->IsDoubleClick()) { m_peventDoubleClick->Trigger(); } else { m_peventSingleClick->Trigger(); } } else if(button == 1 && bDown) { int nSize = GetSignificantSize(*m_ppainter); int nSignificantMouseDim = (int)(m_bHorizontal ? point.X(): point.Y()); SetSelection(m_plist->GetItem((nSignificantMouseDim + GetScrollPos()) / nSize)); NeedPaint(); SelectionChanged(); if (pprovider->IsDoubleClick()) { m_peventDoubleRightClick->Trigger(); } else { m_peventSingleRightClick->Trigger(); } } else if(button == 8 && bDown) { //Imago 8/14/09 mouse wheel NextItem(); SelectionChanged(); } else if(button == 9 && bDown) { PreviousItem(); SelectionChanged(); } return MouseResult(); }
CObject* Search::FindNextObjectOfType( void ) { CObject* obj = NextItem(); while ( obj ) { Dbg_AssertType( obj, CObject ); if ( obj->GetType() == obj_type ) { return obj; } obj = NextItem(); } return obj; }
/***************************************************************************** * * casesin takes a list of selections 'tptr' and returns the number of * distinct selections (including an ELSE if one present). * *****************************************************************************/ PRIVATE int casesin (treenode * tptr) { int n = 0; for (; !EndOfList (tptr); tptr = NextItem (tptr)) { treenode *thisguard = CondGuardOf (skipspecifications (ThisItem (tptr))); if (TagOf (thisguard) == S_ELSE) n++; else n += listitems (thisguard); } return (n); }
long DCirfile::GetItemCount(void) { long count = 0; while (NextItem()) count++; Section(CurrSectName); return count; }
void MoveItemFirst(long ptr) { long next, prev, first, loc0, root; /* Check pointer */ CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); /* Get pointer to common data */ loc0 = (long)RDB[ptr + LIST_PTR_COMMON]; CheckPointer(FUNCTION_NAME, "(loc0)", DATA_ARRAY, loc0); /* Get pointers to previous and next items */ prev = PrevItem(ptr); next = NextItem(ptr); /* Check if already first and put pointer */ if (prev < VALID_PTR) return; else WDB[prev + LIST_PTR_NEXT] = (double)next; /* Check if last and put pointer */ if (next < VALID_PTR) WDB[loc0 + LIST_COMMON_PTR_LAST] = (double)prev; else WDB[next + LIST_PTR_PREV] = (double)prev; /* Get pointer to first */ first = (long)RDB[loc0 + LIST_COMMON_PTR_FIRST]; CheckPointer(FUNCTION_NAME, "(first)", DATA_ARRAY, first); /* Put pointers */ WDB[first + LIST_PTR_PREV] = (double)ptr; WDB[ptr + LIST_PTR_NEXT] = (double)first; WDB[ptr + LIST_PTR_PREV] = NULLPTR; WDB[loc0 + LIST_COMMON_PTR_FIRST] = (double)ptr; /* Get pointer to root */ root = (long)RDB[loc0 + LIST_COMMON_PTR_ROOT]; /* Put pointer */ WDB[root] = (double)ptr; }
void mhmakefileparser::SplitToItems(const string &String,vector<fileinfo*> &Items) const { const char *pTmp=String.c_str(); while (*pTmp) { string Item; pTmp=NextItem(pTmp,Item); if (!Item.empty()) { Items.push_back(GetFileInfo(Item,m_MakeDir)); } } }
///<summary>Deletes all items from the data store.</summary> void CFeedStore::ClearItems() { CRSSItem* rssItem; Reset(); while ((rssItem=NextItem())!=NULL) DeleteItem(rssItem); //-- Finally delete everything in the root of the feedstore QStringListIterator feedStoreI=FeedStoreDir.entryList(QDir::Files|QDir::NoDotAndDotDot); while (feedStoreI.hasNext()) FeedStoreDir.remove(feedStoreI.next()); }
/************************************************************************* * @ [SHLWAPI.22] * * Find an item in a DataBlock list. * * PARAMS * lpList [I] List to search * ulId [I] Id of item to find * * RETURNS * Success: A pointer to the list item found * Failure: NULL * * NOTES * See SHWriteDataBlockList. */ LPSHLWAPI_CLIST WINAPI SHFindDataBlock(LPSHLWAPI_CLIST lpList, ULONG ulId) { TRACE("(%p,%ld)\n", lpList, ulId); if(lpList) { while(lpList->ulSize) { if(lpList->ulId == ulId) return lpList; /* Matched */ else if(lpList->ulId == CLIST_ID_CONTAINER && lpList[1].ulId == ulId) return lpList + 1; /* Contained item matches */ lpList = NextItem(lpList); } } return NULL; }
/************************************************************************* * @ [SHLWAPI.22] * * Find an item in a DataBlock list. * * PARAMS * lpList [I] List to search * dwSignature [I] Id of item to find * * RETURNS * Success: A pointer to the list item found * Failure: NULL * * NOTES * See SHWriteDataBlockList. */ DATABLOCK_HEADER* WINAPI SHFindDataBlock(LPDBLIST lpList, DWORD dwSignature) { TRACE("(%p,%d)\n", lpList, dwSignature); if(lpList) { while(lpList->cbSize) { if(lpList->dwSignature == dwSignature) return lpList; /* Matched */ else if(lpList->dwSignature == CLIST_ID_CONTAINER && lpList[1].dwSignature == dwSignature) return lpList + 1; /* Contained item matches */ lpList = NextItem(lpList); } } return NULL; }
void ScorePB(double fissE, double wgt, long id) { long pbd, pbl, ptr, ncol, idx; /* Check pointer */ if ((pbd = (long)RDB[DATA_PTR_PB0]) < 0) return; /* Check fission energy */ if (fissE < ZERO) return; /* Get collision number */ ptr = (long)RDB[DATA_PTR_COLLISION_COUNT]; ncol = (long)GetPrivateData(ptr, id); /* Loop over geometries */ while (pbd > 0) { /* Get pointer to pebble where collision occured */ if ((ptr = (long)RDB[pbd + PBED_PTR_POW]) > VALID_PTR) if ((pbl = TestValuePair(pbd + PBED_PTR_COL_PEBBLE, ncol, id)) > VALID_PTR) { /* Get pebble index */ idx = (long)RDB[pbl + PEBBLE_IDX]; /* Score */ AddBuf1D(fissE, wgt, ptr, id, idx); } /* Next */ pbd = NextItem(pbd); } }
DBVPolyIF::DBVPolyIF(DBObjData *data) : DBVLineIF(data, data->Table(DBrNContours)) { DBObjTable *items = data->Table(DBrNItems); LineTable = data->Table(DBrNContours); DBObjRecord *polyRec; FirstLineFLD = items->Field(DBrNFirstLine); LineNumFLD = items->Field(DBrNLineNum); ExtentFLD = items->Field(DBrNRegion); LeftPolyFLD = LineTable->Field(DBrNLeftPoly); RightPolyFLD = LineTable->Field(DBrNRightPoly); NextLineFLD = LineTable->Field(DBrNNextLine); PrevLineFLD = LineTable->Field(DBrNPrevLine); VertexNumFLD = items->Field(DBrNVertexNum); AreaFLD = items->Field(DBrNArea); MaxVertexNumVAR = 0; for (polyRec = FirstItem(); polyRec != (DBObjRecord *) NULL; polyRec = NextItem()) MaxVertexNumVAR = MaxVertexNumVAR > VertexNum(polyRec) ? MaxVertexNumVAR : VertexNum(polyRec); if ((CoordsPTR = (DBCoordinate *) malloc(MaxVertexNumVAR * sizeof(DBCoordinate))) == (DBCoordinate *) NULL) { CMmsgPrint(CMmsgSysError, "Memory Allocation Error in: %s %d", __FILE__, __LINE__); } }
const refptr<fileinfoarray> mhmakefileparser::GetIncludeDirs() const { string Includes=ExpandExpression("$(INCLUDES)"); if (!m_pIncludeDirs || Includes != m_IncludeDirs) { ((mhmakefileparser*)this)->m_IncludeDirs=Includes; ((mhmakefileparser*)this)->m_pIncludeDirs=refptr<fileinfoarray>(new fileinfoarray); if (Includes.empty()) // If not defined try a default path Includes="include inc .." OSPATHSEPSTR "include .." OSPATHSEPSTR "inc"; const char *pTmp=Includes.c_str(); while (*pTmp) { string Item; pTmp=NextItem(pTmp,Item); fileinfo *pIncDir=GetFileInfo(Item,m_MakeDir); if (pIncDir->Exists() || pIncDir->GetRule()) ((mhmakefileparser*)this)->m_pIncludeDirs->push_back(pIncDir); } } return m_pIncludeDirs; }
/************************************************************************* * @ [SHLWAPI.17] * * Write a DataBlock list to an IStream object. * * PARAMS * lpStream [I] IStream object to write the list to * lpList [I] List of items to write * * RETURNS * Success: S_OK. The object is written to the stream. * Failure: An HRESULT error code * * NOTES * Ordinals 17,18,19,20,21 and 22 are related and together provide a compact * list structure (a "DataBlock List"), which may be stored and retrieved from * an IStream object. * * The exposed API consists of: * * - SHWriteDataBlockList() - Write a DataBlock list to a stream, * - SHReadDataBlockList() - Read and create a list from a stream, * - SHFreeDataBlockList() - Free a list, * - SHAddDataBlock() - Insert a new item into a list, * - SHRemoveDataBlock() - Remove an item from a list, * - SHFindDataBlock() - Find an item in a list. * * The DataBlock list is stored packed into a memory array. Each element has a * size and an associated ID. Elements must be less than 64k if the list is * to be subsequently read from a stream. * * Elements are aligned on DWORD boundaries. If an elements data size is not * a DWORD size multiple, the element is wrapped by inserting a surrounding * element with an Id of 0xFFFFFFFF, and size sufficient to pad to a DWORD boundary. * * These functions are slow for large objects and long lists. */ HRESULT WINAPI SHWriteDataBlockList(IStream* lpStream, LPDBLIST lpList) { ULONG ulSize; HRESULT hRet = S_OK; TRACE("(%p,%p)\n", lpStream, lpList); if(lpList) { while (lpList->cbSize) { LPDATABLOCK_HEADER lpItem = lpList; if(lpList->dwSignature == CLIST_ID_CONTAINER) lpItem++; hRet = IStream_Write(lpStream,lpItem,lpItem->cbSize,&ulSize); if (FAILED(hRet)) return hRet; if(lpItem->cbSize != ulSize) return STG_E_MEDIUMFULL; lpList = NextItem(lpList); } } if(SUCCEEDED(hRet)) { ULONG ulDummy; ulSize = 0; /* Write a terminating list entry with zero size */ hRet = IStream_Write(lpStream, &ulSize,sizeof(ulSize),&ulDummy); } return hRet; }
bool CPUAccessableBuffer::AddNewData( void * i_pData, unsigned int i_sizeData, unsigned int i_strideData, unsigned int & o_baseIndex ) { Assert( g_pImmediateContext ); unsigned int nextItem = NextItem( i_strideData ); if( ( nextItem * i_strideData ) + i_sizeData >= m_sizeBuffer ) return false; D3D11_MAPPED_SUBRESOURCE mappedResource; ZeroMemory( &mappedResource, sizeof( D3D11_MAPPED_SUBRESOURCE ) ); HRESULT hResult = g_pImmediateContext->Map( m_pBuffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource ); Assert( hResult == S_OK ); memcpy( reinterpret_cast<uint8_t *>( mappedResource.pData ) + ( nextItem * i_strideData ), i_pData, i_sizeData ); g_pImmediateContext->Unmap( m_pBuffer, 0 ); o_baseIndex = nextItem; return true; }
void DCirfile::GetElemSets(void) { if (!Section("ElementSets")) return; char *nm = NULL; long len = 0; while (NextItem()) { // this gets higher-priority items first if ((nm = StrLeft()) == NULL) break; if (*nm == '$') nm++; len = strlen(nm); while (nm[len - 1] == ' ') nm[--len] = '\0'; if (!*nm) continue; if (!ElemSetNames(nm)) { // don't replace higher-priority ones ElemSetNames.add(nm, ++ElemSetNum); ElemSets.add(StrArrRight(), ElemSetNum); } } }
CObject* Search::FindFirstObjectOfType( Lst::Head< CObject >& head, sint type ) { Dbg_AssertType( &head, Lst::Head< CObject > ); CObject* obj = FirstItem( head ); obj_type = type; while ( obj ) { Dbg_AssertType( obj, CObject ); if ( obj->GetType() == obj_type ) { return obj; } obj = NextItem(); } return obj; }
static void LoopRequest( playlist_t *p_playlist, int i_status ) { playlist_private_t *p_sys = pl_priv(p_playlist); assert( !p_sys->p_input ); /* No input. Several cases * - No request, running status -> start new item * - No request, stopped status -> collect garbage * - Request, running requested -> start new item * - Request, stopped requested -> collect garbage */ if( i_status == PLAYLIST_STOPPED ) { p_sys->status.i_status = PLAYLIST_STOPPED; vlc_cond_wait( &p_sys->signal, &p_sys->lock ); return; } playlist_item_t *p_item = NextItem( p_playlist ); if( p_item ) { msg_Dbg( p_playlist, "starting playback of the new playlist item" ); ResyncCurrentIndex( p_playlist, p_item ); PlayItem( p_playlist, p_item ); return; } msg_Dbg( p_playlist, "nothing to play" ); p_sys->status.i_status = PLAYLIST_STOPPED; if( var_InheritBool( p_playlist, "play-and-exit" ) ) { msg_Info( p_playlist, "end of playlist, exiting" ); libvlc_Quit( p_playlist->p_libvlc ); } }
void ScoreICMTrk(long part, double x0, double y0, double z0, double u, double v, double w, double lmax, double E, double wgt, long id) { long icm, ntot, nmu0, nmu1, nmu2, nseg, surf, type, ptr, np, in0, in1; long idx, ng, ncross, icm0, icm1, idx0, idx1, ng0, ng1; long mua, mus, mua0, mus0, mua1, mus1; long s0, s1, s2; double d, l, x, y, z, un0, vn0, wn0, un1, vn1, wn1, un2, vn2, wn2; double wgt0, wgt1, mu0, mu1, mu2; const double *params; /* Check mode */ if ((long)RDB[DATA_ICM_CALC] == NO) return; /* Get sizes */ ntot = (long)RDB[DATA_ICM_NG0]; nmu0 = (long)RDB[DATA_ICM_NMU0]; nmu1 = (long)RDB[DATA_ICM_NMU1]; nmu2 = (long)RDB[DATA_ICM_NMU2]; nseg = (long)RDB[DATA_ICM_NSEG]; /* Get pointer to few-group structure */ ptr = (long)RDB[DATA_ICM_PTR_ENE0]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); /* Get few-group index */ if ((ng = GridSearch(ptr, E)) < 0) return; /* Convert index */ ng = ntot - ng - 1; CheckValue(FUNCTION_NAME, "ng1", "", ng, 0, ntot - 1); /* Reset new data */ icm1 = -1; idx1 = -1; mua1 = -1; mus1 = -1; ng1 = -1; wgt1 = -1; /* Loop over data */ icm = (long)RDB[DATA_PTR_ICM0]; while (icm > VALID_PTR) { /* Get original particle Albedo data */ icm0 = (long)RDB[part + PARTICLE_ICM_PTR_ICM]; idx0 = (long)RDB[part + PARTICLE_ICM_IDX]; mua0 = (long)RDB[part + PARTICLE_ICM_MUA]; mus0 = (long)RDB[part + PARTICLE_ICM_MUS]; ng0 = (long)RDB[part + PARTICLE_ICM_G]; wgt0 = RDB[part + PARTICLE_ICM_WGT]; /* Get surface pointer */ surf = (long)RDB[icm + ICM_PTR_SURF]; CheckPointer(FUNCTION_NAME, "(surf)", DATA_ARRAY, surf); /* Get surface type */ type = (long)RDB[surf + SURFACE_TYPE]; /* Get number of parameters */ np = (long)RDB[surf + SURFACE_N_PARAMS]; /* Pointer to parameter list */ ptr = (long)RDB[surf + SURFACE_PTR_PARAMS]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); params = &RDB[ptr]; /* Move to starting position */ /* Toi ekstrapolointi lienee turhaa sen jälkeen kun */ /* trackin.c:tä muutettiin 14.8.2014 / 2.1.22 */ Die(FUNCTION_NAME, "HUOM!!!"); x = x0 - 2.0*EXTRAP_L*u; y = y0 - 2.0*EXTRAP_L*v; z = z0 - 2.0*EXTRAP_L*w; /* Reset total distance and number of crossings */ l = 0.0; ncross = 0; /* Get initial position */ in0 = TestSurface(surf, x, y, z, NO, id); in1 = -1; /* Loop over all surfaces in track */ while (l < lmax) { /* Get distance */ d = SurfaceDistance(surf, params, type, np, x, y, z, u, v, w, id); /* Extrapolate */ d = d + EXTRAP_L; /* Update coordinates */ x = x + d*u; y = y + d*v; z = z + d*w; /* Test position */ in1 = TestSurface(surf, x, y, z, NO, id); /* Check with maximum */ if (l + d > lmax) { /* Go back to collision site (for debugging) */ x = x0 + lmax*u; y = y0 + lmax*v; z = z0 + lmax*w; /* Cancel crossing */ in1 = in0; /* Break loop */ break; } else { /* Update distance */ l = l + d; } /* Check if surface was crossed */ if (in0 != in1) { /* Add counter */ ncross++; /* Get surface index */ if ((idx = ICMIdx(surf, x, y, z, &un0, &vn0, &wn0, &un1, &vn1, &wn1, &un2, &vn2, &wn2)) > -1) { /* Calculate cosines */ mu0 = un0*u + vn0*v + wn0*w; mu1 = un1*u + vn1*v + wn1*w; mu2 = un2*u + vn2*v + wn2*w; /* Get bins */ ptr = (long)RDB[DATA_ICM_PTR_MU0]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); s0 = SearchArray(&RDB[ptr], fabs(mu0), nmu0 + 1); CheckValue(FUNCTION_NAME, "s0", "", s0, 0, nmu0 - 1); ptr = (long)RDB[DATA_ICM_PTR_MU1]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); s1 = SearchArray(&RDB[ptr], mu1, nmu1 + 1); CheckValue(FUNCTION_NAME, "s1", "", s1, 0, nmu1 - 1); ptr = (long)RDB[DATA_ICM_PTR_MU2]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); s2 = SearchArray(&RDB[ptr], mu2, nmu2 + 1); CheckValue(FUNCTION_NAME, "s2", "", s2, 0, nmu2 - 1); /* Calculate asymmetric and symmetric part */ mua = s1; mus = s0*nmu2 + s2; /* Check direction */ if ((in0 == NO) && (in1 == YES)) { /* Check bins */ CheckValue(FUNCTION_NAME, "idx", "(1)", idx, 0, nseg - 1); CheckValue(FUNCTION_NAME, "mua", "(1)", mua, 0, nmu1 - 1); CheckValue(FUNCTION_NAME, "mus", "(1)", mus, 0, nmu0*nmu2 - 1); CheckValue(FUNCTION_NAME, "ng", "(1)", ng, 0, ntot - 1); /* Score inward current */ if (RDB[DATA_CYCLE_IDX] > RDB[DATA_CRIT_SKIP] - 1.0) { ptr = (long)RDB[icm + ICM_RES_CURR0]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); AddBuf(1.0, wgt, ptr, id, -1, idx, mua, mus, ng); } /* Put new data and reset weight */ icm0 = icm; idx0 = idx; mua0 = mua; mus0 = mus; ng0 = ng; wgt0 = 1.0; } else if ((in0 == YES) && (in1 == NO)) { /* Check active cycles */ if (RDB[DATA_CYCLE_IDX] > RDB[DATA_CRIT_SKIP] - 1.0) { /* Check index, group and angular bins */ if ((idx0 > -1) && (ng0 > -1) && (mua0 > -1) && (mus0 > -1)) { /* Check bins */ CheckValue(FUNCTION_NAME, "idx0", "(2)", idx0, 0, nseg - 1); CheckValue(FUNCTION_NAME, "mua0", "(2)", mua0, 0, nmu1 - 1); CheckValue(FUNCTION_NAME, "mus0", "(2)", mus0, 0, nmu0*nmu2 - 1); CheckValue(FUNCTION_NAME, "ng0", "(2)", ng0, 0, ntot - 1); CheckValue(FUNCTION_NAME, "idx", "(2)", idx, 0, nseg - 1); CheckValue(FUNCTION_NAME, "mua", "(2)", mua, 0, nmu1 - 1); CheckValue(FUNCTION_NAME, "mus", "(2)", mus, 0, nmu0*nmu2 - 1); /* Score outward current */ ptr = (long)RDB[icm + ICM_RES_CC1]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); AddBuf(1.0, wgt, ptr, id, -1, idx0, mua0, mus0, ng0, idx, mua, mus, ng); ptr = (long)RDB[icm + ICM_RES_CC2]; CheckPointer(FUNCTION_NAME, "(ptr)", DATA_ARRAY, ptr); AddBuf(wgt0, wgt, ptr, id, -1, idx0, mua0, mus0, ng0, idx, mua, mus, ng); } else if ((ng0 > -1) && (RDB[DATA_CYCLE_IDX] > RDB[DATA_CRIT_SKIP] + 20.0)) Warn(FUNCTION_NAME, "Problem in geometry?"); } /* Reset values */ icm0 = -1; idx0 = -1; mua0 = -1; mus0 = -1; ng0 = -1; wgt0 = 1.0; } } } /* Put previous position */ in0 = in1; } /* Check if particle is in */ if (in1 == YES) { /* Update new values */ if (icm1 > VALID_PTR) Die(FUNCTION_NAME, "Point (%E, %E, %E) is in multiple regions", x, y, z); else { icm1 = icm0; idx1 = idx0; mua1 = mua0; mus1 = mus0; ng1 = ng0; wgt1 = wgt0; } /* Check number of crossings */ if (ncross == 0) { /* Surface index cannot have changed */ if (idx0 != (long)RDB[part + PARTICLE_ICM_IDX]) Die(FUNCTION_NAME, "This is impossible"); /* No other crossings are possible, add to counter */ ptr = (long)RDB[icm + ICM_BREAK_PTR_COUNT]; CheckPointer(FUNCTION_NAME, "(ptr)", PRIVA_ARRAY, ptr); AddPrivateData(ptr, 1, id); /* Break loop */ break; } } /* Next */ icm = NextItem(icm); } /* Store values */ WDB[part + PARTICLE_ICM_PTR_ICM] = (double)icm1; WDB[part + PARTICLE_ICM_IDX] = (double)idx1; WDB[part + PARTICLE_ICM_MUA] = (double)mua1; WDB[part + PARTICLE_ICM_MUS] = (double)mus1; WDB[part + PARTICLE_ICM_G] = (double)ng1; WDB[part + PARTICLE_ICM_WGT] = wgt1; }