--- libaitcli/src/aitcli.c 2010/04/28 13:54:45 1.1.1.1.2.11 +++ libaitcli/src/aitcli.c 2010/04/28 15:27:55 1.1.1.1.2.12 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcli.c,v 1.1.1.1.2.11 2010/04/28 13:54:45 misho Exp $ +* $Id: aitcli.c,v 1.1.1.1.2.12 2010/04/28 15:27:55 misho Exp $ * *************************************************************************/ #include "global.h" @@ -207,7 +207,7 @@ int cliNetExec(cliCommands_t *cmdList, const char *csP fd_set fds; struct timeval tv = { DEFAULT_SOCK_TIMEOUT, 0 }; u_char buf[BUFSIZ]; - struct telnetAttrs *a, Attr[5]; + struct telnetAttrs *a, Attr[10]; register int i; switch (forkpty(&pty, NULL, term, win)) { @@ -217,7 +217,9 @@ int cliNetExec(cliCommands_t *cmdList, const char *csP case 0: close(sock); -// rl_prep_term_function = cli_Null_Prep_Term; +#ifdef NULL_PREP_TERM + rl_prep_term_function = cli_Null_Prep_Term; +#endif cliNetInit(getprogname(), STDIN_FILENO, term); cliTTY(NULL, NULL, NULL, win); @@ -226,11 +228,19 @@ int cliNetExec(cliCommands_t *cmdList, const char *csP _exit(ret); default: telnet_SetCmd(Attr, DO, TELOPT_TTYPE); - telnet_SetCmd(Attr + 1, WILL, TELOPT_SGA); - telnet_SetCmd(Attr + 2, DO, TELOPT_LFLOW); - telnet_SetCmd(Attr + 3, DO, TELOPT_LINEMODE); - telnet_Set_SubOpt(Attr + 4, TELOPT_LINEMODE, LM_MODE, "\x0", 1); - if ((ret = telnetSend(sock, Attr, 5, NULL, 0, 0)) == -1) { + telnet_SetCmd(Attr + 1, DO, TELOPT_LFLOW); + telnet_Set_SubOpt(Attr + 2, TELOPT_LFLOW, LFLOW_OFF, NULL, 0); + telnet_SetCmd(Attr + 3, DO, TELOPT_BINARY); + telnet_SetCmd(Attr + 4, DO, TELOPT_NAWS); + telnet_SetCmd(Attr + 5, DO, TELOPT_STATUS); + telnet_SetCmd(Attr + 6, DONT, TELOPT_ECHO); +#ifdef TELNET_LINEMODE_ENABLE + telnet_SetCmd(Attr + 7, DO, TELOPT_LINEMODE); + telnet_Set_SubOpt(Attr + 8, TELOPT_LINEMODE, LM_MODE, "\x0", 1); + if ((ret = telnetSend(sock, Attr, 9, NULL, 0, 0)) == -1) { +#else + if ((ret = telnetSend(sock, Attr, 7, NULL, 0, 0)) == -1) { +#endif cli_Errno = telnet_GetErrno(); strlcpy(cli_Error, telnet_GetError(), STRSIZ); return -1; @@ -268,13 +278,14 @@ int cliNetExec(cliCommands_t *cmdList, const char *csP for (attrlen = i = 0; i < alen; i++) { if (TELOPT_TTYPE == a[i].ta_opt && WILL == a[i].ta_cmd) telnet_Set_SubOpt(&Attr[attrlen++], TELOPT_TTYPE, TELQUAL_SEND, NULL, 0); - // if (TELOPT_LINEMODE == a[i].ta_opt && WILL == a[i].ta_cmd) +#ifdef TELNET_LINEMODE_ENABLE if (TELOPT_LINEMODE == a[i].ta_cmd && SB == a[i].ta_cmd) { telnet_Set_SubOpt(&Attr[attrlen++], TELOPT_LINEMODE, LM_SLC, "\x1\x0\x0\x3\xe2\x3\x4\x0\x0\x5\x0\x0\x7\xe2\x1c" "\x8\x82\x4\x9\x0\x0\xa\x82\x7f\xb\x82\x15\xc\x82\x17" "\xd\x82\x12\xe\x82\x16\xf\x82\x11\x10\x82\x13", 42); } +#endif } if (a) free(a);