void void_exit( void ) { phys_exit(); script_exit(); net_exit(); input_exit(); audio_exit(); video_exit(); log_exit(); }
void osd_interface::exit_subsystems() { video_exit(); sound_exit(); input_exit(); output_exit(); #ifdef USE_NETWORK network_exit(); #endif midi_exit(); debugger_exit(); }
int handle_input(t_env *e, char *input) { if (ft_strncmp(input, K_ESC, BUFFSIZE) == 0) input_exit(); else if (is_enter(input)) return (0); else if (is_del(input) && !input_del(e)) return (0); else if (ft_strncmp(input, K_TOP, BUFFSIZE) == 0) e->current_index--; else if (ft_strncmp(input, K_BOTTOM, BUFFSIZE) == 0) e->current_index++; else if (ft_strncmp(input, K_RIGHT, BUFFSIZE) == 0) input_right(e); else if (ft_strncmp(input, K_LEFT, BUFFSIZE) == 0) input_left(e); else if (ft_strncmp(input, K_SPACE, BUFFSIZE) == 0) input_space(e); if (e->current_index < 0 || e->current_index > e->chain_size - e->deleted - 1) e->current_index = (e->current_index + e->chain_size - e->deleted) % (e->chain_size - e->deleted); return (1); }
void osd_common_t::exit_subsystems() { video_exit(); input_exit(); }
int main(int argc,char **argv) { static struct option longopts[] = { {"help",no_argument,NULL,'h'}, {"version",no_argument,NULL,'V'}, {"verbose",no_argument,NULL,'v'}, {"foreground",no_argument,NULL,'f'}, {"evmap",required_argument,NULL,'e'}, {"socket",required_argument,NULL,'s'}, {"mode",required_argument,NULL,'m'}, {"repeat-filter",no_argument,NULL,'R'}, {"release",required_argument,NULL,'r'}, {0, 0, 0, 0} }; const char *progname = NULL; int verbose = 0; bool foreground = false; const char *input_device_evmap_dir = EVMAP_DIR; const char *lircd_socket_path = LIRCD_SOCKET; mode_t lircd_socket_mode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH; bool input_repeat_filter = false; const char *lircd_release_suffix = NULL; int opt; for (progname = argv[0] ; strchr(progname, '/') != NULL ; progname = strchr(progname, '/') + 1); openlog(progname, LOG_CONS | LOG_PERROR | LOG_PID, LOG_DAEMON); while((opt = getopt_long(argc, argv, "hVvfe:s:m:Rr:", longopts, NULL)) != -1) { switch(opt) { case 'h': fprintf(stdout, "Usage: %s [options]\n", progname); fprintf(stdout, " -h --help print this help message and exit\n"); fprintf(stdout, " -V --version print the program version and exit\n"); fprintf(stdout, " -v --verbose increase the output message verbosity (-v, -vv or -vvv)\n"); fprintf(stdout, " -f --foreground run in the foreground\n"); fprintf(stdout, " -e --evmap=<dir> directory containing input device event map files (default is '%s')\n", input_device_evmap_dir); fprintf(stdout, " -s --socket=<socket> lircd socket (default is '%s')\n", lircd_socket_path); fprintf(stdout, " -m --mode=<mode> lircd socket mode (default is '%04o')\n", lircd_socket_mode); fprintf(stdout, " -R --repeat-filter enable repeat filtering (default is '%s')\n", input_repeat_filter ? "false" : "true"); fprintf(stdout, " -r --release=<suffix> generate key release events suffixed with <suffix>\n"); exit(EX_OK); break; case 'V': fprintf(stdout, PACKAGE_STRING "\n"); break; case 'v': if (verbose < 3) { verbose++; } else { syslog(LOG_WARNING, "the highest verbosity level is -vvv\n"); } case 'f': foreground = true; break; case 'e': input_device_evmap_dir = optarg; break; case 's': lircd_socket_path = optarg; break; case 'm': lircd_socket_mode = (mode_t)atol(optarg); break; case 'R': input_repeat_filter = true; break; case 'r': lircd_release_suffix = optarg; break; default: fprintf(stderr, "error: unknown option: %c\n", opt); exit(EX_USAGE); } } if (verbose == 0) { setlogmask(0 | LOG_DEBUG | LOG_INFO | LOG_NOTICE); } else if (verbose == 1) { setlogmask(0 | LOG_DEBUG | LOG_INFO); } else if (verbose == 2) { setlogmask(0 | LOG_DEBUG); } else { setlogmask(0); } signal(SIGPIPE, SIG_IGN); if (monitor_init() != 0) { exit(EXIT_FAILURE); } /* Initialize the lircd socket before daemonizing in order to ensure that programs started after it damonizes will have an lircd socket with which to connect. */ if (lircd_init(lircd_socket_path, lircd_socket_mode, lircd_release_suffix) != 0) { monitor_exit(); exit(EXIT_FAILURE); } if (foreground != true) { daemon(0, 0); } if (input_init(input_device_evmap_dir, input_repeat_filter) != 0) { monitor_exit(); lircd_exit(); exit(EXIT_FAILURE); } monitor_run(); if (input_exit() != 0) { monitor_exit(); lircd_exit(); exit(EXIT_FAILURE); } if (lircd_exit() != 0) { monitor_exit(); exit(EXIT_FAILURE); } if (monitor_exit() != 0) { exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); }
int main(int argc, char **argv) { int ch; const char *conffile; conffile = CONFFILE; while ((ch = getopt(argc, argv, "f:v")) != -1) { switch (ch) { case 'f': conffile = optarg; break; case 'v': verbose++; break; default: usage(); /* NOTREACHED */ } } bzero(&config, sizeof(config)); config.print.feedlines = -1; config.print.cchide_customer = 1; config.print.ccsig_customer = 1; bzero(&header, sizeof(header)); if (parse_config(conffile)) exit(1); /* set database files */ if (config.database.custdb == NULL) if ((config.database.custdb = strdup(config.database.alldb ? config.database.alldb : CUSTDBFILE)) == NULL) err(1, "cannot set customer database file"); if (config.database.menudb == NULL) if ((config.database.menudb = strdup(config.database.alldb ? config.database.alldb : MENUDBFILE)) == NULL) err(1, "cannot set menu database file"); if (config.database.orderdb == NULL) if ((config.database.orderdb = strdup(config.database.alldb ? config.database.alldb : ORDERDBFILE)) == NULL) err(1, "cannot set order database file"); if (config.print.feedlines < 0) config.print.feedlines = PRINT_FEED_LINES; if (licence_init() == -1) errx(1, "cannot proceed without licence"); event_init(); module_init(); rule_init(); input_init(); print_init(); form_init(); display_init(); status_init(); menu_init(); customer_init(); special_init(); payment_init(); window_init(); order_init(); display_refresh(); signal(SIGPIPE, SIG_IGN); if (event_dispatch() == -1) err(1, "terminated abnormally"); if (exitcode != 0 && exitmsg == NULL) exitmsg = strdup(status.status); order_exit(); window_exit(); payment_exit(); special_exit(); customer_exit(); menu_exit(); status_exit(); display_exit(); form_exit(); print_exit(); input_exit(); rule_exit(); module_exit(); if (exitcode && exitmsg != NULL) errx(exitcode, "%s", exitmsg); else fprintf(stdout, "exiting normally\n"); exit(0); }
/** * @brief The entry point of NAEV. * * @param[in] argc Number of arguments. * @param[in] argv Array of argc arguments. * @return EXIT_SUCCESS on success. */ int main( int argc, char** argv ) { char buf[PATH_MAX]; /* Save the binary path. */ binary_path = argv[0]; /* Print the version */ LOG( " "APPNAME" v%s", naev_version(0) ); #ifdef GIT_COMMIT DEBUG( " git HEAD at " GIT_COMMIT ); #endif /* GIT_COMMIT */ /* Initializes SDL for possible warnings. */ SDL_Init(0); /* Set up debug signal handlers. */ debug_sigInit(); /* Create the home directory if needed. */ if (nfile_dirMakeExist("%s", nfile_basePath())) WARN("Unable to create naev directory '%s'", nfile_basePath()); /* Must be initialized before input_init is called. */ if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { WARN("Unable to initialize SDL Video: %s", SDL_GetError()); return -1; } /* Get desktop dimensions. */ #if SDL_VERSION_ATLEAST(1,2,10) const SDL_VideoInfo *vidinfo = SDL_GetVideoInfo(); gl_screen.desktop_w = vidinfo->current_w; gl_screen.desktop_h = vidinfo->current_h; #else /* #elif SDL_VERSION_ATLEAST(1,2,10) */ gl_screen.desktop_w = 0; gl_screen.desktop_h = 0; #endif /* #elif SDL_VERSION_ATLEAST(1,2,10) */ /* We'll be parsing XML. */ LIBXML_TEST_VERSION xmlInitParser(); /* Input must be initialized for config to work. */ input_init(); /* Set the configuration. */ snprintf(buf, PATH_MAX, "%s"CONF_FILE, nfile_basePath()); conf_setDefaults(); /* set the default config values */ conf_loadConfig(buf); /* Lua to parse the configuration file */ conf_parseCLI( argc, argv ); /* parse CLI arguments */ /* Enable FPU exceptions. */ #if !(HAS_WIN32) && defined(DEBUGGING) if (conf.fpu_except) feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); #endif /* DEBUGGING */ /* Open data. */ if (ndata_open() != 0) ERR("Failed to open ndata."); /* Load the data basics. */ LOG(" %s", ndata_name()); DEBUG(); /* Display the SDL Version. */ print_SDLversion(); DEBUG(); /* random numbers */ rng_init(); /* * OpenGL */ if (gl_init()) { /* initializes video output */ ERR("Initializing video output failed, exiting..."); SDL_Quit(); exit(EXIT_FAILURE); } window_caption(); gl_fontInit( NULL, NULL, FONT_SIZE ); /* initializes default font to size */ gl_fontInit( &gl_smallFont, NULL, FONT_SIZE_SMALL ); /* small font */ /* Display the load screen. */ loadscreen_load(); loadscreen_render( 0., "Initializing subsystems..." ); time = SDL_GetTicks(); /* * Input */ if ((conf.joystick_ind >= 0) || (conf.joystick_nam != NULL)) { if (joystick_init()) WARN("Error initializing joystick input"); if (conf.joystick_nam != NULL) { /* use the joystick name to find a joystick */ if (joystick_use(joystick_get(conf.joystick_nam))) { WARN("Failure to open any joystick, falling back to default keybinds"); input_setDefault(); } free(conf.joystick_nam); } else if (conf.joystick_ind >= 0) /* use a joystick id instead */ if (joystick_use(conf.joystick_ind)) { WARN("Failure to open any joystick, falling back to default keybinds"); input_setDefault(); } } /* * OpenAL - Sound */ if (conf.nosound) { LOG("Sound is disabled!"); sound_disabled = 1; music_disabled = 1; } if (sound_init()) WARN("Problem setting up sound!"); music_choose("load"); /* Misc graphics init */ if (nebu_init() != 0) { /* Initializes the nebula */ /* An error has happened */ ERR("Unable to initialize the Nebula subsystem!"); /* Weirdness will occur... */ } gui_init(); /* initializes the GUI graphics */ toolkit_init(); /* initializes the toolkit */ map_init(); /* initializes the map. */ cond_init(); /* Initialize conditional subsystem. */ /* Data loading */ load_all(); /* Unload load screen. */ loadscreen_unload(); /* Start menu. */ menu_main(); /* Force a minimum delay with loading screen */ if ((SDL_GetTicks() - time) < NAEV_INIT_DELAY) SDL_Delay( NAEV_INIT_DELAY - (SDL_GetTicks() - time) ); time = SDL_GetTicks(); /* initializes the time */ /* * main loop */ SDL_Event event; /* flushes the event loop since I noticed that when the joystick is loaded it * creates button events that results in the player starting out acceling */ while (SDL_PollEvent(&event)); /* primary loop */ while (!quit) { while (SDL_PollEvent(&event)) { /* event loop */ if (event.type == SDL_QUIT) quit = 1; /* quit is handled here */ input_handle(&event); /* handles all the events and player keybinds */ } main_loop(); } /* Save configuration. */ conf_saveConfig(buf); /* cleanup some stuff */ player_cleanup(); /* cleans up the player stuff */ gui_free(); /* cleans up the player's GUI */ weapon_exit(); /* destroys all active weapons */ pilots_free(); /* frees the pilots, they were locked up :( */ cond_exit(); /* destroy conditional subsystem. */ land_exit(); /* Destroys landing vbo and friends. */ /* data unloading */ unload_all(); /* cleanup opengl fonts */ gl_freeFont(NULL); gl_freeFont(&gl_smallFont); /* Close data. */ ndata_close(); /* Destroy conf. */ conf_cleanup(); /* Frees some memory the configuration allocated. */ /* exit subsystems */ map_exit(); /* destroys the map. */ toolkit_exit(); /* kills the toolkit */ ai_exit(); /* stops the Lua AI magic */ joystick_exit(); /* releases joystick */ input_exit(); /* cleans up keybindings */ nebu_exit(); /* destroys the nebula */ gl_exit(); /* kills video output */ sound_exit(); /* kills the sound */ news_exit(); /* destroys the news. */ /* Free the icon. */ if (naev_icon) free(naev_icon); SDL_Quit(); /* quits SDL */ /* all is well */ exit(EXIT_SUCCESS); }