--- lbbs/src/netio.c 2005/03/20 17:37:14 1.4 +++ lbbs/src/netio.c 2005/03/22 08:59:32 1.5 @@ -86,3 +86,76 @@ s_send (int socket, const char *in_str) return ret; } + +// from Maple-hightman +// added by flyriver, 2001.3.3 +int +telnetopt (int fd, char *buf, int max) +{ + unsigned char c, d, e; + int pp = 0; + unsigned char tmp[30]; + + while (pp < max) + { + c = buf[pp++]; + if (c == 255) + { + d = buf[pp++]; + e = buf[pp++]; + iflush (); + if ((d == 253) && (e == 3 || e == 24)) + { + tmp[0] = 255; + tmp[1] = 251; + tmp[2] = e; + write (fd, tmp, 3); + continue; + } + if ((d == 251 || d == 252) && (e == 1 || e == 3 || e == 24)) + { + tmp[0] = 255; + tmp[1] = 253; + tmp[2] = e; + write (fd, tmp, 3); + continue; + } + if (d == 251 || d == 252) + { + tmp[0] = 255; + tmp[1] = 254; + tmp[2] = e; + write (fd, tmp, 3); + continue; + } + if (d == 253 || d == 254) + { + tmp[0] = 255; + tmp[1] = 252; + tmp[2] = e; + write (fd, tmp, 3); + continue; + } + if (d == 250) + { + while (e != 240 && pp < max) + e = buf[pp++]; + tmp[0] = 255; + tmp[1] = 250; + tmp[2] = 24; + tmp[3] = 0; + tmp[4] = 65; + tmp[5] = 78; + tmp[6] = 83; + tmp[7] = 73; + tmp[8] = 255; + tmp[9] = 240; + write (fd, tmp, 10); + } + } + else + outc (c); + } + iflush (); + return 0; +}