Sebastian Kuschel reports that pfd_closing can be called for a socket
[u/mdw/putty] / testback.c
CommitLineData
f89c3294 1/* $Id$ */
d361f0a5 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
4a693cfc 36static const char *null_init(void *, void **, Conf *, char *, int, char **,
79bf227b 37 int, int);
4a693cfc 38static const char *loop_init(void *, void **, Conf *, char *, int, char **,
79bf227b 39 int, int);
fabd1805 40static void null_free(void *);
41static void loop_free(void *);
4a693cfc 42static void null_reconfig(void *, Conf *);
d361f0a5 43static int null_send(void *, char *, int);
44static int loop_send(void *, char *, int);
45static int null_sendbuffer(void *);
46static void null_size(void *, int, int);
47static void null_special(void *, Telnet_Special);
bac857ca 48static const struct telnet_special *null_get_specials(void *handle);
bc6cd8b6 49static int null_connected(void *);
d361f0a5 50static int null_exitcode(void *);
51static int null_sendok(void *);
52static int null_ldisc(void *, int);
53static void null_provide_ldisc(void *, void *);
54static void null_provide_logctx(void *, void *);
55static void null_unthrottle(void *, int);
fe37d215 56static int null_cfg_info(void *);
d361f0a5 57
58Backend null_backend = {
fabd1805 59 null_init, null_free, null_reconfig, null_send, null_sendbuffer, null_size,
bc6cd8b6 60 null_special, null_get_specials, null_connected, null_exitcode, null_sendok,
f89c3294 61 null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle,
9e164d82 62 null_cfg_info, "null", -1, 0
d361f0a5 63};
64
65Backend loop_backend = {
fabd1805 66 loop_init, loop_free, null_reconfig, loop_send, null_sendbuffer, null_size,
bc6cd8b6 67 null_special, null_get_specials, null_connected, null_exitcode, null_sendok,
f89c3294 68 null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle,
9e164d82 69 null_cfg_info, "loop", -1, 0
d361f0a5 70};
71
72struct loop_state {
73 Terminal *term;
74};
75
50a0d2b7 76static const char *null_init(void *frontend_handle, void **backend_handle,
4a693cfc 77 Conf *conf, char *host, int port,
79bf227b 78 char **realhost, int nodelay, int keepalive) {
d361f0a5 79
80 return NULL;
81}
82
50a0d2b7 83static const char *loop_init(void *frontend_handle, void **backend_handle,
4a693cfc 84 Conf *conf, char *host, int port,
79bf227b 85 char **realhost, int nodelay, int keepalive) {
3d88e64d 86 struct loop_state *st = snew(struct loop_state);
d361f0a5 87
88 st->term = frontend_handle;
a27230dd 89 *backend_handle = st;
90 return NULL;
d361f0a5 91}
92
fabd1805 93static void null_free(void *handle)
94{
95
96}
97
98static void loop_free(void *handle)
99{
100
101 sfree(handle);
102}
103
4a693cfc 104static void null_reconfig(void *handle, Conf *conf) {
2e96d504 105
106}
107
d361f0a5 108static int null_send(void *handle, char *buf, int len) {
109
110 return 0;
111}
112
113static int loop_send(void *handle, char *buf, int len) {
114 struct loop_state *st = handle;
115
116 return from_backend(st->term, 0, buf, len);
117}
118
119static int null_sendbuffer(void *handle) {
120
121 return 0;
122}
123
124static void null_size(void *handle, int width, int height) {
125
126}
127
128static void null_special(void *handle, Telnet_Special code) {
129
130}
131
bac857ca 132static const struct telnet_special *null_get_specials (void *handle) {
133
134 return NULL;
135}
136
bc6cd8b6 137static int null_connected(void *handle) {
d361f0a5 138
bc6cd8b6 139 return 0;
d361f0a5 140}
141
142static int null_exitcode(void *handle) {
143
144 return 0;
145}
146
147static int null_sendok(void *handle) {
148
149 return 1;
150}
151
152static void null_unthrottle(void *handle, int backlog) {
153
154}
155
156static int null_ldisc(void *handle, int option) {
157
158 return 0;
159}
160
161static void null_provide_ldisc (void *handle, void *ldisc) {
162
163}
164
165static void null_provide_logctx(void *handle, void *logctx) {
166
167}
168
f89c3294 169static int null_cfg_info(void *handle)
170{
171 return 0;
172}
173
174
d361f0a5 175/*
176 * Emacs magic:
177 * Local Variables:
178 * c-file-style: "simon"
179 * End:
180 */