📄 ckutio.c
字号:
#ifdef aegischar *ckxv = "Aegis Communications support, 8.0.303, 17 Apr 2004";#else#ifdef Plan9char *ckxv = "Plan 9 Communications support, 8.0.303, 17 Apr 2004";#elsechar *ckxv = "UNIX Communications support, 8.0.303, 17 Apr 2004";#endif /* Plan9 */#endif /* aegis *//* C K U T I O *//* C-Kermit interrupt, communications control and I/O functions for UNIX *//* Author: Frank da Cruz (fdc@columbia.edu), Columbia University Academic Information Systems, New York City. Copyright (C) 1985, 2004, Trustees of Columbia University in the City of New York. All rights reserved. See the C-Kermit COPYING.TXT file or the copyright text in the ckcmai.c module for disclaimer and permissions.*//* 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 platform-specific modules when they are supported by all compilers/preprocessors that could be used on that platform.*/extern int nettype; /* Defined in ckcmai.c *//* Includes */#include "ckcsym.h" /* This must go first */#include "ckcdeb.h" /* This must go second */#ifdef OSF13#ifdef CK_ANSIC#ifdef _NO_PROTO#undef _NO_PROTO#endif /* _NO_PROTO */#endif /* CK_ANSIC */#endif /* OSF13 */#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 SCO_OSR504#define NBBY 8#endif /* SCO_OSR504 */#ifdef Plan9#define SELECT#include <sys/time.h>#include <select.h>#define FD_SETSIZE (3 * sizeof(long) * 8)static struct timeval tv;#endif /* Plan9 */#ifdef CLIX#include <sys/time.h>#endif /* CLIX */#include "ckcnet.h" /* Symbols for network types. */#ifdef CK_SSL#include "ck_ssl.h"#endif /* CK_SSL *//* 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 */#ifdef QNX#include <sys/dev.h>#endif /* QNX */#ifdef HPUX5#ifndef TCPSOCKET/* I don't know why this is needed here since we never reference bzero(). *//* But without it C-Kermit won't link in an HP-UX 5.xx non-TCP build. */voidbzero(s,n) char *s; int n; { extern char * memset(); memset(s,0,n);}#endif /* TCPSOCKET */#endif /* HPUX5 *//* Definition of HZ, used in msleep() */#ifdef MIPS#define HZ ( 1000 / CLOCK_TICK )#else /* MIPS */#ifdef ATTSV#ifndef NAP#ifdef TRS16#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 *//* 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 2.0 support added by Terry McConnell, Syracuse University <tmc@barnyard.syr.edu> No more sgtty interface, posix compliant.*/#ifdef MINIX2#define _MINIX /* Needed for some Minix header files */#undef MINIX /* Old minix 1.0: used sgtty interface */#define BSD44ORPOSIX#define SVORPOSIX#define DCLTIMEVAL#define NOFILEH#include <sys/types.h>#include <sys/ioctl.h>#include <termios.h>#include <limits.h>#undef TIOCGETC /* defined in sys/ioctl.h, but not really supported */#define TANDEM 0#endif /* MINIX2 *//* 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#define NOSYSIOCTLH#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... */#ifdef OSF /* force OSF to select POSIX wait */#ifdef _BSD /* instead of BSD (see ckcdeb.h) */#define CK_OSF_BSD#undef _BSD#endif /* _BSD */#endif /* OSF */#include <sys/wait.h> /* Include it */#ifdef OSF#ifdef CK_OSF_BSD#define _BSD /* Restore it */#undef CK_OSF_BSD#endif /* CK_OSF_BSD */#endif /* OSF */#endif /* CK_WAIT_H */#endif /* CK_REDIR */#include "ckuver.h" /* Version herald */char *ckxsys = HERALD;#ifdef CK_UTSNAME#include <sys/utsname.h>#ifdef TRU64 /* Tru64 UNIX 4.0 and later *//* Verified on Tru64 4.0F - might break on 4.0E or earlier */#include <sys/sysinfo.h> /* (don't know about OSF/1 or DU) */#include <machine/hal_sysinfo.h>#endif /* TRU64 */#ifdef SOLARIS25 /* Solaris 2.5 and later */#include <sys/systeminfo.h> /* (don't know about earlier ones) */#endif /* SOLARIS25 */#ifdef UW7#ifndef SYS_NMLN#define SYS_NMLN 257#endif /* NMLN */#endif /* UW7 */#ifdef HPUX9PLUSstatic int hpis800 = 0;#endif /* HPUX9PLUS */#ifdef SYS_NMLN#define CK_SYSNMLN SYS_NMLN#else#ifdef _SYS_NMLN#define CK_SYSNMLN _SYS_NMLN#else#ifdef UTSLEN#define CK_SYSNMLN UTSLEN#else#define CK_SYSNMLN 31#endif /* UTSLEN */#endif /* _SYS_NMLN */#endif /* SYS_NMLN */char unm_mch[CK_SYSNMLN+1] = { '\0', '\0' };char unm_mod[CK_SYSNMLN+1] = { '\0', '\0' };char unm_nam[CK_SYSNMLN+1] = { '\0', '\0' };char unm_rel[CK_SYSNMLN+1] = { '\0', '\0' };char unm_ver[CK_SYSNMLN+1] = { '\0', '\0' };#endif /* CK_UTSNAME */#ifdef CIE#include <stat.h> /* For chasing symlinks, etc. */#else#include <sys/stat.h>#endif /* CIE *//* UUCP lockfile material... */#ifndef NOUUCP#ifdef USETTYLOCK#ifdef HAVE_BAUDBOY /* Red Hat baudboy/lockdev */#include <baudboy.h>#else#ifdef USE_UU_LOCK#ifdef __FreeBSD__#include <libutil.h> /* FreeBSD */#else#include <util.h> /* OpenBSD */#endif /* HAVE_BAUDBOY */#endif /* __FreeBSD */#endif /* USE_UU_LOCK */#else /* USETTYLOCK *//* 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 PIDSTRING#ifdef HPUX#undef PIDSTRING#endif /* HPUX */#endif /* PIDSTRING */#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 MACOSX#define LOCK_DIR "/var/spool/lock"#endif /* MACOSX */#endif/* LOCK_DIR */#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#ifdef __OpenBSD__#define LOCK_DIR "/var/spool/lock"#else/* So which ones is this for? *//* Probably original 4.4BSD on Vangogh *//* Plus who knows about Mac OS X... It doesn't even have a cu program */#define LOCK_DIR "/var/spool/uucp"#endif /* __OpenBSD__ */#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 COMMENT/* Sorry no more lockf() -- we lock first and THEN open the device. */#ifdef SVR4#ifndef BSD44#ifndef LOCKF#define LOCKF /* Use lockf() on tty device in SVR4 */#endif /* LOCKF */#endif /* BSD44 */#endif /* SVR4 */#endif /* COMMENT */#ifdef NOLOCKF /* But NOLOCKF cancels LOCKF */#ifdef LOCKF#undef LOCKF#endif /* LOCKF */#endif /* NOLOCKF *//* More about this below... */#endif /* USETTYLOCK */#endif /* NOUUCP *//* MYREAD means use our internally defined nonblocking buffered read routine.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -