static struct Statement * CopyStatement(struct Statement * stmt) { struct Statement * result = (((void *)0)); if(stmt) { switch(stmt->type) { case 2: result = MkCompoundStmt(CopyList(stmt->compound.declarations, CopyDeclaration), CopyList(stmt->compound.statements, CopyStatement)); result->compound.context = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Context); break; case 3: result = MkExpressionStmt(CopyList(stmt->expressions, CopyExpression)); break; case 14: result = MkBadDeclStmt(CopyDeclaration(stmt->decl)); break; } } if(result) { result->loc = stmt->loc; } return result; }
int main (int argc, char* argv[]) { int dataInt[] = {1, 2, 3, 4, 5}; CSinglyListNode* head = CreateTestList(dataInt, 5); PrintList(head); std::cout << "--------------AppendNode-------------" << std::endl; int data; data = 6; if (!AppendNode(&head, data)) std::cout << "failed to AppendNode: " << data << std::endl; data = 7; if (!AppendNode(&head, data)) std::cout << "failed to AppendNode: " << data << std::endl; PrintList(head); std::cout << "----------------------------------------" << std::endl; std::cout << "--------------CopyList-------------" << std::endl; CSinglyListNode* newList = NULL; if (!CopyList(NULL, &newList)) std::cout << "failed to CopyList" << std::endl; PrintList(head); PrintList(newList); if (!CopyList(head, &newList)) std::cout << "failed to CopyList" << std::endl; PrintList(head); PrintList(newList); std::cout << "----------------------------------------" << std::endl; std::cout << "bye" << std::endl; return 0; }
void BST::CopyList(BNode* previousNode) { if(root == NULL){ cout << "List is Empty" << endl; return; } else{ Insert(previousNode->data); if (previousNode->left != NULL) CopyList(previousNode->left); if (previousNode->right != NULL) CopyList(previousNode->right); } }
static void UpdateList() { CopyList(); if (!warning_list.empty()) { warning_list_frame->SetLength(warning_list.size()); int i = -1; if (selected_airspace != NULL) { auto it = std::find(warning_list.begin(), warning_list.end(), *selected_airspace); if (it != warning_list.end()) { i = it - warning_list.begin(); warning_list_frame->SetCursorIndex(i); } } if (i < 0) /* the selection may have changed, update CursorAirspace */ AirspaceWarningCursorCallback(warning_list_frame->GetCursorIndex()); } else { warning_list_frame->SetLength(1); selected_airspace = NULL; } warning_list_frame->Invalidate(); UpdateButtons(); AutoHide(); }
int main() { struct node* node05 = (struct node *)malloc(sizeof(struct node)); node05->data = 7; node05->next = NULL; struct node* node04 = (struct node *)malloc(sizeof(struct node)); node04->data = 3; node04->next = node05; struct node* node03 = (struct node *)malloc(sizeof(struct node)); node03->data = 3; node03->next = node04; struct node* node02 = (struct node *)malloc(sizeof(struct node)); node02->data = 2; node02->next = node03; struct node* node01 = (struct node *)malloc(sizeof(struct node)); node01->data = 5; node01->next = node02; struct node *head = node01; struct node *newList = NULL; CopyList(node05, newList); PrintLinkedList(newList); return 0; }
BST& BST::operator=(const BST& Ftree){ ClearList(); CopyList(Ftree.root); // Ftree = First Tree return *this; }
CActionBaseClass* CSimultaneousOfAction::Copy() { CSimultaneousOfAction* __result = new CSimultaneousOfAction(_name); if (!CopyList(__result)){ delete __result; return NULL; } return __result; }
SLinkedList<T>& SLinkedList<T>::operator =(const SLinkedList<T>& ll) { if(this != &ll) { //object pointer is NULL CopyList(ll); } return *this; }
DwMailboxList::DwMailboxList(const DwMailboxList& aList) : DwFieldBody(aList) { mFirstMailbox = 0; const DwMailbox* firstMailbox = aList.mFirstMailbox; if (firstMailbox) { CopyList(firstMailbox); } mClassId = kCidMailboxList; mClassName = sClassName; }
LinkedList& LinkedList::operator=(const LinkedList& ll) { if (this == &ll) return *this; else { RemoveAll(); CopyList(ll); return *this; } }
VOID OpenID3File(HWND hwndDlg, int file) { SetWindowText(GetDlgItem(hwndDlg, IDC_FILENAME), dat.files[file]); CopyList(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES), GetDlgItem(hwndDlg, IDC_ID3LIST)); FillID3List(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST), dat.files[file]); if (ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_ID3LIST)) > 0) EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE); SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_SETCHECK, BST_UNCHECKED, 0); }
/*----------------------------------------------------------------------------- * ReadLevel * Read in the level file and set up the next list *-----------------------------------------------------------------------------*/ void ReadLevel(FILE* file, char* buf) { /* Read the level */ fgets(buf, BUF_SIZ, file); if(!feof(file)) { /* Create the levels */ ReadTransforms(buf, &tlLevel); CopyList( &tlLevel, &tlAvailableTransforms ); } else gameComplete = TRUE; }
void SwndContainerImpl::OnNextFrame() { if(!IsVisible(TRUE)) return; SList<ITimelineHandler*> lstCopy; CopyList(m_lstTimelineHandler,lstCopy); SPOSITION pos=lstCopy.GetHeadPosition(); while(pos) { ITimelineHandler * pHandler=lstCopy.GetNext(pos); pHandler->OnNextFrame(); } }
int main(int argc, char *argv[]) { if (argc > 1) { if ( 0 == strcmp (argv[1] , "-g") && argc > 2 ) { GenerateList(argv[2]); } else if (0 == strcmp (argv[1] , "-c")) { if (argc < 5) { std::cerr << "Too few parameters for copy mode" << std::endl << std::endl; PrintHelp(); return 1; } std::string strFileList (argv[2]); std::string strSrcPath (argv[3]); std::string strDstPath (argv[4]); CopyList(strFileList, strSrcPath, strDstPath); } else if (0 == strcmp (argv[1] , "-e")) { if (argc < 4) { std::cerr << "Too few parameters for exclude mode" << std::endl << std::endl; PrintHelp(); return 1; } std::string strBaseList (argv[2]); std::string strDiffList (argv[3]); ExcludeList(strBaseList, strDiffList); } else { PrintHelp(); } } else { PrintHelp(); } return 0; }
List UnionList(List L0, List L1) { List UList; pointer object; if(!L0 || !L1) ErrorNULL("UnionList, not initialized List.\n"); UList=CopyList(L0); TailList(L1); while(NextList(&object, L1)) if(!MemberList(object, UList)) InsertList(object, UList); return UList; }
List IntersectList(List L0, List L1) { List InterList; pointer object; if(!L0 || !L1) ErrorNULL("IntersectList, not initialized List.\n"); InterList=CopyList(L0); TailList(InterList); while(NextList(&object, InterList)) if(!MemberList(object, L1)) DeleteList(object, InterList); return InterList; }
const DwMailboxList& DwMailboxList::operator = (const DwMailboxList& aList) { if (this == &aList) return *this; DwFieldBody::operator = (aList); if (mFirstMailbox) { _DeleteAll(); } const DwMailbox* firstMailbox = aList.mFirstMailbox; if (firstMailbox) { CopyList(firstMailbox); } if (mParent && mIsModified) { mParent->SetModified(); } return *this; }
static struct Initializer * CopyInitializer(struct Initializer * initializer) { struct Initializer * copy = (((void *)0)); ; if(initializer->type == 0) copy = MkInitializerAssignment(CopyExpression(initializer->exp)); else if(initializer->type == 1) copy = MkInitializerList(CopyList(initializer->list, CopyInitializer)); if(copy) { copy->loc = initializer->loc; copy->isConstant = initializer->isConstant; } return copy; }
void PurgeItemList(Item **list, char *name) { Item *ip, *copy = NULL; struct stat sb; CopyList(©, *list); for (ip = copy; ip != NULL; ip = ip->next) { if (stat(ip->name, &sb) == -1) { Log(LOG_LEVEL_VERBOSE, "Purging file '%s' from '%s' list as it no longer exists", ip->name, name); DeleteItemLiteral(list, ip->name); } } DeleteItemList(copy); }
AlphaList *DupAlphaListPointers(AlphaList *ap, AlphaList *al) { if (ap != NULL) { memcpy(ap, al, sizeof(AlphaList)); } for (int i = 0; i < CF_ALPHABETSIZE; i++) { Item *tmp = NULL; if (al->list[i]) { CopyList(&tmp, al->list[i]); al->list[i] = tmp; } } return ap; }
VOID OpenID3FileDlg(HWND hwndDlg, int file) { CloseID3File(hwndDlg, file); EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE, FALSE); if (SelectFileName(hwndDlg)) { SetWindowText(GetDlgItem(hwndDlg, IDC_FILENAME), dat.files[file]); CopyList(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES), GetDlgItem(hwndDlg, IDC_ID3LIST)); FillID3List(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST), dat.files[file]); } EnableWindow(GetDlgItem(hwndDlg, IDC_BACKFILE), FALSE); if (dat.fileCount > 1) EnableWindow(GetDlgItem(hwndDlg, IDC_NEXTFILE), TRUE); else EnableWindow(GetDlgItem(hwndDlg, IDC_NEXTFILE), FALSE); if (ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_ID3LIST)) > 0) EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE); SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_SETCHECK, BST_UNCHECKED, 0); }
int LoadProcessTable() { FILE *prp; char pscomm[CF_MAXLINKSIZE]; Item *rootprocs = NULL; Item *otherprocs = NULL; if (PROCESSTABLE) { Log(LOG_LEVEL_VERBOSE, "Reusing cached process table"); return true; } LoadPlatformExtraTable(); CheckPsLineLimitations(); const char *psopts = GetProcessOptions(); snprintf(pscomm, CF_MAXLINKSIZE, "%s %s", VPSCOMM[VPSHARDCLASS], psopts); Log(LOG_LEVEL_VERBOSE, "Observe process table with %s", pscomm); if ((prp = cf_popen(pscomm, "r", false)) == NULL) { Log(LOG_LEVEL_ERR, "Couldn't open the process list with command '%s'. (popen: %s)", pscomm, GetErrorStr()); return false; } size_t vbuff_size = CF_BUFSIZE; char *vbuff = xmalloc(vbuff_size); # ifdef HAVE_GETZONEID char *names[CF_PROCCOLS]; int start[CF_PROCCOLS]; int end[CF_PROCCOLS]; Seq *pidlist = SeqNew(1, NULL); Seq *rootpidlist = SeqNew(1, NULL); bool global_zone = IsGlobalZone(); if (global_zone) { int res = ZLoadProcesstable(pidlist, rootpidlist); if (res == false) { Log(LOG_LEVEL_ERR, "Unable to load solaris zone process table."); return false; } } # endif ARG_UNUSED bool header = true; /* used only if HAVE_GETZONEID */ for (;;) { ssize_t res = CfReadLine(&vbuff, &vbuff_size, prp); if (res == -1) { if (!feof(prp)) { Log(LOG_LEVEL_ERR, "Unable to read process list with command '%s'. (fread: %s)", pscomm, GetErrorStr()); cf_pclose(prp); free(vbuff); return false; } else { break; } } Chop(vbuff, vbuff_size); # ifdef HAVE_GETZONEID if (global_zone) { if (header) { /* this is the banner so get the column header names for later use*/ GetProcessColumnNames(vbuff, &names[0], start, end); } else { int gpid = ExtractPid(vbuff, names, end); if (!IsGlobalProcess(gpid, pidlist, rootpidlist)) { continue; } } } # endif AppendItem(&PROCESSTABLE, vbuff, ""); header = false; } cf_pclose(prp); /* Now save the data */ const char* const statedir = GetStateDir(); snprintf(vbuff, CF_MAXVARSIZE, "%s%ccf_procs", statedir, FILE_SEPARATOR); RawSaveItemList(PROCESSTABLE, vbuff, NewLineMode_Unix); # ifdef HAVE_GETZONEID if (global_zone) /* pidlist and rootpidlist are empty if we're not in the global zone */ { Item *ip = PROCESSTABLE; while (ip != NULL) { ZCopyProcessList(&rootprocs, ip, rootpidlist, names, end); ip = ip->next; } ReverseItemList(rootprocs); ip = PROCESSTABLE; while (ip != NULL) { ZCopyProcessList(&otherprocs, ip, pidlist, names, end); ip = ip->next; } ReverseItemList(otherprocs); } else # endif { CopyList(&rootprocs, PROCESSTABLE); CopyList(&otherprocs, PROCESSTABLE); while (DeleteItemNotContaining(&rootprocs, "root")) { } while (DeleteItemContaining(&otherprocs, "root")) { } } if (otherprocs) { PrependItem(&rootprocs, otherprocs->name, NULL); } snprintf(vbuff, CF_MAXVARSIZE, "%s%ccf_rootprocs", statedir, FILE_SEPARATOR); RawSaveItemList(rootprocs, vbuff, NewLineMode_Unix); DeleteItemList(rootprocs); snprintf(vbuff, CF_MAXVARSIZE, "%s%ccf_otherprocs", statedir, FILE_SEPARATOR); RawSaveItemList(otherprocs, vbuff, NewLineMode_Unix); DeleteItemList(otherprocs); free(vbuff); return true; }
// Copy Constructor LinkedList::LinkedList(const LinkedList& ll) { CopyList(ll); }
void ErrorWindow::MessageReceived(BMessage* message) { switch (message->what) { case M_RUN_PROJECT: case M_RUN_IN_TERMINAL: case M_RUN_IN_DEBUGGER: case M_RUN_WITH_ARGS: case M_MAKE_PROJECT: case M_FORCE_REBUILD: { fParent->PostMessage(message); break; } case M_TOGGLE_ERRORS: case M_TOGGLE_WARNINGS: { RefreshList(); break; } case M_COPY_ERRORS: { CopyList(); break; } case M_CLEAR_ERROR_LIST: { EmptyList(); fErrors.msglist.MakeEmpty(); break; } case M_BUILD_WARNINGS: case M_BUILD_FAILURE: { ErrorList list; list.Unflatten(*message); AppendToList(list); break; } case M_JUMP_TO_MSG: { int32 selection = fErrorList->CurrentSelection(); if (selection >= 0) { ErrorItem* item = (ErrorItem*)fErrorList->ItemAt(selection); error_msg* gcc = item->GetMessage(); if (gcc->path.Length() < 1) break; entry_ref ref; BEntry entry(gcc->path.String()); entry.GetRef(&ref); message->what = EDIT_OPEN_FILE; message->AddRef("refs", &ref); if (gcc->line > 0) message->AddInt32("line", gcc->line); be_app->PostMessage(message); } break; } default: BWindow::MessageReceived(message); } }
BOOL CALLBACK DlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { DWORD fdwMenu; LV_COLUMN lvc; BOOL bResult; int iFiles, i; char fileName[_MAX_PATH]; struct FileDlgData *files; switch (message) { case WM_INITDIALOG: SendMessage(hwndDlg,WM_SETICON,(WPARAM)ICON_SMALL,(LPARAM)LoadIcon(hInstance_for_id3editor,MAKEINTRESOURCE(IDI_ICON))); SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_SETCHECK, BST_CHECKED, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_BACKFILE), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_NEXTFILE), FALSE); /* Set up the list control for the ID3 tag */ /* Initialize the LV_COLUMN structure. */ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; /* Add the columns. */ lvc.iSubItem = 0; lvc.cx = 85; lvc.pszText = "Frame"; ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_ID3LIST), 0, &lvc); lvc.iSubItem = 1; lvc.cx = 325; lvc.pszText = "Data"; ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_ID3LIST), 1, &lvc); lvc.iSubItem = 0; lvc.cx = 75; lvc.pszText = "Frame"; ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_GENFRAMES), 0, &lvc); lvc.iSubItem = 1; lvc.cx = 160; lvc.pszText = "Data"; ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_GENFRAMES), 1, &lvc); return TRUE; case WM_DROPFILES: CloseID3File(hwndDlg, fileIndex); iFiles = DragQueryFile((HDROP)wParam, 0xFFFFFFFF, (LPSTR)fileName, _MAX_PATH - 1); if (iFiles > 0) fileSet = TRUE; files = &dat; FreeFilesMatrix(&files->files); fileIndex = 0; dat.files=(char**)malloc((iFiles+1)*sizeof(char*)); dat.fileCount = iFiles; for (i = 0; i < iFiles; i++) { int len; if (len = DragQueryFile((HDROP)wParam, i, (LPSTR)fileName, _MAX_PATH - 1)) { dat.files[i]=malloc(len+1); CopyMemory(dat.files[i],fileName,len+1); } } DragFinish((HDROP)wParam); SetWindowText(GetDlgItem(hwndDlg, IDC_FILENAME), dat.files[fileIndex]); CopyList(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES), GetDlgItem(hwndDlg, IDC_ID3LIST)); FillID3List(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST), dat.files[fileIndex]); EnableWindow(GetDlgItem(hwndDlg, IDC_BACKFILE), FALSE); if (dat.fileCount > 1) EnableWindow(GetDlgItem(hwndDlg, IDC_NEXTFILE), TRUE); else EnableWindow(GetDlgItem(hwndDlg, IDC_NEXTFILE), FALSE); return FALSE; case WM_NOTIFY: /* Branch depending on the specific notification message. */ switch (((LPNMHDR) lParam)->code) { /* Process LVN_GETDISPINFO to supply information about */ /* callback items. */ case LVN_GETDISPINFO: List_OnGetDispInfo((LV_DISPINFO *)lParam); break; case NM_DBLCLK: /* Fix so that it works for the general list tooo */ bResult = List_EditData(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST)); if (bResult) EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE); bFileChanged = bFileChanged ? bFileChanged : bResult; break; } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ADDSTFRAMES: if (SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_GETCHECK, 0, 0) == BST_CHECKED) { List_AddStandardFrames(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES)); return TRUE; } bResult = List_AddStandardFrames(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST)); if (bResult) EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE); bFileChanged = bFileChanged ? bFileChanged : bResult; return TRUE; case IDC_ADDFRAME: if (SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_GETCHECK, 0, 0) == BST_CHECKED) { List_AddFrame(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES)); return TRUE; } bResult = List_AddFrame(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST)); if (bResult) EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE); bFileChanged = bFileChanged ? bFileChanged : bResult; return TRUE; case IDC_DELFRAME: if (SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_GETCHECK, 0, 0) == BST_CHECKED) { List_DeleteSelected(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES)); return TRUE; } bResult = List_DeleteSelected(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST)); if (ListView_GetItemCount(GetDlgItem(hwndDlg, IDC_ID3LIST)) == 0) EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE, FALSE); bFileChanged = bFileChanged ? bFileChanged : bResult; return TRUE; case IDC_EDITFRAME: if (SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_GETCHECK, 0, 0) == BST_CHECKED) { List_EditData(hwndDlg, GetDlgItem(hwndDlg, IDC_GENFRAMES)); return TRUE; } bResult = List_EditData(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST)); if (bResult) EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), TRUE, TRUE); bFileChanged = bFileChanged ? bFileChanged : bResult; return TRUE; case IDC_ID3V2TAG: bFileChanged = TRUE; return TRUE; case IDC_OPEN_FILE: OpenID3FileDlg(hwndDlg, fileIndex); return TRUE; case IDC_CLOSE_FILE: CloseID3File(hwndDlg, fileIndex); EnableWindow(GetDlgItem(hwndDlg, IDC_BACKFILE), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_NEXTFILE), FALSE); EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE, FALSE); fileSet = FALSE; return TRUE; case IDC_SAVE_FILE: SaveID3File(hwndDlg, fileIndex); bFileChanged = FALSE; return TRUE; case IDC_NEXTFILE: CloseID3File(hwndDlg, fileIndex); EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE, FALSE); fileIndex++; OpenID3File(hwndDlg, fileIndex); SetNextBackButtons(hwndDlg, fileIndex, dat.fileCount); return TRUE; case IDC_BACKFILE: CloseID3File(hwndDlg, fileIndex); EnableCheckbox(GetDlgItem(hwndDlg, IDC_ID3V2TAG), FALSE, FALSE); fileIndex--; OpenID3File(hwndDlg, fileIndex); SetNextBackButtons(hwndDlg, fileIndex, dat.fileCount); return TRUE; case IDC_CLOSE: case IDCANCEL: case IDC_EXIT: if (bFileChanged == TRUE) { fdwMenu = GetMenuState(GetMenu(hwndDlg), IDC_AUTOSAVE, MF_BYCOMMAND); if (!(fdwMenu & MF_CHECKED)) { if (MessageBox(hwndDlg, "Save changes?", "Save changes", MB_YESNO) == IDYES) List_SaveID3(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST), dat.files[fileIndex]); } else { List_SaveID3(hwndDlg, GetDlgItem(hwndDlg, IDC_ID3LIST), dat.files[fileIndex]); } } EndDialog(hwndDlg, wParam); return TRUE; case IDC_ABOUT: DialogBox(hInstance_for_id3editor, MAKEINTRESOURCE(IDD_ABOUT), hwndDlg, DlgProcAbout); return TRUE; case IDC_SETGENERAL: if (fileSet == FALSE) SendMessage(GetDlgItem(hwndDlg, IDC_SETGENERAL), BM_SETCHECK, BST_CHECKED, 0); return TRUE; case IDC_AUTOSAVE: fdwMenu = GetMenuState(GetMenu(hwndDlg), IDC_AUTOSAVE, MF_BYCOMMAND); if (!(fdwMenu & MF_CHECKED)) CheckMenuItem(GetMenu(hwndDlg), IDC_AUTOSAVE, MF_BYCOMMAND | MF_CHECKED); else CheckMenuItem(GetMenu(hwndDlg), IDC_AUTOSAVE, MF_BYCOMMAND | MF_UNCHECKED); return TRUE; } } return FALSE; }
SLinkedList<T>::SLinkedList(const SLinkedList& ll) { //copy helper CopyList(ll); }
int Unix_LoadProcessTable(Item **procdata) { FILE *prp; char pscomm[CF_MAXLINKSIZE], vbuff[CF_BUFSIZE], *sp; Item *rootprocs = NULL; Item *otherprocs = NULL; const char *psopts = GetProcessOptions(); snprintf(pscomm, CF_MAXLINKSIZE, "%s %s", VPSCOMM[VSYSTEMHARDCLASS], psopts); CfOut(cf_verbose, "", "Observe process table with %s\n", pscomm); if ((prp = cf_popen(pscomm, "r")) == NULL) { CfOut(cf_error, "popen", "Couldn't open the process list with command %s\n", pscomm); return false; } while (!feof(prp)) { memset(vbuff, 0, CF_BUFSIZE); CfReadLine(vbuff, CF_BUFSIZE, prp); for (sp = vbuff + strlen(vbuff) - 1; sp > vbuff && isspace(*sp); sp--) { *sp = '\0'; } if (ForeignZone(vbuff)) { continue; } AppendItem(procdata, vbuff, ""); } cf_pclose(prp); /* Now save the data */ snprintf(vbuff, CF_MAXVARSIZE, "%s/state/cf_procs", CFWORKDIR); RawSaveItemList(*procdata, vbuff); CopyList(&rootprocs, *procdata); CopyList(&otherprocs, *procdata); while (DeleteItemNotContaining(&rootprocs, "root")) { } while (DeleteItemContaining(&otherprocs, "root")) { } if (otherprocs) { PrependItem(&rootprocs, otherprocs->name, NULL); } snprintf(vbuff, CF_MAXVARSIZE, "%s/state/cf_rootprocs", CFWORKDIR); RawSaveItemList(rootprocs, vbuff); DeleteItemList(rootprocs); snprintf(vbuff, CF_MAXVARSIZE, "%s/state/cf_otherprocs", CFWORKDIR); RawSaveItemList(otherprocs, vbuff); DeleteItemList(otherprocs); return true; }
int main() { /* Kamus Lokal */ List MyList, List2, List3; int i; infotype isi; address P, Prec; /* Program */ CreateList (&MyList); printf ("Jml Elemen List adalah : %d \n", NbElmt(MyList)); /* Menambah List di awal */ i = 1; while (i <= 5) { InsVFirst (&MyList, i*5); i++; } printf ("Hasil InsVFirst 5 x adalah : "); PrintInfo (MyList); printf ("Node Maksimal = %d ",Max (MyList)); printf ("Node Minimal = %d ",Min (MyList)); printf ("Rata-rata = %d \n",Average (MyList)); /* Mencari suatu elemen di list */ P = Search(MyList, 15); printf ("Search yang berhasil (15) : P = %d, Ketemu = %d \n",P,FSearch(MyList,P)); DelP (&MyList, 15); /* Insert di Last */ printf ("Insert di akhir nilai 723 : "); InsVLast (&MyList, 723); PrintInfo (MyList); /* Insert diantara 2 elemen */ printf ("Insert sebelum elemen 10 : "); Prec = SearchPrec (MyList, 10); P = Alokasi (2712); if (P != Nil) { InsertAfter (&MyList, P, Prec); } PrintInfo (MyList); /* Menghapus elemen List */ printf ("\tHasil Delete dari elemen List :\n"); printf ("Jumlah elemen list = %d \n", NbElmt(MyList)); DelVFirst (&MyList, &isi); printf ("DelVFirst adalah %d\t", isi); DelVLast (&MyList, &isi); printf ("DelVLast adalah %d\t", isi); /* Menghapus elemen di tengah-tengah */ Prec = SearchPrec (MyList, 10); /* Node yang akan dihapus */ if (Prec != Nil) { DelAfter (&MyList, &P, Prec); isi = Info(P); DeAlokasi (P); printf ("DelAfter adalah %d\n", isi); } printf ("Hasil setelah delete : "); PrintInfo (MyList); printf ("Insert sebelum elemen 5 : "); Prec = SearchPrec (MyList, 5); P = Alokasi (-987); if (P != Nil) { InsertAfter (&MyList, P, Prec); } PrintInfo (MyList); /* Invers List */ printf ("\tHasil Invers dari List yang ada : \n"); printf ("Versi 1 : "); List2 = FInversList (MyList); PrintInfo (List2); printf ("Versi 2 : "); InversList (&MyList); PrintInfo (MyList); /* Copy List */ printf ("\tHasil Copy dari List yang ada : \n"); printf("Versi 1 : "); CopyList (MyList, &List2); PrintInfo (List2); printf ("Versi 2 : "); List3 = FCopyList (MyList); PrintInfo (List3); printf ("Versi 3 : "); CpAlokList (MyList, &List2); PrintInfo (List2); /* Konkat */ printf("\tHasil Konkat Invers dan List asli : \n"); List2 = FInversList (MyList); Konkat (List2, List3, &MyList); printf("Versi 1 : "); PrintInfo (MyList); Konkat1 (&List2, &List3, &MyList); printf("Versi 2 : "); PrintInfo (MyList); /* Pecah List */ PecahList (&List2, &List3, MyList); printf ("\tHasil membagi dua list adalah : \n"); printf ("L1 = "); PrintInfo (List2); printf ("L2 = "); PrintInfo (List3); /* Finishing */ P = First(MyList); DeAlokasi (P); P = First(List2); DeAlokasi (P); P = First(List3); DeAlokasi (P); return 0; }
int LoadProcessTable(EvalContext *ctx, Item **procdata) { FILE *prp; char pscomm[CF_MAXLINKSIZE], vbuff[CF_BUFSIZE], *sp; Item *rootprocs = NULL; Item *otherprocs = NULL; if (PROCESSTABLE) { Log(LOG_LEVEL_VERBOSE, "Reusing cached process table"); return true; } const char *psopts = GetProcessOptions(); snprintf(pscomm, CF_MAXLINKSIZE, "%s %s", VPSCOMM[VSYSTEMHARDCLASS], psopts); Log(LOG_LEVEL_VERBOSE, "Observe process table with %s", pscomm); if ((prp = cf_popen(pscomm, "r", false)) == NULL) { Log(LOG_LEVEL_ERR, "Couldn't open the process list with command '%s'. (popen: %s)", pscomm, GetErrorStr()); return false; } for (;;) { ssize_t res = CfReadLine(vbuff, CF_BUFSIZE, prp); if (res == 0) { break; } if (res == -1) { Log(LOG_LEVEL_ERR, "Unable to read process list with command '%s'. (fread: %s)", pscomm, GetErrorStr()); cf_pclose(prp); return false; } for (sp = vbuff + strlen(vbuff) - 1; (sp > vbuff) && (isspace((int)*sp)); sp--) { *sp = '\0'; } if (ForeignZone(vbuff)) { continue; } AppendItem(procdata, vbuff, ""); } cf_pclose(prp); /* Now save the data */ snprintf(vbuff, CF_MAXVARSIZE, "%s/state/cf_procs", CFWORKDIR); RawSaveItemList(*procdata, vbuff); CopyList(&rootprocs, *procdata); CopyList(&otherprocs, *procdata); while (DeleteItemNotContaining(ctx, &rootprocs, "root")) { } while (DeleteItemContaining(ctx, &otherprocs, "root")) { } if (otherprocs) { PrependItem(&rootprocs, otherprocs->name, NULL); } snprintf(vbuff, CF_MAXVARSIZE, "%s/state/cf_rootprocs", CFWORKDIR); RawSaveItemList(rootprocs, vbuff); DeleteItemList(rootprocs); snprintf(vbuff, CF_MAXVARSIZE, "%s/state/cf_otherprocs", CFWORKDIR); RawSaveItemList(otherprocs, vbuff); DeleteItemList(otherprocs); return true; }
tChyba copyTable( TFunction *source ) { TItem *tmp; int ret; for (int i = 0; i < MAX_HTSIZE; ++i){ tmp = (*(source->table))[i]; if( tmp ){ //dmnce karlova if( tmp->druh == ID_FUNCTION ){ ret = htInsert( ptrhtLocal, tmp->key, copyData( tmp->druh, tmp->data), tmp->type, tmp->druh ); } else if( tmp->druh == ID_PARAM ){ ret = htInsert( ptrhtLocal, tmp->key, NULL, tmp->type, tmp->druh ); } else ret = htInsert( ptrhtLocal, tmp->key, copyData( tmp->type, tmp->data), tmp->type, tmp->druh ); if(ret != S_BEZ_CHYB) { return ret; } //ret = htCompleteInsert(ptrhtLocal, tmp->key, tmp->druh, tmp->type, tmp->init); //if(ret != S_BEZ_CHYB) { // return ret; //} } } //zkopiruje cely list instrukci ret = CopyList( &(source->instrList) ); if(ret != S_BEZ_CHYB) { return ret; } //ustanoveni dat tItemPtr ptr = listIntrukci->First; while(ptr){ TItem *item; if( ptr->instruction.instructionType == OC_COLL ){ ptr->instruction.instructionType = OC_CALL; //nastaveni navratovky item = (TItem*)ptr->instruction.address1; ptr->instruction.address3 = htSearch( ptrhtLocal, item->key ); } else if( ptr->instruction.instructionType == OC_NEPRIRAZENI ){ ptr->instruction.instructionType = OC_PRIRAZENI; //navratovka je zdroj ptr->instruction.address1 = item; //htSearch( ptrhtLastLocal, id ) //dodelat nalezeni cile ulozeni } else{ if( ptr->instruction.address1 ){ TItem *tmp1 = (TItem*)ptr->instruction.address1; //write if( tmp1->druh != PRINTSTR ){ ptr->instruction.address1 = htSearch( ptrhtLocal, tmp1->key ); } } if( ptr->instruction.address2 ){ TItem *tmp2 = (TItem*)ptr->instruction.address2; ptr->instruction.address2 = htSearch( ptrhtLocal, tmp2->key ); } if( ptr->instruction.address3 ){ TItem *tmp3 = (TItem*)ptr->instruction.address3; ptr->instruction.address3 = htSearch( ptrhtLocal, tmp3->key ); } } ptr = ptr->nextItem; } return S_BEZ_CHYB; }