static Socket s = NULL;
static int rlogin_bufsize;
+static int rlogin_term_width, rlogin_term_height;
+static void *frontend;
static void rlogin_size(void);
static void c_write(char *buf, int len)
{
- int backlog = from_backend(0, buf, len);
+ int backlog = from_backend(frontend, 0, buf, len);
sk_set_frozen(s, backlog > RLOGIN_MAX_BACKLOG);
}
}
if (error_msg) {
/* A socket error has occurred. */
- connection_fatal(error_msg);
+ logevent(error_msg);
+ connection_fatal("%s", error_msg);
} /* Otherwise, the remote side closed the connection normally. */
return 0;
}
}
firstbyte = 0;
}
- c_write(data, len);
+ if (len > 0)
+ c_write(data, len);
}
return 1;
}
* Also places the canonical host name into `realhost'. It must be
* freed by the caller.
*/
-static char *rlogin_init(char *host, int port, char **realhost)
+static char *rlogin_init(void *frontend_handle,
+ char *host, int port, char **realhost, int nodelay)
{
static struct plug_function_table fn_table = {
rlogin_closing,
SockAddr addr;
char *err;
+ frontend = frontend_handle;
+ rlogin_term_width = cfg.width;
+ rlogin_term_height = cfg.height;
+
/*
* Try to find host.
*/
sprintf(buf, "Connecting to %.100s port %d", addrbuf, port);
logevent(buf);
}
- s = sk_new(addr, port, 1, 0, &fn_table_ptr);
+ s = new_connection(addr, *realhost, port, 1, 0, nodelay, &fn_table_ptr);
if ((err = sk_socket_error(s)))
return err;
/*
* Called to set the size of the window
*/
-static void rlogin_size(void)
+static void rlogin_size(int width, int height)
{
char b[12] = { '\xFF', '\xFF', 0x73, 0x73, 0, 0, 0, 0, 0, 0, 0, 0 };
- b[6] = cols >> 8;
- b[7] = cols & 0xFF;
- b[4] = rows >> 8;
- b[5] = rows & 0xFF;
+ rlogin_term_width = width;
+ rlogin_term_height = height;
+
+ if (s == NULL)
+ return;
+
+ b[6] = rlogin_term_width >> 8;
+ b[7] = rlogin_term_width & 0xFF;
+ b[4] = rlogin_term_height >> 8;
+ b[5] = rlogin_term_height & 0xFF;
rlogin_bufsize = sk_write(s, b, 12);
return;
}
return 0;
}
+static int rlogin_exitcode(void)
+{
+ /* If we ever implement RSH, we'll probably need to do this properly */
+ return 0;
+}
+
Backend rlogin_backend = {
rlogin_init,
rlogin_send,
rlogin_size,
rlogin_special,
rlogin_socket,
+ rlogin_exitcode,
rlogin_sendok,
rlogin_ldisc,
rlogin_unthrottle,