Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/miscutils/strings.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/miscutils/strings.c
r1765 r2725 3 3 * strings implementation for busybox 4 4 * 5 * Copyright Tito Ragusa <farmatito@tiscali.it>5 * Copyright 2003 Tito Ragusa <farmatito@tiscali.it> 6 6 * 7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 8 */ 9 10 #include <getopt.h>11 9 12 10 #include "libbb.h" 13 11 14 #define WHOLE_FILE 15 #define PRINT_NAME 16 #define PRINT_OFFSET 17 #define SIZE 12 #define WHOLE_FILE 1 13 #define PRINT_NAME 2 14 #define PRINT_OFFSET 4 15 #define SIZE 8 18 16 19 int strings_main(int argc, char **argv) ;20 int strings_main(int argc , char **argv)17 int strings_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 18 int strings_main(int argc UNUSED_PARAM, char **argv) 21 19 { 22 20 int n, c, status = EXIT_SUCCESS; 23 unsigned opt;24 21 unsigned count; 25 22 off_t offset; 26 FILE *file = stdin;23 FILE *file; 27 24 char *string; 28 25 const char *fmt = "%s: "; 29 26 const char *n_arg = "4"; 30 27 31 opt =getopt32(argv, "afon:", &n_arg);28 getopt32(argv, "afon:", &n_arg); 32 29 /* -a is our default behaviour */ 33 30 /*argc -= optind;*/ … … 41 38 fmt = "{%s}: "; 42 39 *--argv = (char *)bb_msg_standard_input; 43 goto PIPE;44 40 } 45 41 46 42 do { 47 file = fopen_or_warn (*argv, "r");43 file = fopen_or_warn_stdin(*argv); 48 44 if (!file) { 49 45 status = EXIT_FAILURE; 50 46 continue; 51 47 } 52 PIPE:53 48 offset = 0; 54 49 count = 0; 55 50 do { 56 51 c = fgetc(file); 57 if (isprint (c) || c == '\t') {52 if (isprint_asciionly(c) || c == '\t') { 58 53 if (count > n) { 59 putchar(c);54 bb_putchar(c); 60 55 } else { 61 56 string[count] = c; 62 57 if (count == n) { 63 if (opt & PRINT_NAME) {58 if (option_mask32 & PRINT_NAME) { 64 59 printf(fmt, *argv); 65 60 } 66 if (opt & PRINT_OFFSET) {61 if (option_mask32 & PRINT_OFFSET) { 67 62 printf("%7"OFF_FMT"o ", offset - n); 68 63 } … … 73 68 } else { 74 69 if (count > n) { 75 putchar('\n');70 bb_putchar('\n'); 76 71 } 77 72 count = 0;
Note:
See TracChangeset
for help on using the changeset viewer.