📄 ckutio.c
字号:
#endif /* BSD41 */#endif /* not is68k */#ifdef COHERENT#include <sys/fcntl.h>#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 int mflag;#endif /* HPUXPRE65 */#ifdef HPUXJOBCTL#include <sys/bsdtty.h> /* HP-UX Berkeley tty support */#endif /* HPUXJOBCTL */#endif /* HPUX *//* BSD, V7, Coherent, Minix, et al. */#ifdef SVORPOSIX /* Sys V or POSIX */#ifdef BSD44#include <sys/time.h>#endif /* BSD44 */#ifdef AIXRS#include <sys/time.h>#endif /* AIXRS */#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 /* Not AT&T Sys V or POSIX */#include <sgtty.h> /* So we use <sgtty.h> */#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 /* SVORPOSIX */#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 */#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 _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 *//* 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#ifdef COHERENT char *dftty = "/dev/modem"; char *dfmdm = "none"; int dfloc = 1;#else char *dftty = CTTNAM; /* Remote by default, use normal */ char *dfmdm = "none"; int dfloc = 0; /* controlling terminal name. */#endif /* COHERENT */#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 = 0; /* Default parity (0 = none) */ int ttprty = 0; /* The parity that is in use. */ int ttpflg = 0; /* Parity not sensed yet. */ static int ttpmsk = 0377; /* 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 = -1; /* 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 */extern int ttnproto; /* Defined in ckcnet.c */extern int ttnet; /* Defined in ckcnet.c */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 *//* 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 */static jmp_buf sjbuf; /* Longjump buffers */#ifdef V7static jmp_buf jjbuf;#endif /* V7 *//* static */ /* (Not static any more) */int ttyfd = -1; /* TTY file descriptor */int telnetfd = 0; /* File descriptor is for telnet */int x25fd = 0; /* File descriptor is for X.25 */static int lkf = 0, /* Line lock flag */ cgmf = 0, /* Flag that console modes saved */ xlocal = 0, /* Flag for tty local or remote */ curcarr = 0; /* Carrier mode: require/ignore. */static int netconn = 0; /* 1 if network connection active */static char escchr; /* Escape or attn character */#ifdef AIXRS static struct timeval tv; /* For getting time, from sys/time.h */ static struct timezone tz;#else#ifdef BSD44 static struct timeval tv; /* For getting time, from sys/time.h */ static struct timezone tz;#else#ifdef BSD42 static struct timeval tv; /* For getting time, from sys/time.h */ static struct timezone tz;#ifdef OSF static struct timeb ftp; /* And from sys/timeb.h */#endif /* OSF */#endif /* BSD42 */#endif /* BSD44 */#endif /* AIXRS */#ifdef BSD29 static long xclock; /* For getting time from sys/time.h */ static struct timeb ftp; /* And from sys/timeb.h */#endif /* BSD29 */#ifdef BSD41 static long xclock; /* For getting time from sys/time.h */ static struct timeb ftp; /* And from sys/timeb.h */#endif /* BSD41 */#ifdef FT21 static long xclock; /* For getting time from sys/time.h */ static struct timeb ftp; /* And from sys/timeb.h */#endif /* FT21 */#ifdef TOWER1 static long xclock; /* For getting time from sys/time.h */ static struct timeb ftp; /* And from sys/timeb.h */#endif /* TOWER1 */#ifdef COHERENT static long xclock; /* For getting time from sys/time.h */ static struct timeb ftp; /* And from sys/timeb.h */#endif /* COHERENT */#ifdef V7 static long xclock;#endif /* V7 *//* sgtty/termio information... */#ifdef BSD44ORPOSIX /* POSIX or BSD44 */ static struct termios ttold, ttraw, tttvt, ttcur, ccold, ccraw, cccbrk;#else /* BSD, V7, etc */#ifdef ATTSV static struct termio ttold = {0}; /* Init'd for word alignment, */ static struct termio ttraw = {0}; /* which is important for some */ static struct termio tttvt = {0}; /* systems, like Zilog... */ static struct termio ttcur = {0}; static struct termio ccold = {0}; static struct termio ccraw = {0}; static struct termio cccbrk = {0};#else static struct sgttyb /* sgtty info... */ ttold, ttraw, tttvt, ttcur, /* for communication line */ ccold, ccraw, cccbrk; /* and for console */#ifdef TIOCGETC#ifdef MINIX static struct sgttyb tchold, tchnoi; /* Special chars */#else static struct tchars tchold, tchnoi;#endif /* MINIX */ static int tcharf;#endif /* TIOCGETC */#ifdef TIOCGLTC#ifdef MINIX static struct sgttyb ltchold, ltchnoi;#else static struct ltchars ltchold, ltchnoi;#endif /* MINIX */ static int ltcharf;#endif /* TIOCGLTC */ int lmodef = 0; /* Local modes */ int lmode = 0;#endif /* ATTSV */#endif /* BSD44ORPOSIX */#ifdef PROVX1 static struct sgttyb ttbuf;#endif /* PROVX1 */#ifdef ultrix/* do we really need this? */ static struct sgttyb vanilla;#endif /* ultrix */#ifdef ATT7300static int attmodem = 0; /* ATT7300 internal-modem status */struct updata dialer = {0}; /* Condition dialer for data call */#endif /* ATT7300 */char flfnam[80]; /* uucp lock file path name */#ifdef RTAIXchar lkflfn[80]; /* and possible link to it */#endif /* RTAIX */int haslock = 0; /* =1 if this kermit locked uucp */#ifdef SVORPOSIXstatic int conesc = 0; /* set to 1 if esc char (^\) typed */#else#ifdef V7static int conesc = 0;#else#ifdef C70static int conesc = 0;#endif /* C70 */#endif /* V7 */#endif /* ATTSV */static char ttnmsv[DEVNAMLEN]; /* Copy of open path for tthang */#ifdef aegisstatic status_$t st; /* error status return value */static short concrp = 0; /* true if console is CRP pad */#define CONBUFSIZ 10static char conbuf[CONBUFSIZ]; /* console readahead buffer */static int conbufn = 0; /* # chars in readahead buffer */static char *conbufp; /* next char in readahead buffer */static uid_$t ttyuid; /* tty type uid */static uid_$t conuid; /* stdout type uid *//* APOLLO Aegis main() * establish acl usage and cleanup handling * this makes sure that CRP pads * get restored to a usable mode */main(argc,argv) int argc; char **argv; { status_$t status; pfm_$cleanup_rec dirty; PID_T pid = getpid(); /* acl usage according to invoking environment */ default_acl(USE_DEFENV); /* establish a cleanup continuation */ status = pfm_$cleanup(dirty); if (status.all != pfm_$cleanup_set) { /* only handle faults for the original process */ if (pid == getpid() && status.all > pgm_$max_severity) { /* blew up in main process */ status_$t quo; pfm_$cleanup_rec clean; /* restore the console in any case */ conres(); /* attempt a clean exit */ debug(F101, "cleanup fault status", "", status.all); /* doexit(), then send status to continuation */ quo = pfm_$cleanup(clean); if (quo.all == pfm_$cleanup_set) doexit(pgm_$program_faulted,-1); else if (quo.all > pgm_$max_severity) pfm_$signal(quo); /* blew up in doexit() */ } /* send to the original continuation */ pfm_$signal(status); /*NOTREACHED*/ } return(ckcmai(argc, argv));}#endif /* aegis *//* ANSI-style prototypes for internal functions. *//* Functions used outside this module are prototyped in ckcker.h. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -