15 static Socket s
= NULL
;
17 static void rlogin_size(void);
19 static int sb_opt
, sb_len
;
20 static char *sb_buf
= NULL
;
21 static int sb_size
= 0;
24 static void c_write (char *buf
, int len
) {
25 from_backend(0, buf
, len
);
28 static int rlogin_receive (Socket skt
, int urgent
, char *data
, int len
) {
30 /* A socket error has occurred. */
33 connection_fatal(data
);
36 /* Connection has closed. */
48 * We should flush everything (aka Telnet SYNCH) if we see
49 * 0x02, and we should turn off and on _local_ flow control
50 * on 0x10 and 0x20 respectively. I'm not convinced it's
55 * Main rlogin protocol. This is really simple: the first
56 * byte is expected to be NULL and is ignored, and the rest
59 static int firstbyte
= 1;
61 if (data
[0] == '\0') {
73 * Called to set up the rlogin connection.
75 * Returns an error message, or NULL on success.
77 * Also places the canonical host name into `realhost'.
79 static char *rlogin_init (char *host
, int port
, char **realhost
) {
86 addr
= sk_namelookup(host
, realhost
);
87 if ( (err
= sk_addr_error(addr
)) )
91 port
= 513; /* default rlogin port */
96 s
= sk_new(addr
, port
, 1, 0, rlogin_receive
);
97 if ( (err
= sk_socket_error(s
)) )
103 * Send local username, remote username, terminal/speed
110 sk_write(s
, cfg
.localusername
, strlen(cfg
.localusername
));
112 sk_write(s
, cfg
.username
, strlen(cfg
.username
));
114 sk_write(s
, cfg
.termtype
, strlen(cfg
.termtype
));
116 for(p
= cfg
.termspeed
; isdigit(*p
); p
++);
117 sk_write(s
, cfg
.termspeed
, p
- cfg
.termspeed
);
125 * Called to send data down the rlogin connection.
127 static void rlogin_send (char *buf
, int len
) {
132 sk_write(s
, buf
, len
);
136 * Called to set the size of the window
138 static void rlogin_size(void) {
139 char b
[12] = { '\xFF', '\xFF', 0x73, 0x73, 0, 0, 0, 0, 0, 0, 0, 0 };
141 b
[6] = cols
>> 8; b
[7] = cols
& 0xFF;
142 b
[4] = rows
>> 8; b
[5] = rows
& 0xFF;
148 * Send rlogin special codes.
150 static void rlogin_special (Telnet_Special code
) {
155 static Socket
rlogin_socket(void) { return s
; }
157 static int rlogin_sendok(void) { return 1; }
159 static int rlogin_ldisc(int option
) {
163 Backend rlogin_backend
= {