int main(int argc, char *argv[]) { FILE *parFile = fopen(GCODE_PARAMETER_STORE, "r"); FILE *inputFile = (argc > 1 ? fopen(argv[1], "r") : stdin); char line[0xFF]; init_parameters(parFile); init_machine(NULL); init_stacks(NULL); init_tools(NULL); init_input(inputFile); //TODO: align API, add done_gcode_state(). init_gcode_state(NULL); init_cycles(NULL); //TODO: align API, make it take a pointer to init data. init_queue(); init_checker(NULL); while(machine_running() && gcode_running() && fetch_line_input(line)) { if(gcode_check(line)) update_gcode_state(line); move_machine_queue(); } /* Flush movement queue */ while(move_machine_queue()); done_checker(); done_queue(); done_cycles(); done_input(); done_tools(); done_stacks(); done_machine(); done_parameters(); return 0; }
int main(int argc, const char *argv[]) { init_tools(); init_values(); init_evaluator(); init_interpreter(); init_tests(); init_sexp_to_c(); // TO TRY: Add an -O3 flag to Xcode's compile. Then compile and profile, and see if it runs faster. // run_tests(); // run_benchmarks(); if (argc > 1) { if (streq(argv[1], "test")) { run_tests(); } else if (streq(argv[1], "benchmark")) { run_benchmarks(); } else { value str = value_set_str(argv[1]); value_import(str); value_clear(&str); } } else { run_interpreter(); } return 0; }
main(int argc, char **argv) { giant p = newgiant(CM_SHORTS); giant u = newgiant(CM_SHORTS); giant v = newgiant(CM_SHORTS); giant g[6]; giant plus_order = newgiant(CM_SHORTS); giant minus_order = newgiant(CM_SHORTS); giant a = newgiant(CM_SHORTS); giant b = newgiant(CM_SHORTS); int d, dc, olen, k; init_tools(CM_SHORTS); /* Basic algorithms. */ printf("Give base prime p:\n"); fflush(stdout); gin(p); for(dc=0; dc < 6; dc++) g[dc] = newgiant(CM_SHORTS); for(dc = 0; dc < DCOUNT; dc++) { d = disc12[dc]; /* Next, seek representation 4N = u^2 + |d| v^2. */ if(cornacchia4(p, d, u, v) == 0) continue; /* Here, (u,v) give the quadratic representation of 4p. */ printf("D: %d\n", d); fflush(stdout); gtog(u, g[0]); switch(d) { case -3: olen = 3; /* Six orders: p + 1 +- g[0,1,2]. */ gtog(u, g[1]); gtog(v, g[2]); addg(g[2], g[2]); addg(v, g[2]); /* g[2] := 3v. */ addg(g[2], g[1]); gshiftright(1, g[1]); /* g[1] = (u + 3v)/2. */ subg(u, g[2]); gshiftright(1, g[2]); absg(g[2]); /* g[2] = |u-3v|/2. */ break; case -4: olen = 2; /* Four orders: p + 1 +- g[0,1]. */ gtog(v, g[1]); addg(g[1], g[1]); /* g[1] = 2v. */ break; default: olen = 1; /* Two orders: p + 1 +- g[0]. */ } for(k=0; k < olen; k++) { gtog(p, plus_order); iaddg(1, plus_order); gtog(p, minus_order); iaddg(1, minus_order); addg(g[k], plus_order); subg(g[k], minus_order); printf("curve orders: \n"); printf("(%d) ", prime_probable(plus_order)); gout(plus_order); printf("(%d) ", prime_probable(minus_order)); gout(minus_order); } } }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { int z; CRect rect; if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } // Create the combo box z = m_wndToolBar.CommandToIndex(ID_NEW_SHIP_TYPE); Assert(z != -1); m_wndToolBar.SetButtonInfo(z, ID_NEW_SHIP_TYPE, TBBS_SEPARATOR, 230); // Design guide advises 12 pixel gap between combos and buttons // m_wndToolBar.SetButtonInfo(1, ID_SEPARATOR, TBBS_SEPARATOR, 12); m_wndToolBar.GetItemRect(z, &rect); rect.top = 3; rect.bottom = rect.top + 550; if (!m_new_ship_type_combo_box.Create(CBS_DROPDOWNLIST | WS_VISIBLE | WS_VSCROLL | CBS_HASSTRINGS | LBS_OWNERDRAWFIXED, rect, &m_wndToolBar, ID_NEW_SHIP_TYPE)) { TRACE0("Failed to create new ship type combo-box\n"); return FALSE; } /* if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } */ /* if (!m_wndStatusBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM, ID_MY_STATUS_BAR) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)))*/ if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; } else { m_wndStatusBar.SetPaneInfo(0, 0, SBPS_STRETCH, 0); m_wndStatusBar.SetPaneInfo(1, 0, SBPS_NORMAL, 80); m_wndStatusBar.SetPaneInfo(2, 0, SBPS_NORMAL, 180); // m_wndStatusBar.SetPaneInfo(3, 0, SBPS_NORMAL, 100); m_wndStatusBar.SetPaneInfo(4, 0, SBPS_NORMAL, 130); } // TODO: Remove this if you don't want tool tips or a resizeable toolbar m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); Fred_main_wnd = this; Ship_editor_dialog.Create(); Wing_editor_dialog.Create(); Waypoint_editor_dialog.Create(); init_tools(); LoadBarState("Tools state"); return 0; }