2003-01-12 19:11:27 +03:00
|
|
|
/* $Id: testback.c,v 1.5 2003/01/12 16:11:27 ben Exp $ */
|
2002-11-19 15:29:45 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1999 Simon Tatham
|
|
|
|
* Copyright (c) 1999 Ben Harris
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use,
|
|
|
|
* copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following
|
|
|
|
* conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
|
|
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
|
|
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* PuTTY test backends */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "putty.h"
|
|
|
|
|
2003-01-12 19:11:27 +03:00
|
|
|
static char *null_init(void *, void **, Config *, char *, int, char **, int);
|
|
|
|
static char *loop_init(void *, void **, Config *, char *, int, char **, int);
|
|
|
|
static void null_reconfig(void *, Config *);
|
2002-11-19 15:29:45 +03:00
|
|
|
static int null_send(void *, char *, int);
|
|
|
|
static int loop_send(void *, char *, int);
|
|
|
|
static int null_sendbuffer(void *);
|
|
|
|
static void null_size(void *, int, int);
|
|
|
|
static void null_special(void *, Telnet_Special);
|
|
|
|
static Socket null_socket(void *);
|
|
|
|
static int null_exitcode(void *);
|
|
|
|
static int null_sendok(void *);
|
|
|
|
static int null_ldisc(void *, int);
|
|
|
|
static void null_provide_ldisc(void *, void *);
|
|
|
|
static void null_provide_logctx(void *, void *);
|
|
|
|
static void null_unthrottle(void *, int);
|
|
|
|
|
|
|
|
Backend null_backend = {
|
2003-01-12 19:11:27 +03:00
|
|
|
null_init, null_reconfig, null_send, null_sendbuffer, null_size,
|
|
|
|
null_special, null_socket, null_exitcode, null_sendok, null_ldisc,
|
|
|
|
null_provide_ldisc, null_provide_logctx, null_unthrottle, 0
|
2002-11-19 15:29:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
Backend loop_backend = {
|
2003-01-12 19:11:27 +03:00
|
|
|
loop_init, null_reconfig, loop_send, null_sendbuffer, null_size,
|
|
|
|
null_special, null_socket, null_exitcode, null_sendok, null_ldisc,
|
|
|
|
null_provide_ldisc, null_provide_logctx, null_unthrottle, 0
|
2002-11-19 15:29:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct loop_state {
|
|
|
|
Terminal *term;
|
|
|
|
};
|
|
|
|
|
|
|
|
static char *null_init(void *frontend_handle, void **backend_handle,
|
2003-01-12 19:11:27 +03:00
|
|
|
Config *cfg, char *host, int port, char **realhost,
|
|
|
|
int nodelay) {
|
2002-11-19 15:29:45 +03:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *loop_init(void *frontend_handle, void **backend_handle,
|
2003-01-12 19:11:27 +03:00
|
|
|
Config *cfg, char *host, int port, char **realhost,
|
|
|
|
int nodelay) {
|
2002-11-19 15:29:45 +03:00
|
|
|
struct loop_state *st = smalloc(sizeof(*st));
|
|
|
|
|
|
|
|
st->term = frontend_handle;
|
2002-11-23 22:58:55 +03:00
|
|
|
*backend_handle = st;
|
|
|
|
return NULL;
|
2002-11-19 15:29:45 +03:00
|
|
|
}
|
|
|
|
|
2003-01-12 19:11:27 +03:00
|
|
|
static void null_reconfig(void *handle, Config *cfg) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-11-19 15:29:45 +03:00
|
|
|
static int null_send(void *handle, char *buf, int len) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int loop_send(void *handle, char *buf, int len) {
|
|
|
|
struct loop_state *st = handle;
|
|
|
|
|
|
|
|
return from_backend(st->term, 0, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int null_sendbuffer(void *handle) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void null_size(void *handle, int width, int height) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void null_special(void *handle, Telnet_Special code) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static Socket null_socket(void *handle) {
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int null_exitcode(void *handle) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int null_sendok(void *handle) {
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void null_unthrottle(void *handle, int backlog) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int null_ldisc(void *handle, int option) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void null_provide_ldisc (void *handle, void *ldisc) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void null_provide_logctx(void *handle, void *logctx) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Emacs magic:
|
|
|
|
* Local Variables:
|
|
|
|
* c-file-style: "simon"
|
|
|
|
* End:
|
|
|
|
*/
|