tty.h,v
来自「TCP-IP红宝书源代码」· H,V 代码 · 共 224 行
H,V
224 行
head 1.2;
access;
symbols;
locks
dls:1.2; strict;
comment @ * @;
1.2
date 97.09.21.19.26.19; author dls; state Dist;
branches;
next 1.1;
1.1
date 94.05.10.20.48.46; author dls; state Old;
branches;
next ;
desc
@@
1.2
log
@pre-3e code
@
text
@/* tty.h */
#define IBLEN 256 /* input buffer size */
#define OBLEN 256 /* output buffer size */
/* terminal special characters */
struct tchars {
unsigned char tc_erase;
unsigned char tc_intr;
unsigned char tc_kill;
unsigned char tc_lnext;
unsigned char tc_reprint;
unsigned char tc_eof;
unsigned char tc_stop;
unsigned char tc_start;
unsigned char tc_susp;
unsigned char tc_werase;
unsigned char tc_eol;
};
struct tty {
unsigned char tty_state; /* TTYS_* below */
struct devsw *tty_pdev; /* tty dev structure */
struct devsw *tty_phw; /* hardware dev structure */
struct tchars tty_tchars; /* line editing characters */
int tty_cpid; /* controlling process */
/* TTY input fields */
int tty_isema; /* 1/0 semaphore for tty input */
unsigned char tty_iflags; /* TIF_* below */
unsigned short tty_istart; /* index of first character */
unsigned short tty_icount; /* # characters in input buffer */
unsigned char tty_in[IBLEN];
/* TTY output fields */
int tty_osema; /* output buffer space semaphore*/
unsigned char tty_oflags; /* TOF_* below */
unsigned short tty_ostart; /* index of first character */
unsigned short tty_ocount; /* # characters in output buffer*/
unsigned char tty_out[OBLEN];
int tty_rows;
int tty_cols;
/* login information */
int tty_uid; /* user identifier */
unsigned long tty_ltime; /* login time */
unsigned long tty_ctime; /* last command time */
};
/* TTY states */
#define TTYS_FREE 0
#define TTYS_ALLOC 1
/* TTY input flags */
#define TIF_NOBLOCK 0x0001 /* don't block on input */
#define TIF_NOECHO 0x0002 /* echo input */
#define TIF_RAW 0x0004
#define TIF_CBREAK 0x0008
#define TIF_EXCLUSIVE 0x0010
#define TIF_EOF 0x0020 /* have seen EOF */
/* TTY output flags */
#define TOF_NOBLOCK 0x0001 /* don't block on output */
#define TOF_SYNC 0x0002 /* do synchronous output */
#define TOF_RAW 0x0004 /* do raw output */
/* control() functions */
#define TTC_CPID 0x0001 /* set controlling PID */
#define TTC_SYNC 0x0002 /* do synchronous output */
#define TTC_GIF 0x0003 /* get input flags */
#define TTC_GOF 0x0004 /* get output flags */
#define TTC_NEXTC 0x0005 /* peek at next character */
#define TTC_SUSER 0x0006 /* set uid for a tty */
#define TTC_CUSER 0x0007 /* clear uid for a tty */
#define NOCHAR 256
extern struct tty ttytab[];
@
1.1
log
@Initial revision
@
text
@d3 46
a48 66
#define IOCHERR 0200 /* bit set on when an error */
/* occurred reading the char. */
#define OBMINSP 40 /* min space in buffer before */
/* processes awakened to write */
#define EBUFLEN 50 /* size of echo queue */
/* size constants */
#ifndef Ntty
#define Ntty 1 /* number of serial tty lines */
#endif
#ifndef IBUFLEN
#define IBUFLEN 512 /* num. chars in input queue */
#endif
#ifndef OBUFLEN
#define OBUFLEN 512 /* num. chars in output queue */
#endif
/* mode constants */
#define IMRAW 'R' /* raw mode => nothing done */
#define IMCOOKED 'C' /* cooked mode => line editing */
#define IMCBREAK 'K' /* honor echo, etc, no line edit*/
#define OMRAW 'R' /* raw mode => normal processing*/
struct tty { /* tty line control block */
int ihead; /* head of input queue */
int itail; /* tail of input queue */
char ibuff[IBUFLEN]; /* input buffer for this line */
int isem; /* input semaphore */
int icnt; /* count of chars in input buf */
int ohead; /* head of output queue */
int otail; /* tail of output queue */
char obuff[OBUFLEN]; /* output buffer for this line */
int osem; /* output semaphore */
int ocnt; /* count of chars in output buf */
int odsend; /* sends delayed for space */
int ehead; /* head of echo queue */
int etail; /* tail of echo queue */
char ebuff[EBUFLEN]; /* echo queue */
char imode; /* IMRAW, IMCBREAK, IMCOOKED */
Bool iecho; /* is input echoed? */
Bool ieback; /* do erasing backspace on echo?*/
Bool evis; /* echo control chars as ^X ? */
Bool ecrlf; /* echo CR-LF for newline? */
Bool icrlf; /* map '\r' to '\n' on input? */
Bool ierase; /* honor erase character? */
char ierasec; /* erases character, usu. backsp*/
Bool ikill; /* honor line kill character? */
char ikillc; /* line kill character */
Bool iintr; /* is interrupt char honored? */
char iintrc; /* interrupt character */
int iintpid; /* interrupt process id */
Bool ieof; /* honor end-of-file char? */
char ieofc; /* end-of-file character */
int icursor; /* current cursor position */
Bool oflow; /* honor ostop/ostart? */
Bool oheld; /* output currently being held? */
char ostop; /* character that stops output */
char ostart; /* character that starts output */
Bool ocrlf; /* echo CR/LF for LF ? */
char ifullc; /* char to send when input full */
struct zscc_device *ioaddr; /* device address of this unit */
int intrstate; /* device interrupt state */
Bool tbusy; /* terminal busy bit */
char constatus; /* current device contol status */
a49 1
extern struct tty tty[];
d51 31
a81 28
#define ATSIGN '@@'
#define BACKSP '\b'
#define BELL '\007'
#define BLANK ' '
#define EOFC '\004' /* end-of-file character (^D) */
#define KILLCH '\025' /* line kill character (^U) */
#define NEWLINE '\n'
#define RETURN '\r'
#define STOPCH '\023' /* control-S stops output */
#define STRTCH '\021' /* control-Q restarts output */
#define INTRCH '\002' /* control-B is interrupt */
#define UPARROW '^'
/* ttycontrol function codes */
#define TCSETBRK 1 /* turn on BREAK in transmitter */
#define TCRSTBRK 2 /* turn off BREAK " " */
#define TCNEXTC 3 /* look ahead 1 character */
#define TCMODER 4 /* set input mode to raw */
#define TCMODEC 5 /* set input mode to cooked */
#define TCMODEK 6 /* set input mode to cbreak */
#define TCICHARS 8 /* return number of input chars */
#define TCECHO 9 /* turn on echo */
#define TCNOECHO 10 /* turn off echo */
#define TCINT 11 /* set input interrupt pid */
#define TCINTCH 12 /* set input interrupt char */
#define TCNOINT 13 /* turn off input interrupt */
#define TFULLC BELL /* char to echo when buffer full*/
d83 1
a83 1
#define NOCHAR 256 /* no character to return */
@
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?