]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Very basic hex-dump backend for testing meta handling.
authorBen Harris <bjh21@bjh21.me.uk>
Sun, 28 Mar 1999 15:25:45 +0000 (15:25 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Sun, 28 Mar 1999 15:25:45 +0000 (15:25 +0000)
[originally from svn r134]

putty.h
testback.c

diff --git a/putty.h b/putty.h
index b110db6b8e6c589c87cf77f261fbd1cce4791448..6e629b89e63d76997f7c3286ef0aed1397aa3fef 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -303,6 +303,7 @@ void safefree(void *);
 
 extern Backend null_backend;
 extern Backend loop_backend;
+extern Backend hexdump_backend;
 
 /*
  * Exports from version.c.
index b2ccd17a67e76835bf43777c7dcbce6641eff424..9ecf14a41211624b4c83a82e530c68bee49439f8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: testback.c,v 1.1.2.3 1999/03/21 23:23:43 ben Exp $ */
+/* $Id: testback.c,v 1.1.2.4 1999/03/28 15:25:45 ben Exp $ */
 /*
  * Copyright (c) 1999 Simon Tatham
  * Copyright (c) 1999 Ben Harris
@@ -28,6 +28,7 @@
 
 /* PuTTY test backends */
 
+#include <stdio.h>
 #include <stdlib.h>
 
 #include "putty.h"
@@ -36,6 +37,7 @@ static char *null_init(char *, int, char **);
 static int null_msg(void);
 static void null_send(char *, int);
 static void loop_send(char *, int);
+static void hexdump_send(char *, int);
 static void null_size(void);
 static void null_special(Telnet_Special);
 
@@ -47,6 +49,10 @@ Backend loop_backend = {
     null_init, null_msg, loop_send, null_size, null_special
 };
 
+Backend hexdump_backend = {
+    null_init, null_msg, hexdump_send, null_size, null_special
+};
+
 static char *null_init(char *host, int port, char **realhost) {
 
     return NULL;
@@ -62,6 +68,7 @@ static void null_send(char *buf, int len) {
 }
 
 static void loop_send (char *buf, int len) {
+
     while (len--) {
        int new_head = (inbuf_head + 1) & INBUF_MASK;
        int c = (unsigned char) *buf;
@@ -74,7 +81,15 @@ static void loop_send (char *buf, int len) {
     term_update();
 }
 
+static void hexdump_send(char *buf, int len) {
+    static char mybuf[10];
+    int mylen;
 
+    while (len--) {
+       mylen = sprintf(mybuf, "%02x\015\012", (unsigned char)*buf++);
+       loop_send(mybuf, mylen);
+    }
+}
 
 static void null_size(void) {
 
@@ -83,3 +98,10 @@ static void null_size(void) {
 static void null_special(Telnet_Special code) {
 
 }
+
+/*
+ * Emacs magic:
+ * Local Variables:
+ * c-file-style: "simon"
+ * End:
+ */