WSAEVENT netevent;
+static Backend *back;
+static void *backhandle;
+
int term_ldisc(Terminal *term, int mode)
{
return FALSE;
struct plug_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */
void *c; /* (channel) data used by ssh.c */
+ void *backhandle; /* instance of SSH backend itself */
+ /* Note that backhandle need not be filled in if c is non-NULL */
Socket s;
char hostname[128];
int throttled, throttle_override;
pr->throttled = pr->throttle_override = 0;
pr->ready = 1;
pr->c = c;
+ pr->backhandle = NULL; /* we shouldn't need this */
pr->s = *s = new_connection(addr, dummy_realhost, port, 0, 1, 0, (Plug) pr);
if ((err = sk_socket_error(*s))) {
pr->fn = &fn_table;
pr->c = NULL;
+ pr->backhandle = org->backhandle;
pr->s = s = sk_register(sock, (Plug) pr);
if ((err = sk_socket_error(s))) {
return err != NULL;
}
- pr->c = new_sock_channel(backhandle, s);
+ pr->c = new_sock_channel(org->backhandle, s);
strcpy(pr->hostname, org->hostname);
pr->port = org->port;
return 1;
} else {
/* asks to forward to the specified host/port for this */
- ssh_send_port_open(backhandle, pr->c, pr->hostname,
- pr->port, "forwarding");
+ ssh_send_port_open(pr->c, pr->hostname, pr->port, "forwarding");
}
return 0;
/* Add a new forwarding from port -> desthost:destport
sets up a listener on the local machine on port
*/
-char *pfd_addforward(char *desthost, int destport, int port)
+char *pfd_addforward(char *desthost, int destport, int port, void *backhandle)
{
static struct plug_function_table fn_table = {
pfd_closing,
pr->throttled = pr->throttle_override = 0;
pr->ready = 0;
pr->waiting = NULL;
+ pr->backhandle = backhandle;
pr->s = s = new_listener(port, (Plug) pr, !cfg.lport_acceptall);
if ((err = sk_socket_error(s))) {
*/
char *pwd, *homedir;
+static Backend *back;
+static void *backhandle;
/* ----------------------------------------------------------------------
* Higher-level helper functions used in commands.
cleanup_exit(1);
}
-void ldisc_send(char *buf, int len, int interactive)
+void ldisc_send(void *handle, char *buf, int len, int interactive)
{
/*
* This is only here because of the calls to ldisc_send(NULL,
#include "puttyps.h"
#include "network.h"
-/*
- * Global variables. Most modules declare these `extern', but
- * window.c will do `#define PUTTY_DO_GLOBALS' before including this
- * module, and so will get them properly defined.
- */
-#ifdef PUTTY_DO_GLOBALS
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
-
/* Three attribute types:
* The ATTRs (normal attributes) are stored with the characters in the main
* display arrays
GLOBAL int session_closed;
-GLOBAL char *help_path;
-GLOBAL int help_has_contents;
-
GLOBAL int nsessions;
GLOBAL char **sessions;
int default_port;
};
-GLOBAL Backend *back;
-GLOBAL void *backhandle;
-
extern struct backend_list {
int protocol;
char *name;
static char *gui_hwnd = NULL;
static int using_sftp = 0;
+static Backend *back;
+static void *backhandle;
+
static void source(char *src);
static void rsource(char *src);
static void sink(char *targ, char *src);
*/
#define MAX_SCP_BUFSIZE 16384
-void ldisc_send(char *buf, int len, int interactive)
+void ldisc_send(void *handle, char *buf, int len, int interactive)
{
/*
* This is only here because of the calls to ldisc_send(NULL,
extern void x11_override_throttle(Socket s, int enable);
extern char *pfd_newconnect(Socket * s, char *hostname, int port, void *c);
-extern char *pfd_addforward(char *desthost, int destport, int port);
+extern char *pfd_addforward(char *desthost, int destport, int port,
+ void *backhandle);
extern void pfd_close(Socket s);
extern int pfd_send(Socket s, char *data, int len);
extern void pfd_confirm(Socket s);
}
if (sport && dport) {
if (type == 'L') {
- pfd_addforward(host, dport, sport);
+ pfd_addforward(host, dport, sport, ssh);
sprintf(buf, "Local port %.*s%.*s%d%.*s forwarding to"
" %s:%.*s%.*s%d%.*s",
sserv ? strlen(sports) : 0, sports,
}
if (sport && dport) {
if (type == 'L') {
- pfd_addforward(host, dport, sport);
+ pfd_addforward(host, dport, sport, ssh);
sprintf(buf, "Local port %.*s%.*s%d%.*s forwarding to"
" %s:%.*s%.*s%d%.*s",
sserv ? strlen(sports) : 0, sports,
}
}
-void ssh_send_port_open(void *handle, void *channel, char *hostname,
- int port, char *org)
+void ssh_send_port_open(void *channel, char *hostname, int port, char *org)
{
- Ssh ssh = (Ssh) handle;
struct ssh_channel *c = (struct ssh_channel *)channel;
+ Ssh ssh = c->ssh;
char buf[1024];
sprintf(buf, "Opening forwarded connection to %.512s:%d", hostname, port);
/* Allocate and register a new channel for port forwarding */
void *new_sock_channel(void *handle, Socket s);
-void ssh_send_port_open(void *handle, void *channel,
- char *hostname, int port, char *org);
+void ssh_send_port_open(void *channel, char *hostname, int port, char *org);
Bignum copybn(Bignum b);
Bignum bn_power_2(int n);
char icontitle[sizeof(((Config *)0)->wintitle)];
int master_fd, master_func_id, exited;
void *ldisc;
+ Backend *back;
+ void *backhandle;
};
static struct gui_data the_inst;
gtk_input_remove(inst->master_func_id);
}
- if (!inst->exited && back->exitcode(backhandle) >= 0) {
- int exitcode = back->exitcode(backhandle);
+ if (!inst->exited && inst->back->exitcode(inst->backhandle) >= 0) {
+ int exitcode = inst->back->exitcode(inst->backhandle);
int clean;
clean = WIFEXITED(exitcode) && (WEXITSTATUS(exitcode) == 0);
{
struct gui_data *inst = (struct gui_data *)data;
- if (back->exitcode(backhandle) >= 0) {
+ if (inst->back->exitcode(inst->backhandle) >= 0) {
/*
* The primary child process died. We could keep the
* terminal open for remaining subprocesses to output to,
term = term_init();
- back = &pty_backend;
- back->init((void *)term, &backhandle, NULL, 0, NULL, 0);
+ inst->back = &pty_backend;
+ inst->back->init((void *)term, &inst->backhandle, NULL, 0, NULL, 0);
- term_provide_resize_fn(term, back->size, backhandle);
+ term_provide_resize_fn(term, inst->back->size, inst->backhandle);
term_size(term, cfg.height, cfg.width, cfg.savelines);
- inst->ldisc = ldisc_create(term, back, backhandle, inst);
+ inst->ldisc = ldisc_create(term, inst->back, inst->backhandle, inst);
ldisc_send(inst->ldisc, NULL, 0, 0);/* cause ldisc to notice changes */
inst->master_fd = pty_master_fd;
static int caret_x = -1, caret_y = -1;
static void *ldisc;
+static Backend *back;
+static void *backhandle;
#define FONT_NORMAL 0
#define FONT_BOLD 1
GLOBAL HINSTANCE hinst;
/*
+ * Details of the help file.
+ */
+GLOBAL char *help_path;
+GLOBAL int help_has_contents;
+
+/*
* I've just looked in the windows standard headr files for WM_USER, there
* are hundreds of flags defined using the form WM_USER+123 so I've
* renumbered this NETEVENT value and the two in window.c