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

Diff for /src/usr.bin/ftp/ftp.c between version 1.68 and 1.69

version 1.68, 2008/03/10 22:56:43 version 1.69, 2008/04/12 21:20:58
Line 541 
Line 541 
         volatile off_t hashbytes;          volatile off_t hashbytes;
         char * volatile lmode;          char * volatile lmode;
         char buf[BUFSIZ], *bufp;          char buf[BUFSIZ], *bufp;
         int oprogress;          int oprogress, serrno;
   
         hashbytes = mark;          hashbytes = mark;
         direction = "sent";          direction = "sent";
Line 704 
Line 704 
   
         case TYPE_I:          case TYPE_I:
         case TYPE_L:          case TYPE_L:
                 errno = d = 0;                  d = 0;
                 while ((c = read(fileno(fin), buf, sizeof(buf))) > 0) {                  while ((c = read(fileno(fin), buf, sizeof(buf))) > 0) {
                         may_send_noop_char();                          may_send_noop_char();
                         bytes += c;                          bytes += c;
Line 720 
Line 720 
                                 (void)fflush(ttyout);                                  (void)fflush(ttyout);
                         }                          }
                 }                  }
                   if (c == -1 || d == -1)
                           serrno = errno;
                 if (hash && (!progress || filesize < 0) && bytes > 0) {                  if (hash && (!progress || filesize < 0) && bytes > 0) {
                         if (bytes < mark)                          if (bytes < mark)
                                 (void)putc('#', ttyout);                                  (void)putc('#', ttyout);
Line 727 
Line 729 
                         (void)fflush(ttyout);                          (void)fflush(ttyout);
                 }                  }
                 if (c < 0)                  if (c < 0)
                         warn("local: %s", local);                          warnx("local: %s: %s", local, strerror(serrno));
                 if (d < 0) {                  if (d < 0) {
                         if (errno != EPIPE)                          if (serrno != EPIPE)
                                 warn("netout");                                  warnx("netout: %s", strerror(serrno));
                         bytes = -1;                          bytes = -1;
                 }                  }
                 break;                  break;
Line 759 
Line 761 
                         }                          }
 #endif  #endif
                 }                  }
                   if (ferror(fin) || ferror(dout))
                           serrno = errno;
                 if (hash && (!progress || filesize < 0)) {                  if (hash && (!progress || filesize < 0)) {
                         if (bytes < hashbytes)                          if (bytes < hashbytes)
                                 (void)putc('#', ttyout);                                  (void)putc('#', ttyout);
Line 766 
Line 770 
                         (void)fflush(ttyout);                          (void)fflush(ttyout);
                 }                  }
                 if (ferror(fin))                  if (ferror(fin))
                         warn("local: %s", local);                          warnx("local: %s: %s", local, strerror(serrno));
                 if (ferror(dout)) {                  if (ferror(dout)) {
                         if (errno != EPIPE)                          if (errno != EPIPE)
                                 warn("netout");                                  warnx("netout: %s", strerror(serrno));
                         bytes = -1;                          bytes = -1;
                 }                  }
                 break;                  break;
Line 834 
Line 838 
         FILE * volatile fout, * volatile din;          FILE * volatile fout, * volatile din;
         int (* volatile closefunc)(FILE *);          int (* volatile closefunc)(FILE *);
         volatile sig_t oldinti, oldintr, oldintp;          volatile sig_t oldinti, oldintr, oldintp;
         int c, d;          int c, d, serrno;
         volatile int is_retr, tcrflag, bare_lfs;          volatile int is_retr, tcrflag, bare_lfs;
         static size_t bufsize;          static size_t bufsize;
         static char *buf;          static char *buf;
