try_write();
}
-static void c_write (char *buf, int len) {
- while (len--) {
- int new_head = (inbuf_head + 1) & INBUF_MASK;
- if (new_head != inbuf_reap) {
- inbuf[inbuf_head] = *buf++;
- inbuf_head = new_head;
- } else {
- term_out();
- if( inbuf_head == inbuf_reap ) len++; else break;
- }
- }
-}
-
static void log_option (char *sender, int cmd, int option) {
char buf[50];
sprintf(buf, "%s:\t%s %s", sender,
} telnet_state = TOPLEVEL;
static void do_telnet_read (char *buf, int len) {
- unsigned char b[10];
while (len--) {
int c = (unsigned char) *buf++;
else if (c == IAC)
telnet_state = SEENIAC;
else {
- b[0] = c;
if (!in_synch)
- c_write (b, 1);
+ c_write1(c);
#if 1
/* I can't get the F***ing winsock to insert the urgent IAC
else {
/* ignore everything else; print it if it's IAC */
if (c == IAC) {
- b[0] = c;
- c_write(b,1);
+ c_write1(c);
}
telnet_state = TOPLEVEL;
}
char *newbuf;
sb_size += SB_DELTA;
newbuf = (sb_buf ?
- realloc(sb_buf, sb_size) :
- malloc(sb_size));
+ srealloc(sb_buf, sb_size) :
+ smalloc(sb_size));
if (newbuf)
sb_buf = newbuf;
else
default: return "connect(): unknown error";
}
- if (WSAAsyncSelect (s, hwnd, WM_NETEVENT, FD_READ |
+ if (hwnd && WSAAsyncSelect (s, hwnd, WM_NETEVENT, FD_READ |
FD_WRITE | FD_OOB | FD_CLOSE) == SOCKET_ERROR)
switch (WSAGetLastError()) {
case WSAENETDOWN: return "Network is down";
*/
static int telnet_msg (WPARAM wParam, LPARAM lParam) {
int ret;
- char buf[256];
+ /* This needs to be larger than the packet size now that inbuf
+ * cannot overflow, in fact the fewer calls we make to windows
+ * the faster we will run!
+ */
+ char buf[16384];
/*
* Because reading less than the whole of the available pending
s = INVALID_SOCKET;
return 0;
}
-
do_telnet_read (buf, ret);
} while (in_synch);
}
}
}
+static SOCKET telnet_socket(void) { return s; }
+
+static int telnet_sendok(void) { return 1; }
+
Backend telnet_backend = {
telnet_init,
telnet_msg,
telnet_send,
telnet_size,
- telnet_special
+ telnet_special,
+ telnet_socket,
+ telnet_sendok
};