A couple of useful test backends.
[u/mdw/putty] / testback.c
CommitLineData
d361f0a5 1/* $Id: testback.c,v 1.2 2002/11/19 12:29:45 ben Exp $ */
2/*
3 * Copyright (c) 1999 Simon Tatham
4 * Copyright (c) 1999 Ben Harris
5 * All rights reserved.
6 *
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
14 * conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
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
26 * SOFTWARE.
27 */
28
29/* PuTTY test backends */
30
31#include <stdio.h>
32#include <stdlib.h>
33
34#include "putty.h"
35
36static char *null_init(void *, void **, char *, int, char **, int);
37static char *loop_init(void *, void **, char *, int, char **, int);
38static int null_send(void *, char *, int);
39static int loop_send(void *, char *, int);
40static int null_sendbuffer(void *);
41static void null_size(void *, int, int);
42static void null_special(void *, Telnet_Special);
43static Socket null_socket(void *);
44static int null_exitcode(void *);
45static int null_sendok(void *);
46static int null_ldisc(void *, int);
47static void null_provide_ldisc(void *, void *);
48static void null_provide_logctx(void *, void *);
49static void null_unthrottle(void *, int);
50
51Backend null_backend = {
52 null_init, null_send, null_sendbuffer, null_size, null_special,
53 null_socket, null_exitcode, null_sendok, null_ldisc, null_provide_ldisc,
54 null_provide_logctx, null_unthrottle, 0
55};
56
57Backend loop_backend = {
58 loop_init, loop_send, null_sendbuffer, null_size, null_special,
59 null_socket, null_exitcode, null_sendok, null_ldisc, null_provide_ldisc,
60 null_provide_logctx, null_unthrottle, 0
61};
62
63struct loop_state {
64 Terminal *term;
65};
66
67static char *null_init(void *frontend_handle, void **backend_handle,
68 char *host, int port, char **realhost, int nodelay) {
69
70 return NULL;
71}
72
73static char *loop_init(void *frontend_handle, void **backend_handle,
74 char *host, int port, char **realhost, int nodelay) {
75 struct loop_state *st = smalloc(sizeof(*st));
76
77 st->term = frontend_handle;
78 return (char *)st;
79}
80
81static int null_send(void *handle, char *buf, int len) {
82
83 return 0;
84}
85
86static int loop_send(void *handle, char *buf, int len) {
87 struct loop_state *st = handle;
88
89 return from_backend(st->term, 0, buf, len);
90}
91
92static int null_sendbuffer(void *handle) {
93
94 return 0;
95}
96
97static void null_size(void *handle, int width, int height) {
98
99}
100
101static void null_special(void *handle, Telnet_Special code) {
102
103}
104
105static Socket null_socket(void *handle) {
106
107 return NULL;
108}
109
110static int null_exitcode(void *handle) {
111
112 return 0;
113}
114
115static int null_sendok(void *handle) {
116
117 return 1;
118}
119
120static void null_unthrottle(void *handle, int backlog) {
121
122}
123
124static int null_ldisc(void *handle, int option) {
125
126 return 0;
127}
128
129static void null_provide_ldisc (void *handle, void *ldisc) {
130
131}
132
133static void null_provide_logctx(void *handle, void *logctx) {
134
135}
136
137/*
138 * Emacs magic:
139 * Local Variables:
140 * c-file-style: "simon"
141 * End:
142 */