OSDN Git Service

Fix bugs of corruption on resuming downloading files larger than 4GB.
[ffftp/ffftp.git] / putty / TESTBACK.C
1 /* $Id: testback.c 7628 2007-06-30 21:56:44Z jacob $ */\r
2 /*\r
3  * Copyright (c) 1999 Simon Tatham\r
4  * Copyright (c) 1999 Ben Harris\r
5  * All rights reserved.\r
6  *\r
7  * Permission is hereby granted, free of charge, to any person\r
8  * obtaining a copy of this software and associated documentation\r
9  * files (the "Software"), to deal in the Software without\r
10  * restriction, including without limitation the rights to use,\r
11  * copy, modify, merge, publish, distribute, sublicense, and/or\r
12  * sell copies of the Software, and to permit persons to whom the\r
13  * Software is furnished to do so, subject to the following\r
14  * conditions:\r
15  * \r
16  * The above copyright notice and this permission notice shall be\r
17  * included in all copies or substantial portions of the Software.\r
18  * \r
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
22  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR\r
23  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\r
24  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
25  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
26  * SOFTWARE.\r
27  */\r
28 \r
29 /* PuTTY test backends */\r
30 \r
31 #include <stdio.h>\r
32 #include <stdlib.h>\r
33 \r
34 #include "putty.h"\r
35 \r
36 static const char *null_init(void *, void **, Config *, char *, int, char **,\r
37                              int, int);\r
38 static const char *loop_init(void *, void **, Config *, char *, int, char **,\r
39                              int, int);\r
40 static void null_free(void *);\r
41 static void loop_free(void *);\r
42 static void null_reconfig(void *, Config *);\r
43 static int null_send(void *, char *, int);\r
44 static int loop_send(void *, char *, int);\r
45 static int null_sendbuffer(void *);\r
46 static void null_size(void *, int, int);\r
47 static void null_special(void *, Telnet_Special);\r
48 static const struct telnet_special *null_get_specials(void *handle);\r
49 static int null_connected(void *);\r
50 static int null_exitcode(void *);\r
51 static int null_sendok(void *);\r
52 static int null_ldisc(void *, int);\r
53 static void null_provide_ldisc(void *, void *);\r
54 static void null_provide_logctx(void *, void *);\r
55 static void null_unthrottle(void *, int);\r
56 static int null_cfg_info(void *);\r
57 \r
58 Backend null_backend = {\r
59     null_init, null_free, null_reconfig, null_send, null_sendbuffer, null_size,\r
60     null_special, null_get_specials, null_connected, null_exitcode, null_sendok,\r
61     null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle,\r
62     null_cfg_info, "null", -1, 0\r
63 };\r
64 \r
65 Backend loop_backend = {\r
66     loop_init, loop_free, null_reconfig, loop_send, null_sendbuffer, null_size,\r
67     null_special, null_get_specials, null_connected, null_exitcode, null_sendok,\r
68     null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle,\r
69     null_cfg_info, "loop", -1, 0\r
70 };\r
71 \r
72 struct loop_state {\r
73     Terminal *term;\r
74 };\r
75 \r
76 static const char *null_init(void *frontend_handle, void **backend_handle,\r
77                              Config *cfg, char *host, int port,\r
78                              char **realhost, int nodelay, int keepalive) {\r
79 \r
80     return NULL;\r
81 }\r
82 \r
83 static const char *loop_init(void *frontend_handle, void **backend_handle,\r
84                              Config *cfg, char *host, int port,\r
85                              char **realhost, int nodelay, int keepalive) {\r
86     struct loop_state *st = snew(struct loop_state);\r
87 \r
88     st->term = frontend_handle;\r
89     *backend_handle = st;\r
90     return NULL;\r
91 }\r
92 \r
93 static void null_free(void *handle)\r
94 {\r
95 \r
96 }\r
97 \r
98 static void loop_free(void *handle)\r
99 {\r
100 \r
101     sfree(handle);\r
102 }\r
103 \r
104 static void null_reconfig(void *handle, Config *cfg) {\r
105 \r
106 }\r
107 \r
108 static int null_send(void *handle, char *buf, int len) {\r
109 \r
110     return 0;\r
111 }\r
112 \r
113 static int loop_send(void *handle, char *buf, int len) {\r
114     struct loop_state *st = handle;\r
115 \r
116     return from_backend(st->term, 0, buf, len);\r
117 }\r
118 \r
119 static int null_sendbuffer(void *handle) {\r
120 \r
121     return 0;\r
122 }\r
123 \r
124 static void null_size(void *handle, int width, int height) {\r
125 \r
126 }\r
127 \r
128 static void null_special(void *handle, Telnet_Special code) {\r
129 \r
130 }\r
131 \r
132 static const struct telnet_special *null_get_specials (void *handle) {\r
133 \r
134     return NULL;\r
135 }\r
136 \r
137 static int null_connected(void *handle) {\r
138 \r
139     return 0;\r
140 }\r
141 \r
142 static int null_exitcode(void *handle) {\r
143 \r
144     return 0;\r
145 }\r
146 \r
147 static int null_sendok(void *handle) {\r
148 \r
149     return 1;\r
150 }\r
151 \r
152 static void null_unthrottle(void *handle, int backlog) {\r
153 \r
154 }\r
155 \r
156 static int null_ldisc(void *handle, int option) {\r
157 \r
158     return 0;\r
159 }\r
160 \r
161 static void null_provide_ldisc (void *handle, void *ldisc) {\r
162 \r
163 }\r
164 \r
165 static void null_provide_logctx(void *handle, void *logctx) {\r
166 \r
167 }\r
168 \r
169 static int null_cfg_info(void *handle)\r
170 {\r
171     return 0;\r
172 }\r
173 \r
174 \r
175 /*\r
176  * Emacs magic:\r
177  * Local Variables:\r
178  * c-file-style: "simon"\r
179  * End:\r
180  */\r