aboutsummaryrefslogtreecommitdiff
path: root/crypto/heimdal/appl/telnet/telnet/utilities.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/heimdal/appl/telnet/telnet/utilities.c')
-rw-r--r--crypto/heimdal/appl/telnet/telnet/utilities.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/crypto/heimdal/appl/telnet/telnet/utilities.c b/crypto/heimdal/appl/telnet/telnet/utilities.c
index d62d572a5fe4..0ac31c9ebd9d 100644
--- a/crypto/heimdal/appl/telnet/telnet/utilities.c
+++ b/crypto/heimdal/appl/telnet/telnet/utilities.c
@@ -37,7 +37,7 @@
#include "telnet_locl.h"
-RCSID("$Id: utilities.c 10587 2001-08-29 00:45:23Z assar $");
+RCSID("$Id$");
FILE *NetTrace = 0; /* Not in bss, since needs to stay */
int prettydump;
@@ -248,8 +248,20 @@ optionstatus(void)
}
+static void __attribute__((format (printf, 3, 4)))
+qprintf(int quote, FILE *f, const char *fmt, ...)
+
+{
+ va_list va;
+ if (quote)
+ fprintf(f, "\" ");
+ va_start(va, fmt);
+ vfprintf(f, fmt, va);
+ va_end(va);
+}
+
void
-printsub(int direction, unsigned char *pointer, int length)
+printsub(int direction, unsigned char *pointer, size_t length)
{
int i;
unsigned char buf[512];
@@ -295,7 +307,9 @@ printsub(int direction, unsigned char *pointer, int length)
fprintf(NetTrace, "TERMINAL-TYPE ");
switch (pointer[1]) {
case TELQUAL_IS:
- fprintf(NetTrace, "IS \"%.*s\"", length-2, (char *)pointer+2);
+ fprintf(NetTrace, "IS \"%.*s\"",
+ (int)(length-2),
+ (char *)pointer+2);
break;
case TELQUAL_SEND:
fprintf(NetTrace, "SEND");
@@ -315,7 +329,7 @@ printsub(int direction, unsigned char *pointer, int length)
switch (pointer[1]) {
case TELQUAL_IS:
fprintf(NetTrace, " IS ");
- fprintf(NetTrace, "%.*s", length-2, (char *)pointer+2);
+ fprintf(NetTrace, "%.*s", (int)(length-2), (char *)pointer+2);
break;
default:
if (pointer[1] == 1)
@@ -696,7 +710,7 @@ printsub(int direction, unsigned char *pointer, int length)
fprintf(NetTrace, "X-DISPLAY-LOCATION ");
switch (pointer[1]) {
case TELQUAL_IS:
- fprintf(NetTrace, "IS \"%.*s\"", length-2, (char *)pointer+2);
+ fprintf(NetTrace, "IS \"%.*s\"", (int)(length-2), (char *)pointer+2);
break;
case TELQUAL_SEND:
fprintf(NetTrace, "SEND");
@@ -726,57 +740,44 @@ printsub(int direction, unsigned char *pointer, int length)
fprintf(NetTrace, "INFO ");
env_common:
{
- int noquote = 2;
+ int quote = 0;
for (i = 2; i < length; i++ ) {
switch (pointer[i]) {
- case NEW_ENV_VALUE:
-#ifdef OLD_ENVIRON
- /* case NEW_ENV_OVAR: */
- if (pointer[0] == TELOPT_OLD_ENVIRON) {
- fprintf(NetTrace, "\" VAR " + noquote);
- } else
-#endif /* OLD_ENVIRON */
- fprintf(NetTrace, "\" VALUE " + noquote);
- noquote = 2;
+ case NEW_ENV_VAR:
+ qprintf(quote, NetTrace, "VAR ");
+ quote = 0;
break;
- case NEW_ENV_VAR:
-#ifdef OLD_ENVIRON
- /* case OLD_ENV_VALUE: */
- if (pointer[0] == TELOPT_OLD_ENVIRON) {
- fprintf(NetTrace, "\" VALUE " + noquote);
- } else
-#endif /* OLD_ENVIRON */
- fprintf(NetTrace, "\" VAR " + noquote);
- noquote = 2;
+ case NEW_ENV_VALUE:
+ qprintf(quote, NetTrace, "VALUE");
+ quote = 0;
break;
case ENV_ESC:
- fprintf(NetTrace, "\" ESC " + noquote);
- noquote = 2;
+ qprintf(quote, NetTrace, "ESC ");
+ quote = 0;
break;
case ENV_USERVAR:
- fprintf(NetTrace, "\" USERVAR " + noquote);
- noquote = 2;
+ qprintf(quote, NetTrace, "USERVAR ");
+ quote = 0;
break;
default:
if (isprint(pointer[i]) && pointer[i] != '"') {
- if (noquote) {
+ if (!quote) {
putc('"', NetTrace);
- noquote = 0;
+ quote = 1;
}
putc(pointer[i], NetTrace);
} else {
- fprintf(NetTrace, "\" %03o " + noquote,
- pointer[i]);
- noquote = 2;
+ qprintf(quote, NetTrace, "%03o ", pointer[i]);
+ quote = 0;
}
break;
}
}
- if (!noquote)
+ if (quote)
putc('"', NetTrace);
break;
}