1 /* $Id: testback.c,v 1.1.2.7 1999/08/02 08:04:31 ben Exp $ */
3 * Copyright (c) 1999 Simon Tatham
4 * Copyright (c) 1999 Ben Harris
7 * Permission is hereby granted, free of charge, to any person
8 * obtaining a copy of this software and associated documentation
9 * files (the "Software"), to deal in the Software without
10 * restriction, including without limitation the rights to use,
11 * copy, modify, merge, publish, distribute, sublicense, and/or
12 * sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
24 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 /* PuTTY test backends */
36 static char *null_init(Session *);
37 static int null_msg(Session *, SOCKET, Net_Event_Type);
38 static void null_send(Session *, char *, int);
39 static void loop_send(Session *, char *, int);
40 static void hexdump_send(Session *, char *, int);
41 static void null_size(Session *);
42 static void null_special(Session *, Telnet_Special);
44 Backend null_backend = {
45 null_init, null_msg, null_send, null_size, null_special
48 Backend loop_backend = {
49 null_init, null_msg, loop_send, null_size, null_special
52 Backend hexdump_backend = {
53 null_init, null_msg, hexdump_send, null_size, null_special
56 static char *null_init(Session *s) {
61 static int null_msg(Session *s, SOCKET sock, Net_Event_Type ne) {
66 static void null_send(Session *s, char *buf, int len) {
70 static void loop_send (Session *s, char *buf, int len) {
73 int new_head = (s->inbuf_head + 1) & INBUF_MASK;
74 int c = (unsigned char) *buf;
75 if (new_head != s->inbuf_reap) {
76 s->inbuf[s->inbuf_head] = *buf++;
77 s->inbuf_head = new_head;
84 static void hexdump_send(Session *s, char *buf, int len) {
85 static char mybuf[10];
89 mylen = sprintf(mybuf, "%02x\015\012", (unsigned char)*buf++);
90 loop_send(s, mybuf, mylen);
94 static void null_size(Session *s) {
98 static void null_special(Session *s, Telnet_Special code) {
105 * c-file-style: "simon"