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

Diff for /src/usr.bin/tip/Attic/cu.c between version 1.5 and 1.6

version 1.5, 2001/09/09 17:58:41 version 1.6, 2001/09/09 19:30:49
Line 42 
Line 42 
 #endif /* not lint */  #endif /* not lint */
   
 #include "tip.h"  #include "tip.h"
   #include <getopt.h>
   
 void    cleanup();  void    cleanup();
   void    cuusage();
   
 /*  /*
  * Botch the interface to look like cu's   * Botch the interface to look like cu's
Line 53 
Line 55 
         int argc;          int argc;
         char *argv[];          char *argv[];
 {  {
         register int i;          int ch, i;
           long l;
           char *cp;
         static char sbuf[12];          static char sbuf[12];
   
         if (argc < 2) {          if (argc < 2)
                 printf("usage: cu [phone-number] [-t] [-s speed] [-a acu] [-l line] [-#]\n");                  cuusage();
                 exit(8);  
         }  
         CU = DV = NOSTR;          CU = DV = NOSTR;
         BR = DEFBR;          BR = DEFBR;
         for (; argc > 1; argv++, argc--) {          while ((ch = getopt(argc, argv, "a:l:s:htoe0123456789")) != -1) {
                 if (argv[1][0] != '-')                  switch(ch) {
                         PN = argv[1];  
                 else switch (argv[1][1]) {  
   
                 case 't':  
                         HW = 1, DU = -1;  
                         --argc;  
                         continue;  
   
                 case 'a':                  case 'a':
                         CU = argv[2]; ++argv; --argc;                          CU = optarg;
                         break;                          break;
                   case 'l':
                           DV = optarg;
                           break;
                 case 's':                  case 's':
                         if (argc < 3 || speed(atoi(argv[2])) == 0) {                          l = strtol(optarg, &cp, 10);
                                 fprintf(stderr, "cu: unsupported speed %s\n",                          if (*cp != '\0' || l < 0 || l >= INT_MAX ||
                                         argv[2]);                              speed((int)l) == 0) {
                                   fprintf(stderr, "%s: unsupported speed %s\n",
                                       __progname, optarg);
                                 exit(3);                                  exit(3);
                         }                          }
                         BR = atoi(argv[2]); ++argv; --argc;                          BR = (int)l;
                         break;                          break;
                   case 'h':
                 case 'l':                          value(LECHO) = (char *)TRUE;
                         DV = argv[2]; ++argv; --argc;                          HD = TRUE;
                         break;                          break;
                   case 't':
                           HW = 1, DU = -1;
                           break;
                   case 'o':
                           setparity("odd");
                           break;
                   case 'e':
                           setparity("even");
                           break;
                 case '0': case '1': case '2': case '3': case '4':                  case '0': case '1': case '2': case '3': case '4':
                 case '5': case '6': case '7': case '8': case '9':                  case '5': case '6': case '7': case '8': case '9':
                         if (CU)                          if (CU)
                                 CU[strlen(CU)-1] = argv[1][1];                                  CU[strlen(CU)-1] = ch;
                         if (DV)                          if (DV)
                                 DV[strlen(DV)-1] = argv[1][1];                                  DV[strlen(DV)-1] = ch;
                         break;                          break;
   
                 default:                  default:
                         printf("Bad flag %s", argv[1]);                          cuusage;
                         break;                          break;
                 }                  }
         }          }
           argc -= optind;
           argv += optind;
   
           switch (argc) {
           case 1:
                   PN = argv[0];
                   break;
           case 0:
                   break;
           default:
                   cuusage();
                   break;
           }
   
         signal(SIGINT, cleanup);          signal(SIGINT, cleanup);
         signal(SIGQUIT, cleanup);          signal(SIGQUIT, cleanup);
         signal(SIGHUP, cleanup);          signal(SIGHUP, cleanup);
Line 137 
Line 156 
         }          }
         if (!HW)          if (!HW)
                 ttysetup(speed(BR));                  ttysetup(speed(BR));
   }
   
   void
   cuusage()
   {
           fprintf(stderr, "usage: cu [-ehot] [-a acu] [-l line] [-s speed] [-#] "
               "[phone-number]\n");
           exit(8);
 }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6