aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2014-07-14 22:31:04 -0400
committerFranklin Wei <frankhwei536@gmail.com>2014-07-14 22:31:04 -0400
commit3b104903087460158fd79c9cae27ada2d4dc103e (patch)
tree0d928355a981d37e2e72186828deebdae537150b /util.c
parentf10cfb8bd77327b73da570730dee794d83b5c6ad (diff)
downloadwargames-server-3b104903087460158fd79c9cae27ada2d4dc103e.zip
wargames-server-3b104903087460158fd79c9cae27ada2d4dc103e.tar.gz
wargames-server-3b104903087460158fd79c9cae27ada2d4dc103e.tar.bz2
wargames-server-3b104903087460158fd79c9cae27ada2d4dc103e.tar.xz
Added some features to telnet server
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/util.c b/util.c
index 9539b46..c27981a 100644
--- a/util.c
+++ b/util.c
@@ -69,6 +69,7 @@ void refresh(void)
}
int getnstr(char* buf, int max)
{
+ echo_on();
memset(buf, 0, max);
int ret=read(pipes[out_fd][0], buf, max);
if(ret!=0)
@@ -81,4 +82,17 @@ int getnstr(char* buf, int max)
if(ret<0)
return ERR;
return OK;
+ echo_off();
+}
+void echo_off(void)
+{
+ unsigned char echo_off[]={0xff, 254, 1};
+ write(out_fd, echo_off, 3);
+ fsync(out_fd);
+}
+void echo_on(void)
+{
+ unsigned char echo_on[]={0xff, 253, 1};
+ write(out_fd, echo_on, 3);
+ fsync(out_fd);
}