1 /* vi: set sw=4 ts=4: */
3 * strings implementation for busybox
5 * Copyright Tito Ragusa <farmatito@tiscali.it>
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
18 #define PRINT_OFFSET 4
21 int strings_main(int argc, char **argv);
22 int strings_main(int argc, char **argv)
24 int n, c, i = 0, status = EXIT_SUCCESS;
29 const char *fmt = "%s: ";
30 const char *n_arg = "4";
32 opt = getopt32(argc, argv, "afon:", &n_arg);
33 /* -a is our default behaviour */
38 n = xatoul_range(n_arg, 1, INT_MAX);
39 string = xzalloc(n + 1);
44 *argv = (char *)bb_msg_standard_input;
49 file = fopen_or_warn(*argv, "r");
55 if (isprint(c) || c == '\t') {
62 if (opt & PRINT_NAME) {
65 if (opt & PRINT_OFFSET) {
66 printf("%7lo ", count - n);
79 fclose_if_not_stdin(file);
81 status = EXIT_FAILURE;
85 if (ENABLE_FEATURE_CLEAN_UP)
88 fflush_stdout_and_exit(status);