14 static Socket s
= NULL
;
16 static void rlogin_size(void);
18 static int sb_opt
, sb_len
;
19 static char *sb_buf
= NULL
;
20 static int sb_size
= 0;
23 static void c_write (char *buf
, int len
) {
24 from_backend(0, buf
, len
);
27 static int rlogin_receive (Socket s
, int urgent
, char *data
, int len
) {
29 /* A socket error has occurred. */
30 connection_fatal(data
);
34 /* Connection has closed. */
46 * We should flush everything (aka Telnet SYNCH) if we see
47 * 0x02, and we should turn off and on _local_ flow control
48 * on 0x10 and 0x20 respectively. I'm not convinced it's
57 * Called to set up the rlogin connection.
59 * Returns an error message, or NULL on success.
61 * Also places the canonical host name into `realhost'.
63 static char *rlogin_init (char *host
, int port
, char **realhost
) {
70 addr
= sk_namelookup(host
, realhost
);
71 if ( (err
= sk_addr_error(addr
)) )
75 port
= 513; /* default rlogin port */
80 s
= sk_new(addr
, port
, 1, rlogin_receive
);
81 if ( (err
= sk_socket_error(s
)) )
87 * Send local username, remote username, terminal/speed
94 sk_write(s
, cfg
.localusername
, strlen(cfg
.localusername
));
96 sk_write(s
, cfg
.username
, strlen(cfg
.username
));
98 sk_write(s
, cfg
.termtype
, strlen(cfg
.termtype
));
100 for(p
= cfg
.termspeed
; isdigit(*p
); p
++);
101 sk_write(s
, cfg
.termspeed
, p
- cfg
.termspeed
);
109 * Called to send data down the rlogin connection.
111 static void rlogin_send (char *buf
, int len
) {
116 sk_write(s
, buf
, len
);
120 * Called to set the size of the window
122 static void rlogin_size(void) {
123 char b
[12] = { '\xFF', '\xFF', 0x73, 0x73, 0, 0, 0, 0, 0, 0, 0, 0 };
125 b
[6] = cols
>> 8; b
[7] = cols
& 0xFF;
126 b
[4] = rows
>> 8; b
[5] = rows
& 0xFF;
132 * Send rlogin special codes.
134 static void rlogin_special (Telnet_Special code
) {
139 static Socket
rlogin_socket(void) { return s
; }
141 static int rlogin_sendok(void) { return 1; }
143 static int rlogin_ldisc(int option
) {
147 Backend rlogin_backend
= {