3d88e64d |
1 | /* $Id: testback.c,v 1.7 2003/03/29 16:14:26 simon Exp $ */ |
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 | |
2e96d504 |
36 | static char *null_init(void *, void **, Config *, char *, int, char **, int); |
37 | static char *loop_init(void *, void **, Config *, char *, int, char **, int); |
fabd1805 |
38 | static void null_free(void *); |
39 | static void loop_free(void *); |
2e96d504 |
40 | static void null_reconfig(void *, Config *); |
d361f0a5 |
41 | static int null_send(void *, char *, int); |
42 | static int loop_send(void *, char *, int); |
43 | static int null_sendbuffer(void *); |
44 | static void null_size(void *, int, int); |
45 | static void null_special(void *, Telnet_Special); |
46 | static Socket null_socket(void *); |
47 | static int null_exitcode(void *); |
48 | static int null_sendok(void *); |
49 | static int null_ldisc(void *, int); |
50 | static void null_provide_ldisc(void *, void *); |
51 | static void null_provide_logctx(void *, void *); |
52 | static void null_unthrottle(void *, int); |
53 | |
54 | Backend null_backend = { |
fabd1805 |
55 | null_init, null_free, null_reconfig, null_send, null_sendbuffer, null_size, |
2e96d504 |
56 | null_special, null_socket, null_exitcode, null_sendok, null_ldisc, |
57 | null_provide_ldisc, null_provide_logctx, null_unthrottle, 0 |
d361f0a5 |
58 | }; |
59 | |
60 | Backend loop_backend = { |
fabd1805 |
61 | loop_init, loop_free, null_reconfig, loop_send, null_sendbuffer, null_size, |
2e96d504 |
62 | null_special, null_socket, null_exitcode, null_sendok, null_ldisc, |
63 | null_provide_ldisc, null_provide_logctx, null_unthrottle, 0 |
d361f0a5 |
64 | }; |
65 | |
66 | struct loop_state { |
67 | Terminal *term; |
68 | }; |
69 | |
70 | static char *null_init(void *frontend_handle, void **backend_handle, |
2e96d504 |
71 | Config *cfg, char *host, int port, char **realhost, |
72 | int nodelay) { |
d361f0a5 |
73 | |
74 | return NULL; |
75 | } |
76 | |
77 | static char *loop_init(void *frontend_handle, void **backend_handle, |
2e96d504 |
78 | Config *cfg, char *host, int port, char **realhost, |
79 | int nodelay) { |
3d88e64d |
80 | struct loop_state *st = snew(struct loop_state); |
d361f0a5 |
81 | |
82 | st->term = frontend_handle; |
a27230dd |
83 | *backend_handle = st; |
84 | return NULL; |
d361f0a5 |
85 | } |
86 | |
fabd1805 |
87 | static void null_free(void *handle) |
88 | { |
89 | |
90 | } |
91 | |
92 | static void loop_free(void *handle) |
93 | { |
94 | |
95 | sfree(handle); |
96 | } |
97 | |
2e96d504 |
98 | static void null_reconfig(void *handle, Config *cfg) { |
99 | |
100 | } |
101 | |
d361f0a5 |
102 | static int null_send(void *handle, char *buf, int len) { |
103 | |
104 | return 0; |
105 | } |
106 | |
107 | static int loop_send(void *handle, char *buf, int len) { |
108 | struct loop_state *st = handle; |
109 | |
110 | return from_backend(st->term, 0, buf, len); |
111 | } |
112 | |
113 | static int null_sendbuffer(void *handle) { |
114 | |
115 | return 0; |
116 | } |
117 | |
118 | static void null_size(void *handle, int width, int height) { |
119 | |
120 | } |
121 | |
122 | static void null_special(void *handle, Telnet_Special code) { |
123 | |
124 | } |
125 | |
126 | static Socket null_socket(void *handle) { |
127 | |
128 | return NULL; |
129 | } |
130 | |
131 | static int null_exitcode(void *handle) { |
132 | |
133 | return 0; |
134 | } |
135 | |
136 | static int null_sendok(void *handle) { |
137 | |
138 | return 1; |
139 | } |
140 | |
141 | static void null_unthrottle(void *handle, int backlog) { |
142 | |
143 | } |
144 | |
145 | static int null_ldisc(void *handle, int option) { |
146 | |
147 | return 0; |
148 | } |
149 | |
150 | static void null_provide_ldisc (void *handle, void *ldisc) { |
151 | |
152 | } |
153 | |
154 | static void null_provide_logctx(void *handle, void *logctx) { |
155 | |
156 | } |
157 | |
158 | /* |
159 | * Emacs magic: |
160 | * Local Variables: |
161 | * c-file-style: "simon" |
162 | * End: |
163 | */ |