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

Diff for /src/usr.bin/ftp/util.c between version 1.53 and 1.54

version 1.53, 2008/06/26 05:42:20 version 1.54, 2008/07/08 21:07:57
Line 174 
Line 174 
  * system and not checking this out. This way they have to think about it.   * system and not checking this out. This way they have to think about it.
  */   */
                 overbose = verbose;                  overbose = verbose;
                 if (debug == 0)  #ifndef SMALL
                   if (!debug)
   #endif /* !SMALL */
                         verbose = -1;                          verbose = -1;
                 if (command("SYST") == COMPLETE && overbose) {                  if (command("SYST") == COMPLETE && overbose) {
                         char *cp, c;                          char *cp, c;
Line 364 
Line 366 
  * glob files given in argv[] from the remote server.   * glob files given in argv[] from the remote server.
  * if errbuf isn't NULL, store error messages there instead   * if errbuf isn't NULL, store error messages there instead
  * of writing to the screen.   * of writing to the screen.
    * if type isn't NULL, use LIST instead of NLST, and store filetype.
    * 'd' means directory, 's' means symbolic link, '-' means plain
    * file.
  */   */
 char *  char *
 remglob(char *argv[], int doswitch, char **errbuf)  remglob2(char *argv[], int doswitch, char **errbuf, FILE **ftemp, char *type)
 {  {
         char temp[MAXPATHLEN], *cp, *lmode;          char temp[MAXPATHLEN], *bufp, *cp, *lmode;
         static char buf[MAXPATHLEN], **args;          static char buf[MAXPATHLEN], **args;
         static FILE *ftemp = NULL;  
         int oldverbose, oldhash, fd;          int oldverbose, oldhash, fd;
   
         if (!mflag) {          if (!mflag) {
                 if (!doglob)                  if (!doglob)
                         args = NULL;                          args = NULL;
                 else {                  else {
                         if (ftemp) {                          if (*ftemp) {
                                 (void)fclose(ftemp);                                  (void)fclose(*ftemp);
                                 ftemp = NULL;                                  *ftemp = NULL;
                         }                          }
                 }                  }
                 return (NULL);                  return (NULL);
Line 391 
Line 395 
                         args = NULL;                          args = NULL;
                 return (cp);                  return (cp);
         }          }
         if (ftemp == NULL) {          if (*ftemp == NULL) {
                 int len;                  int len;
   
                 if ((cp = getenv("TMPDIR")) == NULL || *cp == '\0')                  if ((cp = getenv("TMPDIR")) == NULL || *cp == '\0')
Line 419 
Line 423 
                 if (doswitch)                  if (doswitch)
                         pswitch(!proxy);                          pswitch(!proxy);
                 for (lmode = "w"; *++argv != NULL; lmode = "a")                  for (lmode = "w"; *++argv != NULL; lmode = "a")
                         recvrequest("NLST", temp, *argv, lmode, 0, 0);                          recvrequest(type ? "LIST" : "NLST", temp, *argv, lmode,
                               0, 0);
                 if ((code / 100) != COMPLETE) {                  if ((code / 100) != COMPLETE) {
                         if (errbuf != NULL)                          if (errbuf != NULL)
                                 *errbuf = reply_string;                                  *errbuf = reply_string;
Line 428 
Line 433 
                         pswitch(!proxy);                          pswitch(!proxy);
                 verbose = oldverbose;                  verbose = oldverbose;
                 hash = oldhash;                  hash = oldhash;
                 ftemp = fopen(temp, "r");                  *ftemp = fopen(temp, "r");
                 (void)unlink(temp);                  (void)unlink(temp);
                 if (ftemp == NULL) {                  if (*ftemp == NULL) {
                         if (errbuf == NULL)                          if (errbuf == NULL)
                                 fputs("can't find list of remote files, oops.\n",                                  fputs("can't find list of remote files, oops.\n",
                                     ttyout);                                      ttyout);
Line 440 
Line 445 
                         return (NULL);                          return (NULL);
                 }                  }
         }          }
         if (fgets(buf, sizeof(buf), ftemp) == NULL) {  again:
                 (void)fclose(ftemp);          if (fgets(buf, sizeof(buf), *ftemp) == NULL) {
                 ftemp = NULL;                  (void)fclose(*ftemp);
                   *ftemp = NULL;
                 return (NULL);                  return (NULL);
         }          }
   
         buf[strcspn(buf, "\n")] = '\0';          buf[strcspn(buf, "\n")] = '\0';
           bufp = buf;
   
         return (buf);  #ifndef SMALL
           if (type) {
                   parse_list(&bufp, type);
                   if (!bufp)
                           goto again;
           }
   #endif /* !SMALL */
   
           return (bufp);
 }  }
   
   /*
    * wrapper for remglob2
    */
   char *
   remglob(char *argv[], int doswitch, char **errbuf)
   {
           static FILE *ftemp = NULL;
   
           return remglob2(argv, doswitch, errbuf, &ftemp, NULL);
   }
   
 int  int
 confirm(const char *cmd, const char *file, int force)  confirm(const char *cmd, const char *file)
 {  {
         char str[BUFSIZ];          char str[BUFSIZ];
   
         if (!force && (confirmrest || !interactive))          if (file && (confirmrest || !interactive))
                 return (1);                  return (1);
 top:  top:
         fprintf(ttyout, "%s %s? ", cmd, file);          if (file)
                   fprintf(ttyout, "%s %s? ", cmd, file);
           else
                   fprintf(ttyout, "Continue with %s? ", cmd);
         (void)fflush(ttyout);          (void)fflush(ttyout);
         if (fgets(str, sizeof(str), stdin) == NULL)          if (fgets(str, sizeof(str), stdin) == NULL)
                 goto quit;                  goto quit;
Line 545 
Line 574 
   
         overbose = verbose;          overbose = verbose;
         size = -1;          size = -1;
         if (debug == 0)  #ifndef SMALL
           if (!debug)
   #endif /* !SMALL */
                 verbose = -1;                  verbose = -1;
         if (command("SIZE %s", file) == COMPLETE) {          if (command("SIZE %s", file) == COMPLETE) {
                 char *cp, *ep;                  char *cp, *ep;
Line 557 
Line 588 
                         if (*ep != '\0' && !isspace(*ep))                          if (*ep != '\0' && !isspace(*ep))
                                 size = -1;                                  size = -1;
                 }                  }
         } else if (noisy && debug == 0) {          } else if (noisy
   #ifndef SMALL
               && !debug
   #endif /* !SMALL */
               ) {
                 fputs(reply_string, ttyout);                  fputs(reply_string, ttyout);
                 fputc('\n', ttyout);                  fputc('\n', ttyout);
         }          }
Line 578 
Line 613 
         overbose = verbose;          overbose = verbose;
         ocode = code;          ocode = code;
         rtime = -1;          rtime = -1;
         if (debug == 0)  #ifndef SMALL
           if (!debug)
   #endif /* !SMALL */
                 verbose = -1;                  verbose = -1;
         if (command("MDTM %s", file) == COMPLETE) {          if (command("MDTM %s", file) == COMPLETE) {
                 struct tm timebuf;                  struct tm timebuf;
Line 614 
Line 651 
                 timebuf.tm_year = yy - TM_YEAR_BASE;                  timebuf.tm_year = yy - TM_YEAR_BASE;
                 timebuf.tm_isdst = -1;                  timebuf.tm_isdst = -1;
                 rtime = mktime(&timebuf);                  rtime = mktime(&timebuf);
                 if (rtime == -1 && (noisy || debug != 0))                  if (rtime == -1 && (noisy
   #ifndef SMALL
                       || debug
   #endif /* !SMALL */
                       ))
                         fprintf(ttyout, "Can't convert %s to a time.\n", reply_string);                          fprintf(ttyout, "Can't convert %s to a time.\n", reply_string);
                 else                  else
                         rtime += timebuf.tm_gmtoff;     /* conv. local -> GMT */                          rtime += timebuf.tm_gmtoff;     /* conv. local -> GMT */
         } else if (noisy && debug == 0) {          } else if (noisy
   #ifndef SMALL
               && !debug
   #endif /* !SMALL */
               ) {
                 fputs(reply_string, ttyout);                  fputs(reply_string, ttyout);
                 fputc('\n', ttyout);                  fputc('\n', ttyout);
         }          }

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54