diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-11-19 05:42:32 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-11-19 05:42:32 +0000 |
commit | e1850ddde4f3ff14f72d919531f1f254cd353a2c (patch) | |
tree | 11746a3d635b293c29287b1ae0c8e6bcbe88a07f | |
parent | 6a76e652aab7d614c2b47b50318e0690c06779c4 (diff) | |
download | busybox-w32-e1850ddde4f3ff14f72d919531f1f254cd353a2c.tar.gz busybox-w32-e1850ddde4f3ff14f72d919531f1f254cd353a2c.tar.bz2 busybox-w32-e1850ddde4f3ff14f72d919531f1f254cd353a2c.zip |
Stuf
-rw-r--r-- | busybox.def.h | 23 | ||||
-rw-r--r-- | coreutils/ls.c | 51 | ||||
-rw-r--r-- | ls.c | 51 |
3 files changed, 62 insertions, 63 deletions
diff --git a/busybox.def.h b/busybox.def.h index fcdd66e37..a48deeca9 100644 --- a/busybox.def.h +++ b/busybox.def.h | |||
@@ -65,13 +65,22 @@ | |||
65 | // that compiles to 0 if everything else if turned off. | 65 | // that compiles to 0 if everything else if turned off. |
66 | #define BB_UTILITY | 66 | #define BB_UTILITY |
67 | // | 67 | // |
68 | //This is where feature definitions go. | 68 | // |
69 | // | ||
70 | // This is where feature definitions go. Generally speaking, | ||
71 | // turning this stuff off makes things a bit smaller (and less | ||
72 | // pretty/useful). | ||
73 | // | ||
74 | // | ||
75 | //Enable init being called as /linuxrc | ||
69 | #define BB_FEATURE_LINUXRC | 76 | #define BB_FEATURE_LINUXRC |
70 | /* Turning this off makes things a bit smaller (and less pretty) */ | 77 | // Use termios to manipulate the screen (more is much pretties with this on) |
71 | #define BB_FEATURE_USE_TERMIOS | 78 | #define BB_FEATURE_USE_TERMIOS |
72 | /* Turning this off makes things a bit smaller (and less pretty) */ | 79 | // calculate terminal & column widths |
73 | #define BB_FEATURE_AUTOWIDTH | 80 | #define BB_FEATURE_AUTOWIDTH |
74 | 81 | // show username/groupnames (bypasses libc6 NSS) | |
75 | 82 | #define BB_FEATURE_LS_USERNAME | |
76 | 83 | // show file timestamps | |
77 | 84 | #define BB_FEATURE_LS_TIMESTAMPS | |
85 | // enable ls -p and -F | ||
86 | #define BB_FEATURE_LS_FILETYPES | ||
diff --git a/coreutils/ls.c b/coreutils/ls.c index 0558bb227..3b380671d 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -40,11 +40,6 @@ | |||
40 | * 1. requires lstat (BSD) - how do you do it without? | 40 | * 1. requires lstat (BSD) - how do you do it without? |
41 | */ | 41 | */ |
42 | 42 | ||
43 | #define FEATURE_USERNAME /* show username/groupnames (bypasses libc6 NSS) */ | ||
44 | #define FEATURE_TIMESTAMPS /* show file timestamps */ | ||
45 | #define FEATURE_AUTOWIDTH /* calculate terminal & column widths */ | ||
46 | #define FEATURE_FILETYPECHAR /* enable -p and -F */ | ||
47 | |||
48 | #define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */ | 43 | #define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */ |
49 | #define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */ | 44 | #define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */ |
50 | #define COLUMN_GAP 2 /* includes the file type char, if present */ | 45 | #define COLUMN_GAP 2 /* includes the file type char, if present */ |
@@ -64,13 +59,13 @@ | |||
64 | #include <dirent.h> | 59 | #include <dirent.h> |
65 | #include <errno.h> | 60 | #include <errno.h> |
66 | #include <stdio.h> | 61 | #include <stdio.h> |
67 | #ifdef FEATURE_TIMESTAMPS | 62 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
68 | #include <time.h> | 63 | #include <time.h> |
69 | #endif | 64 | #endif |
70 | 65 | ||
71 | #define TYPEINDEX(mode) (((mode) >> 12) & 0x0f) | 66 | #define TYPEINDEX(mode) (((mode) >> 12) & 0x0f) |
72 | #define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)]) | 67 | #define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)]) |
73 | #ifdef FEATURE_FILETYPECHAR | 68 | #ifdef BB_FEATURE_LS_FILETYPES |
74 | #define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)]) | 69 | #define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)]) |
75 | #endif | 70 | #endif |
76 | 71 | ||
@@ -103,14 +98,14 @@ static unsigned char display_fmt = FMT_AUTO; | |||
103 | static unsigned short opts = 0; | 98 | static unsigned short opts = 0; |
104 | static unsigned short column = 0; | 99 | static unsigned short column = 0; |
105 | 100 | ||
106 | #ifdef FEATURE_AUTOWIDTH | 101 | #ifdef BB_FEATURE_AUTOWIDTH |
107 | static unsigned short terminal_width = 0, column_width = 0; | 102 | static unsigned short terminal_width = 0, column_width = 0; |
108 | #else | 103 | #else |
109 | #define terminal_width TERMINAL_WIDTH | 104 | #define terminal_width TERMINAL_WIDTH |
110 | #define column_width COLUMN_WIDTH | 105 | #define column_width COLUMN_WIDTH |
111 | #endif | 106 | #endif |
112 | 107 | ||
113 | #ifdef FEATURE_TIMESTAMPS | 108 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
114 | static unsigned char time_fmt = TIME_MOD; | 109 | static unsigned char time_fmt = TIME_MOD; |
115 | #endif | 110 | #endif |
116 | 111 | ||
@@ -163,7 +158,7 @@ static void tab(short col) | |||
163 | #undef nspaces | 158 | #undef nspaces |
164 | } | 159 | } |
165 | 160 | ||
166 | #ifdef FEATURE_FILETYPECHAR | 161 | #ifdef BB_FEATURE_LS_FILETYPES |
167 | static char append_char(mode_t mode) | 162 | static char append_char(mode_t mode) |
168 | { | 163 | { |
169 | if (!(opts & DISP_FTYPE)) | 164 | if (!(opts & DISP_FTYPE)) |
@@ -185,7 +180,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
185 | { | 180 | { |
186 | char scratch[PATH_MAX]; | 181 | char scratch[PATH_MAX]; |
187 | short len = strlen(name); | 182 | short len = strlen(name); |
188 | #ifdef FEATURE_FILETYPECHAR | 183 | #ifdef BB_FEATURE_LS_FILETYPES |
189 | char append = append_char(info->st_mode); | 184 | char append = append_char(info->st_mode); |
190 | #endif | 185 | #endif |
191 | 186 | ||
@@ -196,7 +191,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
196 | column=10; | 191 | column=10; |
197 | writenum((long)info->st_nlink,(short)5); | 192 | writenum((long)info->st_nlink,(short)5); |
198 | fputs(" ", stdout); | 193 | fputs(" ", stdout); |
199 | #ifdef FEATURE_USERNAME | 194 | #ifdef BB_FEATURE_LS_USERNAME |
200 | if (!(opts & DISP_NUMERIC)) { | 195 | if (!(opts & DISP_NUMERIC)) { |
201 | scratch[8]='\0'; | 196 | scratch[8]='\0'; |
202 | my_getpwuid( scratch, info->st_uid); | 197 | my_getpwuid( scratch, info->st_uid); |
@@ -208,7 +203,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
208 | #endif | 203 | #endif |
209 | writenum((long)info->st_uid,(short)0); | 204 | writenum((long)info->st_uid,(short)0); |
210 | tab(16); | 205 | tab(16); |
211 | #ifdef FEATURE_USERNAME | 206 | #ifdef BB_FEATURE_LS_USERNAME |
212 | if (!(opts & DISP_NUMERIC)) { | 207 | if (!(opts & DISP_NUMERIC)) { |
213 | scratch[8]='\0'; | 208 | scratch[8]='\0'; |
214 | my_getgrgid( scratch, info->st_gid); | 209 | my_getgrgid( scratch, info->st_gid); |
@@ -228,7 +223,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
228 | else | 223 | else |
229 | writenum((long)info->st_size,(short)8); | 224 | writenum((long)info->st_size,(short)8); |
230 | fputs(" ", stdout); | 225 | fputs(" ", stdout); |
231 | #ifdef FEATURE_TIMESTAMPS | 226 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
232 | { | 227 | { |
233 | time_t cal; | 228 | time_t cal; |
234 | char *string; | 229 | char *string; |
@@ -264,7 +259,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
264 | wr(" -> ", 4); | 259 | wr(" -> ", 4); |
265 | len = readlink(fullname, scratch, sizeof scratch); | 260 | len = readlink(fullname, scratch, sizeof scratch); |
266 | if (len > 0) fwrite(scratch, 1, len, stdout); | 261 | if (len > 0) fwrite(scratch, 1, len, stdout); |
267 | #ifdef FEATURE_FILETYPECHAR | 262 | #ifdef BB_FEATURE_LS_FILETYPES |
268 | /* show type of destination */ | 263 | /* show type of destination */ |
269 | if (opts & DISP_FTYPE) { | 264 | if (opts & DISP_FTYPE) { |
270 | if (!stat(fullname, info)) { | 265 | if (!stat(fullname, info)) { |
@@ -275,7 +270,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
275 | } | 270 | } |
276 | #endif | 271 | #endif |
277 | } | 272 | } |
278 | #ifdef FEATURE_FILETYPECHAR | 273 | #ifdef BB_FEATURE_LS_FILETYPES |
279 | else if (append) | 274 | else if (append) |
280 | wr(&append, 1); | 275 | wr(&append, 1); |
281 | #endif | 276 | #endif |
@@ -289,7 +284,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
289 | newline(); | 284 | newline(); |
290 | else { | 285 | else { |
291 | if (nexttab + column_width > terminal_width | 286 | if (nexttab + column_width > terminal_width |
292 | #ifndef FEATURE_AUTOWIDTH | 287 | #ifndef BB_FEATURE_AUTOWIDTH |
293 | || nexttab + len >= terminal_width | 288 | || nexttab + len >= terminal_width |
294 | #endif | 289 | #endif |
295 | ) | 290 | ) |
@@ -298,7 +293,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
298 | tab(nexttab); | 293 | tab(nexttab); |
299 | } | 294 | } |
300 | /* work out where next column starts */ | 295 | /* work out where next column starts */ |
301 | #ifdef FEATURE_AUTOWIDTH | 296 | #ifdef BB_FEATURE_AUTOWIDTH |
302 | /* we know the calculated width is big enough */ | 297 | /* we know the calculated width is big enough */ |
303 | nexttab = column + column_width + COLUMN_GAP; | 298 | nexttab = column + column_width + COLUMN_GAP; |
304 | #else | 299 | #else |
@@ -311,7 +306,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
311 | /* now write the data */ | 306 | /* now write the data */ |
312 | wr(name, len); | 307 | wr(name, len); |
313 | column = column + len; | 308 | column = column + len; |
314 | #ifdef FEATURE_FILETYPECHAR | 309 | #ifdef BB_FEATURE_LS_FILETYPES |
315 | if (append) | 310 | if (append) |
316 | wr(&append, 1), column++; | 311 | wr(&append, 1), column++; |
317 | #endif | 312 | #endif |
@@ -352,7 +347,7 @@ static int list_item(const char *name) | |||
352 | 347 | ||
353 | dir = opendir(name); | 348 | dir = opendir(name); |
354 | if (!dir) goto listerr; | 349 | if (!dir) goto listerr; |
355 | #ifdef FEATURE_AUTOWIDTH | 350 | #ifdef BB_FEATURE_AUTOWIDTH |
356 | column_width = 0; | 351 | column_width = 0; |
357 | while ((entry = readdir(dir)) != NULL) { | 352 | while ((entry = readdir(dir)) != NULL) { |
358 | short w = strlen(entry->d_name); | 353 | short w = strlen(entry->d_name); |
@@ -403,22 +398,22 @@ listerr: | |||
403 | } | 398 | } |
404 | 399 | ||
405 | static const char ls_usage[] = "ls [-1a" | 400 | static const char ls_usage[] = "ls [-1a" |
406 | #ifdef FEATURE_TIMESTAMPS | 401 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
407 | "c" | 402 | "c" |
408 | #endif | 403 | #endif |
409 | "d" | 404 | "d" |
410 | #ifdef FEATURE_TIMESTAMPS | 405 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
411 | "e" | 406 | "e" |
412 | #endif | 407 | #endif |
413 | "ln" | 408 | "ln" |
414 | #ifdef FEATURE_FILETYPECHAR | 409 | #ifdef BB_FEATURE_LS_FILETYPES |
415 | "p" | 410 | "p" |
416 | #endif | 411 | #endif |
417 | #ifdef FEATURE_TIMESTAMPS | 412 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
418 | "u" | 413 | "u" |
419 | #endif | 414 | #endif |
420 | "xAC" | 415 | "xAC" |
421 | #ifdef FEATURE_FILETYPECHAR | 416 | #ifdef BB_FEATURE_LS_FILETYPES |
422 | "F" | 417 | "F" |
423 | #endif | 418 | #endif |
424 | #ifdef FEATURE_RECURSIVE | 419 | #ifdef FEATURE_RECURSIVE |
@@ -451,7 +446,7 @@ ls_main(int argc, char * * argv) | |||
451 | case '1': display_fmt = FMT_SINGLE; break; | 446 | case '1': display_fmt = FMT_SINGLE; break; |
452 | case 'x': display_fmt = FMT_ROWS; break; | 447 | case 'x': display_fmt = FMT_ROWS; break; |
453 | case 'C': display_fmt = FMT_COLUMNS; break; | 448 | case 'C': display_fmt = FMT_COLUMNS; break; |
454 | #ifdef FEATURE_FILETYPECHAR | 449 | #ifdef BB_FEATURE_LS_FILETYPES |
455 | case 'p': opts |= DISP_FTYPE; break; | 450 | case 'p': opts |= DISP_FTYPE; break; |
456 | case 'F': opts |= DISP_FTYPE|DISP_EXEC; break; | 451 | case 'F': opts |= DISP_FTYPE|DISP_EXEC; break; |
457 | #endif | 452 | #endif |
@@ -462,7 +457,7 @@ ls_main(int argc, char * * argv) | |||
462 | #ifdef FEATURE_RECURSIVE | 457 | #ifdef FEATURE_RECURSIVE |
463 | case 'R': opts |= DIR_RECURSE; break; | 458 | case 'R': opts |= DIR_RECURSE; break; |
464 | #endif | 459 | #endif |
465 | #ifdef FEATURE_TIMESTAMPS | 460 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
466 | case 'u': time_fmt = TIME_ACCESS; break; | 461 | case 'u': time_fmt = TIME_ACCESS; break; |
467 | case 'c': time_fmt = TIME_CHANGE; break; | 462 | case 'c': time_fmt = TIME_CHANGE; break; |
468 | case 'e': opts |= DISP_FULLTIME; break; | 463 | case 'e': opts |= DISP_FULLTIME; break; |
@@ -478,7 +473,7 @@ ls_main(int argc, char * * argv) | |||
478 | display_fmt = isatty(fileno(stdout)) ? FMT_COLUMNS : FMT_SINGLE; | 473 | display_fmt = isatty(fileno(stdout)) ? FMT_COLUMNS : FMT_SINGLE; |
479 | if (argi < argc - 1) | 474 | if (argi < argc - 1) |
480 | opts |= DISP_DIRNAME; /* 2 or more items? label directories */ | 475 | opts |= DISP_DIRNAME; /* 2 or more items? label directories */ |
481 | #ifdef FEATURE_AUTOWIDTH | 476 | #ifdef BB_FEATURE_AUTOWIDTH |
482 | /* could add a -w option and/or TIOCGWINSZ call */ | 477 | /* could add a -w option and/or TIOCGWINSZ call */ |
483 | if (terminal_width < 1) terminal_width = TERMINAL_WIDTH; | 478 | if (terminal_width < 1) terminal_width = TERMINAL_WIDTH; |
484 | 479 | ||
@@ -40,11 +40,6 @@ | |||
40 | * 1. requires lstat (BSD) - how do you do it without? | 40 | * 1. requires lstat (BSD) - how do you do it without? |
41 | */ | 41 | */ |
42 | 42 | ||
43 | #define FEATURE_USERNAME /* show username/groupnames (bypasses libc6 NSS) */ | ||
44 | #define FEATURE_TIMESTAMPS /* show file timestamps */ | ||
45 | #define FEATURE_AUTOWIDTH /* calculate terminal & column widths */ | ||
46 | #define FEATURE_FILETYPECHAR /* enable -p and -F */ | ||
47 | |||
48 | #define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */ | 43 | #define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */ |
49 | #define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */ | 44 | #define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */ |
50 | #define COLUMN_GAP 2 /* includes the file type char, if present */ | 45 | #define COLUMN_GAP 2 /* includes the file type char, if present */ |
@@ -64,13 +59,13 @@ | |||
64 | #include <dirent.h> | 59 | #include <dirent.h> |
65 | #include <errno.h> | 60 | #include <errno.h> |
66 | #include <stdio.h> | 61 | #include <stdio.h> |
67 | #ifdef FEATURE_TIMESTAMPS | 62 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
68 | #include <time.h> | 63 | #include <time.h> |
69 | #endif | 64 | #endif |
70 | 65 | ||
71 | #define TYPEINDEX(mode) (((mode) >> 12) & 0x0f) | 66 | #define TYPEINDEX(mode) (((mode) >> 12) & 0x0f) |
72 | #define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)]) | 67 | #define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)]) |
73 | #ifdef FEATURE_FILETYPECHAR | 68 | #ifdef BB_FEATURE_LS_FILETYPES |
74 | #define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)]) | 69 | #define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)]) |
75 | #endif | 70 | #endif |
76 | 71 | ||
@@ -103,14 +98,14 @@ static unsigned char display_fmt = FMT_AUTO; | |||
103 | static unsigned short opts = 0; | 98 | static unsigned short opts = 0; |
104 | static unsigned short column = 0; | 99 | static unsigned short column = 0; |
105 | 100 | ||
106 | #ifdef FEATURE_AUTOWIDTH | 101 | #ifdef BB_FEATURE_AUTOWIDTH |
107 | static unsigned short terminal_width = 0, column_width = 0; | 102 | static unsigned short terminal_width = 0, column_width = 0; |
108 | #else | 103 | #else |
109 | #define terminal_width TERMINAL_WIDTH | 104 | #define terminal_width TERMINAL_WIDTH |
110 | #define column_width COLUMN_WIDTH | 105 | #define column_width COLUMN_WIDTH |
111 | #endif | 106 | #endif |
112 | 107 | ||
113 | #ifdef FEATURE_TIMESTAMPS | 108 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
114 | static unsigned char time_fmt = TIME_MOD; | 109 | static unsigned char time_fmt = TIME_MOD; |
115 | #endif | 110 | #endif |
116 | 111 | ||
@@ -163,7 +158,7 @@ static void tab(short col) | |||
163 | #undef nspaces | 158 | #undef nspaces |
164 | } | 159 | } |
165 | 160 | ||
166 | #ifdef FEATURE_FILETYPECHAR | 161 | #ifdef BB_FEATURE_LS_FILETYPES |
167 | static char append_char(mode_t mode) | 162 | static char append_char(mode_t mode) |
168 | { | 163 | { |
169 | if (!(opts & DISP_FTYPE)) | 164 | if (!(opts & DISP_FTYPE)) |
@@ -185,7 +180,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
185 | { | 180 | { |
186 | char scratch[PATH_MAX]; | 181 | char scratch[PATH_MAX]; |
187 | short len = strlen(name); | 182 | short len = strlen(name); |
188 | #ifdef FEATURE_FILETYPECHAR | 183 | #ifdef BB_FEATURE_LS_FILETYPES |
189 | char append = append_char(info->st_mode); | 184 | char append = append_char(info->st_mode); |
190 | #endif | 185 | #endif |
191 | 186 | ||
@@ -196,7 +191,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
196 | column=10; | 191 | column=10; |
197 | writenum((long)info->st_nlink,(short)5); | 192 | writenum((long)info->st_nlink,(short)5); |
198 | fputs(" ", stdout); | 193 | fputs(" ", stdout); |
199 | #ifdef FEATURE_USERNAME | 194 | #ifdef BB_FEATURE_LS_USERNAME |
200 | if (!(opts & DISP_NUMERIC)) { | 195 | if (!(opts & DISP_NUMERIC)) { |
201 | scratch[8]='\0'; | 196 | scratch[8]='\0'; |
202 | my_getpwuid( scratch, info->st_uid); | 197 | my_getpwuid( scratch, info->st_uid); |
@@ -208,7 +203,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
208 | #endif | 203 | #endif |
209 | writenum((long)info->st_uid,(short)0); | 204 | writenum((long)info->st_uid,(short)0); |
210 | tab(16); | 205 | tab(16); |
211 | #ifdef FEATURE_USERNAME | 206 | #ifdef BB_FEATURE_LS_USERNAME |
212 | if (!(opts & DISP_NUMERIC)) { | 207 | if (!(opts & DISP_NUMERIC)) { |
213 | scratch[8]='\0'; | 208 | scratch[8]='\0'; |
214 | my_getgrgid( scratch, info->st_gid); | 209 | my_getgrgid( scratch, info->st_gid); |
@@ -228,7 +223,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
228 | else | 223 | else |
229 | writenum((long)info->st_size,(short)8); | 224 | writenum((long)info->st_size,(short)8); |
230 | fputs(" ", stdout); | 225 | fputs(" ", stdout); |
231 | #ifdef FEATURE_TIMESTAMPS | 226 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
232 | { | 227 | { |
233 | time_t cal; | 228 | time_t cal; |
234 | char *string; | 229 | char *string; |
@@ -264,7 +259,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
264 | wr(" -> ", 4); | 259 | wr(" -> ", 4); |
265 | len = readlink(fullname, scratch, sizeof scratch); | 260 | len = readlink(fullname, scratch, sizeof scratch); |
266 | if (len > 0) fwrite(scratch, 1, len, stdout); | 261 | if (len > 0) fwrite(scratch, 1, len, stdout); |
267 | #ifdef FEATURE_FILETYPECHAR | 262 | #ifdef BB_FEATURE_LS_FILETYPES |
268 | /* show type of destination */ | 263 | /* show type of destination */ |
269 | if (opts & DISP_FTYPE) { | 264 | if (opts & DISP_FTYPE) { |
270 | if (!stat(fullname, info)) { | 265 | if (!stat(fullname, info)) { |
@@ -275,7 +270,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
275 | } | 270 | } |
276 | #endif | 271 | #endif |
277 | } | 272 | } |
278 | #ifdef FEATURE_FILETYPECHAR | 273 | #ifdef BB_FEATURE_LS_FILETYPES |
279 | else if (append) | 274 | else if (append) |
280 | wr(&append, 1); | 275 | wr(&append, 1); |
281 | #endif | 276 | #endif |
@@ -289,7 +284,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
289 | newline(); | 284 | newline(); |
290 | else { | 285 | else { |
291 | if (nexttab + column_width > terminal_width | 286 | if (nexttab + column_width > terminal_width |
292 | #ifndef FEATURE_AUTOWIDTH | 287 | #ifndef BB_FEATURE_AUTOWIDTH |
293 | || nexttab + len >= terminal_width | 288 | || nexttab + len >= terminal_width |
294 | #endif | 289 | #endif |
295 | ) | 290 | ) |
@@ -298,7 +293,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
298 | tab(nexttab); | 293 | tab(nexttab); |
299 | } | 294 | } |
300 | /* work out where next column starts */ | 295 | /* work out where next column starts */ |
301 | #ifdef FEATURE_AUTOWIDTH | 296 | #ifdef BB_FEATURE_AUTOWIDTH |
302 | /* we know the calculated width is big enough */ | 297 | /* we know the calculated width is big enough */ |
303 | nexttab = column + column_width + COLUMN_GAP; | 298 | nexttab = column + column_width + COLUMN_GAP; |
304 | #else | 299 | #else |
@@ -311,7 +306,7 @@ static void list_single(const char *name, struct stat *info, const char *fullnam | |||
311 | /* now write the data */ | 306 | /* now write the data */ |
312 | wr(name, len); | 307 | wr(name, len); |
313 | column = column + len; | 308 | column = column + len; |
314 | #ifdef FEATURE_FILETYPECHAR | 309 | #ifdef BB_FEATURE_LS_FILETYPES |
315 | if (append) | 310 | if (append) |
316 | wr(&append, 1), column++; | 311 | wr(&append, 1), column++; |
317 | #endif | 312 | #endif |
@@ -352,7 +347,7 @@ static int list_item(const char *name) | |||
352 | 347 | ||
353 | dir = opendir(name); | 348 | dir = opendir(name); |
354 | if (!dir) goto listerr; | 349 | if (!dir) goto listerr; |
355 | #ifdef FEATURE_AUTOWIDTH | 350 | #ifdef BB_FEATURE_AUTOWIDTH |
356 | column_width = 0; | 351 | column_width = 0; |
357 | while ((entry = readdir(dir)) != NULL) { | 352 | while ((entry = readdir(dir)) != NULL) { |
358 | short w = strlen(entry->d_name); | 353 | short w = strlen(entry->d_name); |
@@ -403,22 +398,22 @@ listerr: | |||
403 | } | 398 | } |
404 | 399 | ||
405 | static const char ls_usage[] = "ls [-1a" | 400 | static const char ls_usage[] = "ls [-1a" |
406 | #ifdef FEATURE_TIMESTAMPS | 401 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
407 | "c" | 402 | "c" |
408 | #endif | 403 | #endif |
409 | "d" | 404 | "d" |
410 | #ifdef FEATURE_TIMESTAMPS | 405 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
411 | "e" | 406 | "e" |
412 | #endif | 407 | #endif |
413 | "ln" | 408 | "ln" |
414 | #ifdef FEATURE_FILETYPECHAR | 409 | #ifdef BB_FEATURE_LS_FILETYPES |
415 | "p" | 410 | "p" |
416 | #endif | 411 | #endif |
417 | #ifdef FEATURE_TIMESTAMPS | 412 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
418 | "u" | 413 | "u" |
419 | #endif | 414 | #endif |
420 | "xAC" | 415 | "xAC" |
421 | #ifdef FEATURE_FILETYPECHAR | 416 | #ifdef BB_FEATURE_LS_FILETYPES |
422 | "F" | 417 | "F" |
423 | #endif | 418 | #endif |
424 | #ifdef FEATURE_RECURSIVE | 419 | #ifdef FEATURE_RECURSIVE |
@@ -451,7 +446,7 @@ ls_main(int argc, char * * argv) | |||
451 | case '1': display_fmt = FMT_SINGLE; break; | 446 | case '1': display_fmt = FMT_SINGLE; break; |
452 | case 'x': display_fmt = FMT_ROWS; break; | 447 | case 'x': display_fmt = FMT_ROWS; break; |
453 | case 'C': display_fmt = FMT_COLUMNS; break; | 448 | case 'C': display_fmt = FMT_COLUMNS; break; |
454 | #ifdef FEATURE_FILETYPECHAR | 449 | #ifdef BB_FEATURE_LS_FILETYPES |
455 | case 'p': opts |= DISP_FTYPE; break; | 450 | case 'p': opts |= DISP_FTYPE; break; |
456 | case 'F': opts |= DISP_FTYPE|DISP_EXEC; break; | 451 | case 'F': opts |= DISP_FTYPE|DISP_EXEC; break; |
457 | #endif | 452 | #endif |
@@ -462,7 +457,7 @@ ls_main(int argc, char * * argv) | |||
462 | #ifdef FEATURE_RECURSIVE | 457 | #ifdef FEATURE_RECURSIVE |
463 | case 'R': opts |= DIR_RECURSE; break; | 458 | case 'R': opts |= DIR_RECURSE; break; |
464 | #endif | 459 | #endif |
465 | #ifdef FEATURE_TIMESTAMPS | 460 | #ifdef BB_FEATURE_LS_TIMESTAMPS |
466 | case 'u': time_fmt = TIME_ACCESS; break; | 461 | case 'u': time_fmt = TIME_ACCESS; break; |
467 | case 'c': time_fmt = TIME_CHANGE; break; | 462 | case 'c': time_fmt = TIME_CHANGE; break; |
468 | case 'e': opts |= DISP_FULLTIME; break; | 463 | case 'e': opts |= DISP_FULLTIME; break; |
@@ -478,7 +473,7 @@ ls_main(int argc, char * * argv) | |||
478 | display_fmt = isatty(fileno(stdout)) ? FMT_COLUMNS : FMT_SINGLE; | 473 | display_fmt = isatty(fileno(stdout)) ? FMT_COLUMNS : FMT_SINGLE; |
479 | if (argi < argc - 1) | 474 | if (argi < argc - 1) |
480 | opts |= DISP_DIRNAME; /* 2 or more items? label directories */ | 475 | opts |= DISP_DIRNAME; /* 2 or more items? label directories */ |
481 | #ifdef FEATURE_AUTOWIDTH | 476 | #ifdef BB_FEATURE_AUTOWIDTH |
482 | /* could add a -w option and/or TIOCGWINSZ call */ | 477 | /* could add a -w option and/or TIOCGWINSZ call */ |
483 | if (terminal_width < 1) terminal_width = TERMINAL_WIDTH; | 478 | if (terminal_width < 1) terminal_width = TERMINAL_WIDTH; |
484 | 479 | ||