From e88c882ecc9557ea14734a418252c2c8a5d8caf9 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 10 Feb 2002 17:21:02 +0000 Subject: 2002-02-10 Marcus Brinkmann * term.h: Include `hurd/hurd_types.h'. (struct bottomhalf): Change the return types of the following members from void to error_t: abandon_physical_output, suspend_physical_output, notice_input_flushed, desert_dtr, set_break, clear_break, start_output, set_bits (which now takes an struct termios * as argument), mdmctl and mdmstate (which now takes an int * as argument). Add new members init and type. (bottom): Define as const. (devio_bottom, ptyio_bottom): Declare as const. (drop_output): Change return type from void to error_t. (ptyio_init): Remove prototype. * devio.c (devio_abandon_physical_output): Change return value to error_t, and return 0. (devio_suspend_physical_output): Likewise. (devio_notice_input_flushed): Likewise. (devio_desert_dtr): Likewise. (devio_set_break): Likewise. (devio_clear_break): Likewise. (devio_start_output): Likewise. (devio_set_bits): Likewise. (devio_mdmctl): Likewise. (devio_mdmstate): Likewise. (init_devio): Rename to ... (devio_init): ... this. Do not give constructor attribute. Change return type to error_t, and return an error value, rather than bailing out. Declare as static. (devio_bottom): Add type TERM_ON_MACHDEV and init function devio_init. (devio_set_bits): Accept new argument STATE and use that to work out the terminal state, rather than changing the global termstate. (devio_mdmstate): Accept new argument STATE and use that to return the bits. * ptyio.c: Do not include `hurd/hurd_types.h'. (ptyio_suspend_physical_output): Change return value to error_t, and return 0. Likewise. (ptyio_notice_input_flushed): Likewise. (ptyio_desert_dtr): Likewise. (ptyio_set_bits): Likewise. (ptyio_set_break): Likewise. (ptyio_clear_break): Likewise. (ptyio_mdmctl): Likewise. (ptyio_start_output): Likewise. (ptyio_abandon_physical_output): Likewise. (ptyio_mdmstate): Likewise, and accept new argument STATE. (ptyio_init): Declare as static and change return type to error_t. (ptyio_bottom): Add type TERM_ON_MASTERPTY and init function ptyio_init. (ptyio_set_bits): Accept new argument STATE and use that to work out the terminal state, rather than changing the global termstate. (ptyio_mdmstate): Accept new argument STATE and use that to return the bits. * munge.c (drop_output): Change return value to error_t. Only clear queue if there was no error. * users.c (S_term_get_bottom_type): Just return bottom->type. (set_state): Rework logic to take possible errors into account, and to delay changing the termstate until we know that we won't fail. (S_tioctl_tiocflush): Return errors properly, and clear queue only if notice_input_flushed succeeded. (open_hook): Save error value of set_bits. Save old termflags and restore them if if set_bits failed. Call set_bits with correct arguments. (S_tioctl_tiocmods): Set err to result of mdmctl. (S_tioctl_tiocmset): Likewise. (S_tioctl_tiocmbic): Likewise. (S_tioctl_tiocmbis): Likewise. (S_tioctl_tioccdtr): Likewise. (S_tioctl_tiocsdtr): Likewise. (S_tioctl_tioccbrk): Likewise for clear_break. (S_tioctl_tiocsbrk): Likewise for set_break. (S_tioctl_tiocstart): Likewise for start_output. Save old termflags and restore them if if start_output failed. (S_tioctl_tiocstop): Likewise for stop_output. (S_trivfs_io_write): Abort the operation if start_output fails. Do not call start_output if it just failed, or if there was no data to be written. * main.c (main): Initialize bottom handler (rather than special casing this for ptyio). * users.c (open_hook): Use memcpy instead bcopy and memset instead bzero. (S_tioctl_tiocgeta): Likewise. (set_state): Likewise. (open_hook): Likewise. * munge.c (rescan_inputq): Likewise. --- term/ptyio.c | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'term/ptyio.c') diff --git a/term/ptyio.c b/term/ptyio.c index 9ea632a7..f2ff96e6 100644 --- a/term/ptyio.c +++ b/term/ptyio.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1999, 2002 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ #include -#include #include #include #include @@ -56,11 +55,12 @@ static int ptyopen = 0; static int nptyperopens = 0; -void -ptyio_init () +static error_t +ptyio_init (void) { condition_implies (inputq->wait, &pty_select_wakeup); condition_implies (&pty_read_wakeup, &pty_select_wakeup); + return 0; } error_t @@ -138,7 +138,7 @@ wake_reader () /* Lower half for tty node */ -static void +static error_t ptyio_start_output () { if (packet_mode && output_stopped && (!(termflags & USER_OUTPUT_SUSP))) @@ -148,9 +148,10 @@ ptyio_start_output () output_stopped = 0; } wake_reader (); + return 0; } -static void +static error_t ptyio_abandon_physical_output () { if (packet_mode) @@ -158,9 +159,10 @@ ptyio_abandon_physical_output () control_byte |= TIOCPKT_FLUSHWRITE; wake_reader (); } + return 0; } -static void +static error_t ptyio_suspend_physical_output () { if (packet_mode) @@ -170,6 +172,7 @@ ptyio_suspend_physical_output () output_stopped = 1; wake_reader (); } + return 0; } static int @@ -179,7 +182,7 @@ ptyio_pending_output_size () return 0; } -static void +static error_t ptyio_notice_input_flushed () { if (packet_mode) @@ -187,6 +190,7 @@ ptyio_notice_input_flushed () control_byte |= TIOCPKT_FLUSHREAD; wake_reader (); } + return 0; } static error_t @@ -196,22 +200,23 @@ ptyio_assert_dtr () return 0; } -static void +static error_t ptyio_desert_dtr () { dtr_on = 0; wake_reader (); + return 0; } -static void -ptyio_set_bits () +static error_t +ptyio_set_bits (struct termios *state) { if (packet_mode) { int wakeup = 0; - int stop = ((termstate.c_iflag & IXON) - && CCEQ (termstate.c_cc[VSTOP], CHAR_DC3) - && CCEQ (termstate.c_cc[VSTART], CHAR_DC1)); + int stop = ((state->c_iflag & IXON) + && CCEQ (state->c_cc[VSTOP], CHAR_DC3) + && CCEQ (state->c_cc[VSTART], CHAR_DC1)); if (external_processing) { @@ -237,33 +242,40 @@ ptyio_set_bits () if (wakeup) wake_reader (); } + return 0; } /* These do nothing. In BSD the associated ioctls get errors, but I'd rather just ignore them. */ -static void +static error_t ptyio_set_break () { + return 0; } -static void +static error_t ptyio_clear_break () { + return 0; } -static void +static error_t ptyio_mdmctl (int a, int b) { + return 0; } -static int -ptyio_mdmstate () +static error_t +ptyio_mdmstate (int *state) { + *state = 0; return 0; } -struct bottomhalf ptyio_bottom = +const struct bottomhalf ptyio_bottom = { + TERM_ON_MASTERPTY, + ptyio_init, ptyio_start_output, ptyio_set_break, ptyio_clear_break, -- cgit v1.2.3