summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/sftp.c b/sftp.c
index 1e216be7d..df2aff657 100644
--- a/sftp.c
+++ b/sftp.c
@@ -16,7 +16,7 @@
16 16
17#include "includes.h" 17#include "includes.h"
18 18
19RCSID("$OpenBSD: sftp.c,v 1.49 2004/06/18 06:13:25 dtucker Exp $"); 19RCSID("$OpenBSD: sftp.c,v 1.50 2004/06/20 18:53:39 djm Exp $");
20 20
21#include "buffer.h" 21#include "buffer.h"
22#include "xmalloc.h" 22#include "xmalloc.h"
@@ -61,9 +61,11 @@ char *__progname;
61/* Separators for interactive commands */ 61/* Separators for interactive commands */
62#define WHITESPACE " \t\r\n" 62#define WHITESPACE " \t\r\n"
63 63
64/* Define what type of ls view (0 - multi-column) */ 64/* Define what type of ls view */
65#define LONG_VIEW 1 /* Full view ala ls -l */ 65#define LONG_VIEW 1 /* Full view ala ls -l */
66#define SHORT_VIEW 2 /* Single row view ala ls -1 */ 66#define SHORT_VIEW 2 /* Single row view ala ls -1 */
67#define NUMERIC_VIEW 4 /* Long view with numeric uid/gid */
68#define VIEW_FLAGS (LONG_VIEW|SHORT_VIEW|NUMERIC_VIEW)
67 69
68/* Commands for interactive mode */ 70/* Commands for interactive mode */
69#define I_CHDIR 1 71#define I_CHDIR 1
@@ -339,10 +341,16 @@ parse_ls_flags(const char **cpp, int *lflag)
339 for(; strchr(WHITESPACE, *cp) == NULL; cp++) { 341 for(; strchr(WHITESPACE, *cp) == NULL; cp++) {
340 switch (*cp) { 342 switch (*cp) {
341 case 'l': 343 case 'l':
342 *lflag = LONG_VIEW; 344 *lflag &= ~VIEW_FLAGS;
345 *lflag |= LONG_VIEW;
343 break; 346 break;
344 case '1': 347 case '1':
345 *lflag = SHORT_VIEW; 348 *lflag &= ~VIEW_FLAGS;
349 *lflag |= SHORT_VIEW;
350 break;
351 case 'n':
352 *lflag &= ~VIEW_FLAGS;
353 *lflag |= NUMERIC_VIEW|LONG_VIEW;
346 break; 354 break;
347 default: 355 default:
348 error("Invalid flag -%c", *cp); 356 error("Invalid flag -%c", *cp);
@@ -650,14 +658,17 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
650 xfree(tmp); 658 xfree(tmp);
651 659
652 if (lflag & LONG_VIEW) { 660 if (lflag & LONG_VIEW) {
653 char *lname; 661 if (lflag & NUMERIC_VIEW) {
654 struct stat sb; 662 char *lname;
655 663 struct stat sb;
656 memset(&sb, 0, sizeof(sb)); 664
657 attrib_to_stat(&d[n]->a, &sb); 665 memset(&sb, 0, sizeof(sb));
658 lname = ls_file(fname, &sb, 1); 666 attrib_to_stat(&d[n]->a, &sb);
659 printf("%s\n", lname); 667 lname = ls_file(fname, &sb, 1);
660 xfree(lname); 668 printf("%s\n", lname);
669 xfree(lname);
670 } else
671 printf("%s\n", d[n]->longname);
661 } else { 672 } else {
662 printf("%-*s", colspace, fname); 673 printf("%-*s", colspace, fname);
663 if (c >= columns) { 674 if (c >= columns) {