log_file_handler::log_file_handler(): log_file_ready(false), config(&global_settings::config) { manager.file_system::init(config -> work_dir(), config -> log_file()); switch(config -> output_mode()) { case true: switch(manager.file_system::exists()) { case false: open_and_init(); break; case true: open(); break; } break; } }
/* * main * DESCRIPTION: Play the adventure game. * INPUTS: none (command line arguments are ignored) * OUTPUTS: none * RETURN VALUE: 0 on success, 3 in panic situations */ int main () { game_condition_t game; /* outcome of playing */ /* Randomize for more fun (remove for deterministic layout). */ srand (time (NULL)); /* Provide some protection against fatal errors. */ clean_on_signals (); if (!build_world ()) {PANIC ("can't build world");} init_game (); /* Perform sanity checks. */ if (0 != sanity_check ()) { PANIC ("failed sanity checks"); } open_and_init(); /* Create tux thread. */ if (0 != pthread_create (&tux_thread_id, NULL, tux_thread, NULL)) { PANIC ("failed to create tux thread"); } push_cleanup (cancel_tux_thread, NULL); { /* Create status message thread. */ if (0 != pthread_create (&status_thread_id, NULL, status_thread, NULL)) { PANIC ("failed to create status thread"); } push_cleanup (cancel_status_thread, NULL); { /* Start mode X. */ if (0 != set_mode_X (fill_horiz_buffer, fill_vert_buffer)) { PANIC ("cannot initialize mode X"); } push_cleanup ((cleanup_fn_t)clear_mode_X, NULL); { /* Initialize the keyboard and/or Tux controller. */ if (0 != init_input ()) { PANIC ("cannot initialize input"); } push_cleanup ((cleanup_fn_t)shutdown_input, NULL); { game = game_loop (); } pop_cleanup (1); } pop_cleanup (1); } pop_cleanup (1); } pop_cleanup (1); /* Print a message about the outcome. */ switch (game) { case GAME_WON: printf ("You win the game! CONGRATULATIONS!\n"); break; case GAME_QUIT: printf ("Quitter!\n"); break; } /* Return success. */ return 0; }