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

Diff for /src/usr.bin/uudecode/uudecode.c between version 1.14 and 1.15

version 1.14, 2004/04/09 22:54:02 version 1.15, 2008/07/05 20:59:42
Line 69 
Line 69 
 static FILE *infp, *outfp;  static FILE *infp, *outfp;
 static int base64, cflag, iflag, oflag, pflag, rflag, sflag;  static int base64, cflag, iflag, oflag, pflag, rflag, sflag;
   
 static void     usage(void);  static void     usage(int);
 static int      decode(void);  static int      decode(void);
 static int      decode2(void);  static int      decode2(void);
 static int      uu_decode(void);  static int      uu_decode(void);
 static int      base64_decode(void);  static int      base64_decode(void);
   
   /*
    * program modes
    */
   #define MODE_DECODE     0
   #define MODE_B64DECODE  1
   
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
         int rval, ch;          int rval, ch, mode;
         extern char *__progname;          extern char *__progname;
           static const char *optstr[2] = {
                   "cimo:prs",
                   "cio:prs"
           };
   
         if (strcmp(__progname, "b64decode") == 0)          mode = 0;
   
           if (strcmp(__progname, "b64decode") == 0) {
                 base64 = 1;                  base64 = 1;
                   mode = MODE_B64DECODE;
           }
   
         setlocale(LC_ALL, "");          setlocale(LC_ALL, "");
         while ((ch = getopt(argc, argv, "cimo:prs")) != -1) {          while ((ch = getopt(argc, argv, optstr[mode])) != -1) {
                 switch(ch) {                  switch(ch) {
                 case 'c':                  case 'c':
                         if (oflag || rflag)                          if (oflag || rflag)
                                 usage();                                  usage(mode);
                         cflag = 1; /* multiple uudecode'd files */                          cflag = 1; /* multiple uudecode'd files */
                         break;                          break;
                 case 'i':                  case 'i':
Line 100 
Line 114 
                         break;                          break;
                 case 'o':                  case 'o':
                         if (cflag || pflag || rflag || sflag)                          if (cflag || pflag || rflag || sflag)
                                 usage();                                  usage(mode);
                         oflag = 1; /* output to the specified file */                          oflag = 1; /* output to the specified file */
                         sflag = 1; /* do not strip pathnames for output */                          sflag = 1; /* do not strip pathnames for output */
                         outfile = optarg; /* set the output filename */                          outfile = optarg; /* set the output filename */
                         break;                          break;
                 case 'p':                  case 'p':
                         if (oflag)                          if (oflag)
                                 usage();                                  usage(mode);
                         pflag = 1; /* print output to stdout */                          pflag = 1; /* print output to stdout */
                         break;                          break;
                 case 'r':                  case 'r':
                         if (cflag || oflag)                          if (cflag || oflag)
                                 usage();                                  usage(mode);
                         rflag = 1; /* decode raw data */                          rflag = 1; /* decode raw data */
                         break;                          break;
                 case 's':                  case 's':
                         if (oflag)                          if (oflag)
                                 usage();                                  usage(mode);
                         sflag = 1; /* do not strip pathnames for output */                          sflag = 1; /* do not strip pathnames for output */
                         break;                          break;
                 default:                  default:
                         usage();                          usage(mode);
                 }                  }
         }          }
         argc -= optind;          argc -= optind;
Line 436 
Line 450 
 }  }
   
 static void  static void
 usage(void)  usage(int mode)
 {  {
         (void)fprintf(stderr,          switch (mode) {
             "usage: uudecode [-cimprs] [file ...]\n"          case MODE_DECODE:
             "       uudecode [-i] -o output_file [file]\n"                  (void)fprintf(stderr,
             "       b64decode [-cimprs] [file ...]\n"                      "usage: uudecode [-cimprs] [file ...]\n"
             "       b64decode [-i] -o output_file [file]\n");                      "       uudecode [-i] -o output_file [file]\n");
                   break;
           case MODE_B64DECODE:
                   (void)fprintf(stderr,
                       "usage: b64decode [-ciprs] [file ...]\n"
                       "       b64decode [-i] -o output_file [file]\n");
                   break;
           }
         exit(1);          exit(1);
 }  }

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15