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

Diff for /src/usr.bin/ftp/main.c between version 1.29 and 1.30

version 1.29, 1997/04/11 23:14:04 version 1.30, 1997/04/23 20:33:19
Line 75 
Line 75 
         struct passwd *pw = NULL;          struct passwd *pw = NULL;
         char *cp, homedir[MAXPATHLEN];          char *cp, homedir[MAXPATHLEN];
         int dumb_terminal = 0;          int dumb_terminal = 0;
           int outfd = -1;
   
         sp = getservbyname("ftp", "tcp");          sp = getservbyname("ftp", "tcp");
         if (sp == 0)          if (sp == 0)
Line 116 
Line 117 
                         editing = 1;    /* editing mode on if from a tty */                          editing = 1;    /* editing mode on if from a tty */
 #endif  #endif
         }          }
         if (isatty(fileno(stdout)) && !dumb_terminal)  
           ttyout = stdout;
           if (isatty(fileno(ttyout)) && !dumb_terminal)
                 progress = 1;           /* progress bar on if going to a tty */                  progress = 1;           /* progress bar on if going to a tty */
           else {
                   ttyout = stderr;
                   outfd = fileno(stdout);
           }
   
         while ((ch = getopt(argc, argv, "adeginpPr:tvV")) != -1) {          while ((ch = getopt(argc, argv, "adeginpPr:tvV")) != -1) {
                 switch (ch) {                  switch (ch) {
Line 210 
Line 217 
         if (argc > 0) {          if (argc > 0) {
                 if (strchr(argv[0], ':') != NULL) {                  if (strchr(argv[0], ':') != NULL) {
                         anonftp = 1;    /* Handle "automatic" transfers. */                          anonftp = 1;    /* Handle "automatic" transfers. */
                         rval = auto_fetch(argc, argv);                          rval = auto_fetch(argc, argv, outfd);
                         if (rval >= 0)          /* -1 == connected and cd-ed */                          if (rval >= 0)          /* -1 == connected and cd-ed */
                                 exit(rval);                                  exit(rval);
                 } else {                  } else {
Line 231 
Line 238 
                                         break;                                          break;
                                 if (!connected) {                                  if (!connected) {
                                         macnum = 0;                                          macnum = 0;
                                         puts("Retrying...");                                          fputs("Retrying...\n", ttyout);
                                         sleep(retry_connect);                                          sleep(retry_connect);
                                 }                                  }
                         } while (!connected);                          } while (!connected);
Line 314 
Line 321 
             && !editing              && !editing
 #endif /* !SMALL */  #endif /* !SMALL */
             )              )
                 (void)putchar('\n');                  (void)putc('\n', ttyout);
         for (;;) {          for (;;) {
 #ifndef SMALL  #ifndef SMALL
                 if (!editing) {                  if (!editing) {
 #endif /* !SMALL */  #endif /* !SMALL */
                         if (fromatty) {                          if (fromatty) {
                                 fputs(prompt(), stdout);                                  fputs(prompt(), ttyout);
                                 (void)fflush(stdout);                                  (void)fflush(ttyout);
                         }                          }
                         if (fgets(line, sizeof(line), stdin) == NULL)                          if (fgets(line, sizeof(line), stdin) == NULL)
                                 quit(0, 0);                                  quit(0, 0);
Line 333 
Line 340 
                                         break;                                          break;
                                 line[num] = '\0';                                  line[num] = '\0';
                         } else if (num == sizeof(line) - 2) {                          } else if (num == sizeof(line) - 2) {
                                 puts("sorry, input line too long.");                                  fputs("sorry, input line too long.\n", ttyout);
                                 while ((num = getchar()) != '\n' && num != EOF)                                  while ((num = getchar()) != '\n' && num != EOF)
                                         /* void */;                                          /* void */;
                                 break;                                  break;
Line 349 
Line 356 
                                 if (num == 0)                                  if (num == 0)
                                         break;                                          break;
                         } else if (num >= sizeof(line)) {                          } else if (num >= sizeof(line)) {
                                 puts("sorry, input line too long.");                                  fputs("sorry, input line too long.\n", ttyout);
                                 break;                                  break;
                         }                          }
                         memcpy(line, buf, num);                          memcpy(line, buf, num);
Line 363 
Line 370 
                         continue;                          continue;
                 c = getcmd(margv[0]);                  c = getcmd(margv[0]);
                 if (c == (struct cmd *)-1) {                  if (c == (struct cmd *)-1) {
                         puts("?Ambiguous command.");                          fputs("?Ambiguous command.\n", ttyout);
                         continue;                          continue;
                 }                  }
                 if (c == 0) {                  if (c == 0) {
Line 375 
Line 382 
                          */                           */
                         if (el_parse(el, margc, margv) != 0)                          if (el_parse(el, margc, margv) != 0)
 #endif /* !SMALL */  #endif /* !SMALL */
                                 puts("?Invalid command.");                                  fputs("?Invalid command.\n", ttyout);
                         continue;                          continue;
                 }                  }
                 if (c->c_conn && !connected) {                  if (c->c_conn && !connected) {
                         puts("Not connected.");                          fputs("Not connected.\n", ttyout);
                         continue;                          continue;
                 }                  }
                 confirmrest = 0;                  confirmrest = 0;
                 (*c->c_handler)(margc, margv);                  (*c->c_handler)(margc, margv);
                 if (bell && c->c_bell)                  if (bell && c->c_bell)
                         (void)putchar('\007');                          (void)putc('\007', ttyout);
                 if (c->c_handler != help)                  if (c->c_handler != help)
                         break;                          break;
         }          }
Line 617 
Line 624 
                 StringList *buf;                  StringList *buf;
   
                 buf = sl_init();                  buf = sl_init();
                 printf("%sommands may be abbreviated.  Commands are:\n\n",                  fprintf(ttyout, "%sommands may be abbreviated.  Commands are:\n\n",
                     proxy ? "Proxy c" : "C");                      proxy ? "Proxy c" : "C");
                 for (c = cmdtab; c < &cmdtab[NCMDS]; c++)                  for (c = cmdtab; c < &cmdtab[NCMDS]; c++)
                         if (c->c_name && (!proxy || c->c_proxy))                          if (c->c_name && (!proxy || c->c_proxy))
Line 635 
Line 642 
                 arg = *++argv;                  arg = *++argv;
                 c = getcmd(arg);                  c = getcmd(arg);
                 if (c == (struct cmd *)-1)                  if (c == (struct cmd *)-1)
                         printf("?Ambiguous help command %s\n", arg);                          fprintf(ttyout, "?Ambiguous help command %s\n", arg);
                 else if (c == (struct cmd *)0)                  else if (c == (struct cmd *)0)
                         printf("?Invalid help command %s\n", arg);                          fprintf(ttyout, "?Invalid help command %s\n", arg);
                 else                  else
                         printf("%-*s\t%s\n", HELPINDENT,                          fprintf(ttyout, "%-*s\t%s\n", HELPINDENT,
                                 c->c_name, c->c_help);                                  c->c_name, c->c_help);
         }          }
 }  }

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30