📄 ckucon.c
字号:
c = CONGKS() & 0177; /* Got esc, get its arg */ /* No key mapping here */ doesc((char) c); /* Now process it */ } else { /* It's not the escape character */ csave = c; /* Save it before translation */ /* for local echoing. */#ifndef NOCSETS#ifdef NOESCSEQ /* Translate character sets */ if (sxo) c = (*sxo)(c); /* From local to intermediate. */ if (rxo) c = (*rxo)(c); /* From intermediate to remote. */#else if (inesc == ES_NORMAL) { /* If not inside escape seq.. */ /* Translate character sets */ if (sxo) c = (*sxo)((char)c); /* Local-intermediate */ if (rxo) c = (*rxo)((char)c); /* Intermediate-remote */ } if (escseq) apcrc = chkaes((char)c);#endif /* NOESCSEQ */#endif /* NOCSETS *//* If Shift-In/Shift-Out is selected and we have a 7-bit connection, handle shifting here.*/ if (sosi) { /* Shift-In/Out selected? */ if (cmask == 0177) { /* In 7-bit environment? */ if (c & 0200) { /* 8-bit character? */ if (outshift == 0) { /* If not shifted, */ ttoc(dopar(SO)); /* shift. */ outshift = 1; } } else { if (outshift == 1) { /* 7-bit character */ ttoc(dopar(SI)); /* If shifted, */ outshift = 0; /* unshift. */ } } } if (c == SO) outshift = 1; /* User typed SO */ if (c == SI) outshift = 0; /* User typed SI */ } c &= cmask; /* Apply Kermit-to-host mask now. */#ifdef SUNX25 if (network && nettype == NET_SX25) { if (padparms[PAD_ECHO]) { if (debses) conol(dbchr(c)) ; else if ((c != padparms[PAD_CHAR_DELETE_CHAR]) && (c != padparms[PAD_BUFFER_DELETE_CHAR]) && (c != padparms[PAD_BUFFER_DISPLAY_CHAR])) conoc(c) ; if (seslog) logchar(c); } if (c == CR && (padparms[PAD_LF_AFTER_CR] == 4 || padparms[PAD_LF_AFTER_CR] == 5)) { if (debses) conol(dbchr(LF)) ; else conoc(LF) ; if (seslog) logchar(LF); } if (c == padparms[PAD_BREAK_CHARACTER]) breakact(); else if (padparms[PAD_DATA_FORWARD_TIMEOUT]) { tosend = 1; x25obuf [obufl++] = c; } else if (((c == padparms[PAD_CHAR_DELETE_CHAR]) || (c == padparms[PAD_BUFFER_DELETE_CHAR]) || (c == padparms[PAD_BUFFER_DISPLAY_CHAR])) && (padparms[PAD_EDITING])) if (c == padparms[PAD_CHAR_DELETE_CHAR]) if (obufl > 0) { conol("\b \b"); obufl--; } else {} else if (c == padparms[PAD_BUFFER_DELETE_CHAR]) { conol ("\r\nPAD Buffer Deleted\r\n"); obufl = 0; } else if (c == padparms[PAD_BUFFER_DISPLAY_CHAR]) { conol("\r\n"); conol(x25obuf); conol("\r\n"); } else {} else { x25obuf [obufl++] = c; if (obufl == MAXOX25) tosend = 1; else if (c == CR) tosend = 1; } if (tosend) if (ttol((CHAR *)x25obuf,obufl) < 0) { perror ("\r\nCan't send characters"); active = 0; } else { bzero (x25obuf,sizeof(x25obuf)); obufl = 0; tosend = 0; } else {}; } else {#endif /* SUNX25 */ if (c == '\015') { /* Carriage Return */ int stuff = -1; if (tnlm) { /* TERMINAL NEWLINE ON */ stuff = LF; /* Stuff LF */#ifdef TNCODE } else if (network && /* TELNET NEWLINE ON/OFF/RAW */ (ttnproto == NP_TELNET)) { switch (!me_binary ? tn_nlm : tn_b_nlm) { case TNL_CRLF: stuff = LF; break; case TNL_CRNUL: stuff = NUL; break; }#endif /* TNCODE */ } if (stuff > -1) { ttoc(dopar('\015')); /* Send CR */ if (duplex) conoc('\015'); /* Maybe echo CR */ c = stuff; /* Char to stuff */ csave = c; } }#ifdef TNCODE/* If user types the 0xff character (TELNET IAC), it must be doubled. */ else /* Not CR */ if ((dopar((CHAR) c) == IAC) && /* IAC (0xff) */ network && (ttnproto == NP_TELNET)) { /* Send one copy now */ ttoc((char)IAC); /* and the other one just below. */ }#endif /* TNCODE */ /* Send the character */ if (ttoc((char)dopar((CHAR) c)) > -1) { if (duplex) { /* If half duplex, must echo */ if (debses) conol(dbchr(csave)); /* the original char */ else /* not the translated one */ conoc((char)csave); if (seslog) { /* And maybe log it too */ c2 = csave; if (sessft == 0 && csave == '\r') c2 = '\n'; logchar((char)c2); } } } else { perror("\r\nCan't send character"); active = 0; }#ifdef SUNX25 } #endif /* SUNX25 */ } } /* now active == 0 */ signal(CK_FORK_SIG, SIG_IGN); /* Turn off CK_FORK_SIG */ sjval = CEV_NO; /* Set to hangup */ } /* Come here on termination of child *//* cklongjmp() executed in pipeint() (parent only!) comes here *//* Now the child fork is gone or is waiting for CK_FORK_SIG in ck_sndmsg(). So we can't get (in the parent) any subsequent CK_FORK_SIG signals until we signal the child with CK_FORK_SIG.*/ debug(F100,"CONNECT signaling port fork","",0); signal(CK_FORK_SIG, SIG_IGN); /* Turn this off */ debug(F100,"CONNECT killing port fork","",0);#ifdef BEBOX { long ret_val; if (pid) kill(pid,SIGKILLTHR); /* Kill lower fork */ wait_for_thread (pid, &ret_val); }#else#ifdef Plan9 if (pid) kill(pid,SIGKILL); /* Kill lower fork */#else if (pid) kill(pid,9); /* Kill lower fork */#endif /* Plan9 */#endif /* BEBOX */ debug(F100,"CONNECT killed port fork","",0); pid = -1; wait((WAIT_T *)0); /* Wait till gone. */ if (sjval == CEV_HUP) { /* Read error on comm device */ dohangup = 1; /* so we want to hang up our side */#ifdef NETCONN if (network) { /* and/or close network connection */ ttclos(0);#ifdef SUNX25 if (nettype == NET_SX25) /* If X.25, restore the PAD params */ initpad();#endif /* SUNX25 */ }#endif /* NETCONN */ }#ifdef SUNX25#ifdef COMMENT /* Not used, should not be needed -- see pipeint()... */ if (sjval == CEV_PAD) /* If it was a mode change, go back */ goto newfork; /* and coordinate with other fork. */#endif /* COMMENT */#endif /* SUNX25 */#ifdef CK_APC if (sjval == CEV_APC) { /* Application Program Command rec'd */ apcactive = 1; /* Flag APC as active */ active = 0; /* Flag CONNECT as inactive */ }#endif /* CK_APC */ conres(); /* Reset the console. */ if (dohangup > 0) { /* If hangup requested, do that. */#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 */ dohangup = 0; /* again unless requested again. */ }#ifdef COMMENT#ifdef NETCONN#ifdef SIGPIPE if (network && sigpiph) /* Restore previous SIGPIPE handler */ (VOID) signal(SIGPIPE, sigpiph);#endif /* SIGPIPE */#endif /* NETCONN */#endif /* COMMENT */#ifdef SUNX25 if (dox25clr) { /* If X.25 Clear requested */ x25clear(); /* do that. */ initpad(); dox25clr = 0; /* But only once. */ }#endif /* SUNX25 */ if (quitnow) doexit(GOOD_EXIT,xitsta); /* Exit now if requested. */ if (!quiet#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 */ parent_id = (PID_T) 0; goto conret1; }#ifndef BEBOX else { /* *** */ /* Inferior reads, prints port input */ concld(/* (void *)&pid */); }#endif /* BEBOX */conret1: conret = 1;conret0: signal(CK_FORK_SIG, SIG_IGN); /* In case this wasn't done already */ debug(F101,"ckucon exit ibc","",ibc); debug(F101,"ckucon exit obc","",obc); close(xpipe[0]); xpipe[0] = -1; /* Close the pipe */ close(xpipe[1]); xpipe[1] = -1; return(conret);}/* H C O N N E -- Give help message for connect. */inthconne() { int c; static char *hlpmsg[] = {"\r\n ? for this message","\r\n 0 (zero) to send a null","\r\n B to send a BREAK",#ifdef CK_LBRK"\r\n L to send a Long BREAK",#endif /* CK_LBRK */#ifdef NETCONN"\r\n I to send a network interrupt packet",#ifdef TCPSOCKET"\r\n A to send Are You There?",#endif /* TCPSOCKET */#ifdef SUNX25"\r\n R to reset X.25 virtual circuit",#endif /* SUNX25 */#endif /* NETCONN */"\r\n U to hangup and close the connection","\r\n Q to hangup and quit Kermit","\r\n S for status",#ifdef NOPUSH"\r\n ! to push to local shell (disabled)","\r\n Z to suspend (disabled)",#else"\r\n ! to push to local shell",#ifdef NOJC"\r\n Z to suspend (disabled)",#else"\r\n Z to suspend",#endif /* NOJC */#endif /* NOPUSH */"\r\n \\ backslash code:","\r\n \\nnn decimal character code","\r\n \\Onnn octal character code","\r\n \\Xhh hexadecimal character code","\r\n terminate with carriage return.","\r\n Type the escape character again to send the escape character, or","\r\n press the space-bar to resume the CONNECT command.\r\n\r\n","" }; conol("\r\nPress C to return to "); conol(*myhost ? myhost : "the C-Kermit prompt"); conol(", or:"); conola(hlpmsg); /* Print the help message. */ conol("Command>"); /* Prompt for command. */ c = CONGKS() & 0177; /* Get character, strip any parity. */ /* No key mapping or translation here */ if (c != CMDQ) 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,"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': active = 0; conol("\r\n"); return; 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 */#ifdef SUNX25 if (network && (nettype == NET_SX25)) { /* X.25 */ (VOID) x25intr(0); /* X.25 interrupt packet */ conol("\r\n"); } else#endif /* SUNX25 */ 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 */#ifdef SUNX25 if (network && (nettype == NET_SX25)) dox25clr = 1; else#endif /* SUNX25 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -