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

Diff for /src/usr.bin/telnet/commands.c between version 1.67 and 1.68

version 1.67, 2014/07/20 10:55:26 version 1.68, 2014/07/20 12:08:55
Line 48 
Line 48 
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   
   #ifdef SKEY
   #include <sys/wait.h>
   #define PATH_SKEY       "/usr/bin/skey"
   #endif
   
   static unsigned long sourceroute(char *arg, char **cpp, int *lenp);
   
 int tos = -1;  int tos = -1;
   
 char    *hostname;  char    *hostname;
   
 typedef int (*intrtn_t)(int, char**);  
 static int call(intrtn_t, ...);  
 static unsigned long sourceroute(char *arg, char **cpp, int *lenp);  
   
 typedef struct {  typedef struct {
         char    *name;          /* command name */          char    *name;          /* command name */
         char    *help;          /* help string (NULL for no help) */          char    *help;          /* help string (NULL for no help) */
Line 68 
Line 71 
 static int margc;  static int margc;
 static char *margv[20];  static char *margv[20];
   
 #if     defined(SKEY)  #ifdef SKEY
 #include <sys/wait.h>  
 #define PATH_SKEY       "/usr/bin/skey"  
     int      int
 skey_calc(argc, argv)  skey_calc(argc, argv)
         int argc;          int argc;
Line 994 
Line 995 
  * 'mode' command.   * 'mode' command.
  */   */
 #ifdef  KLUDGELINEMODE  #ifdef  KLUDGELINEMODE
 extern int kludgelinemode;  
   
     static int      static int
 dokludgemode()  dokludgemode()
 {  {
Line 1037 
Line 1036 
     int bit, on;      int bit, on;
 {  {
     unsigned char c;      unsigned char c;
     extern int linemode;  
   
     if (my_want_state_is_wont(TELOPT_LINEMODE)) {      if (my_want_state_is_wont(TELOPT_LINEMODE)) {
         printf("?Need to have LINEMODE option enabled first.\r\n");          printf("?Need to have LINEMODE option enabled first.\r\n");
Line 1332 
Line 1330 
     return 1;      return 1;
 }  }
   
     static int  static void
   close_connection(void)
   {
           if (connected) {
                   (void) shutdown(net, 2);
                   printf("Connection closed.\r\n");
                   (void)close(net);
                   connected = 0;
                   resettermname = 1;
                   /* reset options */
                   tninit();
           }
   }
   
   static int
 bye(argc, argv)  bye(argc, argv)
     int  argc;          /* Number of arguments */      int  argc;          /* Number of arguments */
     char *argv[];       /* arguments */      char *argv[];       /* arguments */
 {  {
     extern int resettermname;          close_connection();
   
     if (connected) {  
         (void) shutdown(net, 2);  
         printf("Connection closed.\r\n");  
         (void)close(net);  
         connected = 0;  
         resettermname = 1;  
         /* reset options */  
         tninit();  
     }  
     if ((argc != 2) || (strcmp(argv[1], "fromquit") != 0))  
         longjmp(toplevel, 1);          longjmp(toplevel, 1);
     return 0;  
 }  }
   
 void  void
 quit(void)  quit(void)
 {  {
         (void) call(bye, "bye", "fromquit", 0);          close_connection();
         Exit(0);          Exit(0);
 }  }
   
Line 1758 
Line 1758 
         return(NULL);          return(NULL);
 }  }
   
 /*  static void
  * Print status about the connection.  connection_status(int local_only)
  */  
     static int  
 status(argc, argv)  
     int  argc;  
     char *argv[];  
 {  {
     if (connected) {          if (!connected)
         printf("Connected to %s.\r\n", hostname);                  printf("No connection.\r\n");
         if ((argc < 2) || strcmp(argv[1], "notmuch")) {          else {
             int mode = getconnmode();                  printf("Connected to %s.\r\n", hostname);
                   if (!local_only) {
                           int mode = getconnmode();
   
             if (my_want_state_is_will(TELOPT_LINEMODE)) {                          printf("Operating ");
                 printf("Operating with LINEMODE option\r\n");                          if (my_want_state_is_will(TELOPT_LINEMODE)) {
                 printf("%s line editing\r\n", (mode&MODE_EDIT) ? "Local" : "No");                                  printf("with LINEMODE option\r\n"
                 printf("%s catching of signals\r\n",                                      "%s line editing\r\n"
                                         (mode&MODE_TRAPSIG) ? "Local" : "No");                                      "%s catching of signals\r\n",
                 slcstate();                                      (mode & MODE_EDIT) ? "Local" : "No",
                                       (mode & MODE_TRAPSIG) ? "Local" : "No");
                                   slcstate();
 #ifdef  KLUDGELINEMODE  #ifdef  KLUDGELINEMODE
             } else if (kludgelinemode && my_want_state_is_dont(TELOPT_SGA)) {                          } else if (kludgelinemode &&
                 printf("Operating in obsolete linemode\r\n");                              my_want_state_is_dont(TELOPT_SGA)) {
                                   printf("in obsolete linemode\r\n");
 #endif  #endif
             } else {                          } else {
                 printf("Operating in single character mode\r\n");                                  printf("in single character mode\r\n");
                 if (localchars)                                  if (localchars)
                     printf("Catching signals locally\r\n");                                          printf("Catching signals locally\r\n");
             }                          }
             printf("%s character echo\r\n", (mode&MODE_ECHO) ? "Local" : "Remote");  
             if (my_want_state_is_will(TELOPT_LFLOW))                          printf("%s character echo\r\n",
                 printf("%s flow control\r\n", (mode&MODE_FLOW) ? "Local" : "No");                              (mode & MODE_ECHO) ? "Local" : "Remote");
                           if (my_want_state_is_will(TELOPT_LFLOW))
                                   printf("%s flow control\r\n",
                                       (mode & MODE_FLOW) ? "Local" : "No");
                   }
         }          }
     } else {          printf("Escape character is '%s'.\r\n", control(escape));
         printf("No connection.\r\n");          (void) fflush(stdout);
     }  
     printf("Escape character is '%s'.\r\n", control(escape));  
     (void) fflush(stdout);  
     fflush(stdout);  
     return 1;  
 }  }
   
   /*
    * Print status about the connection.
    */
   static int
   status(int argc, char *argv[])
   {
           connection_status(0);
           return 1;
   }
   
 #ifdef  SIGINFO  #ifdef  SIGINFO
 /*  /*
  * Function that gets called when SIGINFO is received.   * Function that gets called when SIGINFO is received.
  */   */
 void  void
 ayt_status()  ayt_status(int sig)
 {  {
     (void) call(status, "status", "notmuch", 0);          connection_status(1);
 }  }
 #endif  #endif
   
Line 2113 
Line 2122 
         env_define((unsigned char *)"USER", (unsigned char *)user);          env_define((unsigned char *)"USER", (unsigned char *)user);
         env_export((unsigned char *)"USER");          env_export((unsigned char *)"USER");
     }      }
     (void) call(status, "status", "notmuch", 0);      connection_status(1);
     if (setjmp(peerdied) == 0)      if (setjmp(peerdied) == 0)
         telnet(user);          telnet(user);
     (void)close(net);      (void)close(net);
Line 2163 
Line 2172 
         { "!",          shellhelp,      shell,          0 },          { "!",          shellhelp,      shell,          0 },
         { "environ",    envhelp,        env_cmd,        0 },          { "environ",    envhelp,        env_cmd,        0 },
         { "?",          helphelp,       help,           0 },          { "?",          helphelp,       help,           0 },
 #if     defined(SKEY)  #ifdef SKEY
         { "skey",       skeyhelp,       skey_calc,      0 },          { "skey",       skeyhelp,       skey_calc,      0 },
 #endif  #endif
         { 0,            0,              0,              0 }          { 0,            0,              0,              0 }
Line 2178 
Line 2187 
         { "crmod",      crmodhelp,      togcrmod,       0 },          { "crmod",      crmodhelp,      togcrmod,       0 },
         { 0,            0,              0,              0 }          { 0,            0,              0,              0 }
 };  };
   
   
 /*  
  * Call routine with argc, argv set from args (terminated by 0).  
  */  
   
     /*VARARGS1*/  
     static int  
 call(intrtn_t routine, ...)  
 {  
     va_list ap;  
     char *args[100];  
     int argno = 0;  
   
     va_start(ap, routine);  
     while ((args[argno++] = va_arg(ap, char *)) != 0);  
     va_end(ap);  
     return (*routine)(argno-1, args);  
 }  
   
   
     static Command *      static Command *

Legend:
Removed from v.1.67  
changed lines
  Added in v.1.68