📄 ckucns.c
字号:
ckcputc(BS); }#ifdef CK_XYZ else { int i; for (i = 0; i < 3; i++) ckcputc(CAN); }#endif /* CK_XYZ */#ifndef NOICP sprintf(apcbuf, "set proto %s, %s, set proto %s", ptab[k].p_name, ksign ? "server" : "receive", ptab[protocol].p_name ); apclength = strlen(apcbuf); debug(F111,"CONNECT ksbuf",ksbuf,k); debug(F110,"CONNECT autodownload",apcbuf,0); apcactive = APC_LOCAL; ckcputf(); /* Force screen update */ goto conret1;#else/* Here's another way that doesn't require APC, but then we'll have to change all the other CONNECT modules, and then the mainline code that calls them.*/ { extern char sstate; sstate = ksign ? 'x' : 'v'; proto(); }#endif /* NOICP */ } } }#ifdef NOSERVER noserver:#endif /* NOSERVER */#endif /* CK_AUTODL */#endif /* NOXFER */ if (sosi) { /* Handle SI/SO */ if (c == SO) { /* Shift Out */ inshift = 1; continue; } else if (c == SI) { /* Shift In */ inshift = 0; continue; } if (inshift) c |= 0200; } inxbuf[0] = c; /* In case there is no translation */ inxcount = 1; /* ... */#ifndef NOCSETS if (inesc[0] == ES_NORMAL /* If not in an escape sequence */ && !printing /* and not in transparent print */ ) { /* Translate character sets */#ifdef UNICODE int x; if (unicode == 1) { /* Remote is UTF-8 */ x = u_to_b((CHAR)c); if (x == -1) continue; else if (x == -2) { /* LS or PS */ inxbuf[0] = CR; inxbuf[1] = LF; inxcount = 2; } else if (x == -9) { /* UTF-8 error */ inxbuf[0] = '?'; inxbuf[1] = u_to_b2(); inxcount = 2; } else { inxbuf[0] = (unsigned)(x & 0xff); } c = inxbuf[0]; } else if (unicode == 2) { /* Local is UTF-8 */ inxcount = b_to_u((CHAR)c,inxbuf,OUTXBUFSIZ,tcssize); c = inxbuf[0]; } else {#endif /* UNICODE */ if (sxi) c = (*sxi)((CHAR)c); if (rxi) c = (*rxi)((CHAR)c); inxbuf[0] = c;#ifdef UNICODE }#endif /* UNICODE */ }#endif /* NOCSETS */#ifndef NOESCSEQ if (escseq) { /* If handling escape sequences */ oldprt = printing; /* remember printer state */ apcrc = chkaes((char)c,0); /* and update escseq state. */ if (printing && !oldprt) /* If printer was turned on */ continue; /* don't print final char of escseq */ }#ifdef CK_APC/* If we are handling APCs, we have several possibilities at this point: 1. Ordinary character to be written to the screen. 2. An Esc; we can't write it because it might be the beginning of an APC. 3. The character following an Esc, in which case we write Esc, then char, but only if we have not just entered an APC sequence.*/ if (escseq && apcstatus != APC_OFF) { if (inesc[0] == ES_GOTESC) /* Don't write ESC yet */ continue; else if (oldesc[0] == ES_GOTESC && !apcactive) { debug(F100,"XXX WRITING ESC","",0); ckcputc(ESC); /* Write saved ESC */ if (seslog && !sessft) logchar((char)ESC); } else if (apcrc) { /* We have an APC */ debug(F111,"CONNECT APC complete",apcbuf,apclength); ckcputf(); /* Force screen update */ goto conret1; } }#endif /* CK_APC */#endif /* NOESCSEQ */ debug(F111,"INXBUF",inxbuf,inxcount); for (i = 0; i < inxcount; i++) { /* Loop thru */ c = inxbuf[i]; /* input expansion buffer... */ if (#ifdef CK_APC !apcactive && /* Don't display APC sequences */#endif /* CK_APC */ !printing /* or transparent print material */ ) { c &= cmdmsk; /* Apply command mask. */ if (c == CR && tt_crd) { /* SET TERM CR-DISPLA CRLF? */ ckcputc(c); /* Yes, output CR */ if (seslog && !sessft) logchar((char)c); c = LF; /* and insert a linefeed */ } ckcputc(c); /* Write character to screen */ } if (seslog && !sessft) /* Handle session log. */ logchar((char)c);#ifdef XPRINT if (printing && !inesc[0]) { /* Do transparent printing. */ /* zchout() can't be used because */ /* it's buffered differently. */ cbuf[0] = c; zsoutx(ZMFILE,(char *)cbuf,1); }#endif /* XPRINT */#ifdef CK_TRIGGER /* Check for trigger string */ if (tt_trigger[0]) { int i; if ((i = autoexitchk((CHAR)c)) > -1) { makestr(&triggerval,tt_trigger[i]); ckcputf(); /* Force screen update */#ifdef NOSETBUF fflush(stdout); /* I mean really force it */#endif /* NOSETBUF */ goto conret1; } }#endif /* CK_TRIGGER */ } } }#ifndef BEBOX if (FD_ISSET(scrnout, &out)) { FD_CLR(scrnout, &out); }#endif /* BEBOX */ } /* End of big loop */ conret1: /* Come here to succeed */ rc = 1; conret0: /* Common exit point */#ifdef BEBOX { long ret_val; closesocket(pair[0]); closesocket(pair[1]); x = kill(tid,SIGKILLTHR); /* Kill thread */ wait_for_thread (tid, &ret_val); }#endif /* BEBOX */ conres(); if (dohangup > 0) {#ifndef NODIAL extern int dialmhu;#endif /* NODIAL */#ifdef NETCONN if (network) ttclos(0);#endif /* NETCONN */#ifndef COMMENT/* This is bad because if they said SET MODEM HANGUP-METHOD MODEM-COMMAND, they mean it -- we shouldn't fall back on tthang() if mdmhup() fails, because maybe they have some special kind of connection. On the other hand, making this change prevents dialing from working at all in some cases. Further study needed.*/#ifndef NODIAL if (dohangup > 1) /* User asked for it */ if (mdmhup() < 1) /* Maybe hang up via modem */#endif /* NODIAL */ tthang(); /* And make sure we don't hang up */#else if (!network) { /* Serial connection. */ if (dialmhu) /* Hang up the way they said. */ mdmhup(); else tthang(); }#endif /* COMMENT */ dohangup = 0; /* again unless requested again. */ } if (quitnow) /* Exit now if requested. */ doexit(GOOD_EXIT,xitsta); if (msgflg#ifdef CK_APC && !apcactive#endif /* CK_APC */ ) printf("(Back at %s)", *myhost ? myhost : "local UNIX system");#ifdef CK_APC if (!apcactive)#endif /* CK_APC */ printf("\n"); what = W_NOTHING; /* So console modes set right. */#ifndef NOCSETS language = langsv; /* Restore language */#endif /* NOCSETS */#ifdef CK_APC debug(F101,"CONNECT exit apcactive","",apcactive); debug(F101,"CONNECT exit justone","",justone);#endif /* CK_APC */ if (msgflg) {#ifdef CK_APC if (apcactive == APC_LOCAL) printf("\n");#endif /* CK_APC */ printf("----------------------------------------------------\n"); printbar = 1; } else printbar = 0; fflush(stdout); return(1);}/* H C O N N E -- Give help message for connect. */#define CXM_SER 1 /* Serial connections only */#define CXM_NET 2 /* Network only (but not Telnet) */#define CXM_TEL 4 /* Telnet only */static struct hmsgtab { char * hmsg; int hflags;} hlpmsg[] = { " ? or H for this message", 0, " 0 (zero) to send the NUL (0) character", 0, " B to send a BREAK signal (0.275sec)", CXM_SER,#ifdef NETCONN " B to send a network BREAK", CXM_NET, " B to send a Telnet BREAK", CXM_TEL,#endif /* NETCONN */#ifdef CK_LBRK " L to send a Long BREAK (1.5sec)", CXM_SER,#endif /* CK_LBRK */#ifdef NETCONN " I to send a network interrupt packet", CXM_NET, " I to send a Telnet Interrupt request", CXM_TEL,#ifdef TNCODE " A to send Telnet Are-You-There?", CXM_TEL,#endif /* TNCODE */#endif /* NETCONN */ " U to hangup and close the connection", 0, " Q to hangup and quit Kermit", 0, " S for status", 0,#ifdef NOPUSH " ! to push to local shell (disabled)", 0, " Z to suspend (disabled)", 0,#else " ! to push to local shell", 0,#ifdef NOJC " Z to suspend (disabled)", 0,#else " Z to suspend", 0,#endif /* NOJC */#endif /* NOPUSH */ " \\ backslash code:", 0, " \\nnn decimal character code", 0, " \\Onnn octal character code", 0, " \\Xhh hexadecimal character code;", 0, " terminate with Carriage Return.", 0, " Type the escape character again to send the escape character itself,",0, " or press the space-bar to resume the CONNECT session.", 0, NULL, 0};inthconne() { int c, i, cxtype; if (network) cxtype = (ttnproto == NP_TELNET) ? CXM_TEL : CXM_NET; else cxtype = CXM_SER; conol("\r\n----------------------------------------------------\r\n"); conoll("Press:"); conol(" C to return to "); conoll(*myhost ? myhost : "the C-Kermit prompt"); for (i = 0; hlpmsg[i].hmsg; i++) { if (!(hlpmsg[i].hflags) || (hlpmsg[i].hflags == cxtype)) conoll(hlpmsg[i].hmsg); } conol("Press a key>"); /* Prompt for command. */ c = CONGKS() & 0177; /* Get character, strip any parity. */ /* No key mapping or translation here */ if (c != CMDQ) conoll(""); conoll("----------------------------------------------------"); return(c); /* Return it. */}/* D O E S C -- Process an escape character argument */VOID#ifdef CK_ANSICdoesc(char c)#elsedoesc(c) char c;#endif /* CK_ANSIC *//* doesc */ { CHAR d; debug(F101,"CONNECT doesc","",c); while (1) { if (c == escape) { /* Send escape character */ d = dopar((CHAR) c); ttoc((char) d); return; } else /* Or else look it up below. */ if (isupper(c)) c = tolower(c); switch(c) { case 'c': /* Escape back to prompt */ case '\03':#ifdef NOICP conoll(""); conoll(""); conoll(" WARNING: This version of C-Kermit has no command processor to escape" ); conoll(" back to. To return to your local system, log out from the remote and/or" ); conoll(" use the escape character followed by the letter U to close (hang Up) the" ); conoll(" connection. Resuming your session..." ); conoll(""); return;#else active = 0; conol("\r\n"); return;#endif /* NOICP */ case 'b': /* Send a BREAK signal */ case '\02': ttsndb(); return;#ifdef NETCONN case 'i': /* Send Interrupt */ case '\011':#ifdef TCPSOCKET#ifndef IP#define IP 244#endif /* IP */ if (network && ttnproto == NP_TELNET) { /* TELNET */ temp[0] = (CHAR) IAC; /* I Am a Command */ temp[1] = (CHAR) IP; /* Interrupt Process */ temp[2] = NUL; ttol((CHAR *)temp,2); } else#endif /* TCPSOCKET */ conoc(BEL); return;#ifdef TCPSOCKET case 'a': /* "Are You There?" */ case '\01':#ifndef AYT#define AYT 246#endif /* AYT */ if (network && ttnproto == NP_TELNET) { temp[0] = (CHAR) IAC; /* I Am a Command */ temp[1] = (CHAR) AYT; /* Are You There? */ temp[2] = NUL; ttol((CHAR *)temp,2); } else conoc(BEL); return;#endif /* TCPSOCKET */#endif /* NETCONN */#ifdef CK_LBRK case 'l': /* Send a Long BREAK signal */ ttsndlb(); return;#endif /* CK_LBRK */ case 'u': /* Hangup */ /* case '\010': */ /* No, too dangerous */ dohangup = 2; active = 0; conol("\r\nHanging up "); return; case 'q': /* Quit */ dohangup = 2; quitnow = 1; active = 0; conol("\r\n"); return; case 's': /* Status */ conoll(""); conoll("----------------------------------------------------");#ifdef PTYORPIPE if (ttpipe) sprintf(temp, " Pipe: \"%s\"", ttname); else if (ttpty) sprintf(temp, " Pty: \"%s\"", ttname); else#endif /* PTYORPIPE */ sprintf(temp, " %s: %s", (network ? "Host" : "Device"), ttname); conoll(temp); if (!network && speed >= 0L) { sprintf(temp,"Speed %ld", speed); conoll(temp); } sprintf(temp," Terminal echo: %s", dup
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -