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

Diff for /src/usr.bin/ssh/sftp.c between version 1.52 and 1.53

version 1.52, 2004/06/21 22:04:50 version 1.53, 2004/06/21 22:30:45
Line 61 
Line 61 
 #define WHITESPACE " \t\r\n"  #define WHITESPACE " \t\r\n"
   
 /* ls flags */  /* ls flags */
 #define LONG_VIEW       0x01    /* Full view ala ls -l */  #define LS_LONG_VIEW    0x01    /* Full view ala ls -l */
 #define SHORT_VIEW      0x02    /* Single row view ala ls -1 */  #define LS_SHORT_VIEW   0x02    /* Single row view ala ls -1 */
 #define NUMERIC_VIEW    0x04    /* Long view with numeric uid/gid */  #define LS_NUMERIC_VIEW 0x04    /* Long view with numeric uid/gid */
 #define NAME_SORT       0x08    /* Sort by name (default) */  #define LS_NAME_SORT    0x08    /* Sort by name (default) */
 #define TIME_SORT       0x10    /* Sort by mtime */  #define LS_TIME_SORT    0x10    /* Sort by mtime */
 #define SIZE_SORT       0x20    /* Sort by file size */  #define LS_SIZE_SORT    0x20    /* Sort by file size */
 #define REVERSE_SORT    0x40    /* Reverse sort order */  #define LS_REVERSE_SORT 0x40    /* Reverse sort order */
   
 #define VIEW_FLAGS      (LONG_VIEW|SHORT_VIEW|NUMERIC_VIEW)  #define VIEW_FLAGS      (LS_LONG_VIEW|LS_SHORT_VIEW|LS_NUMERIC_VIEW)
 #define SORT_FLAGS      (NAME_SORT|TIME_SORT|SIZE_SORT)  #define SORT_FLAGS      (LS_NAME_SORT|LS_TIME_SORT|LS_SIZE_SORT)
   
 /* Commands for interactive mode */  /* Commands for interactive mode */
 #define I_CHDIR         1  #define I_CHDIR         1
