[BACK]Return to telnet.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / telnet

Diff for /src/usr.bin/telnet/telnet.c between version 1.28 and 1.29

version 1.28, 2014/07/20 10:55:26 version 1.29, 2014/07/22 07:30:24
Line 149 
Line 149 
  * Initialize telnet environment.   * Initialize telnet environment.
  */   */
   
     void  void
 init_telnet()  init_telnet(void)
 {  {
     env_init();      env_init();
   
Line 181 
Line 181 
  * is in disagreement as to what the current state should be.   * is in disagreement as to what the current state should be.
  */   */
   
     void  void
 send_do(c, init)  send_do(int c, int init)
     int c, init;  
 {  {
     if (init) {      if (init) {
         if (((do_dont_resp[c] == 0) && my_state_is_do(c)) ||          if (((do_dont_resp[c] == 0) && my_state_is_do(c)) ||
Line 197 
Line 196 
     printoption("SENT",DO, c);      printoption("SENT",DO, c);
 }  }
   
     void  void
 send_dont(c, init)  send_dont(int c, int init)
     int c, init;  
 {  {
     if (init) {      if (init) {
         if (((do_dont_resp[c] == 0) && my_state_is_dont(c)) ||          if (((do_dont_resp[c] == 0) && my_state_is_dont(c)) ||
Line 213 
Line 211 
     printoption("SENT", DONT, c);      printoption("SENT", DONT, c);
 }  }
   
     void  void
 send_will(c, init)  send_will(int c, int init)
     int c, init;  
 {  {
     if (init) {      if (init) {
         if (((will_wont_resp[c] == 0) && my_state_is_will(c)) ||          if (((will_wont_resp[c] == 0) && my_state_is_will(c)) ||
Line 229 
Line 226 
     printoption("SENT", WILL, c);      printoption("SENT", WILL, c);
 }  }
   
     void  void
 send_wont(c, init)  send_wont(int c, int init)
     int c, init;  
 {  {
     if (init) {      if (init) {
         if (((will_wont_resp[c] == 0) && my_state_is_wont(c)) ||          if (((will_wont_resp[c] == 0) && my_state_is_wont(c)) ||
Line 245 
Line 241 
     printoption("SENT", WONT, c);      printoption("SENT", WONT, c);
 }  }
   
   
 static void  static void
 willoption(option)  willoption(int option)
         int option;  
 {  {
         int new_state_ok = 0;          int new_state_ok = 0;
   
Line 301 
Line 295 
 }  }
   
 static void  static void
 wontoption(option)  wontoption(int option)
         int option;  
 {  {
         if (do_dont_resp[option]) {          if (do_dont_resp[option]) {
             --do_dont_resp[option];              --do_dont_resp[option];
Line 350 
Line 343 
 }  }
   
 static void  static void
 dooption(option)  dooption(int option)
         int option;  
 {  {
         int new_state_ok = 0;          int new_state_ok = 0;
   
Line 440 
Line 432 
 }  }
   
 static void  static void
 dontoption(option)  dontoption(int option)
         int option;  
 {  {
   
         if (will_wont_resp[option]) {          if (will_wont_resp[option]) {
Line 476 
Line 467 
 static char *name_unknown = "UNKNOWN";  static char *name_unknown = "UNKNOWN";
 static char *unknown[] = { NULL, NULL };  static char *unknown[] = { NULL, NULL };
   
         char **  char **
 mklist(buf, name)  mklist(char *buf, char *name)
         char *buf, *name;  
 {  {
         int n;          int n;
         char c, *cp, **argvp, *cp2, **argv, **avt;          char c, *cp, **argvp, *cp2, **argv, **avt;
Line 588 
Line 578 
                 return(unknown);                  return(unknown);
 }  }
   
         int  int
 is_unique(name, as, ae)  is_unique(char *name, char **as, char **ae)
         char *name, **as, **ae;  
 {  {
         char **ap;          char **ap;
         int n;          int n;
Line 604 
Line 593 
   
 int resettermname = 1;  int resettermname = 1;
   
         char *  char *
 gettermname()  gettermname(void)
 {  {
         char *tname;          char *tname;
         static char **tnamep = NULL;          static char **tnamep = NULL;
Line 633 
Line 622 
                 next = tnamep;                  next = tnamep;
         return(*next++);          return(*next++);
 }  }
   
 /*  /*
  * suboption()   * suboption()
  *   *
Line 647 
Line 637 
  *              Linemode   *              Linemode
  */   */
   
     static void  static void
 suboption()  suboption(void)
 {  {
     unsigned char subchar;      unsigned char subchar;
   
Line 812 
Line 802 
 static unsigned char str_lm[] = { IAC, SB, TELOPT_LINEMODE, 0, 0, IAC, SE };  static unsigned char str_lm[] = { IAC, SB, TELOPT_LINEMODE, 0, 0, IAC, SE };
   
 static void  static void
 lm_will(cmd, len)  lm_will(unsigned char *cmd, int len)
     unsigned char *cmd;  
     int len;  
 {  {
     if (len < 1) {      if (len < 1) {
 /*@*/   printf("lm_will: no command!!!\n");     /* Should not happen... */  /*@*/   printf("lm_will: no command!!!\n");     /* Should not happen... */
Line 835 
Line 823 
 }  }
   
 static void  static void
 lm_wont(cmd, len)  lm_wont(unsigned char *cmd, int len)
     unsigned char *cmd;  
     int len;  
 {  {
     if (len < 1) {      if (len < 1) {
 /*@*/   printf("lm_wont: no command!!!\n");     /* Should not happen... */  /*@*/   printf("lm_wont: no command!!!\n");     /* Should not happen... */
Line 852 
Line 838 
 }  }
   
 static void  static void
 lm_do(cmd, len)  lm_do(unsigned char *cmd, int len)
     unsigned char *cmd;  
     int len;  
 {  {
     if (len < 1) {      if (len < 1) {
 /*@*/   printf("lm_do: no command!!!\n");       /* Should not happen... */  /*@*/   printf("lm_do: no command!!!\n");       /* Should not happen... */
Line 875 
Line 859 
 }  }
   
 static void  static void
 lm_dont(cmd, len)  lm_dont(unsigned char *cmd, int len)
     unsigned char *cmd;  
     int len;  
 {  {
     if (len < 1) {      if (len < 1) {
 /*@*/   printf("lm_dont: no command!!!\n");     /* Should not happen... */  /*@*/   printf("lm_dont: no command!!!\n");     /* Should not happen... */
Line 895 
Line 877 
         IAC, SB, TELOPT_LINEMODE, LM_MODE, 0, IAC, SE          IAC, SB, TELOPT_LINEMODE, LM_MODE, 0, IAC, SE
 };  };
   
         void  void
 lm_mode(cmd, len, init)  lm_mode(unsigned char *cmd, int len, int init)
         unsigned char *cmd;  
         int len, init;  
 {  {
         if (len != 1)          if (len != 1)
                 return;                  return;
Line 938 
Line 918 
 static int slc_mode = SLC_EXPORT;  static int slc_mode = SLC_EXPORT;
   
 static void  static void
 slc_init()  slc_init(void)
 {  {
         struct spc *spcp;          struct spc *spcp;
   
Line 989 
Line 969 
   
 }  }
   
     void  void
 slcstate()  slcstate(void)
 {  {
     printf("Special characters are %s values\n",      printf("Special characters are %s values\n",
                 slc_mode == SLC_IMPORT ? "remote default" :                  slc_mode == SLC_IMPORT ? "remote default" :
Line 998 
Line 978 
                                          "remote");                                           "remote");
 }  }
   
     void  void
 slc_mode_export(int unused)  slc_mode_export(int unused)
 {  {
     slc_mode = SLC_EXPORT;      slc_mode = SLC_EXPORT;
Line 1006 
Line 986 
         slc_export();          slc_export();
 }  }
   
     void  void
 slc_mode_import(def)  slc_mode_import(int def)
     int def;  
 {  {
     slc_mode = def ? SLC_IMPORT : SLC_RVALUE;      slc_mode = def ? SLC_IMPORT : SLC_RVALUE;
     if (my_state_is_will(TELOPT_LINEMODE))      if (my_state_is_will(TELOPT_LINEMODE))
Line 1023 
Line 1002 
 };  };
   
 static void  static void
 slc_import(def)  slc_import(int def)
     int def;  
 {  {
     if (NETROOM() > sizeof(slc_import_val)) {      if (NETROOM() > sizeof(slc_import_val)) {
         if (def) {          if (def) {
Line 1039 
Line 1017 
 }  }
   
 static void  static void
 slc_export()  slc_export(void)
 {  {
     struct spc *spcp;      struct spc *spcp;
   
Line 1063 
Line 1041 
 }  }
   
 static void  static void
 slc(cp, len)  slc(unsigned char *cp, int len)
         unsigned char *cp;  
         int len;  
 {  {
         struct spc *spcp;          struct spc *spcp;
         int func,level;          int func,level;
Line 1132 
Line 1108 
                 setconnmode(1); /* set the  new character values */                  setconnmode(1); /* set the  new character values */
 }  }
   
     void  void
 slc_check()  slc_check(void)
 {  {
     struct spc *spcp;      struct spc *spcp;
   
Line 1156 
Line 1132 
 static unsigned char slc_reply[2 * SUBBUFSIZE];  static unsigned char slc_reply[2 * SUBBUFSIZE];
 static unsigned char *slc_replyp;  static unsigned char *slc_replyp;
   
         unsigned char  unsigned char
 slc_add(unsigned char ch)  slc_add(unsigned char ch)
 {  {
         if (slc_replyp == slc_reply + sizeof(slc_reply))          if (slc_replyp == slc_reply + sizeof(slc_reply))
Line 1165 
Line 1141 
 }  }
   
 static void  static void
 slc_start_reply()  slc_start_reply(void)
 {  {
         slc_replyp = slc_reply;          slc_replyp = slc_reply;
         slc_add(IAC);          slc_add(IAC);
Line 1175 
Line 1151 
 }  }
   
 static void  static void
 slc_add_reply(func, flags, value)  slc_add_reply(unsigned char func, unsigned char flags, cc_t value)
         unsigned char func;  
         unsigned char flags;  
         cc_t value;  
 {  {
         if (slc_replyp + 6 >= slc_reply + sizeof(slc_reply)) {          if (slc_replyp + 6 >= slc_reply + sizeof(slc_reply)) {
                 printf("slc_add_reply: not enough room\n");                  printf("slc_add_reply: not enough room\n");
Line 1193 
Line 1166 
 }  }
   
 static void  static void
 slc_end_reply()  slc_end_reply(void)
 {  {
     int len;      int len;
   
Line 1215 
Line 1188 
 }  }
   
 static int  static int
 slc_update()  slc_update(void)
 {  {
         struct spc *spcp;          struct spc *spcp;
         int need_update = 0;          int need_update = 0;
Line 1233 
Line 1206 
 }  }
   
 static void  static void
 env_opt(buf, len)  env_opt(unsigned char *buf, int len)
         unsigned char *buf;  
         int len;  
 {  {
         unsigned char *ep = 0, *epc = 0;          unsigned char *ep = 0, *epc = 0;
         int i;          int i;
Line 1286 
Line 1257 
 static unsigned char *opt_replyp;  static unsigned char *opt_replyp;
 static unsigned char *opt_replyend;  static unsigned char *opt_replyend;
   
         void  void
 opt_add(unsigned char ch)  opt_add(unsigned char ch)
 {  {
         if (opt_replyp == opt_replyend)          if (opt_replyp == opt_replyend)
                 return;                  return;
         *opt_replyp++ = ch;          *opt_replyp++ = ch;
 }  }
   
 static void  static void
 env_opt_start()  env_opt_start(void)
 {  {
         unsigned char *p;          unsigned char *p;
   
Line 1315 
Line 1287 
         opt_add(TELQUAL_IS);          opt_add(TELQUAL_IS);
 }  }
   
         void  void
 env_opt_start_info()  env_opt_start_info(void)
 {  {
         env_opt_start();          env_opt_start();
         if (opt_replyp)          if (opt_replyp)
             opt_replyp[-1] = TELQUAL_INFO;              opt_replyp[-1] = TELQUAL_INFO;
 }  }
   
         void  void
 env_opt_add(ep)  env_opt_add(unsigned char *ep)
         unsigned char *ep;  
 {  {
         unsigned char *vp, c;          unsigned char *vp, c;
   
Line 1394 
Line 1365 
         }          }
 }  }
   
         int  int
 opt_welldefined(ep)  opt_welldefined(char *ep)
         char *ep;  
 {  {
         if ((strcmp(ep, "USER") == 0) ||          if ((strcmp(ep, "USER") == 0) ||
             (strcmp(ep, "DISPLAY") == 0) ||              (strcmp(ep, "DISPLAY") == 0) ||
Line 1407 
Line 1377 
                 return(1);                  return(1);
         return(0);          return(0);
 }  }
         void  
 env_opt_end(emptyok)  void
         int emptyok;  env_opt_end(int emptyok)
 {  {
         int len;          int len;
   
Line 1431 
Line 1401 
   
   
   
     int  int
 telrcv()  telrcv(void)
 {  {
     int c;      int c;
     int scc;      int scc;
Line 1648 
Line 1618 
   
 static int bol = 1, local = 0;  static int bol = 1, local = 0;
   
     int  int
 rlogin_susp()  rlogin_susp(void)
 {  {
     if (local) {      if (local) {
         local = 0;          local = 0;
Line 1660 
Line 1630 
     return(0);      return(0);
 }  }
   
     static int  static int
 telsnd()  telsnd(void)
 {  {
     int tcc;      int tcc;
     int count;      int count;
Line 1810 
Line 1780 
  *   *
  */   */
   
   int
     int  Scheduler(int block)                    /* should we block in the select ? */
 Scheduler(block)  
     int block;                  /* should we block in the select ? */  
 {  {
                 /* One wants to be a bit careful about setting returnValue                  /* One wants to be a bit careful about setting returnValue
                  * to one, since a one implies we did some useful work,                   * to one, since a one implies we did some useful work,
Line 1866 
Line 1834 
 /*  /*
  * Select from tty and network...   * Select from tty and network...
  */   */
     void  void
 telnet(user)  telnet(char *user)
     char *user;  
 {  {
     sys_telnet_init();      sys_telnet_init();
   
Line 1916 
Line 1883 
  * character.   * character.
  */   */
   
     static char *  static char *
 nextitem(current)  nextitem(char *current)
     char *current;  
 {  {
     if ((*current&0xff) != IAC) {      if ((*current&0xff) != IAC) {
         return current+1;          return current+1;
Line 1964 
Line 1930 
  * us in any case.   * us in any case.
  */   */
   
     static void  static void
 netclear()  netclear(void)
 {  {
 #if     0       /* XXX */  #if     0       /* XXX */
     char *thisitem, *next;      char *thisitem, *next;
Line 2007 
Line 1973 
  * These routines add various telnet commands to the data stream.   * These routines add various telnet commands to the data stream.
  */   */
   
     static void  static void
 doflush()  doflush(void)
 {  {
     NET2ADD(IAC, DO);      NET2ADD(IAC, DO);
     NETADD(TELOPT_TM);      NETADD(TELOPT_TM);
Line 2019 
Line 1985 
     printoption("SENT", DO, TELOPT_TM);      printoption("SENT", DO, TELOPT_TM);
 }  }
   
     void  void
 xmitAO()  xmitAO(void)
 {  {
     NET2ADD(IAC, AO);      NET2ADD(IAC, AO);
     printoption("SENT", IAC, AO);      printoption("SENT", IAC, AO);
Line 2030 
Line 1996 
 }  }
   
   
     void  void
 xmitEL()  xmitEL(void)
 {  {
     NET2ADD(IAC, EL);      NET2ADD(IAC, EL);
     printoption("SENT", IAC, EL);      printoption("SENT", IAC, EL);
 }  }
   
     void  void
 xmitEC()  xmitEC(void)
 {  {
     NET2ADD(IAC, EC);      NET2ADD(IAC, EC);
     printoption("SENT", IAC, EC);      printoption("SENT", IAC, EC);
 }  }
   
   
     int  int
 dosynch()  dosynch(void)
 {  {
     netclear();                 /* clear the path to the network */      netclear();                 /* clear the path to the network */
     NETADD(IAC);      NETADD(IAC);
Line 2058 
Line 2024 
   
 int want_status_response = 0;  int want_status_response = 0;
   
     int  int
 get_status()  get_status(void)
 {  {
     unsigned char tmp[16];      unsigned char tmp[16];
     unsigned char *cp;      unsigned char *cp;
Line 2084 
Line 2050 
     return 1;      return 1;
 }  }
   
     void  void
 intp()  intp(void)
 {  {
     NET2ADD(IAC, IP);      NET2ADD(IAC, IP);
     printoption("SENT", IAC, IP);      printoption("SENT", IAC, IP);
Line 2098 
Line 2064 
     }      }
 }  }
   
     void  void
 sendbrk()  sendbrk(void)
 {  {
     NET2ADD(IAC, BREAK);      NET2ADD(IAC, BREAK);
     printoption("SENT", IAC, BREAK);      printoption("SENT", IAC, BREAK);
Line 2112 
Line 2078 
     }      }
 }  }
   
     void  void
 sendabort()  sendabort(void)
 {  {
     NET2ADD(IAC, ABORT);      NET2ADD(IAC, ABORT);
     printoption("SENT", IAC, ABORT);      printoption("SENT", IAC, ABORT);
Line 2126 
Line 2092 
     }      }
 }  }
   
     void  void
 sendsusp()  sendsusp(void)
 {  {
     NET2ADD(IAC, SUSP);      NET2ADD(IAC, SUSP);
     printoption("SENT", IAC, SUSP);      printoption("SENT", IAC, SUSP);
Line 2140 
Line 2106 
     }      }
 }  }
   
     void  void
 sendeof()  sendeof(void)
 {  {
     NET2ADD(IAC, xEOF);      NET2ADD(IAC, xEOF);
     printoption("SENT", IAC, xEOF);      printoption("SENT", IAC, xEOF);
 }  }
   
     void  void
 sendayt()  sendayt(void)
 {  {
     NET2ADD(IAC, AYT);      NET2ADD(IAC, AYT);
     printoption("SENT", IAC, AYT);      printoption("SENT", IAC, AYT);
Line 2158 
Line 2124 
  * Send a window size update to the remote system.   * Send a window size update to the remote system.
  */   */
   
     void  void
 sendnaws()  sendnaws(void)
 {  {
     long rows, cols;      long rows, cols;
     unsigned char tmp[16];      unsigned char tmp[16];
Line 2190 
Line 2156 
     }      }
 }  }
   
     void  void
 tel_enter_binary(rw)  tel_enter_binary(int rw)
     int rw;  
 {  {
     if (rw&1)      if (rw&1)
         send_do(TELOPT_BINARY, 1);          send_do(TELOPT_BINARY, 1);
Line 2200 
Line 2165 
         send_will(TELOPT_BINARY, 1);          send_will(TELOPT_BINARY, 1);
 }  }
   
     void  void
 tel_leave_binary(rw)  tel_leave_binary(int rw)
     int rw;  
 {  {
     if (rw&1)      if (rw&1)
         send_dont(TELOPT_BINARY, 1);          send_dont(TELOPT_BINARY, 1);

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29