- char buf[256];
- switch (SB_GET()) {
- case TELOPT_TTYPE:
- if (TFLAG_ISSET(TELOPT_TTYPE, WONT)) return;
- if (SB_EOF() || SB_GET() != TELQUAL_SEND) {
- return;
- } else {
- const char *name = getenv("TERM");
- if (name) {
- snprintf(buf, sizeof(buf), "%c%c%c%c%s%c%c", IAC, SB,
- TELOPT_TTYPE, TELQUAL_IS, name, IAC, SE);
- write(net, buf, strlen(name)+6);
- }
- }
- break;
- case TELOPT_TSPEED:
- if (TFLAG_ISSET(TELOPT_TSPEED, WONT)) return;
- if (SB_EOF()) return;
- if (SB_GET() == TELQUAL_SEND) {
- /*
- long oospeed, iispeed;
- netoring.printf("%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED,
- TELQUAL_IS, oospeed, iispeed, IAC, SE);
- */
- }
- break;
- /*
- case TELOPT_LFLOW:
- if (TFLAG_ISSET(TELOPT_LFLOW, WONT)) return;
- if (SB_EOF()) return;
- switch(SB_GET()) {
- case 1: localflow = 1; break;
- case 0: localflow = 0; break;
- default: return;
- }
- break;
- case TELOPT_LINEMODE:
- if (TFLAG_ISSET(TELOPT_LINEMODE, WONT)) return;
- if (SB_EOF()) return;
- switch (SB_GET()) {
- case WILL: lm_will(subpointer, SB_LEN()); break;
- case WONT: lm_wont(subpointer, SB_LEN()); break;
- case DO: lm_do(subpointer, SB_LEN()); break;
- case DONT: lm_dont(subpointer, SB_LEN()); break;
- case LM_SLC: slc(subpointer, SB_LEN()); break;
- case LM_MODE: lm_mode(subpointer, SB_LEN(), 0); break;
- default: break;
- }
- break;
- case TELOPT_ENVIRON:
- if (SB_EOF()) return;
- switch(SB_PEEK()) {
- case TELQUAL_IS:
- case TELQUAL_INFO:
- if (TFLAG_ISSET(TELOPT_ENVIRON, DONT)) return;
- break;
- case TELQUAL_SEND:
- if (TFLAG_ISSET(TELOPT_ENVIRON, WONT)) return;
- break;
- default:
- return;
- }
- env_opt(subpointer, SB_LEN());
- break;
- */
- case TELOPT_XDISPLOC:
- if (TFLAG_ISSET(TELOPT_XDISPLOC, WONT)) return;
- if (SB_EOF()) return;
- if (SB_GET() == TELQUAL_SEND) {
- const char *dp = getenv("DISPLAY");
- if (dp) {
- snprintf(buf, sizeof(buf), "%c%c%c%c%s%c%c", IAC, SB,
- TELOPT_XDISPLOC, TELQUAL_IS, dp, IAC, SE);
- write(net, buf, strlen(dp)+6);
- }
- }
- break;
- default:
- break;
+ cookmode();
+ exit(ev);
+}
+
+static void conescape(void)
+{
+ char b;
+
+ if (G.gotsig) /* came from line mode... go raw */
+ rawmode();
+
+ WriteCS(1, "\r\nConsole escape. Commands are:\r\n\n"
+ " l go to line mode\r\n"
+ " c go to character mode\r\n"
+ " z suspend telnet\r\n"
+ " e exit telnet\r\n");
+
+ if (read(0, &b, 1) <= 0)
+ doexit(1);
+
+ switch (b)
+ {
+ case 'l':
+ if (!G.gotsig)
+ {
+ do_linemode();
+ goto rrturn;
+ }
+ break;
+ case 'c':
+ if (G.gotsig)
+ {
+ will_charmode();
+ goto rrturn;
+ }
+ break;
+ case 'z':
+ cookmode();
+ kill(0, SIGTSTP);
+ rawmode();
+ break;
+ case 'e':
+ doexit(0);