Mirror of git://git.busybox.net/busybox with our patches on top
Source
xxxxxxxxxx
/* vi: set sw=4 ts=4: */
/*
* head implementation for busybox
*
* Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 compliant */
/* BB_AUDIT GNU compatible -c, -q, and -v options in 'fancy' configuration. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/head.html */
static const char head_opts[] ALIGN1 =
"n:"
"c:qv"
;
static const struct suffix_mult head_suffixes[] = {
{ "b", 512 },
{ "k", 1024 },
{ "m", 1024*1024 },
{ }
};
static const char header_fmt_str[] ALIGN1 = "\n==> %s <==\n";
int head_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int head_main(int argc, char **argv)
{
unsigned long count = 10;
unsigned long i;
int count_bytes = 0;
int header_threshhold = 1;
FILE *fp;
const char *fmt;
char *p;
int opt;
int c;
int retval = EXIT_SUCCESS;
/* Allow legacy syntax of an initial numeric option without -n. */
if (argc > 1 && argv[1][0] == '-'
&& isdigit(argv[1][1])
) {
--argc;
++argv;
p = (*argv) + 1;
goto GET_COUNT;
}
/* No size benefit in converting this to getopt32 */