📄 ckuus4.c
字号:
setint(); concb((char)escape); /* Restore console for commands */#else /* This is how it has always been so better leave it */ /* this way for all non-HP-UX-8.00 builds. */ concb((char)escape); /* Restore console for commands */ setint();#endif /* CKCONINTB4CB */#ifdef OS2 term_io_save = term_io; /* Disable I/O by emulator */ term_io = 0;#endif /* OS2 */#ifdef CK_APC/* If an APC command was received during CONNECT mode, we define it now as a macro, execute the macro, and then return to CONNECT mode. We do this in a WHILE loop in case additional APCs come during subsequent CONNECT sessions.*/ debug(F101,"doconect apcactive","",apcactive); debug(F101,"doconect success","",success); while (x > 0 && (apcactive == APC_LOCAL || (apcactive == APC_REMOTE && apcstatus != APC_OFF))) { debug(F101,"doconect justone 3","",justone); if (mlook(mactab,"_apc_commands",nmac) == -1) { debug(F110,"doconect about to execute APC",apcbuf,0); domac("_apc_commands",apcbuf,cmdstk[cmdlvl].ccflgs|CF_APC); delmac("_apc_commands");#ifdef DEBUG } else { debug(F100,"doconect APC in progress","",0);#endif /* DEBUG */ } debug(F101,"doconect apcactive after domac","",apcactive); if (!apcactive) { /* In case CLEAR APC was in APC */ debug(F101,"doconect quit APC loop: apcactive","",apcactive); break; } /* Also don't reconnect if autodownload failed - very confusing! */ /* Let them view the local screen to see what happened. */#ifndef NOXFER debug(F101,"doconect xferstat","",xferstat); if (apcactive == APC_LOCAL & !xferstat) { debug(F101,"doconect quit APC loop: xferstat","",xferstat); apcactive = APC_INACTIVE; break; }#endif /* NOXFER */#ifdef OS2 msleep(250);#endif /* OS2 */ debug(F101,"doconect justone 4","",justone); qsave = quiet; /* Do this again... */ if (!quiet && q > -1) quiet = q;#ifdef CK_AUTODL ksbuf[0] = NUL;#endif /* CK_AUTODL */#ifdef IKS_OPTION#ifdef CK_AUTODL if (is_tn && TELOPT_ME(TELOPT_KERMIT) && !TELOPT_SB(TELOPT_KERMIT).kermit.me_start && autodl#ifdef CK_APC && !apcactive#endif /* CK_APC */#ifdef OS2 && !viewonly#endif /* OS2 */ ) { tn_siks(KERMIT_START); /* Send Kermit-Server Start */ }#endif /* CK_AUTODL */#endif /* IKS_OPTION */ x = conect(); /* Re-CONNECT. */#ifdef COMMENT#ifdef IKS_OPTION#ifdef CK_AUTODL if (is_tn && TELOPT_ME(TELOPT_KERMIT) && autodl#ifdef CK_APC && !apcactive#endif /* CK_APC */#ifdef OS2 && !viewonly#endif /* OS2 */ ) { tn_siks(KERMIT_STOP); /* Send Kermit-Server Stop */ }#endif /* CK_AUTODL */#endif /* IKS_OPTION */#endif /* COMMENT */#ifdef OS2 term_io = term_io_save;#endif /* OS2 */ quiet = qsave; debug(F101,"doconect justone 5","",justone);#ifdef NETCONN if (network && ttchk() < 0) { if (tn_exit || exitonclose) doexit(GOOD_EXIT,xitsta); else break; }#endif /* NETCONN */#ifdef OS2ORUNIX /* If connection dropped */ if (ttchk() < 0) { concb((char)escape); /* Restore console. */ if (exitonclose) doexit(GOOD_EXIT,xitsta); else break; }#endif /* OS2ORUNIX */ } /* Loop back for more. */#endif /* CK_APC */#ifndef NOKVERBS if ((keymac > 0) && (keymacx > -1)) { /* Executing a keyboard macro? */ /* Set up the macro and return */ /* Do not clear the keymac flag */ return(dodo(keymacx,NULL,CF_KMAC|cmdstk[cmdlvl].ccflgs)); }#endif /* NOKVERBS */#ifdef OS2 term_io = term_io_save;#endif /* OS2 */#ifdef CKCONINTB4CB /* The order makes a difference in HP-UX 8.00. */ /* The other order makes it think it's in the background when it */ /* returns from CONNECT (Apr 1999). */ setint(); concb((char)escape); /* Restore console for commands */#else /* This is how it has always been so better leave it */ /* this way for all non-HP-UX-8.00 builds. */ concb((char)escape); /* Restore console for commands */ setint();#endif /* CKCONINTB4CB */ what = W_COMMAND; /* Back in command mode. */ return(x); /* Done. */}#endif /* NOLOCAL */#ifndef NOICP#ifdef COMMENT/* It seemed that this was needed for OS/2, in which \v(cmdfile) and other file-oriented variables or functions can return filenames containing backslashes, which are subsequently interpreted as quotes rather than directory separators (e.g. see commented section for VN_CMDF below). But the problem can't be cured at this level. Example: type \v(cmdfile) Without doubling, the filename is parsed correctly, but then when passed to UNIX 'cat' through the shell, the backslash is removed, and then cat can't open the file. With doubling, the filename is not parsed correctly and the TYPE command fails immediately with a "file not found" error.*//* Utility routine to double all backslashes in a string. s1 is pointer to source string, s2 is pointer to destination string, n is length of destination string, both NUL-terminated. Returns 0 if OK, -1 if not OK (destination string too short).*/intdblbs(s1,s2,n) char *s1, *s2; int n; { int i = 0; while (*s1) { if (*s1 == '\\') { if (++i > n) return(-1); *s2++ = '\\'; } if (++i > n) return(-1); *s2++ = *s1++; } *s2 = NUL; return(0);}#endif /* COMMENT */char *gmdmtyp() { /* Get modem type */#ifndef NODIAL int i, x; x = mdmtyp; if (x < 0) /* In case of network dialing */ x = mdmsav; if (x < 1) return("none"); else for (i = 0; i < nmdm; i++) if ((mdmtab[i].kwval == x) && (mdmtab[i].flgs == 0)) return(mdmtab[i].kwd);#endif /* NODIAL */ return("none");}#ifndef NOXMIT#ifndef NOLOCAL/* T R A N S M I T -- Raw upload *//* Obey current line, duplex, parity, flow, text/binary settings. *//* Returns 0 upon apparent success, 1 on obvious failure. *//*** Things to add: . Make both text and binary mode obey set file bytesize. . Maybe allow user to specify terminators other than CR? . Maybe allow user to specify prompts other than single characters? . Make STATISTICS also work for TRANSMIT. . If TRANSMIT is done without echo, make some kind of (optional) display. . Make the same optimization for binary-mode transmit that was done for text-mode (in the no-echo / no-prompt / no-pause case).***//* T R A N S M I T -- Raw upload *//* s is the filename, t is the turnaround (prompt) character *//* Maximum number of characters to buffer. Must be less than LINBUFSIZ*/#ifdef OS2#define XMBUFS 4096 /* For compatibility with XYZmodem */#else /* OS2 */#define XMBUFS 1024#endif /* OS2 */#ifdef TNCODE#ifndef IAC#define IAC 255#endif /* IAC */#endif /* TNCODE */#define OUTXBUFSIZ 15static CHAR inxbuf[OUTXBUFSIZ+1]; /* Host-to-screen expansion buffer */static int inxcount = 0; /* and count */static CHAR outxbuf[OUTXBUFSIZ+1]; /* Keyboard-to-host expansion buf */static int outxcount = 0; /* and count *//* T R A N S M I T -- Unguarded non-protocol file transmission *//* Call with: char * s: Name of file to transmit. char t: Turnaround char for text-mode transmission (normally LF). int xlate: nonzero = charset translation for text-mode xfer, 0 = skip. int binary: nonzero = transmit in binary mode, 0 = in text mode.*/int#ifdef CK_ANSICtransmit(char * s, char t, int xlate, int binary)#elsetransmit(s,t,xlate,binary) char *s; char t; int xlate, binary;#endif /* CK_ANSIC *//* transmit */ {#ifdef MAC extern char sstate; int count = 100;#else#ifdef OS2#ifdef NT SIGTYP (* oldsig)(int); /* For saving old interrupt trap. */#else /* NT */ SIGTYP (* volatile oldsig)(int);#endif /* NT */#else /* OS2 */ SIGTYP (* oldsig)();#endif /* OS2 */#endif /* MAC */ int eof = 0; /* End of File flag */ int eol = 0; /* End of Line flag */ int rc = 1; /* Return code. 0=fail, 1=succeed. */ int myflow; /* Local copy of global flow... */ int is_tn = 0; /* Do Telnet negotiations */ int xbufsiz = XMBUFS; /* Size of TRANSMIT buffer */ int k, x, c, i; /* Int workers... */ int control = 0; /* Echo loop control */ long nbytes = 0; /* File byte count */ long zz; /* Long worker */ char *p; /* Char * worker */#ifdef PIPESEND extern int pipesend;#endif /* PIPESEND */#ifndef NOCSETS int tcs = TC_TRANSP; /* Intermediate (xfer) char set */ int langsv = L_USASCII; /* Save current language */ int unicode = 0; int tcssize = 0;#ifdef CK_ANSIC /* ANSI C prototypes... */ CHAR (*sxo)(CHAR); CHAR (*rxo)(CHAR); CHAR (*sxi)(CHAR); CHAR (*rxi)(CHAR);#else /* Not ANSI C... */ CHAR (*sxo)(); CHAR (*rxo)(); CHAR (*sxi)(); CHAR (*rxi)();#endif /* CK_ANSIC */#ifdef UNICODE union ck_short uc; int bomorder = 0;#ifdef CK_ANSIC extern int (*xl_ufc[MAXFCSETS+1])(USHORT); /* Unicode to FCS */ extern USHORT (*xl_fcu[MAXFCSETS+1])(CHAR); /* FCS to Unicode */ extern int (*xuf)(USHORT); extern USHORT (*xfu)(CHAR);#else extern int (*xl_ufc[MAXFCSETS+1])(); extern USHORT (*xl_fcu[MAXFCSETS+1])(); extern int (*xuf)(); extern USHORT (*xfu)();#endif /* CK_ANSIC */#endif /* UNICODE */#endif /* NOCSETS */ debug(F101,"xmit t","",t); debug(F101,"xmit xlate","",xlate); debug(F101,"xmit binary","",binary);#ifdef PIPESEND if (pipesend) { if (nopush) return(-2); if (zxcmd(ZIFILE,s) < 1) { printf("?Can't start command: %s\n",s); return(0); } } else#endif /* PIPESEND */ if (zopeni(ZIFILE,s) == 0) { /* Open the file to be transmitted */ printf("?Can't open file %s\n",s); return(0); } x = -1; /* Open the communication channel */ if (ttopen(ttname,&x,mdmtyp,cdtimo) < 0) { /* (no harm if already open) */ printf("Can't open device %s\n",ttname); return(0); } zz = x ? speed : -1L; if (binary) { /* Binary file transmission */ myflow = (flow == FLO_XONX) ? FLO_NONE : flow; if (ttvt(zz,myflow) < 0) { /* So no Xon/Xoff! */ printf("Can't condition line\n"); return(0); } } else { if (ttpkt(zz,flow,parity) < 0) { /* Put the line in "packet mode" */ printf("Can't condition line\n"); /* so Xon/Xoff will work, etc. */ return(0); } } is_tn =#ifdef TNCODE (local && network && (ttnproto == NP_TELNET)) || (!local && sstelnet)#else 0#endif /* TNCODE */ ;#ifndef NOCSETS/* Set up character set translations */ tcs = 0; /* "Transfer" or "Other" charset */ sxo = rxo = NULL; /* Initialize byte-to-byte functions */ sxi = rxi = NULL; unicode = 0; /* Assume Unicode won't be involved */ if (!binary && xlate) { /* Set up charset translations *//* In the SENDING direction, we are converting from the local file's character-set (fcharset) to the remote terminal charset (tcsr). In the RECEIVING direction (echoing) we are converting from the remote end of the terminal charset (tcsr) to its local end (tcsl), which is not necessarily the same as the file character-set. Especially when the file character set is UCS-2, which is not a valid terminal character set. The various combinations are represented in this table: FCS = File Character Set RCS = Remote Terminal Character Set CCS = Console (Local Terminal) Character Set 8 4 2 1 F
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -