/*
* NAME: telnet.c
* DESCRIPTION: connection object specialized for telnet connections
*/
inherit "/std/connection";
# include <moo/errors.h>
private int flags; /* special telnet flags */
# define F_NOECHO 0x01 /* telnet noecho option enabled? */
/*
* NAME: send()
* DESCRIPTION: called to send a partial line to the user (raw data)
*/
void send(string msg)
{
send_message(msg);
}
/*
* NAME: notify()
* DESCRIPTION: called to send a single line of text to the user
*/
void notify(string msg)
{
send_message(msg + "\n");
}
/*
* NAME: receive_message()
* DESCRIPTION: called by DGD when a line of input is received
*/
static
void receive_message(string line)
{
if (flags & F_NOECHO)
{
send_message(1);
notify("");
flags &= ~F_NOECHO;
}
if (want_binary())
process_data(line);
else
process_line(line);
finish();
}
/*
* NAME: set_noecho()
* DESCRIPTION: enable telnet noecho option
*/
int set_noecho(void)
{
send_message(0);
flags |= F_NOECHO;
return E_NONE;
}