⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ckutio.c

📁 linux终端仿真程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifdef aegischar *ckxv = "Aegis Communications support, 6.0.169, 6 Sep 96";#else#ifdef Plan9char *ckxv = "Plan 9 Communications support, 6.0.169, 6 Sep 96";#elsechar *ckxv = "UNIX Communications support, 6.0.169, 6 Sep 96";#endif /* Plan9 */#endif /* aegis *//*  C K U T I O  *//* C-Kermit interrupt, communications control and I/O functions for UNIX *//*  NOTE TO CONTRIBUTORS: This file, and all the other C-Kermit files, must be  compatible with C preprocessors that support only #ifdef, #else, #endif,  #define, and #undef.  Please do not use #if, logical operators, or other  preprocessor features in any of the portable C-Kermit modules.  You can,  of course, use these constructions in system-specific modules when they  are supported.*//*  Author: Frank da Cruz (fdc@columbia.edu),  Columbia University Academic Information Systems, New York City.  Copyright (C) 1985, 1996, Trustees of Columbia University in the City of New  York.  All rights reserved.*//* Includes */#include "ckcsym.h"			/* This must go first   */#include "ckcdeb.h"			/* This must go second  */#include <errno.h>			/* System error numbers */#ifdef __386BSD__#define ENOTCONN 57#else#ifdef __bsdi__#define ENOTCONN 57#else#ifdef __FreeBSD__#define ENOTCONN 57#endif /* __FreeBSD__ */#endif /* __bsdi__ */#endif /* __386BSD__ */#ifdef Plan9#define SELECT#include <sys/time.h>#include <select.h>#define FD_SETSIZE (3 * sizeof(long) * 8)static struct timeval tv;#endif /* Plan9 */#include "ckcnet.h"			/* Symbols for network types. */#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 *//*  The directory-related includes are here because we need to test some  file-system-related symbols to find out which system we're being compiled  under.  For example, MAXNAMLEN is defined in BSD4.2 but not 4.1.*/#ifdef SDIRENT				/* Directory bits... */#define DIRENT#endif /* SDIRENT */#ifdef XNDIR#include <sys/ndir.h>#else /* !XNDIR */#ifdef NDIR#include <ndir.h>#else /* !NDIR, !XNDIR */#ifdef RTU#include "/usr/lib/ndir.h"#else /* !RTU, !NDIR, !XNDIR */#ifdef DIRENT#ifdef SDIRENT#include <sys/dirent.h>#else#include <dirent.h>#endif /* SDIRENT */#else /* !RTU, !NDIR, !XNDIR, !DIRENT, i.e. all others */#include <sys/dir.h>#endif /* DIRENT */#endif /* RTU */#endif /* NDIR */#endif /* XNDIR *//* Definition of HZ, used in msleep() */#ifdef MIPS#define HZ ( 1000 / CLOCK_TICK )#else#ifdef ATTSV#ifndef NAP#ifndef TRS16#include <sys/param.h>#else#define HZ ( 1000 / CLOCK_TICK )#endif /* TRS16 */#ifdef NAPHACK#define nap(x) (void)syscall(3112, (x))#define NAP#endif /* NAPHACK */#endif /* NAP */#endif /* ATTSV */#endif /* MIPS */#ifdef M_UNIX#undef NGROUPS_MAX		/* Prevent multiple definition warnings */#endif /* M_UNIX *//*  NOTE: HP-UX 8.0 has a <sys/poll.h>, but there is no corresponding  library routine, so _poll comes up undefined at link time.*/#ifdef CK_POLL#ifndef AIXRS			/* IBM AIX needs special handling */#include <poll.h>		/* "standard" (SVID) i/o multiplexing, etc */#else /* AIXRS */#ifdef SVR4			/* AIX 3.2 is like SVID... */#include <poll.h>#else				/* But AIX 3.1 is not ... */#include <sys/poll.h>		/* The include file is in include/sys */#define events reqevents	/* And it does not map IBM-specific member */#define revents rtnevents	/* names to the System V equivalents */#endif /* SVR4 */#endif /* AIXRS */#endif /* CK_POLL */#include <signal.h>                     /* Signals *//* For setjmp and longjmp */#ifndef ZILOG#include <setjmp.h>#else#include <setret.h>#endif /* ZILOG *//* Maximum length for the name of a tty device */#ifndef DEVNAMLEN#define DEVNAMLEN 32#endif /* DEVNAMLEN */#ifdef	NETCONN#undef DEVNAMLEN#define DEVNAMLEN 256			/* Longer field for host:service */#endif  /* NETCONN *//*  The following test differentiates between 4.1 BSD and 4.2 & later.  If you have a 4.1BSD system with the DIRENT library, this test could  mistakenly diagnose 4.2BSD and then later enable the use of system calls  that aren't defined.  If indeed there are such systems, we can use some  other way of testing for 4.1BSD, or add yet another compile-time switch.*/  #ifdef BSD4#ifdef MAXNAMLEN#ifndef FT21				/* Except for Fortune. */#ifndef FT18#ifndef BELLV10				/* And Bell Labs Research UNIX V10 */#define BSD42#endif /* BELLV10 */#endif /* FT18 */#endif /* FT21 */#endif /* MAXNAMLEN */#endif /* BSD4 *//* MINIX 1.0 support added by Charles Hedrick, Rutgers University <hedrick@aramis.rutgers.edu>. MINIX also has V7 enabled.*/#ifdef MINIX#define TANDEM 0#define MYREAD#include <limits.h>#endif /* MINIX */#ifdef CK_REDIR		/* <sys/wait.h> needed only for REDIRECT command. *//*  If anybody can figure out how to make this work with NeXTSTEP, be  my guest!  (NeXTBlah/NeXTBlah/bsd/sys/wait.h does not define WEXITSTATUS)*/#ifndef CK_WAIT_H			/* If wait.h not already included... */#include <sys/wait.h>			/* Include it */#endif /* CK_WAIT_H */#endif /* CK_REDIR */#include "ckuver.h"			/* Version herald */char *ckxsys = HERALD;/* UUCP lockfile name definition */#ifndef NOUUCP/* Name of UUCP tty device lockfile */#ifdef LINUXFSSTND#ifndef HDBUUCP#define HDBUUCP#endif /* HDBUUCP */#endif /* LINUXFSSTND */#ifdef ACUCNTRL#define LCKDIR#endif /* ACUCNTRL *//*  PIDSTRING means use ASCII string to represent pid in lockfile.*/#ifndef PIDSTRING#ifdef HDBUUCP#define PIDSTRING#else#ifdef BSD44#define PIDSTRING#else#ifdef RTAIX#define PIDSTRING#else#ifdef AIXRS#define PIDSTRING#else#ifdef COHERENT#define PIDSTRING#endif /* COHERENT */#endif /* AIXRS */#endif /* RTAIX */#endif /* BSD44 */#endif /* HDBUUCP */#endif /* PIDSTRING *//* Now the PIDSTRING exceptions... */#ifdef HPUX10				/* HP-UX 10.00 */#ifdef PIDSTRING#undef PIDSTRING#endif /* PIDSTRING */#endif /* HPUX10 */#ifdef __bsdi__				/* BSDI (at least thru 1.1) */#ifdef PIDSTRING#undef PIDSTRING#endif /* PIDSTRING */#endif /* __bsdi__ */#ifdef OSF32				/* Digital UNIX (OSF/1) 3.2 */#ifdef PIDSTRING#undef PIDSTRING#endif /* PIDSTRING */#endif /* OSF32 *//*  LOCK_DIR is the name of the lockfile directory.  If LOCK_DIR is already defined (e.g. on command line), we don't change it.*/#ifndef LOCK_DIR#ifdef BSD44#ifdef __386BSD__#define LOCK_DIR "/var/spool/lock";#else#ifdef __FreeBSD__#define LOCK_DIR "/var/spool/lock";#else#ifdef __NetBSD__#define LOCK_DIR "/var/spool/lock";#else#define LOCK_DIR "/var/spool/uucp";#endif /* __NetBSD__ */#endif /* __FreeBSD__ */#endif /* __386BSD__ */#else#ifdef DGUX430#define LOCK_DIR "/var/spool/locks";#else#ifdef HPUX10#define LOCK_DIR "/var/spool/locks";#else#ifdef RTAIX				/* IBM RT PC AIX 2.2.1 */#define LOCK_DIR "/etc/locks";#else#ifdef AIXRS#define LOCK_DIR "/etc/locks";#else#ifdef ISIII#define LOCK_DIR "/etc/locks";#else#ifdef HDBUUCP#ifdef M_SYS5#define LOCK_DIR "/usr/spool/uucp";#else#ifdef M_UNIX#define LOCK_DIR "/usr/spool/uucp";#else#ifdef SVR4#define LOCK_DIR "/var/spool/locks";#else#ifdef SUNOS4#define LOCK_DIR "/var/spool/locks";#else#ifdef LINUXFSSTND#define LOCK_DIR "/var/lock";#else#define LOCK_DIR "/usr/spool/locks";#endif /* LINUXFSSTND */#endif /* SUNOS4 */#endif /* SVR4 */#endif /* M_UNIX */#endif /* M_SYS5 */#else#ifdef LCKDIR#define LOCK_DIR "/usr/spool/uucp/LCK";#else#ifdef COHERENT#define LOCK_DIR "/usr/spool/uucp";#else#define LOCK_DIR "/usr/spool/uucp";#endif /* COHERENT */#endif /* LCKDIR */#endif /* HDBUUCP */#endif /* ISIII */#endif /* AIXRS */#endif /* RTAIX */#endif /* HPUX10 */#endif /* DGUX430 */#endif /* BSD44 */#endif /* !LOCK_DIR (outside ifndef) */   #ifdef OSF2				/* OSF/1 2.0 or later */#ifdef LOCK_DIR				/* (maybe 1.x too, who knows...) */#undef LOCK_DIR#define LOCK_DIR "/var/spool/locks";#endif /* LOCK_DIR */#endif /* OSF2 */#ifdef SVR4#ifndef BSD44#ifndef LOCKF#define LOCKF				/* Use lockf() on tty device in SVR4 */#endif /* LOCKF */#endif /* BSD44 */#endif /* SVR4 */#ifdef NOLOCKF				/* But NOLOCKF cancels LOCKF */#ifdef LOCKF#undef LOCKF#endif /* LOCKF */#endif /* NOLOCKF */#endif /* !NOUUCP *//*  MYREAD means use our internally defined nonblocking buffered read routine.*/#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.   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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -