void bye(void) { /* Force my personal prejudices upon the poor luser */ if (LOG_ENABLED) fprintf(log_fp, "Cleanup & exit\n"); default_level(); /* Enter ANSI mode (if in VT52 mode) */ decckm(FALSE); /* cursor keys normal */ deccolm(FALSE); /* 80 col mode */ decscnm(FALSE); /* Normal screen */ decom(FALSE); /* Absolute origin mode */ decawm(TRUE); /* Wrap around on */ decarm(TRUE); /* Auto repeat on */ decstbm(0, 0); /* No scroll region */ sgr("0"); /* Normal character attributes */ /* Say goodbye */ vt_clear(2); vt_move(12, 30); printf("That's all, folks!\n"); printf("\n\n\n"); inflush(); close_tty(); exit(EXIT_SUCCESS); }
void init_ttymodes(int pn) { int speed_code, n; dump_ttymodes("init_ttymodes", pn); #ifdef UNIX if (pn==0) { fflush(stdout); # if USE_POSIX_TERMIOS || USE_TERMIO tcgetattr(0, &old_modes); speed_code = cfgetospeed(&old_modes); # else # if USE_SGTTY gtty(0, &old_modes); ioctl(0, TIOCGETC, &old_tchars); ioctl(0, TIOCGLTC, &old_ltchars); speed_code = old_modes.sg_ospeed; # endif # endif new_modes = old_modes; for (n = 0; n < TABLESIZE(speeds); n++) { if (speeds[n].name == speed_code) { tty_speed = speeds[n].code; break; } } } else { putchar(BEL); fflush(stdout); inflush(); new_modes = old_modes; sleep(2); } # if USE_POSIX_TERMIOS || USE_TERMIO new_modes.c_iflag = BRKINT | old_modes.c_iflag; new_modes.c_oflag &= ~tabs; # else /* USE_SGTTY */ new_modes.sg_flags = old_modes.sg_flags | CBREAK; # endif set_ttymodes(&new_modes); # ifdef HAVE_FCNTL_H # ifndef O_NDELAY # define O_NDELAY O_NONBLOCK /* O_NONBLOCK is POSIX */ # endif close(2); open("/dev/tty", O_RDWR|O_NDELAY); # endif #endif /* UNIX */ dump_ttymodes("...init_ttymodes", pn); }