Line 342 
Line 342 
         const char *cp = *cpp;          const char *cp = *cpp;
   
         /* Defaults */          /* Defaults */
         *lflag = NAME_SORT;          *lflag = LS_NAME_SORT;
   
         /* Check for flags */          /* Check for flags */
         if (cp++[0] == '-') {          if (cp++[0] == '-') {
Line 350 
Line 350 
                         switch (*cp) {                          switch (*cp) {
                         case 'l':                          case 'l':
                                 *lflag &= ~VIEW_FLAGS;                                  *lflag &= ~VIEW_FLAGS;
                                 *lflag |= LONG_VIEW;                                  *lflag |= LS_LONG_VIEW;
                                 break;                                  break;
                         case '1':                          case '1':
                                 *lflag &= ~VIEW_FLAGS;                                  *lflag &= ~VIEW_FLAGS;
                                 *lflag |= SHORT_VIEW;                                  *lflag |= LS_SHORT_VIEW;
                                 break;                                  break;
                         case 'n':                          case 'n':
                                 *lflag &= ~VIEW_FLAGS;                                  *lflag &= ~VIEW_FLAGS;
                                 *lflag |= NUMERIC_VIEW|LONG_VIEW;                                  *lflag |= LS_NUMERIC_VIEW|LS_LONG_VIEW;
                                 break;                                  break;
                         case 'S':                          case 'S':
                                 *lflag &= ~SORT_FLAGS;                                  *lflag &= ~SORT_FLAGS;
                                 *lflag |= SIZE_SORT;                                  *lflag |= LS_SIZE_SORT;
                                 break;                                  break;
                         case 't':                          case 't':
                                 *lflag &= ~SORT_FLAGS;                                  *lflag &= ~SORT_FLAGS;
                                 *lflag |= TIME_SORT;                                  *lflag |= LS_TIME_SORT;
                                 break;                                  break;
                         case 'r':                          case 'r':
                                 *lflag |= REVERSE_SORT;                                  *lflag |= LS_REVERSE_SORT;
                                 break;                                  break;
                         case 'f':                          case 'f':
                                 *lflag &= ~SORT_FLAGS;                                  *lflag &= ~SORT_FLAGS;
Line 633 
Line 633 
 {  {
         SFTP_DIRENT *a = *(SFTP_DIRENT **)aa;          SFTP_DIRENT *a = *(SFTP_DIRENT **)aa;
         SFTP_DIRENT *b = *(SFTP_DIRENT **)bb;          SFTP_DIRENT *b = *(SFTP_DIRENT **)bb;
         int rmul = sort_flag & REVERSE_SORT ? -1 : 1;          int rmul = sort_flag & LS_REVERSE_SORT ? -1 : 1;
   
 #define NCMP(a,b) (a == b ? 0 : (a < b ? 1 : -1))  #define NCMP(a,b) (a == b ? 0 : (a < b ? 1 : -1))
         if (sort_flag & NAME_SORT)          if (sort_flag & LS_NAME_SORT)
                 return (rmul * strcmp(a->filename, b->filename));                  return (rmul * strcmp(a->filename, b->filename));
         else if (sort_flag & TIME_SORT)          else if (sort_flag & LS_TIME_SORT)
                 return (rmul * NCMP(a->a.mtime, b->a.mtime));                  return (rmul * NCMP(a->a.mtime, b->a.mtime));
         else if (sort_flag & SIZE_SORT)          else if (sort_flag & LS_SIZE_SORT)
                 return (rmul * NCMP(a->a.size, b->a.size));                  return (rmul * NCMP(a->a.size, b->a.size));
   
         fatal("Unknown ls sort type");          fatal("Unknown ls sort type");
Line 656 
Line 656 
         if ((n = do_readdir(conn, path, &d)) != 0)          if ((n = do_readdir(conn, path, &d)) != 0)
                 return (n);                  return (n);
   
         if (!(lflag & SHORT_VIEW)) {          if (!(lflag & LS_SHORT_VIEW)) {
                 int m = 0, width = 80;                  int m = 0, width = 80;
                 struct winsize ws;                  struct winsize ws;
                 char *tmp;                  char *tmp;
Line 680 
Line 680 
         }          }
   
         if (lflag & SORT_FLAGS) {          if (lflag & SORT_FLAGS) {
                 sort_flag = lflag & (SORT_FLAGS|REVERSE_SORT);                  sort_flag = lflag & (SORT_FLAGS|LS_REVERSE_SORT);
                 qsort(d, n, sizeof(*d), sdirent_comp);                  qsort(d, n, sizeof(*d), sdirent_comp);
         }          }
   
Line 691 
Line 691 
                 fname = path_strip(tmp, strip_path);                  fname = path_strip(tmp, strip_path);
                 xfree(tmp);                  xfree(tmp);
   
                 if (lflag & LONG_VIEW) {                  if (lflag & LS_LONG_VIEW) {
                         if (lflag & NUMERIC_VIEW) {                          if (lflag & LS_NUMERIC_VIEW) {
                                 char *lname;                                  char *lname;
                                 struct stat sb;                                  struct stat sb;
   
Line 715 
Line 715 
                 xfree(fname);                  xfree(fname);
         }          }
   
         if (!(lflag & LONG_VIEW) && (c != 1))          if (!(lflag & LS_LONG_VIEW) && (c != 1))
                 printf("\n");                  printf("\n");
   
         free_sftp_dirents(d);          free_sftp_dirents(d);
Line 759 
Line 759 
                 }                  }
         }          }
   
         if (!(lflag & SHORT_VIEW)) {          if (!(lflag & LS_SHORT_VIEW)) {
                 int m = 0, width = 80;                  int m = 0, width = 80;
                 struct winsize ws;                  struct winsize ws;
   
Line 780 
Line 780 
   
                 fname = path_strip(g.gl_pathv[i], strip_path);                  fname = path_strip(g.gl_pathv[i], strip_path);
   
                 if (lflag & LONG_VIEW) {                  if (lflag & LS_LONG_VIEW) {
                         char *lname;                          char *lname;
                         struct stat sb;                          struct stat sb;
   
Line 809 
Line 809 
                 xfree(fname);                  xfree(fname);
         }          }
   
         if (!(lflag & LONG_VIEW) && (c != 1))          if (!(lflag & LS_LONG_VIEW) && (c != 1))
                 printf("\n");                  printf("\n");
   
  out:   out:

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