]> asedeno.scripts.mit.edu Git - PuTTY_svn.git/blob - testback.c
Return the state information from loop_init() in the correct way. This means
[PuTTY_svn.git] / testback.c
1 /* $Id: testback.c,v 1.3 2002/11/23 19:58:55 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
36 static char *null_init(void *, void **, char *, int, char **, int);
37 static char *loop_init(void *, void **, char *, int, char **, int);
38 static int null_send(void *, char *, int);
39 static int loop_send(void *, char *, int);
40 static int null_sendbuffer(void *);
41 static void null_size(void *, int, int);
42 static void null_special(void *, Telnet_Special);
43 static Socket null_socket(void *);
44 static int null_exitcode(void *);
45 static int null_sendok(void *);
46 static int null_ldisc(void *, int);
47 static void null_provide_ldisc(void *, void *);
48 static void null_provide_logctx(void *, void *);
49 static void null_unthrottle(void *, int);
50
51 Backend 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
57 Backend 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
63 struct loop_state {
64     Terminal *term;
65 };
66
67 static char *null_init(void *frontend_handle, void **backend_handle,
68                        char *host, int port, char **realhost, int nodelay) {
69
70     return NULL;
71 }
72
73 static 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     *backend_handle = st;
79     return NULL;
80 }
81
82 static int null_send(void *handle, char *buf, int len) {
83
84     return 0;
85 }
86
87 static int loop_send(void *handle, char *buf, int len) {
88     struct loop_state *st = handle;
89     int i;
90
91     fprintf(stderr, "%d chars: ", len);
92     for (i = 0; i < len; i++)
93         fprintf(stderr, " 0x%x", buf[i]);
94     fprintf(stderr, "\n");
95     return from_backend(st->term, 0, buf, len);
96 }
97
98 static int null_sendbuffer(void *handle) {
99
100     return 0;
101 }
102
103 static void null_size(void *handle, int width, int height) {
104
105 }
106
107 static void null_special(void *handle, Telnet_Special code) {
108
109 }
110
111 static Socket null_socket(void *handle) {
112
113     return NULL;
114 }
115
116 static int null_exitcode(void *handle) {
117
118     return 0;
119 }
120
121 static int null_sendok(void *handle) {
122
123     return 1;
124 }
125
126 static void null_unthrottle(void *handle, int backlog) {
127
128 }
129
130 static int null_ldisc(void *handle, int option) {
131
132     return 0;
133 }
134
135 static void null_provide_ldisc (void *handle, void *ldisc) {
136
137 }
138
139 static void null_provide_logctx(void *handle, void *logctx) {
140
141 }
142
143 /*
144  * Emacs magic:
145  * Local Variables:
146  * c-file-style: "simon"
147  * End:
148  */