int my_put_in_list(t_cmd **begin) { t_cmd *new_elem; if ((new_elem = malloc(sizeof(*new_elem))) == NULL) return (0); new_elem->next = *begin; init_cmd(new_elem); init_cmd(new_elem); *begin = new_elem; return (1); }
void cmd (void) { init_twins(".devA", ".devB"); init_shell(NULL); init_cmd(); if (shell()) warn("shell error"); }
int main (int argc, char *argv[]) { char *dev_name = ".btree"; #if DEVELOPMENT debugon(); fdebugon(); #else debugoff(); fdebugoff(); #endif FN; if (argc > 1) { dev_name = argv[1]; } #if DEVELOPMENT unlink(dev); /* Development only */ #endif binit(20); Dev = bopen(dev_name); if (!Dev) eprintf("Couldn't open %s:", dev_name); blazy(Dev); init_string(Dev); init_shell(quit_callback); init_cmd(); return shell(); }
static void init_controller(int port, int nrouters, int nworkers) { if (!new_server(port, &listen_fd, NULL)) err(true, "Cannot set up server on port %u", port); #if RPT >= 2 report(2, "Listening socket has descriptor %d", listen_fd); #endif router_addr_set = word_set_new(); new_conn_map = word_keyvalue_new(); router_fd_set = word_set_new(); worker_fd_set = word_set_new(); client_fd_set = word_set_new(); init_cmd(); add_cmd("status", do_controller_status_cmd, " | Determine status of connected nodes"); add_cmd("flush", do_controller_flush_cmd, " | Flush state of all agents"); add_cmd("collect", do_controller_collect_cmd, " | Initiate garbage collection"); add_quit_helper(quit_controller); need_routers = nrouters; need_workers = nworkers; worker_cnt = nworkers; stat_message_cnt = 0; flush_requestor_fd = -1; stat_messages = calloc_or_fail(worker_cnt, sizeof(chunk_ptr), "init_controller"); gc_state = GC_READY; need_worker_cnt = 0; need_client_fd_set = NULL; defer_client_fd_set = NULL; gc_generation = 0; }
int main (int argc, char *argv[]) { char *dev_name = ".btree"; #if DEVELOPMENT debugon(); fdebugon(); #else debugoff(); fdebugoff(); #endif FN; if (argc > 1) { dev_name = argv[1]; } binit(20); #if DEVELOPMENT unlink(dev_name); #else blazy(); #endif start_string(dev_name); init_shell(quit_callback); init_cmd(); return shell(); }
int main(int argc, char *argv[]) { init_cmd(); add_cmd("times", do_times, "Multiply"); add_cmd("plus", do_plus, "Add"); add_param("value", &value, "Value", NULL); add_quit_helper(app_quit); run_console(NULL); finish_cmd(); return 0; }
int main (int argc, char *argv[]) { // debugoff(); debugon(); FN; init_dir(); init_shell(NULL); init_cmd(); return shell(); }
/* * main */ int main(int argc, char **argv) { if(argc == 1) { return 1; } fd = open_port(); if(fd == -1) { printf("Error opening serial port\n"); } else { if(init_port() == -1) { sleep(.5); printf("Error initializing serial port\n"); close(fd); return 0; } sleep(.5); init_cmd(); /* // todo: recive response from reciver if (n < 0) { fputs("write() of X bytes failed!\n", stderr); } else { printf("Successfully wrote 8 bytes\n"); sleep(.5); char buffer[200]; int n = read(fd, buffer, sizeof(buffer)); sleep(.5); if (n < 0) { fputs("read failed!\n", stderr); } else { printf("Successfully read from serial port -- %s\n", buffer); } } */ sleep(.5); if(run_cmd(argv[1], argv[2]) == 1) { printf("Command not found\n"); } sleep(.5); close(fd); } return 0; }
int main (int argc, char *argv[]) { char *dev = ".btree"; // debugoff(); debugon(); FN; if (argc > 1) { dev = argv[1]; } unlink(dev); /* Development only */ binit(20); init_fs(dev); init_shell(NULL); init_cmd(); return shell(); }
void init_fd(t_env *e) { int i; i = 0; e->max = 0; FD_ZERO(&e->fd_read); FD_ZERO(&e->fd_write); init_cmd(e); while (i < e->maxfd) { if (e->fds[i].type != FD_FREE) { FD_SET(i, &e->fd_read); if (ft_strlen(e->fds[i].buf_read) > 0) FD_SET(i, &e->fd_write); e->max = MAX(e->max, i); } i++; } }
int init_net (void) { int rc; rc = init_msg_tau(getprogname()); if (rc) { eprintf("init_msg failed %d", rc); } sw_register(getprogname()); rc = init_cmd(); if (rc) return failure("init_cmd", rc); rc = init_hello(); if (rc) return failure("init_hello", rc); rc = init_sage(); if (rc) return failure("init_sage", rc); return rc; }
void gwave_main(void *p, int argc, char **argv) { int c; int i; int nobacktrace = 0; /* In guile-1.5 and later, need to use scm_primitive_eval_x * in order to change modules so that our C primitives * registered below become globals, instead of hidden away * in the guile-user module */ { SCM exp = scm_c_read_string("(define-module (guile))"); scm_primitive_eval_x(exp); } init_scwm_guile(); init_gtkmisc(); init_gwave(); init_cmd(); init_wavewin(); init_wavelist(); init_wavepanel(); init_event(); init_draw(); gtk_init(&argc, &argv); prog_name = argv[0]; /* simple pre-processing of debugging options that we need to set up * before we get into guile. These options cannot be bundled. * Most of the general user options are handled in std-args.scm */ for(i = 1; i < argc; i++) { if(strcmp(argv[i], "-n") == 0) { nobacktrace = 1; } else if (strcmp(argv[i], "-v") == 0) { v_flag = 1; } else if (strcmp(argv[i], "-x") == 0) { x_flag = 1; SCM_SETCDR(scm_gwave_debug, SCM_BOOL_T); } } gtk_rc_parse_string(gwave_base_gtkrc); gtk_rc_parse("gwave.gtkrc"); // assert( SCM_CONSP(scm_gwave_tooltips) ); #ifdef GUILE_GTK_EXTRA_LOADPATH scm_c_eval_string("(set! %load-path (cons \"" GUILE_GTK_EXTRA_LOADPATH "\" %load-path))"); #endif /* the default for this seems to have changed between guile-1.3 and guile-1.3.2; only the first clause is needed when we drop support for guile-1.3.2 */ if (!nobacktrace) { scm_c_eval_string("(debug-enable 'debug)(debug-enable 'backtrace) (read-enable 'positions)"); } /* else { scm_c_eval_str("(debug-disable 'debug)(read-disable 'positions)"); }*/ /* the compiled-in initial scheme code comes from minimal.scm, built into init_scheme_string.c by the Makefile Among other things, it finds and loads system and user .gwaverc files. */ { /* scope */ extern char *init_scheme_string; SCM res; if(v_flag) {fprintf(stderr, "running init_scheme_string\n");} res = scwm_safe_eval_str(init_scheme_string); if(v_flag) { printf("result="); fflush(stdout); scm_display(res, scm_cur_outp); printf("\n"); fflush(stdout); } if(!SCM_NFALSEP(res)) { fprintf(stderr, "gwave: aborting due to errors.\n"); exit(1); } } /* end scope */ wtable = g_new0(WaveTable, 1); wtable->cursor[0] = g_new0(VBCursor, 1); wtable->cursor[1] = g_new0(VBCursor, 1); wtable->srange = g_new0(SelRange, 1); wtable->npanels = 0; wtable->panels = NULL; setup_colors(wtable); setup_waveform_window(); xg_init(NULL); /* X-server interprocess communication for Gtk+ */ gtk_main(); exit(0); }
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ int main(int argc, char *argv[]) { char window_title[MAX_TITLE_CMD_LENGTH + 1 + 25 + 1]; static String fallback_res[] = { ".show_cmd*mwmDecorations : 110", ".show_cmd*mwmFunctions : 30", ".show_cmd.mainform_w.cmd_outputSW*XmText.fontList : fixed", ".show_cmd*background : NavajoWhite2", ".show_cmd.mainform_w.cmd_outputSW.cmd_output.background : NavajoWhite1", ".show_cmd.mainform_w.buttonbox_w*background : PaleVioletRed2", ".show_cmd.mainform_w.buttonbox_w*foreground : Black", ".show_cmd.mainform_w.buttonbox_w*highlightColor : Black", ".show_cmd.Print Data*background : NavajoWhite2", ".show_cmd.Print Data*XmText.background : NavajoWhite1", ".show_cmd.Print Data.main_form.buttonbox*background : PaleVioletRed2", ".show_cmd.Print Data.main_form.buttonbox*foreground : Black", ".show_cmd.Print Data.main_form.buttonbox*highlightColor : Black", NULL }; Widget mainform_w, button, buttonbox_w, separator_w; Arg args[MAXARGS]; Cardinal argcount; XmFontListEntry entry; XmFontList fontlist; uid_t euid, /* Effective user ID. */ ruid; /* Real user ID. */ CHECK_FOR_VERSION(argc, argv); p_work_dir = work_dir; init_cmd(&argc, argv, window_title); /* * SSH wants to look at .Xauthority and with setuid flag * set we cannot do that. So when we initialize X lets temporaly * disable it. After XtAppInitialize() we set it back. */ euid = geteuid(); ruid = getuid(); if (euid != ruid) { if (seteuid(ruid) == -1) { (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n", ruid, strerror(errno)); } } argcount = 0; XtSetArg(args[argcount], XmNtitle, window_title); argcount++; appshell = XtAppInitialize(&app, "AFD", NULL, 0, &argc, argv, fallback_res, args, argcount); disable_drag_drop(appshell); if (euid != ruid) { if (seteuid(euid) == -1) { (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n", euid, strerror(errno)); } } if ((display = XtDisplay(appshell)) == NULL) { (void)fprintf(stderr, "ERROR : Could not open Display : %s (%s %d)\n", strerror(errno), __FILE__, __LINE__); exit(INCORRECT); } #ifdef HAVE_XPM /* Setup AFD logo as icon. */ setup_icon(display, appshell); #endif /* Create managing widget. */ mainform_w = XmCreateForm(appshell, "mainform_w", NULL, 0); /* Prepare the font. */ entry = XmFontListEntryLoad(XtDisplay(appshell), font_name, XmFONT_IS_FONT, "TAG1"); fontlist = XmFontListAppendEntry(NULL, entry); XmFontListEntryFree(&entry); argcount = 0; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNfractionBase, 31); argcount++; buttonbox_w = XmCreateForm(mainform_w, "buttonbox_w", args, argcount); button = XtVaCreateManagedWidget("Repeat", xmPushButtonWidgetClass, buttonbox_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 1, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 10, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 30, NULL); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)repeat_button, 0); button = XtVaCreateManagedWidget("Print", xmPushButtonWidgetClass, buttonbox_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 11, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 20, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 30, NULL); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)print_button, 0); button = XtVaCreateManagedWidget("Close", xmPushButtonWidgetClass, buttonbox_w, XmNfontList, fontlist, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 1, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 21, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 30, XmNbottomAttachment, XmATTACH_POSITION, XmNbottomPosition, 30, NULL); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc)close_button, 0); XtManageChild(buttonbox_w); /*-----------------------------------------------------------------------*/ /* Horizontal Separator */ /*-----------------------------------------------------------------------*/ argcount = 0; XtSetArg(args[argcount], XmNorientation, XmHORIZONTAL); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, buttonbox_w); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; separator_w = XmCreateSeparator(mainform_w, "separator", args, argcount); XtManageChild(separator_w); /*-----------------------------------------------------------------------*/ /* Status Box */ /* ---------- */ /* The status of the output log is shown here. If eg. no files are found */ /* it will be shown here. */ /*-----------------------------------------------------------------------*/ statusbox_w = XtVaCreateManagedWidget(" ", xmLabelWidgetClass, mainform_w, XmNfontList, fontlist, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, separator_w, NULL); /*-----------------------------------------------------------------------*/ /* Horizontal Separator */ /*-----------------------------------------------------------------------*/ argcount = 0; XtSetArg(args[argcount], XmNorientation, XmHORIZONTAL); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, statusbox_w); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; separator_w = XmCreateSeparator(mainform_w, "separator", args, argcount); XtManageChild(separator_w); /* Create cmd_output as a ScrolledText window. */ argcount = 0; XtSetArg(args[argcount], XmNrows, 18); argcount++; XtSetArg(args[argcount], XmNcolumns, 80); argcount++; XtSetArg(args[argcount], XmNeditable, False); argcount++; XtSetArg(args[argcount], XmNeditMode, XmMULTI_LINE_EDIT); argcount++; XtSetArg(args[argcount], XmNwordWrap, False); argcount++; XtSetArg(args[argcount], XmNscrollHorizontal, True); argcount++; XtSetArg(args[argcount], XmNcursorPositionVisible, True); argcount++; XtSetArg(args[argcount], XmNautoShowCursorPosition, False); argcount++; XtSetArg(args[argcount], XmNfontList, fontlist); argcount++; XtSetArg(args[argcount], XmNtopAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM); argcount++; XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET); argcount++; XtSetArg(args[argcount], XmNbottomWidget, separator_w); argcount++; cmd_output = XmCreateScrolledText(mainform_w, "cmd_output", args, argcount); XtManageChild(cmd_output); XtManageChild(mainform_w); #ifdef WITH_EDITRES XtAddEventHandler(appshell, (EventMask)0, True, _XEditResCheckMessages, NULL); #endif /* Realize all widgets. */ XtRealizeWidget(appshell); /* Set some signal handlers. */ if ((signal(SIGBUS, sig_bus) == SIG_ERR) || (signal(SIGSEGV, sig_segv) == SIG_ERR)) { (void)xrec(WARN_DIALOG, "Failed to set signal handler's for %s : %s", SHOW_CMD, strerror(errno)); } xexec_cmd(cmd); /* We want the keyboard focus on the cmd output. */ XmProcessTraversal(cmd_output, XmTRAVERSE_CURRENT); /* Start the main event-handling loop. */ XtAppMainLoop(app); exit(SUCCESS); }
void D3D12Render::init_d3d() { #if defined(DEBUG) || defined(_DEBUG) // Enable the D3D12 debug layer. { ComPtr<ID3D12Debug> debugController; ThrowIfFailed(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController))); debugController->EnableDebugLayer(); } #endif ThrowIfFailed(CreateDXGIFactory1(IID_PPV_ARGS(&m_pFactory))); // Try to create hardware device. HRESULT hardwareResult = D3D12CreateDevice( nullptr, // default adapter D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_pD3D12Device)); // Fallback to WARP device. if(FAILED(hardwareResult)) { ComPtr<IDXGIAdapter> pWarpAdapter; ThrowIfFailed(m_pFactory->EnumWarpAdapter(IID_PPV_ARGS(&pWarpAdapter))); ThrowIfFailed(D3D12CreateDevice( pWarpAdapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_pD3D12Device))); } ThrowIfFailed(m_pD3D12Device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m_pFence))); m_RtvDescriptorSize = m_pD3D12Device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); m_DsvDescriptorSize = m_pD3D12Device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV); m_CbvSrvUavDescriptorSize = m_pD3D12Device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); // Check 4X MSAA quality support for our back buffer format. // All Direct3D 11 capable devices support 4X MSAA for all render // target formats, so we only need to check quality support. D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS msQualityLevels; msQualityLevels.Format = m_BackBufferFormat; msQualityLevels.SampleCount = 4; msQualityLevels.Flags = D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_NONE; msQualityLevels.NumQualityLevels = 0; ThrowIfFailed(m_pD3D12Device->CheckFeatureSupport( D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &msQualityLevels, sizeof(msQualityLevels))); m_4xMsaaQuality = msQualityLevels.NumQualityLevels; assert(m_4xMsaaQuality > 0 && "Unexpected MSAA quality level."); #ifdef _DEBUG LogAdapters(); #endif init_cmd(); init_swapchain(); init_descHeaps(); }