diff options
Diffstat (limited to 'term/term.h')
-rw-r--r-- | term/term.h | 133 |
1 files changed, 91 insertions, 42 deletions
diff --git a/term/term.h b/term/term.h index 954fb73c..81d0efee 100644 --- a/term/term.h +++ b/term/term.h @@ -1,5 +1,5 @@ -/* - Copyright (C) 1995, 1996 Free Software Foundation, Inc. +/* + Copyright (C) 1995,96,98,99, 2002 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -23,7 +23,16 @@ #include <errno.h> #include <hurd/trivfs.h> #include <sys/types.h> +#include <sys/mman.h> #include <fcntl.h> +#include <features.h> +#include <hurd/hurd_types.h> + +#ifdef TERM_DEFINE_EI +#define TERM_EI +#else +#define TERM_EI __extern_inline +#endif #undef MDMBUF #undef ECHO @@ -33,16 +42,26 @@ #undef NOFLSH #include <termios.h> -#define CHAR_SOH '\001' /* C-a */ #define CHAR_EOT '\004' /* C-d */ #define CHAR_DC1 '\021' /* C-q */ #define CHAR_DC2 '\022' /* C-r */ #define CHAR_DC3 '\023' /* C-s */ #define CHAR_USER_QUOTE '\377' /* break quoting, etc. */ +/* This bit specifies control */ +#define CTRL_BIT 0x40 + /* XXX These belong in <termios.h> */ +#ifdef IUCLC +#define ILCASE IUCLC +#else #define ILCASE (1 << 14) +#endif +#ifdef OLCUC +#define OLCASE OLCUC +#else #define OLCASE (1 << 9) +#endif #define OTILDE (1 << 10) /* used in mdmctl device call */ @@ -68,6 +87,13 @@ long termflags; #define NO_OWNER 0x00000200 /* there is no foreground_id */ #define ICKY_ASYNC 0x00000400 /* some user has set O_ASYNC */ +/* Use a high watermark that allows about as much input as once as + other operating systems do. Using something just a bit smaller + than a power of 2 helps to make maximum use of the buffer and avoid + reallocation for just a few bytes. */ +#define QUEUE_LOWAT 200 +#define QUEUE_HIWAT 8100 + /* Global lock */ struct mutex global_lock; @@ -101,9 +127,6 @@ struct trivfs_control *termctl; /* Trivfs control structure for the pty */ struct trivfs_control *ptyctl; -/* Mach device name for this terminal */ -char *pterm_name; - /* The queues we use */ struct queue *inputq, *rawq, *outputq; @@ -123,25 +146,33 @@ uid_t term_group; mode_t term_mode; +/* XXX Including <sys/ioctl.h> or <hurd/ioctl_types.h> leads to "ECHO + undeclared" errors in munge.c or users.c. */ +struct winsize; + /* Functions a bottom half defines */ struct bottomhalf { - void (*start_output) (void); - void (*set_break) (void); - void (*clear_break) (void); - void (*abandon_physical_output) (void); - void (*suspend_physical_output) (void); + enum term_bottom_type type; + error_t (*init) (void); + error_t (*fini) (void); + error_t (*gwinsz) (struct winsize *size); + error_t (*start_output) (void); + error_t (*set_break) (void); + error_t (*clear_break) (void); + error_t (*abandon_physical_output) (void); + error_t (*suspend_physical_output) (void); int (*pending_output_size) (void); - void (*notice_input_flushed) (void); + error_t (*notice_input_flushed) (void); error_t (*assert_dtr) (void); - void (*desert_dtr) (void); - void (*set_bits) (void); - void (*mdmctl) (int, int); - int (*mdmstate) (void); + error_t (*desert_dtr) (void); + error_t (*set_bits) (struct termios *state); + error_t (*mdmctl) (int how, int bits); + error_t (*mdmstate) (int *state); }; -struct bottomhalf *bottom; -extern struct bottomhalf devio_bottom, ptyio_bottom; +const struct bottomhalf *bottom; +extern const struct bottomhalf devio_bottom, hurdio_bottom, ptyio_bottom; /* Character queues */ @@ -160,38 +191,53 @@ struct queue struct queue *create_queue (int size, int lowat, int hiwat); +extern int qsize (struct queue *q); +extern int qavail (struct queue *q); +extern void clear_queue (struct queue *q); +extern quoted_char dequeue_quote (struct queue *q); +extern char dequeue (struct queue *q); +extern void enqueue_internal (struct queue **qp, quoted_char c); +extern void enqueue (struct queue **qp, char c); +extern void enqueue_quote (struct queue **qp, char c); +extern char unquote_char (quoted_char c); +extern int char_quoted_p (quoted_char c); +extern short queue_erase (struct queue *q); + +#if defined(__USE_EXTERN_INLINES) || defined(TERM_DEFINE_EI) /* Return the number of characters in Q. */ -extern inline int +TERM_EI int qsize (struct queue *q) { return q->ce - q->cs; } /* Return nonzero if characters can be added to Q. */ -extern inline int +TERM_EI int qavail (struct queue *q) { return !q->susp; } /* Flush all the characters from Q. */ -extern inline int +TERM_EI void clear_queue (struct queue *q) { q->susp = 0; q->cs = q->ce = q->array; condition_broadcast (q->wait); } +#endif /* Use extern inlines. */ /* Should be below, but inlines need it. */ void call_asyncs (int dir); +#if defined(__USE_EXTERN_INLINES) || defined(TERM_DEFINE_EI) /* Return the next character off Q; leave the quoting bit on. */ -extern inline quoted_char +TERM_EI quoted_char dequeue_quote (struct queue *q) { int beep = 0; - + assert (qsize (q)); if (q->susp && (qsize (q) < q->lowat)) { @@ -210,23 +256,25 @@ dequeue_quote (struct queue *q) } /* Return the next character off Q. */ -extern inline char +TERM_EI char dequeue (struct queue *q) { return dequeue_quote (q) & ~QUEUE_QUOTE_MARK; } +#endif /* Use extern inlines. */ struct queue *reallocate_queue (struct queue *); +#if defined(__USE_EXTERN_INLINES) || defined(TERM_DEFINE_EI) /* Add C to *QP. */ -extern inline void +TERM_EI void enqueue_internal (struct queue **qp, quoted_char c) { struct queue *q = *qp; if (q->ce - q->array == q->arraylen) q = *qp = reallocate_queue (q); - + *q->ce++ = c; if (qsize (q) == 1) @@ -241,28 +289,28 @@ enqueue_internal (struct queue **qp, quoted_char c) } /* Add C to *QP. */ -extern inline void +TERM_EI void enqueue (struct queue **qp, char c) { enqueue_internal (qp, c); } /* Add C to *QP, marking it with a quote. */ -extern inline void +TERM_EI void enqueue_quote (struct queue **qp, char c) { enqueue_internal (qp, c | QUEUE_QUOTE_MARK); -} +} /* Return the unquoted version of a quoted_char. */ -extern inline char +TERM_EI char unquote_char (quoted_char c) { return c & ~QUEUE_QUOTE_MARK; } /* Tell if a quoted_char is actually quoted. */ -extern inline int +TERM_EI int char_quoted_p (quoted_char c) { return c & QUEUE_QUOTE_MARK; @@ -270,12 +318,12 @@ char_quoted_p (quoted_char c) /* Remove the most recently enqueue character from Q; leaving the quote mark on. */ -extern inline short +TERM_EI short queue_erase (struct queue *q) { short answer; int beep = 0; - + assert (qsize (q)); answer = *--q->ce; if (q->susp && (qsize (q) < q->lowat)) @@ -289,16 +337,18 @@ queue_erase (struct queue *q) condition_broadcast (q->wait); return answer; } +#endif /* Use extern inlines. */ /* Functions devio is supposed to call */ int input_character (int); void report_carrier_on (void); void report_carrier_off (void); +void report_carrier_error (error_t); /* Other decls */ -void drop_output (void); +error_t drop_output (void); void send_signal (int); error_t drain_output (); void output_character (int); @@ -307,18 +357,17 @@ void rescan_inputq (void); void write_character (int); void init_users (void); -/* Call this before using ptyio_bottom. */ -void ptyio_init (void); +extern char *tty_arg; +extern dev_t rdev; /* kludge--these are pty versions of trivfs_S_io_* functions called by the real functions in users.c to do work for ptys. */ -error_t pty_io_write (struct trivfs_protid *, char *, +error_t pty_io_write (struct trivfs_protid *, char *, mach_msg_type_number_t, mach_msg_type_number_t *); -error_t pty_io_read (struct trivfs_protid *, char **, +error_t pty_io_read (struct trivfs_protid *, char **, mach_msg_type_number_t *, mach_msg_type_number_t); -error_t pty_io_readable (int *); -error_t pty_io_select (struct trivfs_protid *, mach_port_t, int *, int *); -error_t pty_open_hook (struct trivfs_control *, uid_t *, u_int, uid_t *, - u_int, int); +error_t pty_io_readable (size_t *); +error_t pty_io_select (struct trivfs_protid *, mach_port_t, int *); +error_t pty_open_hook (struct trivfs_control *, struct iouser *, int); error_t pty_po_create_hook (struct trivfs_peropen *); error_t pty_po_destroy_hook (struct trivfs_peropen *); |