Line 890 
Line 894 
         oldinti = signal(SIGINFO, psummary);          oldinti = signal(SIGINFO, psummary);
         if (ignorespecial || (strcmp(local, "-") && *local != '|')) {          if (ignorespecial || (strcmp(local, "-") && *local != '|')) {
                 if (access(local, W_OK) < 0) {                  if (access(local, W_OK) < 0) {
                         char *dir = strrchr(local, '/');                          char *dir;
   
                         if (errno != ENOENT && errno != EACCES) {                          if (errno != ENOENT && errno != EACCES) {
                                 warn("local: %s", local);                                  warn("local: %s", local);
Line 899 
Line 903 
                                 code = -1;                                  code = -1;
                                 return;                                  return;
                         }                          }
                           dir = strrchr(local, '/');
                         if (dir != NULL)                          if (dir != NULL)
                                 *dir = 0;                                  *dir = 0;
                         d = access(dir == local ? "/" : dir ? local : ".", W_OK);                          d = access(dir == local ? "/" : dir ? local : ".", W_OK);
Line 1048 
Line 1053 
                                 (void)fflush(ttyout);                                  (void)fflush(ttyout);
                         }                          }
                 }                  }
                   if (c == -1 || d < c)
                           serrno = errno;
                 if (hash && (!progress || filesize < 0) && bytes > 0) {                  if (hash && (!progress || filesize < 0) && bytes > 0) {
                         if (bytes < mark)                          if (bytes < mark)
                                 (void)putc('#', ttyout);                                  (void)putc('#', ttyout);
Line 1055 
Line 1062 
                         (void)fflush(ttyout);                          (void)fflush(ttyout);
                 }                  }
                 if (c < 0) {                  if (c < 0) {
                         if (errno != EPIPE)                          if (serrno != EPIPE)
                                 warn("netin");                                  warnx("netin: %s", strerror(serrno));
                         bytes = -1;                          bytes = -1;
                 }                  }
                 if (d < c) {                  if (d < c) {
                         if (d < 0)                          if (d < 0)
                                 warn("local: %s", local);                                  warnx("local: %s: %s", local, strerror(serrno));
                         else                          else
                                 warnx("%s: short write", local);                                  warnx("%s: short write", local);
                 }                  }
Line 1075 
Line 1082 
                                 goto done;                                  goto done;
                         n = restart_point;                          n = restart_point;
                         for (i = 0; i++ < n;) {                          for (i = 0; i++ < n;) {
                                 if ((ch = fgetc(fout)) == EOF)                                  if ((ch = fgetc(fout)) == EOF) {
                                           if (!ferror(fout))
                                                   errno = 0;
                                         goto done;                                          goto done;
                                   }
                                 if (ch == '\n')                                  if (ch == '\n')
                                         i++;                                          i++;
                         }                          }
                         if (fseek(fout, 0L, SEEK_CUR) < 0) {                          if (fseek(fout, 0L, SEEK_CUR) < 0) {
 done:  done:
                                 warn("local: %s", local);                                  if (errno)
                                           warn("local: %s", local);
                                   else
                                           warnx("local: %s", local);
                                 progress = oprogress;                                  progress = oprogress;
                                 preserve = opreserve;                                  preserve = opreserve;
                                 if (closefunc != NULL)                                  if (closefunc != NULL)
Line 1119 
Line 1132 
         contin2:        ;          contin2:        ;
                 }                  }
 break2:  break2:
                   if (ferror(din) || ferror(fout))
                           serrno = errno;
                 if (bare_lfs) {                  if (bare_lfs) {
                         fprintf(ttyout,                          fprintf(ttyout,
 "WARNING! %d bare linefeeds received in ASCII mode.\n", bare_lfs);  "WARNING! %d bare linefeeds received in ASCII mode.\n", bare_lfs);
Line 1132 
Line 1147 
                         (void)fflush(ttyout);                          (void)fflush(ttyout);
                 }                  }
                 if (ferror(din)) {                  if (ferror(din)) {
                         if (errno != EPIPE)                          if (serrno != EPIPE)
                                 warn("netin");                                  warnx("netin: %s", strerror(serrno));
                         bytes = -1;                          bytes = -1;
                 }                  }
                 if (ferror(fout))                  if (ferror(fout))
                         warn("local: %s", local);                          warnx("local: %s: %s", local, strerror(serrno));
                 break;                  break;
         }          }
         progressmeter(1);          progressmeter(1);

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