&o_we_sga, &o_they_sga, NULL
};
+static int echoing = TRUE, editing = TRUE;
+
static int in_synch;
static int sb_opt, sb_len;
static char *sb_buf = NULL;
* Generate side effects of enabling or disabling an option.
*/
static void option_side_effects(struct Opt *o, int enabled) {
- if (o->option == TELOPT_ECHO && cfg.ldisc_term)
- ldisc = enabled ? &ldisc_simple : &ldisc_term;
+ if (o->option == TELOPT_ECHO && o->send == DO)
+ echoing = !enabled;
+ else if (o->option == TELOPT_SGA && o->send == DO)
+ editing = !enabled;
+ ldisc_send(NULL, 0); /* cause ldisc to notice the change */
}
static void activate_option (struct Opt *o) {
}
}
-static int telnet_receive(Socket s, int urgent, char *data, int len) {
+static int telnet_receive(Socket skt, int urgent, char *data, int len) {
if (urgent==3) {
/* A socket error has occurred. */
+ sk_close(s);
+ s = NULL;
connection_fatal(data);
- len = 0;
- }
- if (!len) {
+ return 0;
+ } else if (!len) {
/* Connection has closed. */
sk_close(s);
s = NULL;
return 0;
}
+ if(urgent) in_synch = TRUE;
do_telnet_read (data, len);
return 1;
}
/*
* Open socket.
*/
- s = sk_new(addr, port, 0, telnet_receive);
+ s = sk_new(addr, port, 0, 1, telnet_receive);
if ( (err = sk_socket_error(s)) )
return err;
/*
* Initialise option states.
*/
- if( cfg.ldisc_term )
- {
- struct Opt **o;
-
- for (o = opts; *o; o++)
- if ((*o)->state == REQUESTED)
- (*o)->state = INACTIVE;
- }
- else
{
struct Opt **o;
*/
in_synch = FALSE;
- /*
- * We have no pre-session phase.
- */
- begin_session();
-
return NULL;
}
static int telnet_sendok(void) { return 1; }
+static int telnet_ldisc(int option) {
+ if (option == LD_ECHO) return echoing;
+ if (option == LD_EDIT) return editing;
+ return FALSE;
+}
+
Backend telnet_backend = {
telnet_init,
telnet_send,
telnet_special,
telnet_socket,
telnet_sendok,
+ telnet_ldisc,
23
};