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 skt
, int urgent
, char *data
, int len
) {
29 /* A socket error has occurred. */
32 connection_fatal(data
);
35 /* Connection has closed. */
47 * We should flush everything (aka Telnet SYNCH) if we see
48 * 0x02, and we should turn off and on _local_ flow control
49 * on 0x10 and 0x20 respectively. I'm not convinced it's
54 * Main rlogin protocol. This is really simple: the first
55 * byte is expected to be NULL and is ignored, and the rest
58 static int firstbyte
= 1;
60 if (data
[0] == '\0') {
72 * Called to set up the rlogin connection.
74 * Returns an error message, or NULL on success.
76 * Also places the canonical host name into `realhost'.
78 static char *rlogin_init (char *host
, int port
, char **realhost
) {
85 addr
= sk_namelookup(host
, realhost
);
86 if ( (err
= sk_addr_error(addr
)) )
90 port
= 513; /* default rlogin port */
95 s
= sk_new(addr
, port
, 1, 0, rlogin_receive
);
96 if ( (err
= sk_socket_error(s
)) )
102 * Send local username, remote username, terminal/speed
109 sk_write(s
, cfg
.localusername
, strlen(cfg
.localusername
));
111 sk_write(s
, cfg
.username
, strlen(cfg
.username
));
113 sk_write(s
, cfg
.termtype
, strlen(cfg
.termtype
));
115 for(p
= cfg
.termspeed
; isdigit(*p
); p
++);
116 sk_write(s
, cfg
.termspeed
, p
- cfg
.termspeed
);
124 * Called to send data down the rlogin connection.
126 static void rlogin_send (char *buf
, int len
) {
131 sk_write(s
, buf
, len
);
135 * Called to set the size of the window
137 static void rlogin_size(void) {
138 char b
[12] = { '\xFF', '\xFF', 0x73, 0x73, 0, 0, 0, 0, 0, 0, 0, 0 };
140 b
[6] = cols
>> 8; b
[7] = cols
& 0xFF;
141 b
[4] = rows
>> 8; b
[5] = rows
& 0xFF;
147 * Send rlogin special codes.
149 static void rlogin_special (Telnet_Special code
) {
154 static Socket
rlogin_socket(void) { return s
; }
156 static int rlogin_sendok(void) { return 1; }
158 static int rlogin_ldisc(int option
) {
162 Backend rlogin_backend
= {