📄 ckutio.c
字号:
*//*Functions for console terminal: congm() -- Get console terminal modes. concb(esc) -- Put the console in single-character wakeup mode with no echo. conbin(esc) -- Put the console in binary (raw) mode. conres() -- Restore the console to mode obtained by congm(). conoc(c) -- Unbuffered output, one character to console. conol(s) -- Unbuffered output, null-terminated string to the console. conola(s) -- Unbuffered output, array of strings to the console. conxo(n,s) -- Unbuffered output, n characters to the console. conchk() -- Check if characters available at console (bsd 4.2). Check if escape char (^\) typed at console (System III/V). coninc(timo) -- Timed get a character from the console. congks(timo) -- Timed get keyboard scan code. conint() -- Enable terminal interrupts on the console if not background. connoi() -- Disable terminal interrupts on the console if not background.Time functions msleep(m) -- Millisecond sleep ztime(&s) -- Return pointer to date/time string rtimer() -- Reset timer gtimer() -- Get elapsed time since last call to rtimer()*//* Conditional Includes *//* Whether to include <sys/file.h> */#ifdef RTU /* RTU doesn't */#define NOFILEH#endif /* RTU */#ifdef CIE /* CIE does. */#undef NOFILEH#endif /* CIE */#ifdef BSD41 /* 4.1 BSD doesn't */#define NOFILEH#endif /* BSD41 */#ifdef is68k /* is68k (whatever that is) */#define NOFILEH#endif /* is68k */#ifdef MINIX /* MINIX */#define NOFILEH#endif /* MINIX */#ifdef COHERENT /* Coherent */#define NOFILEH#endif /* COHERENT */#ifndef NOFILEH /* Now include if selected. */#include <sys/file.h>#endif /* NOFILEH *//* POSIX */#ifdef BSD44ORPOSIX /* POSIX uses termios.h */#define TERMIOS#ifdef __bsdi__#ifdef POSIX#undef _POSIX_SOURCE /* Get extra stuff from termios.h */#endif /* POSIX */#endif /* __bsdi__ */#include <termios.h>#ifdef __bsdi__#ifdef POSIX#define _POSIX_SOURCE#endif /* POSIX */#endif /* __bsdi__ */#ifndef BSD44 /* Really POSIX */#ifndef CK_QNX32#define NOSYSIOCTLH /* No ioctl's allowed. */#undef ultrix /* Turn off any ultrix features. */#endif /* CK_QNX32 */#endif /* BSD44 */#endif /* POSIX *//* System III, System V */#ifdef ATTSV#ifndef BSD44#ifndef POSIX#include <termio.h>#endif /* POSIX */#endif /* BSD44 *//* #ifdef SVR4 */ /* Sys V R4 and later */#ifdef TERMIOX/* Need this for termiox structure, RTS/CTS and DTR/CD flow control */#include <termiox.h> struct termiox rctsx;#else#ifdef STERMIOX#include <sys/termiox.h> struct termiox rctsx;#endif /* STERMIOX */#endif /* TERMIOX *//* #endif */ /* SVR4 */#endif /* ATTSV */#ifdef COHERENT /* Use termio.h, not sgtty.h for Coherent */#include <termio.h>#endif /* COHERENT */#ifdef MINIX /* MINIX uses ioctl's */#define NOSYSIOCTLH /* but has no <sys/ioctl.h> */#endif /* MINIX *//* Others */#ifndef NOSYSIOCTLH /* Others use ioctl() */#ifdef SUN4S5/* This is to get rid of cpp warning messages that occur because all of these symbols are defined by both termios.h and ioctl.h on the SUN.*/#undef ECHO#undef NL0#undef NL1#undef TAB0#undef TAB1#undef TAB2#undef XTABS#undef CR0#undef CR1#undef CR2#undef CR3#undef FF0#undef FF1#undef BS0#undef BS1#undef TOSTOP#undef FLUSHO#undef PENDIN#undef NOFLSH#endif /* SUN4S5 */#include <sys/ioctl.h>#endif /* NOSYSIOCTLH */#ifdef BELLV10#include <sys/filio.h> /* For FIONREAD */#ifdef FIONREAD#define MYREAD#endif /* MYREAD */#endif /* BELLV10 *//* Whether to include <fcntl.h> */#ifndef is68k /* Only a few don't have this one. */#ifndef BSD41#ifndef FT21#ifndef FT18#ifndef COHERENT#include <fcntl.h>#endif /* COHERENT */#endif /* FT18 */#endif /* FT21 */#endif /* BSD41 */#endif /* not is68k */#ifdef COHERENT#ifdef _I386#include <fcntl.h>#else#include <sys/fcntl.h>#endif /* _I386 */#endif /* COHERENT */#ifdef ATT7300 /* Unix PC, internal modem dialer */#include <sys/phone.h>#endif /* ATT7300 */#ifdef HPUX /* HP-UX variations. */#define HPUXJOBCTL#include <sys/modem.h> /* HP-UX modem signals */#ifdef hp9000s500 /* Model 500 */#undef HPUXJOBCTL#endif /* hp9000s500 */#ifdef HPUXPRE65#undef HPUXJOBCTLtypedef long mflag;#endif /* HPUXPRE65 */#ifdef HPUXJOBCTL#include <sys/bsdtty.h> /* HP-UX Berkeley tty support */#endif /* HPUXJOBCTL */#endif /* HPUX *//* AT&T Sys V or POSIX */#ifdef SVORPOSIX /* Sys V or POSIX */#ifdef M_UNIX#include <sys/time.h>#else#ifdef OXOS /* Olivetti X/OS */#include <sys/time.h>#else#ifdef BSD44 /* 4.4BSD */#include <sys/time.h>#else#ifdef __linux__ /* Linux *//* Kludge to fix redefinition in <linux/wait.h> */#undef WNOHANG#undef WUNTRACED#include <linux/fs.h>#include <linux/tty.h>#include <sys/time.h>#ifdef LINUXHISPEED#include <linux/serial.h>#endif /* LINUXHISPEED */#else#ifdef AIXRS /* IBM AIX */#include <sys/time.h>#else#ifdef IRIX60#include <sys/time.h>#endif /* IRIX60 */#endif /* AIXRS */#endif /* __linux__ */#endif /* BSD44 */#endif /* OXOS */#endif /* M_UNIX */#ifdef NOIEXTEN /* This is broken on some systems */#undef IEXTEN /* like Convex/OS 9.1 */#endif /* NOIEXTEN */#ifndef IEXTEN /* Turn off ^O/^V processing. */#define IEXTEN 0 /* Needed, at least, on BSDI. */#endif /* IEXTEN */#else /* BSD, V7, Coherent, Minix, et al. */#include <sgtty.h> /* So we use <sgtty.h> */#ifndef BELLV10#ifndef PROVX1 /* Now <sys/time.h> ... */#ifndef V7#ifndef BSD41#ifndef COHERENT#include <sys/time.h> /* Clock info (for break generation) */#endif /* COHERENT */#endif /* BSD41 */#endif /* V7 */#endif /* PROVX1 */#endif /* BELLV10 */#endif /* SVORPOSIX */#ifdef BELLV10#include <sys/timeb.h>#endif /* BELLV10 */#ifdef PS2AIX10#include <sys/time.h> /* Clock info for PS/2 AIX 1.x */#endif /* PS2AIX10 */#ifdef OSF /* DEC OSF/1 1.0 */#include <sys/timeb.h>#endif /* OSF */#ifdef BSD41 /* BSD 4.1 */#include <sys/timeb.h>#endif /* BSD41 */#ifdef FT21 /* For:Pro 2.1 */#include <sys/timeb.h>#endif /* FT21 */#ifdef BSD29 /* BSD 2.9 */#include <sys/timeb.h>#endif /* BSD29 */#ifdef TOWER1#include <sys/timeb.h> /* Clock info for NCR Tower */#endif /* TOWER1 */#ifdef COHERENT#include <sys/timeb.h> /* Clock info for NCR Tower */#endif /* COHERENT *//* Pick up definitions needed for select() if we don't have them already. Normally they come from <sys/types.h> but some systems get them from <sys/select.h>... Rather than hardwire all of them into the source, we include it if SELECT_H is defined in compile-time CFLAGS.*/#ifdef SELECT_H#include <sys/select.h>#endif /* SELECT_H */#ifdef aegis#include "/sys/ins/base.ins.c"#include "/sys/ins/error.ins.c"#include "/sys/ins/ios.ins.c"#include "/sys/ins/sio.ins.c"#include "/sys/ins/pad.ins.c"#include "/sys/ins/time.ins.c"#include "/sys/ins/pfm.ins.c"#include "/sys/ins/pgm.ins.c"#include "/sys/ins/ec2.ins.c"#include "/sys/ins/type_uids.ins.c"#include <default_acl.h>#undef TIOCEXCL#undef FIONREAD#endif /* aegis */#ifdef sxaE50 /* PFU Compact A SX/A TISP V10/L50 */#undef FIONREAD#endif /* sxaE50 *//* The following #defines are catch-alls for those systems *//* that didn't have or couldn't find <file.h>... */#ifndef FREAD#define FREAD 0x01#endif /* FREAD */#ifndef FWRITE#define FWRITE 0x10#endif /* FWRITE */#ifndef O_RDONLY#define O_RDONLY 000#endif /* O_RDONLY *//* Declarations */#ifdef OXOS#undef TCGETA#undef TCSETA#undef TCSETAW#undef TCSETAF#define TCGETA TCGETS#define TCSETA TCSETS#define TCSETAW TCSETSW#define TCSETAF TCSETSF#define termio termios#endif /* OXOS */#ifdef HPUX#include <time.h>#else#ifdef _POSIX_SOURCE /* This includes MINIX */#ifndef AIXRS#include <time.h>#endif /* AIXRS */#ifdef __GNUC__#ifdef XENIX/* Because Xenix <time.h> doesn't declare time() if we're using gcc.*/time_t time();#endif /* XENIX */#endif /* __GNUC__ */#elsetime_t time(); /* All Unixes should have this... */#endif /* _POSIX_SOURCE */#endif /* HPUX *//* Special stuff for V7 input buffer peeking */#ifdef V7int kmem[2] = { -1, -1};char *initrawq(), *qaddr[2]={0,0};#define CON 0#define TTY 1#endif /* V7 *//* dftty is the device name of the default device for file transfer *//* dfloc is 0 if dftty is the user's console terminal, 1 if an external line */#ifndef DFTTY#ifdef PROVX1 char *dftty = "/dev/com1.dout"; /* Only example so far of a system */ char *dfmdm = "none"; int dfloc = 1; /* that goes in local mode by default */#else char *dftty = CTTNAM; /* Remote by default, use normal */ char *dfmdm = "none"; int dfloc = 0; /* controlling terminal name. */#endif /* PROVX1 */#else char *dftty = DFTTY; /* Default location specified on */ char *dfmdm = "none"; /* command line. */ int dfloc = 1; /* controlling terminal name. */#endif /* DFTTY */#ifdef RTU int rtu_bug = 0; /* set to 1 when returning from SIGTSTP */#endif /* RTU */ int dfprty = DEFPAR; /* Default parity (0 = none) */ int ttprty = 0; /* The parity that is in use. */ int ttpflg = 0; /* Parity not sensed yet. */ static int ttpmsk = 0xff; /* Parity stripping mask. */ int ttmdm = 0; /* Modem in use. */ int ttcarr = CAR_AUT; /* Carrier handling mode. */ int dfflow = FLO_XONX; /* Default is Xon/Xoff */ int backgrd = 0; /* Assume in foreground (no '&' ) */#ifdef ultrix int iniflags = 0; /* fcntl flags for ttyfd */#endif /* ultrix */ int fdflag = 0; /* Flag for redirected stdio */ int ttfdflg = 0; /* Open File descriptor was given */ int tvtflg = 0; /* Flag that ttvt has been called */ long ttspeed = -1L; /* For saving speed */ int ttflow = -9; /* For saving flow */ int ttld = -1; /* Line discipline */#ifdef sony_news static int km_con = -1; /* Kanji mode for console tty */ static int km_ext = -1; /* Kanji mode for external device */#endif /* sony_news *//* Having this module rely on external globals is bad, but fixing this requires overhaul of the ck*tio.c modules for all the different operating systems supported by C-Kermit. Left for a future release.*/extern int ttnproto; /* Defined in ckcnet.c */extern int ttnet; /* Defined in ckcnet.c */extern int xfrcan, xfrchr, xfrnum; /* Defined in ckcmai.c */extern int suspend;int ckxech = 0; /* 0 if system normally echoes console characters, else 1 *//* Declarations of variables global within this module */static time_t tcount; /* Elapsed time counter */static SIGTYP (*saval)() = NULL; /* For saving alarm() handler */#ifndef NOJCstatic SIGTYP (*jchdlr)() = NULL; /* For checking suspend handler */#endif /* NOJC */static int jcshell = -1; /* And flag for result *//* BREAKNULS is defined for systems that simulate sending a BREAK signal by sending a bunch of NUL characters at low speed.*/#ifdef PROVX1#ifndef BREAKNULS#define BREAKNULS#endif /* BREAKNULS */#endif /* PROVX1 */#ifdef V7#ifndef BREAKNULS#define BREAKNULS#endif /* BREAKNULS */#endif /* V7 */#ifdef BREAKNULSstatic char /* A string of nulls */*brnuls = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";#endif /* BREAKNULS */#ifdef CK_POSIX_SIG /* Longjump buffers */static sigjmp_buf sjbuf; /* POSIX signal handling */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -