int main() { int op = 0; // 当前要执行的操作代码 Car carBase; // 空的链表头 carBase.next = NULL; printf("==============================\n"); printf("=== Used car database ========\n"); printf("==============================\n"); while (op != 4) { printf("Enter an operation:\n"); printf("1 - Car aquired. Add a new entry for it.\n"); printf("2 - sold. Remove its entry.\n"); printf("3 - Query. Look up a car's informaiton."\n); printf("4 - Quit\n"); scanf("%d", &op); if (op == 1) AddEntry(&carBase); else if (op == 2) DeleteEntry(&carBase); else if (op == 3) Search(&carBase); else if (op == 4) printf("Goodbye.\n\n"); else printf("Invalid option. Try again.\n\n"); } }
//************************************************************************ // deletes a group object by string //************************************************************************ void CContactList::DeleteGroupObjectByPath(tstring strPath) { ASSERT(!strPath.empty()); CContactListGroup *pParentGroup = NULL; vector<CContactListGroup*>::iterator iter = m_Groups.begin(); for(iter = m_Groups.begin();iter != m_Groups.end();iter++) { if((*iter)->strPath == strPath) { CContactListGroup *pGroup = *iter; m_Groups.erase(iter); if(pGroup->pContactListEntry) { DeleteEntry(pGroup->pContactListEntry); } delete pGroup; tstring strParse = strPath; tstring::size_type pos = strParse.rfind('\\'); if(pos != tstring::npos ) { strParse = strParse.substr(0,pos); pParentGroup = GetGroupObjectByPath(strParse); pParentGroup->iGroups--; if(pParentGroup->iMembers <= 0 && pParentGroup->iGroups <= 0) DeleteGroupObjectByPath(strParse); } return; } } }
void CLDS_File::Delete(const CLDS_Set& record_set) { CLDS_Set::enumerator en(record_set.first()); for ( ; en.valid(); ++en) { DeleteEntry(*en); } }
void MTnode::SortEntries () { int n = NumEntries (); MTentry **array = new MTentry *[n], *objEntry = NULL; for (int i=0; i<n; i++) { array[i] = (MTentry *) ((MTentry *)(*this)[i].Ptr())->Copy(); if (&((MTentry *)(*this)[i].Ptr())->object() == obj) { objEntry = array[i]; } } qsort (array, n, sizeof(MTentry *), MTentryCmp); while (NumEntries() > 0) { DeleteEntry (0); // also delete the obj } int obji = -1; for (int i=0; i<n; i++) { InsertBefore (*(array[i]), i); if (array[i] == objEntry) { obji = i; } delete array[i]; } delete []array; if (obji >= 0) { obj = &((MTentry *)(*this)[obji].Ptr())->object(); } }
void TTreeView::DeleteItem(uint32 item) { TableEntryRecord *foo; TableEntryRecord *me,*par; me = (TableEntryRecord *)item; par = me->parent; if (par == NULL) { if (fRoot == me) { fRoot = me->next; } else for (foo = fRoot; foo != NULL; foo = foo->next) { if (foo->next == me) { foo->next = me->next; break; } } } else { if (par->child == me) { par->child = me->next; } else for (foo = par->child; foo != NULL; foo = foo->next) { if (foo->next == me) { foo->next = me->next; break; } } } DeleteEntry(me); Update(); }
void GiSTnode::DeleteBulk (int vec[], int veclen) { qsort (vec, veclen, sizeof(int), GiSTintcmp); for (int i=veclen-1; i>=0; i--) { DeleteEntry (vec[i]); } }
bool CAcceleratorManager::DeleteEntry(LPCTSTR szCommand) { ASSERT(szCommand != NULL); WORD wIDCommand; if (m_mapAccelString.Lookup(szCommand, wIDCommand) == TRUE) { return DeleteEntry(wIDCommand); } return true; }
void EditTOC::ConnectSignalsToSlots() { connect(this, SIGNAL(accepted()), this, SLOT(Save())); connect(ui.AddEntryAbove, SIGNAL(clicked()), this, SLOT(AddEntryAbove())); connect(ui.AddEntryBelow, SIGNAL(clicked()), this, SLOT(AddEntryBelow())); connect(ui.DeleteEntry, SIGNAL(clicked()), this, SLOT(DeleteEntry())); connect(ui.MoveLeft, SIGNAL(clicked()), this, SLOT(MoveLeft())); connect(ui.MoveRight, SIGNAL(clicked()), this, SLOT(MoveRight())); connect(ui.MoveUp, SIGNAL(clicked()), this, SLOT(MoveUp())); connect(ui.MoveDown, SIGNAL(clicked()), this, SLOT(MoveDown())); connect(m_MoveUp, SIGNAL(triggered()), this, SLOT(MoveUp())); connect(m_MoveDown, SIGNAL(triggered()), this, SLOT(MoveDown())); connect(ui.SelectTarget, SIGNAL(clicked()), this, SLOT(SelectTarget())); connect(ui.TOCTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(OpenContextMenu(const QPoint &))); connect(m_Rename, SIGNAL(triggered()), this, SLOT(Rename())); connect(m_Delete, SIGNAL(triggered()), this, SLOT(DeleteEntry())); connect(m_CollapseAll, SIGNAL(triggered()), this, SLOT(CollapseAll())); connect(m_ExpandAll, SIGNAL(triggered()), this, SLOT(ExpandAll())); }
bool CAcceleratorManager::DeleteEntry(LPCTSTR szCommand) { ASSERT(szCommand != NULL); // WORD wIDCommand; CMapStringToWord::iterator it = m_mapAccelString.find((char *)szCommand); if (it != m_mapAccelString.end()) { return DeleteEntry(it->second); } return true; }
void TTreeView::DeleteAll() { TableEntryRecord *te; while (fRoot) { te = fRoot; fRoot = fRoot->next; DeleteEntry(te); } Update(); }
void sentinelTest() { HashTablePTR table = (HashTablePTR) junkdatasentinel; VER(InsertEntry(table, NULL, NULL, NULL), "Insert"); VER(DeleteEntry(table, NULL, NULL), "Delete"); VER(FindEntry(table, NULL, NULL), "Find"); VER(GetKeys(table, NULL, NULL), "Get"); VER(GetLoadFactor(table, NULL), "Load"); VER(GetHashTableInfo(table, NULL), "Info"); VER(SetResizeBehaviour(table, 0, 0, 0), "Resize factor"); VER(DestroyHashTable(&table), "Destroy"); }
void TTreeView::DeleteEntry(TableEntryRecord *e) { TableEntryRecord *foo; SetSelected( (uint32)e, false ); while (e->child) { foo = e->child; e->child = foo->next; DeleteEntry(foo); } if (e->strHandle) { fData.Free(e->strHandle); } if (e->dataHandle) { fData.Free(e->dataHandle); } delete e; }
bool D3DVertexBufferCache::InitBuffer(D3DDevice *d3d, BYTE *data, int size, CacheEntryInfo &info) { assert(d3d != NULL); assert(data != NULL); assert(size > 0); int best = FindBestEntry(size); CacheEntry *ce = NULL; // Reallocate if (best >= 0 && _cache[best].size < size) { DeleteEntry(best); best = -1; } // New if (best < 0) { CacheEntry new_entry; if (!CreateEntry(d3d, new_entry, size)) { WRN("Failed to create new vbcache entry"); return false; } _cache.Add(new_entry); info.id = _cache.Length() - 1; ce = _cache.Last(); } else { info.id = best; ce = &_cache[best]; } assert(ce != NULL); if (!InsertData(*ce, data, size)) { WRN("Failed to insert vbcache data"); return false; } return true; }
// quick-sort the entries with respect to the distance from the parent void MTnode::Order() { int i, obji=-1, n=NumEntries(); MTentry **array=new MTentry *[n], *objEntry=NULL; for(i=0; i<n; i++) { array[i]=(MTentry *)((MTentry *)(*this)[i].Ptr())->Copy(); if(obj==&((MTentry *)(*this)[i].Ptr())->object()) objEntry=array[i]; } qsort(array, n, sizeof(MTentry *), MTentrycmp); while(NumEntries()>0) DeleteEntry(0); for(i=0; i<n; i++) { InsertBefore(*(array[i]), i); if(objEntry==array[i]) obji=i; delete array[i]; } delete []array; if(obji>=0) obj=&((MTentry *)(*this)[obji].Ptr())->object(); }
void VolumeWorker::_Work() { list_collection collection; fVolumeWatcher->GetSecureEntries(collection); if (collection.createdList->size() == 0 && collection.deletedList->size() == 0 && collection.modifiedList->size() == 0 && collection.movedList->size() == 0) return; _SetBusy(true); for (unsigned int i = 0; i < collection.createdList->size() || Stopped(); i++) AnalyseEntry((*collection.createdList)[i]); collection.createdList->clear(); for (unsigned int i = 0; i < collection.deletedList->size() || Stopped(); i++) DeleteEntry((*collection.deletedList)[i]); collection.deletedList->clear(); for (unsigned int i = 0; i < collection.modifiedList->size() || Stopped(); i++) AnalyseEntry((*collection.modifiedList)[i]); collection.modifiedList->clear(); for (unsigned int i = 0; i < collection.movedList->size() || Stopped(); i++) MoveEntry((*collection.movedFromList)[i], (*collection.movedList)[i]); collection.movedList->clear(); collection.movedFromList->clear(); LastEntry(); PostMessage(kTriggerWork); _SetBusy(false); }
int ListInterface::DeleteSelectionFrom( const wxString &name ) { List *list = FindListByName(name); if( !list ) return DELETE_FAIL; //Find name in list int itemid = list->GetSelectedIndex(); if( itemid == -1 ) return DELETE_FAIL; wxString entryName = list->GetColumnValue(itemid, 0); list->DeleteItem(itemid); DeleteEntry(entryName); if( list->isEmpty() ) return DELETE_OK_AND_EMPTY_LIST; return DELETE_OK; }
// delete a tuple from all its indexes it belongs to. void TransactionLevelGCManager::DeleteTupleFromIndexes(ItemPointer *indirection) { // do nothing if indirection is null if (indirection == nullptr){ return; } LOG_TRACE("Deleting indirection %p from index", indirection); ItemPointer location = *indirection; auto &manager = catalog::Manager::GetInstance(); auto tile_group = manager.GetTileGroup(location.block); PL_ASSERT(tile_group != nullptr); storage::DataTable *table = dynamic_cast<storage::DataTable *>(tile_group->GetAbstractTable()); PL_ASSERT(table != nullptr); // construct the expired version. expression::ContainerTuple<storage::TileGroup> expired_tuple(tile_group.get(), location.offset); // unlink the version from all the indexes. for (size_t idx = 0; idx < table->GetIndexCount(); ++idx) { auto index = table->GetIndex(idx); auto index_schema = index->GetKeySchema(); auto indexed_columns = index_schema->GetIndexedColumns(); // build key. std::unique_ptr<storage::Tuple> key( new storage::Tuple(index_schema, true)); key->SetFromTuple(&expired_tuple, indexed_columns, index->GetPool()); index->DeleteEntry(key.get(), indirection); } }
/* Scrubs object sPath entry and data if possible. Returns: SCRUB_OK - Successful SCRUB_ERR - Errors occured */ int Scrubber::ScrubObject(const char* sPath, char* arrBuffer) { int nVal, nResult = SCRUB_OK; Utility::FILE_TYPE fType = Utility::GetFileType(sPath); // Check if file can be scrubbed if(fType != Utility::DIRECTORY) { int fdFile; int flags = O_RDWR; off64_t nFileSize; // Open file for writing fdFile = open(sPath, flags, 0644); // Check for open errors if(fdFile < 0) { // Report open error snprintf(sLogBuf, MESSAGE_LEN, "ERROR: %s. Occured while opening file %s. Inside function ScrubObject().", strerror(errno), sPath); WriteToLog(ScrubLogger::SCRUB_OPEN_ERROR, this->nCurrFile, sLogBuf); nResult = SCRUB_ERR; } else { nFileSize = Utility::GetFileSize(sPath); if (nFileSize == -1) { nResult = SCRUB_ERR; snprintf(sLogBuf, MESSAGE_LEN, "ERROR: Unable to get file size: %s. File skipped.\nInside function ScrubObject().\n", sPath); WriteToLog(ScrubLogger::SCRUB_ERROR, this->nCurrFile, sLogBuf); } else { // Scrub data nVal = ScrubData(fdFile, nFileSize, arrBuffer); // Check if scrub was successful if(nVal != SCRUB_OK) { nResult = SCRUB_ERR; } } // Close file if (close(fdFile) < 0) { snprintf(sLogBuf, MESSAGE_LEN, "ERROR: %s - Occured while closing file %s.\nInside function ScrubObject().\n", strerror(errno), sPath); WriteToLog(ScrubLogger::SCRUB_ERROR, this->nCurrFile, sLogBuf); nResult = SCRUB_ERR; } } } // Check if file/directory for entry scrub if ((nResult == SCRUB_OK) && (fType == Utility::REGULAR || fType == Utility::DIRECTORY)) { char* sNewPath; // Report scrub entry start WriteToLog(ScrubLogger::SCRUB_ENTRY_START, this->nCurrFile); // Scrub entry if(ScrubEntry(sPath, sNewPath) != SCRUB_OK) nResult = SCRUB_ERR; // Delete file/directory if(DeleteEntry(sNewPath) != SCRUB_OK) nResult = SCRUB_ERR; // Report scrub entry end with result WriteToLog(ScrubLogger::SCRUB_ENTRY_END, nResult); delete [] sNewPath; } return nResult; }
bool QueueEditor::InternEditList(DownloadQueue* pDownloadQueue, IDList* pIDList, bool bSmartOrder, EEditAction eAction, int iOffset, const char* szText) { if (eAction == eaGroupMoveOffset) { AlignAffectedGroups(pDownloadQueue, pIDList, bSmartOrder, iOffset); } ItemList cItemList; PrepareList(pDownloadQueue, &cItemList, pIDList, bSmartOrder, eAction, iOffset); if (eAction == eaFilePauseAllPars || eAction == eaFilePauseExtraPars) { PauseParsInGroups(&cItemList, eAction == eaFilePauseExtraPars); } else if (eAction == eaGroupMerge) { MergeGroups(pDownloadQueue, &cItemList); } else if (eAction == eaFileReorder) { ReorderFiles(pDownloadQueue, &cItemList); } else { for (ItemList::iterator it = cItemList.begin(); it != cItemList.end(); it++) { EditItem* pItem = *it; switch (eAction) { case eaFilePause: PauseUnpauseEntry(pItem->m_pFileInfo, true); break; case eaFileResume: PauseUnpauseEntry(pItem->m_pFileInfo, false); break; case eaFileMoveOffset: case eaFileMoveTop: case eaFileMoveBottom: MoveEntry(pDownloadQueue, pItem->m_pFileInfo, pItem->m_iOffset); break; case eaFileDelete: DeleteEntry(pItem->m_pFileInfo); break; case eaFileSetPriority: SetPriorityEntry(pItem->m_pFileInfo, szText); break; case eaGroupSetCategory: SetNZBCategory(pItem->m_pFileInfo->GetNZBInfo(), szText); break; case eaGroupSetName: SetNZBName(pItem->m_pFileInfo->GetNZBInfo(), szText); break; case eaGroupSetParameter: SetNZBParameter(pItem->m_pFileInfo->GetNZBInfo(), szText); break; case eaGroupPause: case eaGroupResume: case eaGroupDelete: case eaGroupMoveTop: case eaGroupMoveBottom: case eaGroupMoveOffset: case eaGroupPauseAllPars: case eaGroupPauseExtraPars: case eaGroupSetPriority: EditGroup(pDownloadQueue, pItem->m_pFileInfo, eAction, iOffset, szText); break; case eaFilePauseAllPars: case eaFilePauseExtraPars: case eaGroupMerge: case eaFileReorder: // remove compiler warning "enumeration not handled in switch" break; } delete pItem; } } return cItemList.size() > 0; }
bool QueueEditor::InternEditList(ItemList* itemList, IdList* idList, DownloadQueue::EEditAction action, int offset, const char* text) { ItemList workItems; if (!itemList) { itemList = &workItems; PrepareList(itemList, idList, action, offset); } switch (action) { case DownloadQueue::eaFilePauseAllPars: case DownloadQueue::eaFilePauseExtraPars: PauseParsInGroups(itemList, action == DownloadQueue::eaFilePauseExtraPars); break; case DownloadQueue::eaGroupMerge: return MergeGroups(itemList); case DownloadQueue::eaGroupSort: return SortGroups(itemList, text); case DownloadQueue::eaFileSplit: return SplitGroup(itemList, text); case DownloadQueue::eaFileReorder: ReorderFiles(itemList); break; default: for (EditItem& item : itemList) { switch (action) { case DownloadQueue::eaFilePause: PauseUnpauseEntry(item.m_fileInfo, true); break; case DownloadQueue::eaFileResume: PauseUnpauseEntry(item.m_fileInfo, false); break; case DownloadQueue::eaFileMoveOffset: case DownloadQueue::eaFileMoveTop: case DownloadQueue::eaFileMoveBottom: MoveEntry(item.m_fileInfo, item.m_offset); break; case DownloadQueue::eaFileDelete: DeleteEntry(item.m_fileInfo); break; case DownloadQueue::eaGroupSetPriority: SetNzbPriority(item.m_nzbInfo, text); break; case DownloadQueue::eaGroupSetCategory: case DownloadQueue::eaGroupApplyCategory: SetNzbCategory(item.m_nzbInfo, text, action == DownloadQueue::eaGroupApplyCategory); break; case DownloadQueue::eaGroupSetName: SetNzbName(item.m_nzbInfo, text); break; case DownloadQueue::eaGroupSetDupeKey: case DownloadQueue::eaGroupSetDupeScore: case DownloadQueue::eaGroupSetDupeMode: SetNzbDupeParam(item.m_nzbInfo, action, text); break; case DownloadQueue::eaGroupSetParameter: SetNzbParameter(item.m_nzbInfo, text); break; case DownloadQueue::eaGroupMoveTop: case DownloadQueue::eaGroupMoveBottom: case DownloadQueue::eaGroupMoveOffset: MoveGroup(item.m_nzbInfo, item.m_offset); break; case DownloadQueue::eaGroupPause: case DownloadQueue::eaGroupResume: case DownloadQueue::eaGroupPauseAllPars: case DownloadQueue::eaGroupPauseExtraPars: EditGroup(item.m_nzbInfo, action, offset, text); break; case DownloadQueue::eaGroupDelete: case DownloadQueue::eaGroupParkDelete: case DownloadQueue::eaGroupDupeDelete: case DownloadQueue::eaGroupFinalDelete: if (item.m_nzbInfo->GetKind() == NzbInfo::nkUrl) { DeleteUrl(item.m_nzbInfo, action); } else { EditGroup(item.m_nzbInfo, action, offset, text); } default: // suppress compiler warning "enumeration not handled in switch" break; } } } return itemList->size() > 0; }
static LONG_PTR WINAPI DlgProc(HANDLE hDlg,int Msg,int Param1,LONG_PTR Param2) { static TCHAR Filter[MAX_PATH]; static TCHAR spFilter[MAX_PATH]; static FarListTitles ListTitle; switch(Msg) { case DN_RESIZECONSOLE: { Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0); ResizeDialog(hDlg); Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0); } return TRUE; case DMU_UPDATE: { int OldPos = static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,0)); if (Param1) UpDateInfo(); ListSize = 0; int NewPos = -1; if (OldPos >= 0 && OldPos < nCount) { if (!*Filter || strstri(p[OldPos].Keys[DisplayName],Filter)) //без учета регистра в OEM кодировке NewPos = OldPos; } for (int i = 0; i < nCount; i++) { const TCHAR* DispName = p[i].Keys[DisplayName], *Find; if (*Filter) Find = strstri(DispName,Filter); else Find = DispName; if (Find != nullptr) //без учета регистра в OEM кодировке { FLI[i].Flags &= ~LIF_HIDDEN; if (Param2 && (i == OldPos)) { if (FLI[i].Flags & LIF_CHECKED) { FLI[i].Flags &= ~LIF_CHECKED; } else { FLI[i].Flags |= LIF_CHECKED; } } //без учета регистра - а кодировка ANSI if (NewPos == -1 && Find == DispName) NewPos = i; ListSize++; } else FLI[i].Flags |= LIF_HIDDEN; } if (Param1 == 0 && Param2) { // Снятие или установка пометки (Ins) if (Param2 == 1) { for (int i = (OldPos+1); i < nCount; i++) { if (!(FLI[i].Flags & LIF_HIDDEN)) { OldPos = i; break; } } NewPos = OldPos; } // Снятие или установка пометки (RClick) else if (Param2 == 2) { NewPos = OldPos; } } else if (NewPos == -1) { NewPos = OldPos; } Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0); Info.SendDlgMessage(hDlg,DM_LISTSET,LIST_BOX,reinterpret_cast<LONG_PTR>(&FL)); StringCchPrintf(spFilter,ARRAYSIZE(spFilter), GetMsg(MFilter),Filter,ListSize,nCount); ListTitle.Title = spFilter; ListTitle.TitleLen = lstrlen(spFilter); Info.SendDlgMessage(hDlg,DM_LISTSETTITLES,LIST_BOX,reinterpret_cast<LONG_PTR>(&ListTitle)); ResizeDialog(hDlg); struct FarListPos FLP; FLP.SelectPos = NewPos; FLP.TopPos = -1; Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,LIST_BOX,reinterpret_cast<LONG_PTR>(&FLP)); Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0); } break; case DN_INITDIALOG: { StringCchCopy(Filter,ARRAYSIZE(Filter),_T("")); ListTitle.Bottom = const_cast<TCHAR*>(GetMsg(MBottomLine)); ListTitle.BottomLen = lstrlen(GetMsg(MBottomLine)); //подстраиваемся под размеры консоли Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0); ResizeDialog(hDlg); Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0); //заполняем диалог Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } break; case DN_MOUSECLICK: { if (Param1 == LIST_BOX) { MOUSE_EVENT_RECORD *mer = (MOUSE_EVENT_RECORD *)Param2; if (mer->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) { // find list on-screen coords (excluding frame and border) SMALL_RECT list_rect; Info.SendDlgMessage(hDlg, DM_GETDLGRECT, 0, reinterpret_cast<LONG_PTR>(&list_rect)); list_rect.Left += 2; list_rect.Top += 1; list_rect.Right -= 2; list_rect.Bottom -= 1; if ((mer->dwEventFlags == 0) && (mer->dwMousePosition.X > list_rect.Left) && (mer->dwMousePosition.X < list_rect.Right) && (mer->dwMousePosition.Y > list_rect.Top) && (mer->dwMousePosition.Y < list_rect.Bottom)) { DlgProc(hDlg, DN_KEY, LIST_BOX, KEY_ENTER); return TRUE; } // pass message to scrollbar if needed if ((mer->dwMousePosition.X == list_rect.Right) && (mer->dwMousePosition.Y > list_rect.Top) && (mer->dwMousePosition.Y < list_rect.Bottom)) return FALSE; return TRUE; } else if (mer->dwButtonState == RIGHTMOST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMU_UPDATE,0,2); return TRUE; } } } break; case DN_KEY: switch (Param2) { case KEY_F8: { if (ListSize) { TCHAR DlgText[MAX_PATH + 200]; StringCchPrintf(DlgText, ARRAYSIZE(DlgText), GetMsg(MConfirm), p[Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)].Keys[DisplayName]); if (EMessage((const TCHAR * const *) DlgText, 0, 2) == 0) { if (!DeleteEntry(static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)))) DrawMessage(FMSG_WARNING, 1, "%s",GetMsg(MPlugIn),GetMsg(MDelRegErr),GetMsg(MBtnOk),NULL); Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } } } return TRUE; case (KEY_F9|KEY_SHIFT|KEY_ALT): case (KEY_F9): { Configure(0); } return TRUE; case KEY_CTRLR: { Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } return TRUE; case KEY_INS: { Info.SendDlgMessage(hDlg,DMU_UPDATE,0,1); } return TRUE; case KEY_ENTER: case KEY_SHIFTENTER: { if (ListSize) { int liChanged = 0; int liSelected = 0, liFirst = -1; for (int i = 0; i < nCount; i++) { if (FLI[i].Flags & LIF_CHECKED) { if (liFirst == -1) liFirst = i; liSelected++; } } if (liSelected <= 1) { int liAction = (Param2 == KEY_ENTER) ? Opt.EnterAction : Opt.ShiftEnterAction; int pos = (liFirst == -1) ? static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL)) : liFirst; liChanged = ExecuteEntry(pos, liAction, (Opt.RunLowPriority!=0)); } else { int liAction = (Param2 == KEY_ENTER) ? Opt.EnterAction : Opt.ShiftEnterAction; bool LowPriority = (Opt.RunLowPriority!=0); // Обязательно ожидание - два инсталлятора сразу недопускаются if (liAction == Action_Menu) { if (EntryMenu(0, liAction, LowPriority, liSelected) < 0) return TRUE; } else if (liAction == Action_Uninstall) liAction = Action_UninstallWait; else if (liAction == Action_Modify) liAction = Action_ModifyWait; else if (liAction == Action_Repair) liAction = Action_RepairWait; for (int pos = 0; pos < nCount; pos++) { if (!(FLI[pos].Flags & LIF_CHECKED)) continue; struct FarListPos FLP; FLP.SelectPos = pos; FLP.TopPos = -1; Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,LIST_BOX,reinterpret_cast<LONG_PTR>(&FLP)); int li = ExecuteEntry(pos, liAction, LowPriority); if (li == -1) break; // отмена if (li == 1) liChanged = 1; } } if (liChanged == 1) { Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } } } return TRUE; case KEY_SHIFTINS: case KEY_CTRLV: { TCHAR * bufP = FSF.PasteFromClipboard(); static TCHAR bufData[MAX_PATH]; if (bufP) { StringCchCopy(bufData,ARRAYSIZE(bufData),bufP); FSF.DeleteBuffer(bufP); unQuote(bufData); FSF.LStrlwr(bufData); for (int i = lstrlen(bufData); i >= 1; i--) for (int j = 0; j < nCount; j++) if (strnstri(p[j].Keys[DisplayName],bufData,i)) { lstrcpyn(Filter,bufData,i+1); Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); return TRUE; } } } return TRUE; case KEY_DEL: { if (lstrlen(Filter) > 0) { StringCchCopy(Filter,ARRAYSIZE(Filter),_T("")); Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); } } return TRUE; case KEY_F3: case KEY_F4: { if (ListSize) { DisplayEntry(static_cast<int>(Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,LIST_BOX,NULL))); Info.SendDlgMessage(hDlg,DM_REDRAW,NULL,NULL); } } return TRUE; case KEY_F2: { Opt.SortByDate = !Opt.SortByDate; Info.SendDlgMessage(hDlg,DMU_UPDATE,1,0); } return TRUE; case KEY_BS: { if (lstrlen(Filter)) { Filter[lstrlen(Filter)-1] = '\0'; Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); } } return TRUE; default: { if (Param2 >= KEY_SPACE && Param2 < KEY_FKEY_BEGIN) { struct FarListInfo ListInfo; Info.SendDlgMessage(hDlg,DM_LISTINFO,LIST_BOX,reinterpret_cast<LONG_PTR>(&ListInfo)); if ((lstrlen(Filter) < sizeof(Filter)) && ListInfo.ItemsNumber) { int filterL = lstrlen(Filter); Filter[filterL] = FSF.LLower(static_cast<unsigned>(Param2)); Filter[filterL+1] = '\0'; Info.SendDlgMessage(hDlg,DMU_UPDATE,0,0); return TRUE; } } } } return FALSE; case DN_CTLCOLORDIALOG: return Info.AdvControl(Info.ModuleNumber,ACTL_GETCOLOR,(void *)COL_MENUTEXT); case DN_CTLCOLORDLGLIST: if (Param1 == LIST_BOX) { FarListColors *Colors = (FarListColors *)Param2; int ColorIndex[] = { COL_MENUBOX, COL_MENUBOX, COL_MENUTITLE, COL_MENUTEXT, COL_MENUHIGHLIGHT, COL_MENUBOX, COL_MENUSELECTEDTEXT, COL_MENUSELECTEDHIGHLIGHT, COL_MENUSCROLLBAR, COL_MENUDISABLEDTEXT, COL_MENUARROWS, COL_MENUARROWSSELECTED, COL_MENUARROWSDISABLED }; int Count = ARRAYSIZE(ColorIndex); if (Count > Colors->ColorCount) Count = Colors->ColorCount; for (int i = 0; i < Count; i++) Colors->Colors[i] = static_cast<BYTE>(Info.AdvControl(Info.ModuleNumber, ACTL_GETCOLOR, reinterpret_cast<void *>(ColorIndex[i]))); return TRUE; } break; } return Info.DefDlgProc(hDlg,Msg,Param1,Param2); }
void CMnemosynthDb::IncorporateDelta (CDatum dPayload) // IncorporateDelta // // Incorporates the delta data { CSmartLock Lock(m_cs); int i; // Get various elements CDatum dCollections = dPayload.GetElement(STR_COLLECTIONS); CDatum dEndpoint = dPayload.GetElement(STR_ENDPOINT); CDatum dEntries = dPayload.GetElement(STR_ENTRIES); DWORD dwProcessID = dPayload.GetElement(FIELD_PROCESS_ID); // Make sure the endpoint exists SEndpoint *pEndpoint = GetOrAddEndpoint(dEndpoint, dwProcessID); DWORD dwOriginalSeq = pEndpoint->dwSeqRecv; DWORD dwMaxSeq = dwOriginalSeq; // Loop over all entries for (i = 0; i < dEntries.GetCount(); i++) { CDatum dEntry = dEntries.GetElement(i); DWORD dwSeq = (DWORD)(int)dEntry.GetElement(3); if (dwSeq > dwOriginalSeq) { // LATER: Detect and resolve conflicts if (dwSeq > dwMaxSeq) dwMaxSeq = dwSeq; const CString &sCollection = dCollections.GetElement((int)dEntry.GetElement(0)); const CString &sKey = dEntry.GetElement(1); CDatum dValue = dEntry.GetElement(2); // If we're not CentralModule and we get a deletion, then delete // right away. If we're CentralModule then we incorporate because // we will send it out on the next update. if (dValue.IsNil() && !m_pProcess->IsCentralModule()) { DeleteEntry(sCollection, sKey); #ifdef DEBUG_MNEMOSYNTH printf("Delete entry: %s/%s\n", (LPSTR)sCollection, (LPSTR)sKey); #endif } // Incorporate else { SEntry *pEntry = GetWriteEntry(sCollection, sKey); pEntry->dValue = dValue; pEntry->dwOwnerID = pEndpoint->dwID; pEntry->dwSequence = dwSeq; #ifdef DEBUG_MNEMOSYNTH printf("Modify entry: %s/%s [owner = %s seq = %d]\n", (LPSTR)sCollection, (LPSTR)sKey, (LPSTR)pEndpoint->sName, dwSeq); #endif } } #ifdef DEBUG_MNEMOSYNTH else { printf("%s: Skipping %s because %d <= %d\n", (LPSTR)m_pProcess->GetModuleName(), (LPSTR)dCollections.GetElement((int)dEntry.GetElement(0)).AsString(), dwSeq, dwOriginalSeq); } #endif } // Done pEndpoint->dwSeqRecv = dwMaxSeq; }
int main(void) { int choice; int ret; ret = eXdbmInit(); if(ret==-1) { ErrorMessage(); return(EXIT_FAILURE); } choice=-1; while(choice!=12) { choice = MainMenu(); switch(choice) { case 1 : OpenDatabase(); break; case 2 : NewDatabase(); break; case 3 : CloseDatabase(); break; case 4 : UpdateDatabase(); break; case 5 : BackupDatabase(); break; case 6 : ReloadDatabase(); break; case 7 : PrintDatabase(); break; case 8 : PrintValues(); break; case 9 : AddEntry(); break; case 10: ChangeEntry(); break; case 11 : DeleteEntry(); break; } } printf("\n\nBye bye ...\n"); return(1); }
access_token_ = s.value("access_token").toString(); server_ = s.value("server").toString(); QByteArray tree_bytes = s.value("tree").toByteArray(); if (!tree_bytes.isEmpty()) { QDataStream stream(&tree_bytes, QIODevice::ReadOnly); stream >> tree_; } app->player()->RegisterUrlHandler(new SeafileUrlHandler(this, this)); connect(&tree_, SIGNAL(ToAdd(QString, QString, SeafileTree::Entry)), this, SLOT(AddEntry(QString, QString, SeafileTree::Entry))); connect(&tree_, SIGNAL(ToDelete(QString, QString, SeafileTree::Entry)), this, SLOT(DeleteEntry(QString, QString, SeafileTree::Entry))); connect(&tree_, SIGNAL(ToUpdate(QString, QString, SeafileTree::Entry)), this, SLOT(UpdateEntry(QString, QString, SeafileTree::Entry))); } bool SeafileService::has_credentials() const { return !access_token_.isEmpty(); } void SeafileService::AddAuthorizationHeader(QNetworkRequest* request) const { request->setRawHeader("Authorization", QString("Token %1").arg(access_token_).toAscii()); } void SeafileService::ForgetCredentials() { QSettings s;
int main() { HashTablePTR table = NULL; for(;;) { char cmd[80]; printf("Command: "); int retval = scanf("%79s", cmd); if (retval <= 0) break; if (strcmp(cmd, "create") == 0) { printf("Size: "); int size; scanf("%d", &size); /* note: this is a signed int because unsigned int * conversion in scanf is drunk and return 0xffffffff * for -1. */ if (size < 0) { printf("Size cannot be negative, clamping to 0.\n"); size = 0; } if (table != NULL) DestroyHashTable(&table); CreateHashTable(&table, (unsigned int) size); if (table == NULL) { printf("create returned NULL\n"); } else { printf("create returned non-NULL\n"); } } else if (strcmp(cmd, "destroy") == 0) { freeHashTableContents(table); DestroyHashTable(&table); if (table != NULL) { printf("FAIL: destroy did not set NULL"); } } else if (strcmp(cmd, "print") == 0) { printHashTable(table); } else if (strcmp(cmd, "set") == 0) { printf("Key: "); char key[81]; scanf(" %80s", key); char* value = malloc(81 * sizeof(char)); scanf(" %80s", value); char* existingData = NULL; int success = InsertEntry(table, key, value, (void**) &existingData); switch(success){ case GET_NONE: printf("Inserted into blank space\n"); break; case GET_COLLIDE: printf("Inserted after resolving hash collision\n"); break; case GET_EXISTS: printf("Inserted after removing existing data: %s\n", existingData); free(existingData); break; default: printf("InsertEntry failed\n"); free(value); break; } if (success >= 0) { HashTableInfo info; int status2 = GetHashTableInfo(table, &info); if (status2 == 0) { if (info.dynamicBehaviour && info.useFactor > info.expandUseFactor) { printf("Insert FAIL: use factor %f" " greater than expand use factor. %f\n", info.useFactor, info.expandUseFactor); } } } } else if (strcmp(cmd, "read") == 0) { printf("Key: "); char key[81]; scanf(" %80s", key); char* value; int success = FindEntry(table, key, (void**) &value); if (success == 0) { printf("%s\n", value); } else { printf("readPosition returned failure\n"); } } else if (strcmp(cmd, "delete") == 0) { printf("Key: "); char key[81]; scanf(" %80s", key); char* value; int success = DeleteEntry(table, key, (void**) &value); if (success == 0) { printf("Deleted (was %s)\n", value); free(value); HashTableInfo info; int status2 = GetHashTableInfo(table, &info); if (status2 == 0) { if (info.dynamicBehaviour && info.useFactor < info.contractUseFactor) { printf("Delete FAIL: use factor %f" " less than contract use factor. %f\n", info.useFactor, info.contractUseFactor); } } } else { printf("DeleteValue returned failure\n"); } } else if (strcmp(cmd, "load") == 0) { float myfloat; int status = GetLoadFactor(table, &myfloat); if (status == 0) { printf("Load factor: %f\n", myfloat); } else { printf("Load factor returned failure\n"); } } else if (strcmp(cmd, "sentinel") == 0) { sentinelTest(); } else if (strcmp(cmd, "info") == 0) { HashTableInfo info; int status = GetHashTableInfo(table, &info); if (status == 0) { printf( "Bucket count: %u\n" "Load factor: %f\n" "Use factor: %f\n" "Largest bucket size: %u\n" "Dynamic behaviour: %d\n" "Expand use factor: %f\n" "Contract use factor: %f\n", info.bucketCount, info.loadFactor, info.useFactor, info.largestBucketSize, info.dynamicBehaviour, info.expandUseFactor, info.contractUseFactor); } else { printf("GetHashTableInfo returned failure\n"); } } else if (strcmp(cmd, "setresize") == 0) { int resize; float expand, contract; printf("Resize: (0/1) "); scanf("%d", &resize); printf("Expand: "); scanf("%f", &expand); printf("Contract: "); scanf("%f", &contract); int status = SetResizeBehaviour(table, resize, expand, contract); if (status != 0) { printf("Set resize returned failure\n"); } } else if (strcmp(cmd, "quit") == 0) { break; } else { printf("Invalid command\n"); } } if (table != NULL) { freeHashTableContents(table); DestroyHashTable(&table); } return 0; }