示例#1
0
int main(int argc, char *argv[])
{
    SETUP_THE_NUMBERS;
    TEARDOWN_THE_NUMBERS;
    char *char_string = string("asdasd");
    int c;

    while ((c = getopt(argc, argv, "hv")) != -1) {
        switch (c) {
            case 'h':
                print_help_message();
                prepare_for_exit();
                return EXIT_FAILURE;
            case 'v':
                print_licence_message();
                prepare_for_exit();
                return EXIT_FAILURE;
        }
    }
    random_init();
    set_signals();
    init_windows();
    init_modes();

    loop();

    prepare_for_exit();
    free_memory();
    return EXIT_SUCCESS;
}
示例#2
0
static void
termination_handler (int signum)
{
  prepare_for_exit ();
  fprintf (stderr, "GAME ABORTED (signal %d)\n", signum);
  /* We did `signal (signum, SIG_DFL)' in `generic_handler'.  */
  raise (signum);
}
示例#3
0
static void
tstp_handler (int signum)
{
  clock_freeze ();
  mode_signal (signum);
  prepare_for_exit ();
  install_signal (SIGTSTP, SIG_DFL);
  raise (SIGTSTP);
}
示例#4
0
/**
 * @sig: number of the signal
 *
 * Signal handler called if signal is emmitted.
 */
static void signal_handler(const int sig)
{
    prepare_for_exit();
#ifdef SIGWINCH
    if (SIGWINCH == sig) {
        refresh();
        init_windows();
        gamemode_draw();

        return;
    }
#endif
    free_memory();
    exit(EXIT_FAILURE);
}
示例#5
0
/**
 * @format: Formatstring like in fprintf.
 *
 * Signal a fatal error and quit immediately.
 */
void error_exit(const char *format, ...)
{
    va_list ap;

    /* clean all ncurses windows */
    prepare_for_exit();
    free_memory();

    va_start(ap, format);
    vfprintf(stderr, format, ap);
    fputc('\n', stderr);
    va_end(ap);

    exit(EXIT_FAILURE);
}
示例#6
0
void
fatal (const char *format, ...)
/* Signal a fatal error and quit immediately.  The arguments have the
 * same meaning, as in the function `printf'.
 * The message should start with a capital letter.  */
{
  va_list  ap;

  prepare_for_exit ();

  va_start (ap, format);
  fflush (NULL);
  fputs ("Fatal error: ", stderr);
  vfprintf (stderr, format, ap);
  fputc ('\n', stderr);
  va_end (ap);

  exit (EXIT_FAILURE);
}