[BACK]Return to sftp-int.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/Attic/sftp-int.c between version 1.49 and 1.50

version 1.49, 2002/09/12 00:13:06 version 1.50, 2002/11/21 23:03:51
Line 552 
Line 552 
         SFTP_DIRENT *a = *(SFTP_DIRENT **)aa;          SFTP_DIRENT *a = *(SFTP_DIRENT **)aa;
         SFTP_DIRENT *b = *(SFTP_DIRENT **)bb;          SFTP_DIRENT *b = *(SFTP_DIRENT **)bb;
   
         return (strcmp(a->filename, b->filename));          return (strcmp(a->filename, b->filename));
 }  }
   
 /* sftp ls.1 replacement for directories */  /* sftp ls.1 replacement for directories */
Line 565 
Line 565 
         if ((n = do_readdir(conn, path, &d)) != 0)          if ((n = do_readdir(conn, path, &d)) != 0)
                 return (n);                  return (n);
   
         /* Count entries for sort */          /* Count entries for sort */
         for (n = 0; d[n] != NULL; n++)          for (n = 0; d[n] != NULL; n++)
                 ;                  ;
   
Line 573 
Line 573 
   
         for (n = 0; d[n] != NULL; n++) {          for (n = 0; d[n] != NULL; n++) {
                 char *tmp, *fname;                  char *tmp, *fname;
   
                 tmp = path_append(path, d[n]->filename);                  tmp = path_append(path, d[n]->filename);
                 fname = path_strip(tmp, strip_path);                  fname = path_strip(tmp, strip_path);
                 xfree(tmp);                  xfree(tmp);
Line 591 
Line 591 
                         /* XXX - multicolumn display would be nice here */                          /* XXX - multicolumn display would be nice here */
                         printf("%s\n", fname);                          printf("%s\n", fname);
                 }                  }
   
                 xfree(fname);                  xfree(fname);
         }          }
   
Line 601 
Line 601 
   
 /* sftp ls.1 replacement which handles path globs */  /* sftp ls.1 replacement which handles path globs */
 static int  static int
 do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,  do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
     int lflag)      int lflag)
 {  {
         glob_t g;          glob_t g;
Line 611 
Line 611 
   
         memset(&g, 0, sizeof(g));          memset(&g, 0, sizeof(g));
   
         if (remote_glob(conn, path, GLOB_MARK|GLOB_NOCHECK|GLOB_BRACE,          if (remote_glob(conn, path, GLOB_MARK|GLOB_NOCHECK|GLOB_BRACE,
             NULL, &g)) {              NULL, &g)) {
                 error("Can't ls: \"%s\" not found", path);                  error("Can't ls: \"%s\" not found", path);
                 return (-1);                  return (-1);
         }          }
   
         /*          /*
          * If the glob returns a single match, which is the same as the           * If the glob returns a single match, which is the same as the
          * input glob, and it is a directory, then just list its contents           * input glob, and it is a directory, then just list its contents
          */           */
         if (g.gl_pathc == 1 &&          if (g.gl_pathc == 1 &&
             strncmp(path, g.gl_pathv[0], strlen(g.gl_pathv[0]) - 1) == 0) {              strncmp(path, g.gl_pathv[0], strlen(g.gl_pathv[0]) - 1) == 0) {
                 if ((a = do_lstat(conn, path, 1)) == NULL) {                  if ((a = do_lstat(conn, path, 1)) == NULL) {
                         globfree(&g);                          globfree(&g);
                         return (-1);                          return (-1);
                 }                  }
                 if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) &&                  if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) &&
                     S_ISDIR(a->perm)) {                      S_ISDIR(a->perm)) {
                         globfree(&g);                          globfree(&g);
                         return (do_ls_dir(conn, path, strip_path, lflag));                          return (do_ls_dir(conn, path, strip_path, lflag));
Line 642 
Line 642 
                 if (lflag) {                  if (lflag) {
                         /*                          /*
                          * XXX: this is slow - 1 roundtrip per path                           * XXX: this is slow - 1 roundtrip per path
                          * A solution to this is to fork glob() and                           * A solution to this is to fork glob() and
                          * build a sftp specific version which keeps the                           * build a sftp specific version which keeps the
                          * attribs (which currently get thrown away)                           * attribs (which currently get thrown away)
                          * that the server returns as well as the filenames.                           * that the server returns as well as the filenames.
                          */                           */
Line 668 
Line 668 
 }  }
   
 static int  static int
 parse_args(const char **cpp, int *pflag, int *lflag,  parse_args(const char **cpp, int *pflag, int *lflag,
     unsigned long *n_arg, char **path1, char **path2)      unsigned long *n_arg, char **path1, char **path2)
 {  {
         const char *cmd, *cp = *cpp;          const char *cmd, *cp = *cpp;
Line 902 
Line 902 
                         do_globbed_ls(conn, *pwd, *pwd, lflag);                          do_globbed_ls(conn, *pwd, *pwd, lflag);
                         break;                          break;
                 }                  }
   
                 /* Strip pwd off beginning of non-absolute paths */                  /* Strip pwd off beginning of non-absolute paths */
                 tmp = NULL;                  tmp = NULL;
                 if (*path1 != '/')                  if (*path1 != '/')

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.50