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

📄 ckutio.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
char *ckxv = "UNIX Communications support, 5A(0102), 23 Nov 92";/*  C K U T I O  *//* C-Kermit interrupt, terminal control & i/o functions for UNIX *//*  Author: Frank da Cruz (fdc@columbia.edu, FDCCU@CUVMA.BITNET),  Columbia University Center for Computing Activities.  First released January 1985.  Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New  York.  Permission is granted to any individual or institution to use this  software as long as it is not sold for profit.  This copyright notice must be  retained.  This software may not be included in commercial products without  written permission of Columbia University.*//* Includes */#include "ckcdeb.h"			/* This moved to here. */#include <errno.h>			/* System error numbers */#ifdef __386BSD__#define ENOTCONN 57#endif /* __386BSD__ */#include "ckcnet.h"			/* Symbols for network types. *//*  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 */#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 25#endif#ifdef	NETCONN#undef DEVNAMLEN#define DEVNAMLEN 50			/* 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#ifndef FT18				/* Except for Fortune. */#define BSD42#endif /* FT18 */#endif /* FT21 */#endif /* MAXNAMLEN */#endif /* BSD4 *//* Minix 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 */#include "ckuver.h"			/* Version herald */char *ckxsys = HERALD;/* UUCP lock file name definition */#ifndef NOUUCP/* Name of UUCP tty device lock file */#ifdef ACUCNTRL#define LCKDIR#endif /* ACUCNTRL *//*  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.  PIDSTRING means use ASCII string to represent pid in lockfile.*/#ifndef LOCK_DIR#ifdef BSD44#define LOCK_DIR "/var/spool/uucp";#else#ifdef DGUX430#define LOCK_DIR "/var/spool/locks";#else#ifdef RTAIX				/* IBM RT PC AIX 2.2.1 */#define PIDSTRING#define LOCK_DIR "/etc/locks";#else#ifdef AIXRS#define PIDSTRING#define LOCK_DIR "/etc/locks";#else#ifdef ISIII#define LOCK_DIR "/etc/locks";#else#ifdef HDBUUCP#define PIDSTRING#ifdef M_SYS5  /* wht@n4hgf - SCO */#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";#ifndef LOCKF#define LOCKF				/* Use lockf() too in SVR4 */#endif /* LOCKF */#else#ifdef SUNOS4#define LOCK_DIR "/var/spool/locks";#else#define LOCK_DIR "/usr/spool/locks";#endif /* SUNOS4 */#endif /* SVR4 */#endif /* M_UNIX */#endif /* M_SYS5 */#else#ifdef LCKDIR#define LOCK_DIR "/usr/spool/uucp/LCK";#else#define LOCK_DIR "/usr/spool/uucp";#endif /* LCKDIR */#endif /* HDBUUCP */#endif /* ISIII */#endif /* AIXRS */#endif /* RTAIX */#endif /* DGUX430 */#endif /* BSD44 */#endif /* !LOCK_DIR (outside ifndef) */   #endif /* !NOUUCP */#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 *//* 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*//*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#ifndef NCCS#define NCCS 20#endif /* NCCS */#endif /* bsdi */#include <termios.h>#ifndef BSD44				/* Really POSIX */#define NOSYSIOCTLH			/* No ioctl's allowed. */#undef ultrix				/* Turn off any ultrix features. */#endif /* BSD44 */#endif /* POSIX *//* System III, System V */#ifdef ATTSV#ifndef BSD44#include <termio.h>#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 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 *//* 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 */

⌨️ 快捷键说明

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