[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.12 and 1.13

version 1.12, 2003/07/10 00:06:51 version 1.13, 2003/12/09 01:31:42
Line 60 
Line 60 
   
 #include <pwd.h>  #include <pwd.h>
 #include <unistd.h>  #include <unistd.h>
   #include <err.h>
   
 static int decode(int);  static int decode(int);
 static void usage(void);  static void usage(void);
Line 90 
Line 91 
                 rval = 0;                  rval = 0;
                 do {                  do {
                         if (!freopen(filename = *argv, "r", stdin)) {                          if (!freopen(filename = *argv, "r", stdin)) {
                                 (void)fprintf(stderr, "uudecode: %s: %s\n",                                  warn("%s", *argv);
                                     *argv, strerror(errno));  
                                 rval = 1;                                  rval = 1;
                                 continue;                                  continue;
                         }                          }
Line 116 
Line 116 
         /* search for header line */          /* search for header line */
         do {          do {
                 if (!fgets(buf, sizeof(buf), stdin)) {                  if (!fgets(buf, sizeof(buf), stdin)) {
                         (void)fprintf(stderr,                          warnx("%s: no \"begin\" line", filename);
                             "uudecode: %s: no \"begin\" line\n", filename);  
                         return(1);                          return(1);
                 }                  }
         } while (strncmp(buf, "begin ", 6));          } while (strncmp(buf, "begin ", 6));
Line 126 
Line 125 
         /* handle ~user/file format */          /* handle ~user/file format */
         if (buf[0] == '~') {          if (buf[0] == '~') {
                 if (!(p = strchr(buf, '/'))) {                  if (!(p = strchr(buf, '/'))) {
                         (void)fprintf(stderr, "uudecode: %s: illegal ~user.\n",                          warnx("%s: illegal ~user", filename);
                             filename);  
                         return(1);                          return(1);
                 }                  }
                 *p++ = NULL;                  *p++ = NULL;
                 if (!(pw = getpwnam(buf + 1))) {                  if (!(pw = getpwnam(buf + 1))) {
                         (void)fprintf(stderr, "uudecode: %s: no user %s.\n",                          warnx("%s: no user %s", filename, buf);
                             filename, buf);  
                         return(1);                          return(1);
                 }                  }
                 n = strlen(pw->pw_dir);                  n = strlen(pw->pw_dir);
                 n1 = strlen(p);                  n1 = strlen(p);
                 if (n + n1 + 2 > MAXPATHLEN) {                  if (n + n1 + 2 > MAXPATHLEN) {
                         (void)fprintf(stderr, "uudecode: %s: path too long.\n",                          warnx("%s: path too long", filename);
                             filename);  
                         return(1);                          return(1);
                 }                  }
                 bcopy(p, buf + n + 1, n1 + 1);                  bcopy(p, buf + n + 1, n1 + 1);
Line 152 
Line 148 
                 /* create output file, set mode */                  /* create output file, set mode */
                 if (!freopen(buf, "w", stdout) ||                  if (!freopen(buf, "w", stdout) ||
                     fchmod(fileno(stdout), mode&0666)) {                      fchmod(fileno(stdout), mode&0666)) {
                         (void)fprintf(stderr, "uudecode: %s: %s: %s\n", buf,                          warn("%s: %s", buf, filename);
                             filename, strerror(errno));  
                         return(1);                          return(1);
                 }                  }
         }          }
Line 161 
Line 156 
         /* for each input line */          /* for each input line */
         for (;;) {          for (;;) {
                 if (!fgets(p = buf, sizeof(buf), stdin)) {                  if (!fgets(p = buf, sizeof(buf), stdin)) {
                         (void)fprintf(stderr, "uudecode: %s: short file.\n",                          warnx("%s: short file", filename);
                             filename);  
                         return(1);                          return(1);
                 }                  }
 #define DEC(c)  (((c) - ' ') & 077)             /* single character decode */  #define DEC(c)  (((c) - ' ') & 077)             /* single character decode */
Line 197 
Line 191 
                         }                          }
         }          }
         if (!fgets(buf, sizeof(buf), stdin) || strcmp(buf, "end\n")) {          if (!fgets(buf, sizeof(buf), stdin) || strcmp(buf, "end\n")) {
                 (void)fprintf(stderr, "uudecode: %s: no \"end\" line.\n",                  warnx("%s: no \"end\" line", filename);
                     filename);  
                 return(1);                  return(1);
         }          }
         return(0);          return(0);

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13