Diff for /libaitcli/src/aitcli.c between versions 1.1.1.1.2.10 and 1.1.1.1.2.12

version 1.1.1.1.2.10, 2010/04/28 11:23:56 version 1.1.1.1.2.12, 2010/04/28 15:27:55
Line 27  char cli_Error[STRSIZ]; Line 27  char cli_Error[STRSIZ];
 #pragma GCC visibility pop  #pragma GCC visibility pop
   
   
   #ifdef NULL_PREP_TERM
   
 static void cli_Null_Prep_Term(int meta)  static void cli_Null_Prep_Term(int meta)
 {  {
 }  }
   
   #endif
   
   
 // cli_GetErrno() Get error code of last operation  // cli_GetErrno() Get error code of last operation
 inline int cli_GetErrno()  inline int cli_GetErrno()
 {  {
Line 149  inline int cli_WriteHistory(const char *csFile, int li Line 153  inline int cli_WriteHistory(const char *csFile, int li
 }  }
   
 /*  /*
  * cliInit() Initialize Readline  
  * @csProg = program name  
  * return: none  
 */  
 inline void cliInit(const char *csProg)  
 {  
         rl_readline_name = csProg;  
   
         rl_variable_bind("editing-mode", "emacs");  
 }  
   
 /*  
  * cliNetInit() Initialize Readline if CLI bind to socket   * cliNetInit() Initialize Readline if CLI bind to socket
  * @csProg = program name   * @csProg = program name
  * @pty = Master pty   * @pty = Master pty
Line 192  void cliNetInit(const char *csProg, int pty, struct te Line 184  void cliNetInit(const char *csProg, int pty, struct te
   
         ioctl(pty, TIOCPKT, &on);          ioctl(pty, TIOCPKT, &on);
   
        cliInit(csProg);        rl_readline_name = csProg;
         rl_variable_bind("editing-mode", "emacs");
 
 #ifdef NULL_PREP_TERM
         rl_instream = fdopen(pty, "r");          rl_instream = fdopen(pty, "r");
   #endif
 }  }
   
 /*  /*
Line 211  int cliNetExec(cliCommands_t *cmdList, const char *csP Line 207  int cliNetExec(cliCommands_t *cmdList, const char *csP
         fd_set fds;          fd_set fds;
         struct timeval tv = { DEFAULT_SOCK_TIMEOUT, 0 };          struct timeval tv = { DEFAULT_SOCK_TIMEOUT, 0 };
         u_char buf[BUFSIZ];          u_char buf[BUFSIZ];
        struct telnetAttrs *a, Attr[5];        struct telnetAttrs *a, Attr[10];
         register int i;          register int i;
   
         switch (forkpty(&pty, NULL, term, win)) {          switch (forkpty(&pty, NULL, term, win)) {
Line 221  int cliNetExec(cliCommands_t *cmdList, const char *csP Line 217  int cliNetExec(cliCommands_t *cmdList, const char *csP
                 case 0:                  case 0:
                         close(sock);                          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);                          cliNetInit(getprogname(), STDIN_FILENO, term);
 //                      cliInit(getprogname());  
                         cliTTY(NULL, NULL, NULL, win);                          cliTTY(NULL, NULL, NULL, win);
 //                      ret = cliExec(cmdList, csPrompt) < 0 ? 1 : 0;  //                      ret = cliExec(cmdList, csPrompt) < 0 ? 1 : 0;
                         execl("/bin/tcsh", "tcsh", NULL);                          execl("/bin/tcsh", "tcsh", NULL);
                         _exit(ret);                          _exit(ret);
                 default:                  default:
                         cliNetInit(getprogname(), pty, term);  
   
                         telnet_SetCmd(Attr, DO, TELOPT_TTYPE);                          telnet_SetCmd(Attr, DO, TELOPT_TTYPE);
                        telnet_SetCmd(Attr + 1, WILL, TELOPT_SGA);                        telnet_SetCmd(Attr + 1, DO, TELOPT_LFLOW);
                        telnet_SetCmd(Attr + 2, DO, TELOPT_LINEMODE);                        telnet_Set_SubOpt(Attr + 2, TELOPT_LFLOW, LFLOW_OFF, NULL, 0);
                        telnet_Set_SubOpt(Attr + 3, TELOPT_LINEMODE, LM_MODE, "\x0", 1);                        telnet_SetCmd(Attr + 3, DO, TELOPT_BINARY);
                        if ((ret = telnetSend(sock, Attr, 4, NULL, 0, 0)) == -1) {                        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();                                  cli_Errno = telnet_GetErrno();
                                 strlcpy(cli_Error, telnet_GetError(), STRSIZ);                                  strlcpy(cli_Error, telnet_GetError(), STRSIZ);
                                 return -1;                                  return -1;
Line 274  int cliNetExec(cliCommands_t *cmdList, const char *csP Line 278  int cliNetExec(cliCommands_t *cmdList, const char *csP
                                 for (attrlen = i = 0; i < alen; i++) {                                  for (attrlen = i = 0; i < alen; i++) {
                                         if (TELOPT_TTYPE == a[i].ta_opt && WILL == a[i].ta_cmd)                                          if (TELOPT_TTYPE == a[i].ta_opt && WILL == a[i].ta_cmd)
                                                 telnet_Set_SubOpt(&Attr[attrlen++], TELOPT_TTYPE, TELQUAL_SEND, NULL, 0);                                                  telnet_Set_SubOpt(&Attr[attrlen++], TELOPT_TTYPE, TELQUAL_SEND, NULL, 0);
   #ifdef TELNET_LINEMODE_ENABLE
                                         if (TELOPT_LINEMODE == a[i].ta_cmd && SB == a[i].ta_cmd) {                                          if (TELOPT_LINEMODE == a[i].ta_cmd && SB == a[i].ta_cmd) {
                                                 telnet_Set_SubOpt(&Attr[attrlen++], TELOPT_LINEMODE, LM_SLC,                                                   telnet_Set_SubOpt(&Attr[attrlen++], TELOPT_LINEMODE, LM_SLC, 
                                                                 "\x1\x0\x0\x3\xe2\x3\x4\x0\x0\x5\x0\x0\x7\xe2\x1c"                                                                  "\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"                                                                  "\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);                                                                  "\xd\x82\x12\xe\x82\x16\xf\x82\x11\x10\x82\x13", 42);
                                         }                                          }
   #endif
                                 }                                  }
                                 if (a)                                  if (a)
                                         free(a);                                          free(a);
   
                                   /*
                                   if (s == sock && ret > 2 && 0x1b == buf[0] && 0x5b == buf[1]) {
                                           memmove(buf, buf + 3, ret);
                                           ret -= 3;
                                   }
                                   */
 #include "syslog.h"  #include "syslog.h"
                                 int j;                                  int j;
                                 for (j = 0; j < ret; j++)                                  for (j = 0; j < ret; j++)
                                         syslog(LOG_CRIT, "prepare to send %d = %X", j, buf[j]);                                          syslog(LOG_CRIT, "prepare to send %d = %X", j, buf[j]);
                                syslog(LOG_CRIT, "send packet %d ===========", ret);                                syslog(LOG_CRIT, "send packet %d === %s ========", ret, r == pty ? "pty -> sock" : "sock -> pty");
                                 if ((ret = telnetSend(s, Attr, attrlen, buf, ret, 0)) == -1) {                                  if ((ret = telnetSend(s, Attr, attrlen, buf, ret, 0)) == -1) {
                                         cli_Errno = telnet_GetErrno();                                          cli_Errno = telnet_GetErrno();
                                         strlcpy(cli_Error, telnet_GetError(), STRSIZ);                                          strlcpy(cli_Error, telnet_GetError(), STRSIZ);

Removed from v.1.1.1.1.2.10  
changed lines
  Added in v.1.1.1.1.2.12


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>