📄 ckutio.c
字号:
*/#ifdef ATTSV#define MYREAD#endif /* ATTSV */#ifdef ATT7300#ifndef MYREAD#define MYREAD#endif /* MYREAD *//* bits for attmodem: internal modem in use, restart getty */#define ISMODEM 1#define DOGETY 512#endif /* ATT7300 */#ifdef BSD42#define MYREAD#endif /* BSD42 */#ifdef POSIX#define MYREAD#endif /* POSIX */#ifdef __bsdi__#ifndef O_NDELAY#define O_NDELAY O_NONBLOCK#endif /* O_NDELAY */#endif /* __bsdi__ *//* Variables available to outside world: dftty -- Pointer to default tty name string, like "/dev/tty". dfloc -- 0 if dftty is console, 1 if external line. dfprty -- Default parity dfflow -- Default flow control ckxech -- Flag for who echoes console typein: 1 - The program (system echo is turned off) 0 - The system (or front end, or terminal). functions that want to do their own echoing should check this flag before doing so. flfnam -- Name of lock file, including its path, e.g., "/usr/spool/uucp/LCK..cul0" or "/etc/locks/tty77" lkflfn -- Name of link to lock file, including its paths haslock -- Flag set if this kermit established a uucp lock. lockpid -- PID of other process that has desired line open, as string. backgrd -- Flag indicating program executing in background ( & on end of shell command). Used to ignore INT and QUIT signals. rtu_bug -- Set by stptrap(). RTU treats ^Z as EOF (but only when we handle SIGTSTP) Functions for assigned communication line (either external or console tty): sysinit() -- System dependent program initialization syscleanup() -- System dependent program shutdown ttopen(ttname,local,mdmtyp,timo) -- Open the named tty for exclusive access. ttclos() -- Close & reset the tty, releasing any access lock. ttsspd(cps) -- Set the transmission speed of the tty. ttgspd() -- Get (read) the the transmission speed of the tty. ttpkt(speed,flow,parity) -- Put the tty in packet mode and set the speed. ttvt(speed,flow) -- Put the tty in virtual terminal mode. or in DIALING or CONNECTED modem control state. ttres() -- Restore original tty modes. ttscarr(carrier) -- Set carrier control mode, on/off/auto. ttinl(dest,max,timo) -- Timed read line from the tty. ttinc(timo) -- Timed read character from tty. myread() -- Raw mode bulk buffer read, gives subsequent chars one at a time and simulates FIONREAD. myunrd(c) -- Places c back in buffer to be read (one only) ttchk() -- See how many characters in tty input buffer. ttxin(n,buf) -- Read n characters from tty (untimed). ttol(string,length) -- Write a string to the tty. ttoc(c) -- Write a character to the tty. ttflui() -- Flush tty input buffer. ttsndb() -- Send BREAK signal. ttsndlb() -- Send Long BREAK signal. ttlock(ttname) -- "Lock" tty device against uucp collisions. ttunlck() -- Unlock tty device. For ATT7300/Unix PC, System V: attdial(ttname,speed,telnbr) -- dials ATT7300/Unix PC internal modem offgetty(ttname) -- Turns off getty(1m) for comms line ongetty(ttname) -- Restores getty() to comms line*//*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 /* Integrated Solutions 68000 UNIX */#define NOFILEH /* e.g. on Plexux P60 and Sun-1 */#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 LINUX#include <sys/ioctl.h>#endif /* LINUX */#ifdef QNX16#include <ioctl.h>#else#ifdef QNX6#include <ioctl.h>#endif /* QNX6 */#endif /* QNX16 */#ifdef __bsdi__#ifdef POSIX#define _POSIX_SOURCE#endif /* POSIX */#endif /* __bsdi__ */#ifndef BSD44 /* Really POSIX */#ifndef CK_QNX32 /* was 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 TERMIOX/* Need this for termiox structure, RTS/CTS and DTR/CD flow control */#include <termiox.h> struct termiox rctsx;#else#ifdef STERMIOX#ifdef SCO_OSR504/* Sorry, this is truly disgusting but it's SCO's fault. */#ifndef _SVID3#define _CK_SVID3_X#define _SVID3#endif /* _SVID3 */#endif /* SCO_OSR504 */#include <sys/termiox.h> struct termiox rctsx;#ifdef CK_SVID3_X#undef _SVID3#undef CK_SVID3_X#endif /* CK_SVID3_X */#endif /* STERMIOX */#endif /* TERMIOX */#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 *//* We really, really, REALLY want FIONREAD, because it is the only way to find out not just *if* stuff is waiting to be read, but how much, which is critical to our sliding-window and streaming procedures, not to mention efficiency of CONNECT, etc.*/#ifdef BELLV10#include <sys/filio.h> /* For FIONREAD */#ifdef FIONREAD#define MYREAD#endif /* MYREAD */#endif /* BELLV10 */#ifndef FIONREAD/* It wasn't found in ioctl.h or term*.h - try these places: */#ifdef UNIXWARE#include <sys/filio.h>#else#ifdef SOLARIS#include <sys/filio.h>#endif /* SOLARIS */#endif /* UNIXWARE */#endif /* FIONREAD */#ifdef XENIX /* Was M_UNIX but XENIX implies M_UNIX and applies to XENIX too *//* <sys/socket.h> included above via "ckcnet.h" defines FIONREAD as something. Due to this, in_chk() uses the FIONREAD instead of RDCHK and the hot keys during file transfer (X to cancel file etc) do not work because FIONREAD doesn't work even though it is defined. NOTE: This might also be true elsewhere.*/#ifdef FIONREAD#undef FIONREAD#endif /* FIONREAD */#endif /* XENIX */#ifdef CK_SCOV5 /* Ditto for SCO OpenServer 5.0 */#ifdef FIONREAD#undef FIONREAD#endif /* FIONREAD */#endif /* XENIX *//* 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 *//* Which time.h files to include... See ckcdeb.h for defaults. Note that 0, 1, 2, or all 3 of these can be included according to the symbol definitions.*/#ifndef NOTIMEH#ifdef TIMEH#include <time.h>#endif /* TIMEH */#endif /* NOTIMEH */#ifndef NOSYSTIMEH#ifdef SYSTIMEH#include <sys/time.h>#endif /* SYSTIMEH */#endif /* NOSYSTIMEH */#ifndef NOSYSTIMEBH#ifdef SYSTIMEBH#include <sys/timeb.h>#endif /* SYSTIMEBH */#endif /* NOSYSTIMEBH */#ifndef NODCLTIMEVAL#ifdef DCLTIMEVAL/* In certain POSIX builds (like Unixware 7), <[sys/]time.h> refuses to define the structs we need to access the higher speeds, so we have to do it ourselves.*/struct timeval { long tv_sec; long tv_usec;};struct timezone { int tz_minuteswest; int tz_dsttime;};#endif /* DCLTIMEVAL */#endif /* NODCLTIMEVAL */#ifdef __linux__/* THIS IS OBSOLETE since about Linux 0.92 */#ifdef OLINUXHISPEED#include <linux/serial.h>#endif /* OLINUXHISPEED */#ifdef __alpha__ /* Linux on DEC Alpha */#ifndef __GLIBC__ /* But not with glibc */#include <asm/termios.h>#endif /* __GLIBC__ */#endif /* __alpha__ */#endif /* __linux__ */#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 *//* 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.*/#ifndef SCO_OSR504#ifdef SELECT_H#include <sys/select.h>#endif /* SELECT_H */#endif /* SCO_OSR504 */#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 */#ifdef SVORPOSIX/* Modem signals are also forbidden in the POSIX world. But some POSIX-based platforms let us at them anyway if we know where to look.*/#ifndef NEEDMDMDEFS/* Doesn't work for Linux */#ifdef UNIXWARE7#define NEEDMDMDEFS#endif /* UNIXWARE7 */#endif /* NEEDMDMDEFS */#ifdef NEEDMDMDEFS#ifndef TIOCMGET#define TIOCMGET (('t'<<8)|29)#endif /* TIOCMGET */#ifndef TIOCM_DTR#define TIOCM_DTR 0x0002#endif /* TIOCM_DTR */#ifndef TIOCM_RTS#define TIOCM_RTS 0x0004#endif /* TIOCM_RTS */#ifndef TIOCM_CTS#define TIOCM_CTS 0x0020#endif /* TIOCM_CTS */#ifndef TIOCM_CAR#define TIOCM_CAR 0x0040#endif /* TIOCM_CAR */#ifndef TIOCM_RNG#define TIOCM_RNG 0x0080#endif /* TIOCM_RNG */#ifndef TIOCM_DSR#define TIOCM_DSR 0x0100#endif /* TIOCM_DSR */#endif /* NEEDMDMDEFS */#endif /* SVORPOSIX *//* 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 SVORPOSIX /* AT&T Sys V or POSIX */#ifdef UNIXWAREPOSIX /* UnixWare 7 POSIX build *//* In Unixware POSIX builds, <[sys/]time.h> refuses to define the structs we need to access the higher speeds, so we have to do it ourselves.*/struct timeval { long tv_sec; long tv_usec;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -