[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.17 and 1.18

version 1.17, 1997/04/16 05:02:54 version 1.18, 1997/04/23 20:33:13
Line 129 
Line 129 
                         hp->h_addr_list++;                          hp->h_addr_list++;
                         memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0],                          memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0],
                             hp->h_length);                              hp->h_length);
                         printf("Trying %s...\n", inet_ntoa(hisctladdr.sin_addr));                          fprintf(ttyout, "Trying %s...\n", inet_ntoa(hisctladdr.sin_addr));
                         (void)close(s);                          (void)close(s);
                         s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);                          s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
                         if (s < 0) {                          if (s < 0) {
Line 166 
Line 166 
                 goto bad;                  goto bad;
         }          }
         if (verbose)          if (verbose)
                 printf("Connected to %s.\n", hostname);                  fprintf(ttyout, "Connected to %s.\n", hostname);
         if (getreply(0) > 2) {  /* read startup message from server */          if (getreply(0) > 2) {  /* read startup message from server */
                 if (cin)                  if (cin)
                         (void)fclose(cin);                          (void)fclose(cin);
Line 198 
Line 198 
 {  {
   
         alarmtimer(0);          alarmtimer(0);
         putchar('\n');          putc('\n', ttyout);
         (void)fflush(stdout);          (void)fflush(ttyout);
         abrtflag++;          abrtflag++;
         if (ptflag)          if (ptflag)
                 longjmp(ptabort, 1);                  longjmp(ptabort, 1);
Line 223 
Line 223 
   
         abrtflag = 0;          abrtflag = 0;
         if (debug) {          if (debug) {
                 fputs("---> ", stdout);                  fputs("---> ", ttyout);
 #ifdef __STDC__  #ifdef __STDC__
                 va_start(ap, fmt);                  va_start(ap, fmt);
 #else  #else
Line 231 
Line 231 
                 fmt = va_arg(ap, const char *);                  fmt = va_arg(ap, const char *);
 #endif  #endif
                 if (strncmp("PASS ", fmt, 5) == 0)                  if (strncmp("PASS ", fmt, 5) == 0)
                         fputs("PASS XXXX", stdout);                          fputs("PASS XXXX", ttyout);
                 else if (strncmp("ACCT ", fmt, 5) == 0)                  else if (strncmp("ACCT ", fmt, 5) == 0)
                         fputs("ACCT XXXX", stdout);                          fputs("ACCT XXXX", ttyout);
                 else                  else
                         vprintf(fmt, ap);                          vprintf(fmt, ap);
                 va_end(ap);                  va_end(ap);
                 putchar('\n');                  putc('\n', ttyout);
                 (void)fflush(stdout);                  (void)fflush(ttyout);
         }          }
         if (cout == NULL) {          if (cout == NULL) {
                 warnx("No control connection for command.");                  warnx("No control connection for command.");
Line 311 
Line 311 
                                 }                                  }
                                 lostpeer();                                  lostpeer();
                                 if (verbose) {                                  if (verbose) {
                                         puts(                                          fputs(
 "421 Service not available, remote server has closed connection.");  "421 Service not available, remote server has closed connection.\n", ttyout);
                                         (void)fflush(stdout);                                          (void)fflush(ttyout);
                                 }                                  }
                                 code = 421;                                  code = 421;
                                 return (4);                                  return (4);
Line 323 
Line 323 
                             (n < '5' || !retry_connect)) {                              (n < '5' || !retry_connect)) {
                                 if (proxflag &&                                  if (proxflag &&
                                    (dig == 1 || (dig == 5 && verbose == 0)))                                     (dig == 1 || (dig == 5 && verbose == 0)))
                                         printf("%s:", hostname);                                          fprintf(ttyout, "%s:", hostname);
                                 (void)putchar(c);                                  (void)putc(c, ttyout);
                         }                          }
                         if (dig < 4 && isdigit(c))                          if (dig < 4 && isdigit(c))
                                 code = code * 10 + (c - '0');                                  code = code * 10 + (c - '0');
Line 352 
Line 352 
                 }                  }
                 if (verbose > 0 || ((verbose > -1 && n == '5') &&                  if (verbose > 0 || ((verbose > -1 && n == '5') &&
                     (n < '5' || !retry_connect))) {                      (n < '5' || !retry_connect))) {
                         (void)putchar(c);                          (void)putc(c, ttyout);
                         (void)fflush (stdout);                          (void)fflush (ttyout);
                 }                  }
                 if (line == 0) {                  if (line == 0) {
                         size_t len = cp - current_line;                          size_t len = cp - current_line;
Line 403 
Line 403 
         alarmtimer(0);          alarmtimer(0);
         mflag = 0;          mflag = 0;
         abrtflag = 0;          abrtflag = 0;
         puts("\nsend aborted\nwaiting for remote to finish abort.");          fputs("\nsend aborted\nwaiting for remote to finish abort.\n", ttyout);
         (void)fflush(stdout);          (void)fflush(ttyout);
         longjmp(sendabort, 1);          longjmp(sendabort, 1);
 }  }
   
Line 429 
Line 429 
         oprogress = progress;          oprogress = progress;
         if (verbose && printnames) {          if (verbose && printnames) {
                 if (local && *local != '-')                  if (local && *local != '-')
                         printf("local: %s ", local);                          fprintf(ttyout, "local: %s ", local);
                 if (remote)                  if (remote)
                         printf("remote: %s\n", remote);                          fprintf(ttyout, "remote: %s\n", remote);
         }          }
         if (proxy) {          if (proxy) {
                 proxtrans(cmd, local, remote);                  proxtrans(cmd, local, remote);
Line 492 
Line 492 
                 closefunc = fclose;                  closefunc = fclose;
                 if (fstat(fileno(fin), &st) < 0 ||                  if (fstat(fileno(fin), &st) < 0 ||
                     (st.st_mode & S_IFMT) != S_IFREG) {                      (st.st_mode & S_IFMT) != S_IFREG) {
                         printf("%s: not a plain file.\n", local);                          fprintf(ttyout, "%s: not a plain file.\n", local);
                         (void)signal(SIGINT, oldintr);                          (void)signal(SIGINT, oldintr);
                         (void)signal(SIGINFO, oldinti);                          (void)signal(SIGINFO, oldinti);
                         fclose(fin);                          fclose(fin);
Line 587 
Line 587 
                                         break;                                          break;
                         if (hash && (!progress || filesize < 0) ) {                          if (hash && (!progress || filesize < 0) ) {
                                 while (bytes >= hashbytes) {                                  while (bytes >= hashbytes) {
                                         (void)putchar('#');                                          (void)putc('#', ttyout);
                                         hashbytes += mark;                                          hashbytes += mark;
                                 }                                  }
                                 (void)fflush(stdout);                                  (void)fflush(ttyout);
                         }                          }
                 }                  }
                 if (hash && (!progress || filesize < 0) && bytes > 0) {                  if (hash && (!progress || filesize < 0) && bytes > 0) {
                         if (bytes < mark)                          if (bytes < mark)
                                 (void)putchar('#');                                  (void)putc('#', ttyout);
                         (void)putchar('\n');                          (void)putc('\n', ttyout);
                         (void)fflush(stdout);                          (void)fflush(ttyout);
                 }                  }
                 if (c < 0)                  if (c < 0)
                         warn("local: %s", local);                          warn("local: %s", local);
Line 613 
Line 613 
                         if (c == '\n') {                          if (c == '\n') {
                                 while (hash && (!progress || filesize < 0) &&                                  while (hash && (!progress || filesize < 0) &&
                                     (bytes >= hashbytes)) {                                      (bytes >= hashbytes)) {
                                         (void)putchar('#');                                          (void)putc('#', ttyout);
                                         (void)fflush(stdout);                                          (void)fflush(ttyout);
                                         hashbytes += mark;                                          hashbytes += mark;
                                 }                                  }
                                 if (ferror(dout))                                  if (ferror(dout))
Line 633 
Line 633 
                 }                  }
                 if (hash && (!progress || filesize < 0)) {                  if (hash && (!progress || filesize < 0)) {
                         if (bytes < hashbytes)                          if (bytes < hashbytes)
                                 (void)putchar('#');                                  (void)putc('#', ttyout);
                         (void)putchar('\n');                          (void)putc('\n', ttyout);
                         (void)fflush(stdout);                          (void)fflush(ttyout);
                 }                  }
                 if (ferror(fin))                  if (ferror(fin))
                         warn("local: %s", local);                          warn("local: %s", local);
Line 693 
Line 693 
         alarmtimer(0);          alarmtimer(0);
         mflag = 0;          mflag = 0;
         abrtflag = 0;          abrtflag = 0;
         puts("\nreceive aborted\nwaiting for remote to finish abort.");          fputs("\nreceive aborted\nwaiting for remote to finish abort.\n", ttyout);
         (void)fflush(stdout);          (void)fflush(ttyout);
         longjmp(recvabort, 1);          longjmp(recvabort, 1);
 }  }
   
Line 724 
Line 724 
         is_retr = strcmp(cmd, "RETR") == 0;          is_retr = strcmp(cmd, "RETR") == 0;
         if (is_retr && verbose && printnames) {          if (is_retr && verbose && printnames) {
                 if (local && *local != '-')                  if (local && *local != '-')
                         printf("local: %s ", local);                          fprintf(ttyout, "local: %s ", local);
                 if (remote)                  if (remote)
                         printf("remote: %s\n", remote);                          fprintf(ttyout, "remote: %s\n", remote);
         }          }
         if (proxy && is_retr) {          if (proxy && is_retr) {
                 proxtrans(cmd, local, remote);                  proxtrans(cmd, local, remote);
Line 896 
Line 896 
                         bytes += c;                          bytes += c;
                         if (hash && (!progress || filesize < 0)) {                          if (hash && (!progress || filesize < 0)) {
                                 while (bytes >= hashbytes) {                                  while (bytes >= hashbytes) {
                                         (void)putchar('#');                                          (void)putc('#', ttyout);
                                         hashbytes += mark;                                          hashbytes += mark;
                                 }                                  }
                                 (void)fflush(stdout);                                  (void)fflush(ttyout);
                         }                          }
                 }                  }
                 if (hash && (!progress || filesize < 0) && bytes > 0) {                  if (hash && (!progress || filesize < 0) && bytes > 0) {
                         if (bytes < mark)                          if (bytes < mark)
                                 (void)putchar('#');                                  (void)putc('#', ttyout);
                         (void)putchar('\n');                          (void)putc('\n', ttyout);
                         (void)fflush(stdout);                          (void)fflush(ttyout);
                 }                  }
                 if (c < 0) {                  if (c < 0) {
                         if (errno != EPIPE)                          if (errno != EPIPE)
Line 950 
Line 950 
                         while (c == '\r') {                          while (c == '\r') {
                                 while (hash && (!progress || filesize < 0) &&                                  while (hash && (!progress || filesize < 0) &&
                                     (bytes >= hashbytes)) {                                      (bytes >= hashbytes)) {
                                         (void)putchar('#');                                          (void)putc('#', ttyout);
                                         (void)fflush(stdout);                                          (void)fflush(ttyout);
                                         hashbytes += mark;                                          hashbytes += mark;
                                 }                                  }
                                 bytes++;                                  bytes++;
Line 975 
Line 975 
                 if (bare_lfs) {                  if (bare_lfs) {
                         printf(                          printf(
 "WARNING! %d bare linefeeds received in ASCII mode.\n", bare_lfs);  "WARNING! %d bare linefeeds received in ASCII mode.\n", bare_lfs);
                         puts("File may not have transferred correctly.");                          fputs("File may not have transferred correctly.\n", ttyout);
                 }                  }
                 if (hash && (!progress || filesize < 0)) {                  if (hash && (!progress || filesize < 0)) {
                         if (bytes < hashbytes)                          if (bytes < hashbytes)
                                 (void)putchar('#');                                  (void)putc('#', ttyout);
                         (void)putchar('\n');                          (void)putc('\n', ttyout);
                         (void)fflush(stdout);                          (void)fflush(ttyout);
                 }                  }
                 if (ferror(din)) {                  if (ferror(din)) {
                         if (errno != EPIPE)                          if (errno != EPIPE)
Line 1077 
Line 1077 
                                sizeof(on)) < 0)                                 sizeof(on)) < 0)
                         warn("setsockopt (ignored)");                          warn("setsockopt (ignored)");
                 if (command("PASV") != COMPLETE) {                  if (command("PASV") != COMPLETE) {
                         puts("Passive mode refused.");                          fputs("Passive mode refused.\n", ttyout);
                         goto bad;                          goto bad;
                 }                  }
   
Line 1091 
Line 1091 
   
                 if (sscanf(pasv, "%d,%d,%d,%d,%d,%d",                  if (sscanf(pasv, "%d,%d,%d,%d,%d,%d",
                            &a0, &a1, &a2, &a3, &p0, &p1) != 6) {                             &a0, &a1, &a2, &a3, &p0, &p1) != 6) {
                         puts(                          fputs(
 "Passive mode address scan failure. Shouldn't happen!");  "Passive mode address scan failure. Shouldn't happen!\n", ttyout);
                         goto bad;                          goto bad;
                 }                  }
   
Line 1330 
Line 1330 
 {  {
   
         alarmtimer(0);          alarmtimer(0);
         putchar('\n');          putc('\n', ttyout);
         (void)fflush(stdout);          (void)fflush(ttyout);
         ptabflg++;          ptabflg++;
         mflag = 0;          mflag = 0;
         abrtflag = 0;          abrtflag = 0;
Line 1360 
Line 1360 
         if (curtype != prox_type)          if (curtype != prox_type)
                 changetype(prox_type, 1);                  changetype(prox_type, 1);
         if (command("PASV") != COMPLETE) {          if (command("PASV") != COMPLETE) {
                 puts("proxy server does not support third party transfers.");                  fputs("proxy server does not support third party transfers.\n",
                       ttyout);
                 return;                  return;
         }          }
         pswitch(0);          pswitch(0);
         if (!connected) {          if (!connected) {
                 puts("No primary connection.");                  fputs("No primary connection.\n", ttyout);
                 pswitch(1);                  pswitch(1);
                 code = -1;                  code = -1;
                 return;                  return;
Line 1396 
Line 1397 
         (void)signal(SIGINT, oldintr);          (void)signal(SIGINT, oldintr);
         pswitch(1);          pswitch(1);
         ptflag = 0;          ptflag = 0;
         printf("local: %s remote: %s\n", local, remote);          fprintf(ttyout, "local: %s remote: %s\n", local, remote);
         return;          return;
 abort:  abort:
         (void)signal(SIGINT, SIG_IGN);          (void)signal(SIGINT, SIG_IGN);
Line 1502 
Line 1503 
         *cp++ = '.';          *cp++ = '.';
         while (!d) {          while (!d) {
                 if (++count == 100) {                  if (++count == 100) {
                         puts("runique: can't find unique file name.");                          fputs("runique: can't find unique file name.\n", ttyout);
                         return ((char *) 0);                          return ((char *) 0);
                 }                  }
                 *cp++ = ext;                  *cp++ = ext;

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18