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)
23 int n, c, i = 0, status = EXIT_SUCCESS;
28 const char *fmt = "%s: ";
31 opt = bb_getopt_ulflags(argc, argv, "afon:", &n_arg);
32 /* -a is our default behaviour */
37 n = bb_xgetlarg(n_arg, 10, 1, INT_MAX);
38 string = xzalloc(n + 1);
43 *argv = (char *)bb_msg_standard_input;
48 if ((file = bb_wfopen(*argv, "r"))) {
53 if (isprint(c) || c == '\t') {
60 if (opt & PRINT_NAME) {
63 if (opt & PRINT_OFFSET) {
64 printf("%7lo ", count - n);
77 bb_fclose_nonstdin(file);
79 status = EXIT_FAILURE;
83 if (ENABLE_FEATURE_CLEAN_UP)
86 bb_fflush_stdout_and_exit(status);