#include "ckcsym.h"
-char *connv = "CONNECT Command for UNIX:select(), 8.0.135, 29 Nov 2002";
+char *connv = "CONNECT Command for UNIX:select(), 9.0.139, 1 Mar 2010";
/* C K U C N S -- Terminal connection to remote system, for UNIX */
/*
Author: Frank da Cruz <fdc@columbia.edu>,
Columbia University Academic Information Systems, New York City.
- Copyright (C) 1985, 2004,
+ Copyright (C) 1985, 2010,
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.
extern int local, escape, duplex, parity, flow, seslog, sessft, debses,
mdmtyp, ttnproto, cmask, cmdmsk, network, nettype, sosi, tnlm,
- xitsta, what, ttyfd, ttpipe, quiet, backgrd, pflag, tt_crd, tn_nlm, ttfdflg,
+ xitsta, what, ttyfd, ttpipe, quiet, backgrd, pflag, tt_crd, tt_lfd,
+ tn_nlm, ttfdflg,
tt_escape, justone, carrier, ttpty, hwparity;
#ifndef NODIAL
#endif /* NOCSETS */
#endif /* NOESCSEQ */
+/* inesc[] and oldesc[] made global 2010/03/01 for INPUT command */
+
static int escseq = 0; /* 1 = Recognizer is active */
-static int inesc[2] = { 0, 0 }; /* State of sequence recognizer */
-static int oldesc[2] = { -1, -1 }; /* Previous state of recognizer */
+/* static */ int inesc[2] = { 0, 0 }; /* State of sequence recognizer */
+/* static */ int oldesc[2] = { -1, -1 }; /* Previous state of recognizer */
#ifdef NOESCSEQ
+#define ES_NORMAL 0 /* Normal, not in an escape sequence */
#define chkaes(x,y) 0
#else
/*
As of C-Kermit 5A(178), the CONNECT command skips past ANSI escape sequences
to avoid translating the characters within them. This allows the CONNECT
command to work correctly with a host that uses a 7-bit ISO 646 national
- character set, in which characters like '[' would normally be translated
- into accented characters, ruining the terminal's interpretation (and
- generation) of escape sequences.
+ character set, in which characters like '[' would normally be converted to
+ accented letters, ruining the terminal's interpretation (and generation)
+ of escape sequences.
As of 5A(190), the CONNECT command responds to APC escape sequences
(ESC _ text ESC \) if the user SETs TERMINAL APC ON or UNCHECKED, and the
}
#endif /* NOESCSEQ */
+VOID
+#ifdef CK_ANSIC
+LOGCHAR(char c)
+#else
+LOGCHAR(c) char c;
+#endif /* CK_ANSIC */
+/* LOGCHAR */ { /* Log character c to session log */
+ /* but skip over escape sequences if session log is text */
+ if (escseq) {
+ if ((sessft == XYFT_T) && (debses == 0) &&
+ (inesc[0] != ES_NORMAL || oldesc[0] != ES_NORMAL))
+ return;
+ }
+ logchar(c);
+}
+
/* C K C P U T C -- C-Kermit CONNECT Put Character to Screen */
/*
Output is buffered to avoid slow screen writes on fast connections.
default:
s = "binary";
}
- printf("Session Log: %s, %s\r\n",sesfil,s);
+ printf("Session Log: %s, %s (%d) \r\n",sesfil,s,sessft);
}
if (debses) printf("Debugging Display...)\r\n");
}
/*
We need to activate the escape-sequence recognition feature when:
(a) translation is elected, AND
- (b) the local and/or remote set is a 7-bit set other than US ASCII.
+ (b) the local and/or remote set is a 7-bit set other than US ASCII;
+ Or:
+ SET SESSION-LOG is TEXT (so we can strip escape sequences out of the log);
Or:
SET TERMINAL APC is not OFF (handled in the next statement).
*/
#endif /* NOCSETS */
#ifndef NOESCSEQ
+ if (!escseq) { /* 2009/10/22 */
+ if (seslog && !sessft)
+ escseq = 1;
+ }
#ifdef CK_APC
escseq = escseq || (apcstatus & APC_ON);
apcactive = 0; /* An APC command is not active */
#ifdef XPRINT
escseq |= tt_print;
#endif /* XPRINT */
- inesc[0] = ES_NORMAL; /* Initial state of recognizer */
- inesc[1] = ES_NORMAL;
+ /* Initial state of recognizer */
+ inesc[0] = ES_NORMAL; /* Remote to screen */
+ inesc[1] = ES_NORMAL; /* Keyboard to remote */
debug(F101,"CONNECT escseq","",escseq);
#endif /* NOESCSEQ */
if (deblog) {
debug(F101,"CONNECT gotkbd","",gotkbd);
debug(F101,"CONNECT kbc","",kbc);
+#ifdef COMMENT
#ifndef NOSETKEY
debug(F101,"CONNECT kmptr","",kmptr);
#endif /* NOSETKEY */
+#endif /* COMMENT */
}
#endif /* DEBUG */
}
if (escseq)
apcrc = chkaes((char)c,1);
-#else
+#else /* NOCSETS */
outxbuf[0] = c;
outxcount = 1;
outxbuf[outxcount] = NUL;
c2 = csave;
if (sessft == 0 && csave == '\r')
c2 = '\n';
- logchar((char)c2);
+ LOGCHAR((char)c2);
}
}
} else {
gotnet = 0;
prev = c;
c = ckcgetc(0); /* Get next character */
- /* debug(F101,"CONNECT c","",c); */
if (c < 0) { /* Failed... */
ckcputf(); /* Flush CONNECT output buffer */
if (msgflg) {
if (debses) { /* Output character to screen */
char *s; /* Debugging display... */
- s = dbchr(c);
- while (*s)
- ckcputc(*s++);
+ s = dbchr(c); /* Make char into string */
+ while (*s) { /* Output each char from string */
+ ckcputc(*s);
+ if (seslog) /* And maybe log it. */
+ LOGCHAR((char)*s);
+ s++;
+ }
} else { /* Regular display ... */
c &= cmask; /* Apply Kermit-to-remote mask */
if (seslog && sessft) /* If binary session log */
- logchar((char)c); /* log the character now. */
+ LOGCHAR((char)c); /* log the character now. */
#ifndef NOXFER
#ifdef CK_AUTODL
/*
continue;
else if (oldesc[0] == ES_GOTESC && !apcactive) {
ckcputc(ESC); /* Write saved ESC */
- if (seslog && !sessft) logchar((char)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 */
) {
c &= cmdmsk; /* Apply command mask. */
+
+ /* Handle bare carriage returns and linefeeds */
+
if (c == CR && tt_crd) { /* SET TERM CR-DISPLA CRLF? */
ckcputc(c); /* Yes, output CR */
- if (seslog && !sessft) logchar((char)c);
+ if (seslog && !sessft) LOGCHAR((char)c);
c = LF; /* and insert a linefeed */
}
+ if (c == LF && tt_lfd) { /* SET TERM CR-DISPLA CRLF? */
+ ckcputc(CR); /* Yes, output CR */
+ if (seslog && !sessft) LOGCHAR((char)CR);
+ }
+#ifndef NOESCSEQ
if (dontprint) { /* Do transparent printing. */
dontprint = 0;
continue;
} else
-
+#endif /* NOESCSEQ */
ckcputc(c); /* Write character to screen */
}
- if (seslog && !sessft) /* Handle session log. */
- logchar((char)c);
+ if (seslog && !sessft) { /* Handle session log. */
+ LOGCHAR((char)c);
+ }
#ifdef XPRINT
if (printing && !inesc[0]) {
/* zchout() can't be used because */