[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.5 and 1.6

version 1.5, 1998/05/29 21:07:22 version 1.6, 1998/08/31 02:13:41
Line 46 
Line 46 
 #endif /* not lint */  #endif /* not lint */
   
 /*  /*
  * uudecode [file ...]   * uudecode [-p] [file ...]
  *   *
  * create the specified file, decoding as you go.   * create the specified file, decoding as you go.
  * used with uuencode.   * used with uuencode.
    *
    * Write to stdout if '-p' is specified.  Use this option if you care about
    * security at all.
  */   */
 #include <stdio.h>  #include <stdio.h>
 #include <string.h>  #include <string.h>
Line 61 
Line 64 
 #include <pwd.h>  #include <pwd.h>
 #include <unistd.h>  #include <unistd.h>
   
 static int decode();  static int decode(int);
 static void usage();  static void usage();
 char *filename;  char *filename;
   
Line 71 
Line 74 
         char *argv[];          char *argv[];
 {  {
         int rval;          int rval;
           char ch;
           int tostdout = 0;
   
         setlocale(LC_ALL, "");          setlocale(LC_ALL, "");
   
         while (getopt(argc, argv, "") != -1)          while ((ch = getopt(argc, argv, "p")) != -1)
                 usage();                  switch((char)ch) {
                   case 'p':
                           tostdout++;
                           break;
                   case '?':
                   default:
                           usage();
                   }
         argc -= optind;          argc -= optind;
         argv += optind;          argv += optind;
   
Line 88 
Line 100 
                                 rval = 1;                                  rval = 1;
                                 continue;                                  continue;
                         }                          }
                         rval |= decode();                          rval |= decode(tostdout);
                 } while (*++argv);                  } while (*++argv);
         } else {          } else {
                 filename = "stdin";                  filename = "stdin";
                 rval = decode();                  rval = decode(tostdout);
         }          }
         exit(rval);          exit(rval);
 }  }
   
 static int  static int
 decode()  decode(int tostdout)
 {  {
         extern int errno;          extern int errno;
         struct passwd *pw;          struct passwd *pw;
Line 142 
Line 154 
                 buf[n] = '/';                  buf[n] = '/';
         }          }
   
         /* create output file, set mode */          if (!tostdout) {
         if (!freopen(buf, "w", stdout) ||                  /* create output file, set mode */
             fchmod(fileno(stdout), mode&0666)) {                  if (!freopen(buf, "w", stdout) ||
                 (void)fprintf(stderr, "uudecode: %s: %s: %s\n", buf,                      fchmod(fileno(stdout), mode&0666)) {
                     filename, strerror(errno));                          (void)fprintf(stderr, "uudecode: %s: %s: %s\n", buf,
                 return(1);                              filename, strerror(errno));
                           return(1);
                   }
         }          }
   
         /* for each input line */          /* for each input line */
Line 199 
Line 213 
 static void  static void
 usage()  usage()
 {  {
         (void)fprintf(stderr, "usage: uudecode [file ...]\n");          (void)fprintf(stderr, "usage: uudecode [-p] [file ...]\n");
         exit(1);          exit(1);
 }  }

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