예제 #1
0
/*
**	bye_kids(exit-condition)
**
**	Shutdown the terminal, clear the signals, and exit
*/
void
bye_kids(int n)
{				/* reset the tty and exit */
	ignoresig();
	if (send_reset_init) {
		if (exit_ca_mode) {
			tc_putp(exit_ca_mode);
		}
		if (initial_stty_query(TTY_XON_XOFF)) {
			if (enter_xon_mode) {
				tc_putp(enter_xon_mode);
			}
		} else if (exit_xon_mode) {
			tc_putp(exit_xon_mode);
		}
	}
	if (debug_fp) {
		fclose(debug_fp);
	}
	if (log_fp) {
		fclose(log_fp);
	}
	tty_reset();
	fclose(stdin);
	fclose(stdout);
	fclose(stderr);
	if (not_a_tty)
		sleep(1);
	exit(n);
}
예제 #2
0
int
tty_meta_prep(void)
{				/* print a warning before the meta key test */
    if (not_a_tty) {
	return 0;
    }
    if (initial_stty_query(TTY_8_BIT)) {
	return 0;
    }
    ptext("The meta key test must be run with the");
    ptext(" terminal set for 8 data bits.  Two stop bits");
    ptext(" may also be needed for correct display.  I will");
    ptext(" transmit 8 bit data but if the terminal is set for");
    ptextln(" 7 bit data, garbage may appear on the screen.");
    return 1;
}
예제 #3
0
/*
**	curses_setup(exec_name)
**
**	Startup ncurses
*/
void
curses_setup(
	char *exec_name)
{
	int status;
	static TERMTYPE term;
	char tty_filename[2048];

	tty_init();

	/**
	   See if the terminal is in the terminfo data base.  This call has
	two useful benefits, 1) it returns the filename of the terminfo entry,
	and 2) it searches only terminfo's.  This allows us to abort before
	ncurses starts scanning the termcap file.
	**/
	if ((status = _nc_read_entry(tty_basename, tty_filename, &term)) == 0) {
		const TERMTYPE *fallback = _nc_fallback(tty_basename);

		if (fallback) {
		    term = *fallback;
		    sprintf(tty_filename, "(fallback)%s", tty_basename);
		    status = 1;
		} else {
		    fprintf(stderr, "Terminal not found: TERM=%s\n", tty_basename);
		    show_usage(exec_name);
		    exit(1);
		}
	}
	if (status == -1) {
		fprintf(stderr, "Terminfo database is inaccessible\n");
		exit(1);
	}

	/**
	   This call will load the terminfo data base and set the cur-term
	variable.  Only terminals that actually exist will get here so its
	OK to ignore errors.  This is a good thing since ncurses does not
	permit (os) or (gn) to be set.
	**/
	setupterm(tty_basename, 1, &status);

	/**
	   Get the current terminal definitions.  This must be done before
	getting the baudrate.
	**/
	_nc_get_curterm(&cur_term->Nttyb);
	tty_baud_rate = baudrate();
	tty_cps = (tty_baud_rate << 1) / tty_frame_size;

	/* set up the defaults */
	replace_mode = TRUE;
	scan_mode = 0;
	char_count = 0;
	select_delay_type = debug_level = 0;
	char_mask = (meta_on && meta_on[0] == '\0') ? ALLOW_PARITY : STRIP_PARITY;
	/* Don't change the XON/XOFF modes yet. */
	select_xon_xoff = initial_stty_query(TTY_XON_XOFF) ? 1 : needs_xon_xoff;

	fflush(stdout);	/* flush any output */
	tty_set();

	go_home();	/* set can_go_home */
	put_clear();	/* set can_clear_screen */

	if (send_reset_init) {
		reset_init();
	}

	/*
	   I assume that the reset and init strings may not have the correct
	   pads.  (Because that part of the test comes much later.)  Because
	   of this, I allow the terminal some time to catch up.
	*/
	fflush(stdout);	/* waste some time */
	sleep(1);	/* waste more time */
	charset_can_test();
	can_test("lines cols cr nxon rf if iprog rmp smcup rmcup", FLAG_CAN_TEST);
	edit_init();			/* initialize the edit data base */

	if (send_reset_init && enter_ca_mode) {
		tc_putp(enter_ca_mode);
		put_clear();	/* just in case we switched pages */
	}
	put_crlf();
	ptext("Using terminfo from: ");
	ptextln(tty_filename);
	put_crlf();

	if (tty_can_sync == SYNC_NEEDED) {
		verify_time();
	}

	display_basic();
}