int main(int argc,char *argv[]) { int retval = 0; /* Initialize rtdk */ #ifdef _RTUTILS_H rt_print_auto_init(1); #endif /* Try to Exit Cleanly on Signals */ parentThread = getpid(); signal(SIGINT,signal_handler); signal(SIGABRT,signal_handler); signal(SIGSEGV,signal_handler); /* Handle Command-Line Options */ cli_options_t cli_options; if (!parse_cli_options(argc,argv,&cli_options)) return -EINVAL; /* Find Configuration File */ std::string config_file; if (cli_options.config_file.length()) config_file = cli_options.config_file; else if (getenv("RTXI_CONF")) config_file = getenv("RTXI_CONF"); else config_file = "/etc/rtxi.conf"; /************************************************************ * Create Main System Components * * * * These need to be created early because they should have * * Settings::IDs of 0 and 1. * ************************************************************/ /* Create GUI Objects */ QApplication *app = new QApplication(argc,argv); app->connect(app,SIGNAL(lastWindowClosed()),app,SLOT(quit())); MainWindow::getInstance()->showMaximized(); CmdLine::getInstance(); RT::System::getInstance(); IO::Connector::getInstance(); /* Bootstrap the System */ Settings::Manager::getInstance()->load(config_file); retval = app->exec(); Plugin::Manager::getInstance()->unloadAll(); return retval; }
int main(int ac, char **av) { int ret; struct ospfd *ospfd; int ev_flags = 0; ospfd = alloc_ospfd(); ret = parse_cli_options(ospfd, ac, av); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Can't parse command line"); msg(ospfd, GENTLE, PROGRAMNAME " - " VERSIONSTRING); /* seed pseudo number randon generator */ init_pnrg(ospfd); /* initialize event subsystem. In this case this belongs * to open a epoll filedescriptor */ ospfd->ev = ev_new(); if (!ospfd->ev) err_msg_die(EXIT_FAILURE, "Can't initialize event subsystem"); ret = parse_rc_file(ospfd); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Can't parse configuration file"); ret = init_network(ospfd); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Can't initialize network subsystem"); /* and branch into the main loop * This loop will never return (with the exception of SIGINT or failure * condition) */ ret = ev_loop(ospfd->ev, ev_flags); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Main loop returned unexpected - exiting now"); fini_network(ospfd); free_options(ospfd); ev_free(ospfd->ev); free_ospfd(ospfd); return EXIT_SUCCESS; }
int censorscope_options_init(censorscope_options_t *options, int argc, char **argv) { /* set default options first */ if (set_default_options(options)) { /* we've already logged the error */ return -1; } /* parse the config file */ if (parse_config_file(options)) { /* we've already logged the error */ return -1; } /* parse the command line arguments */ if (parse_cli_options(options, argc, argv)) { /* we've already logged the error */ return -1; } return 0; }
/* * main */ int main (int argc, char *argv[]) { #undef DEBUGFUNCTION #define DEBUGFUNCTION "main()" XVC_ErrorListItem *errors_after_cli = NULL; int resultCode; XVC_CapTypeOptions s_tmp_capture_options, *target; #ifdef HasDGA int dga_evb, dga_errb; #endif // HasDGA #ifdef ENABLE_NLS // i18n initialization bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif // xvc initialization init (&s_tmp_capture_options, &argc, argv); // read options file now xvc_read_options_file (app); // parse cli options and merge with app data parse_cli_options (&s_tmp_capture_options, argc, argv); target = merge_cli_options (&s_tmp_capture_options); // get errors in options to pass to xvc_ui_create { int rc; rc = 0; errors_after_cli = xvc_appdata_validate (app, 1, &rc); if (rc == -1) { fprintf (stderr, _ ("%s %s: Unrecoverable error while validating options, please contact the xvidcap project.\n"), DEBUGFILE, DEBUGFUNCTION); exit (1); } } // these are the hooks for a GUI to create the GUI, // the selection frame, and do some initialization ... if (!xvc_ui_create ()) { fprintf (stderr, _("%s %s: can't create GUI ... aborting\n"), DEBUGFILE, DEBUGFUNCTION); exit (2); } if (!xvc_frame_create (capture_window)) { fprintf (stderr, _("%s %s: can't create selection Frame ... aborting\n"), DEBUGFILE, DEBUGFUNCTION); exit (2); } if (!xvc_ui_init (errors_after_cli)) { fprintf (stderr, _("%s %s: can't initialize GUI ... aborting\n"), DEBUGFILE, DEBUGFUNCTION); exit (2); } if (app->verbose) { print_current_settings (target); } // signal handling for --gui no operation (CTRL-C) and // unsleeping the recoring thread on stop my_signal_add (SIGALRM, xvc_signal_handler); my_signal_add (SIGINT, xvc_signal_handler); // this is a hook for the GUI's main loop resultCode = xvc_ui_run (); cleanup (); return (resultCode); }
int main(int argc, char **argv) { XEvent event; config_init(); parse_cli_options(argc, argv); config_read(); mixer_init(config.mixer_device, config.verbose, (const char **)config.exclude_channel); mixer_set_channel(0); display = XOpenDisplay(config.display_name); if (display == NULL) { const char *name; if (config.display_name) { name = config.display_name; } else { name = getenv("DISPLAY"); if (name == NULL) { fprintf(stderr, "wmix:error: Unable to open display, variable $DISPLAY not set\n"); return EXIT_FAILURE; } } fprintf(stderr, "wmix:error: Unable to open display \"%s\"\n", name); return EXIT_FAILURE; } display_width = (float)DisplayWidth(display, DefaultScreen(display)) / 4.0; display_height = (float)DisplayHeight(display, DefaultScreen(display)) / 2.0; dockapp_init(display); new_window("wmix", 64, 64); new_osd(DisplayWidth(display, DefaultScreen(display)) - 200, 60); if (config.mmkeys) mmkey_install(display); config_release(); blit_string("wmix " VERSION); scroll_text(3, 4, 57, true); ui_update(); /* add click regions */ add_region(1, 37, 36, 25, 25); /* knob */ add_region(2, 4, 42, 27, 15); /* balancer */ add_region(3, 2, 26, 7, 10); /* previous channel */ add_region(4, 10, 26, 7, 10); /* next channel */ add_region(5, 39, 14, 20, 7); /* mute toggle */ add_region(6, 4, 14, 13, 7); /* rec toggle */ add_region(10, 3, 4, 56, 7); /* re-scroll current channel name */ /* setup up/down signal handler */ create_pid_file(); signal(SIGUSR1, (void *) signal_catch); signal(SIGUSR2, (void *) signal_catch); while (true) { if (button_pressed || slider_pressed || (XPending(display) > 0)) { XNextEvent(display, &event); switch (event.type) { case KeyPress: if (key_press_event(&event.xkey)) idle_loop = 0; break; case Expose: redraw_window(); break; case ButtonPress: button_press_event(&event.xbutton); idle_loop = 0; break; case ButtonRelease: button_release_event(&event.xbutton); idle_loop = 0; break; case MotionNotify: /* process cursor change, or drag events */ motion_event(&event.xmotion); idle_loop = 0; break; case LeaveNotify: /* go back to standard cursor */ if ((!button_pressed) && (!slider_pressed)) set_cursor(NORMAL_CURSOR); break; case DestroyNotify: XCloseDisplay(display); return EXIT_SUCCESS; default: break; } } else { usleep(100000); scroll_text(3, 4, 57, false); /* rescroll message after some delay */ if (idle_loop++ > 256) { scroll_text(3, 4, 57, true); idle_loop = 0; } /* get rid of OSD after a few seconds of idle */ if ((idle_loop > 15) && osd_mapped() && !button_pressed) { unmap_osd(); idle_loop = 0; } if (mixer_is_changed()) ui_update(); } } return EXIT_SUCCESS; }