projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Extra diagnostics in the hope that we can track down the problem with
[u/mdw/putty]
/
rlogin.c
diff --git
a/rlogin.c
b/rlogin.c
index
c77f381
..
acb27c8
100644
(file)
--- a/
rlogin.c
+++ b/
rlogin.c
@@
-1,6
+1,7
@@
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
+#include <ctype.h>
#include "putty.h"
#include "putty.h"
@@
-24,23
+25,22
@@
static void c_write (char *buf, int len) {
from_backend(0, buf, len);
}
from_backend(0, buf, len);
}
-static int rlogin_receive (Socket s, int urgent, char *data, int len) {
- if (urgent==3) {
+static int rlogin_closing (Plug plug, char *error_msg, int error_code, int calling_back) {
+ sk_close(s);
+ s = NULL;
+ if (error_msg) {
/* A socket error has occurred. */
/* A socket error has occurred. */
- connection_fatal(data);
- len = 0;
- }
- if (!len) {
- /* Connection has closed. */
- sk_close(s);
- s = NULL;
- return 0;
- }
+ connection_fatal (error_msg);
+ } /* Otherwise, the remote side closed the connection normally. */
+ return 0;
+}
+
+static int rlogin_receive (Plug plug, int urgent, char *data, int len) {
if (urgent == 2) {
char c;
c = *data++; len--;
if (urgent == 2) {
char c;
c = *data++; len--;
- if (c ==
0x80
)
+ if (c ==
'\x80'
)
rlogin_size();
/*
* We should flush everything (aka Telnet SYNCH) if we see
rlogin_size();
/*
* We should flush everything (aka Telnet SYNCH) if we see
@@
-48,8
+48,22
@@
static int rlogin_receive (Socket s, int urgent, char *data, int len) {
* on 0x10 and 0x20 respectively. I'm not convinced it's
* worth it...
*/
* on 0x10 and 0x20 respectively. I'm not convinced it's
* worth it...
*/
+ } else {
+ /*
+ * Main rlogin protocol. This is really simple: the first
+ * byte is expected to be NULL and is ignored, and the rest
+ * is printed.
+ */
+ static int firstbyte = 1;
+ if (firstbyte) {
+ if (data[0] == '\0') {
+ data++;
+ len--;
+ }
+ firstbyte = 0;
+ }
+ c_write(data, len);
}
}
- c_write(data, len);
return 1;
}
return 1;
}
@@
-61,6
+75,11
@@
static int rlogin_receive (Socket s, int urgent, char *data, int len) {
* Also places the canonical host name into `realhost'.
*/
static char *rlogin_init (char *host, int port, char **realhost) {
* Also places the canonical host name into `realhost'.
*/
static char *rlogin_init (char *host, int port, char **realhost) {
+ static struct plug_function_table fn_table = {
+ rlogin_closing,
+ rlogin_receive
+ }, *fn_table_ptr = &fn_table;
+
SockAddr addr;
char *err;
SockAddr addr;
char *err;
@@
-77,7
+96,7
@@
static char *rlogin_init (char *host, int port, char **realhost) {
/*
* Open socket.
*/
/*
* Open socket.
*/
- s = sk_new(addr, port, 1,
rlogin_receive
);
+ s = sk_new(addr, port, 1,
0, &fn_table_ptr
);
if ( (err = sk_socket_error(s)) )
return err;
if ( (err = sk_socket_error(s)) )
return err;
@@
-102,8
+121,6
@@
static char *rlogin_init (char *host, int port, char **realhost) {
sk_write(s, &z, 1);
}
sk_write(s, &z, 1);
}
- begin_session();
-
return NULL;
}
return NULL;
}
@@
-142,6
+159,10
@@
static Socket rlogin_socket(void) { return s; }
static int rlogin_sendok(void) { return 1; }
static int rlogin_sendok(void) { return 1; }
+static int rlogin_ldisc(int option) {
+ return 0;
+}
+
Backend rlogin_backend = {
rlogin_init,
rlogin_send,
Backend rlogin_backend = {
rlogin_init,
rlogin_send,
@@
-149,5
+170,6
@@
Backend rlogin_backend = {
rlogin_special,
rlogin_socket,
rlogin_sendok,
rlogin_special,
rlogin_socket,
rlogin_sendok,
+ rlogin_ldisc,
1
};
1
};