1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* human.h -- print human readable file size
5 Copyright (C) 1996-2007, 2009-2013 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* Written by Paul Eggert and Larry McVoy. */
32 /* A conservative bound on the maximum length of a human-readable string.
33 The output can be the square of the largest uintmax_t, so double
34 its size before converting to a bound.
35 log10 (2.0) < 146/485. Add 1 for integer division truncation.
36 Also, the output can have a thousands separator between every digit,
37 so multiply by MB_LEN_MAX + 1 and then subtract MB_LEN_MAX.
38 Append 1 for a space before the suffix.
39 Finally, append 3, the maximum length of a suffix. */
40 # define LONGEST_HUMAN_READABLE \
41 ((2 * sizeof (uintmax_t) * CHAR_BIT * 146 / 485 + 1) * (MB_LEN_MAX + 1) \
44 /* Options for human_readable. */
47 /* Unless otherwise specified these options may be ORed together. */
49 /* The following three options are mutually exclusive. */
50 /* Round to plus infinity (default). */
52 /* Round to nearest, ties to even. */
53 human_round_to_nearest = 1,
54 /* Round to minus infinity. */
57 /* Group digits together, e.g. "1,000,000". This uses the
58 locale-defined grouping; the traditional C locale does not group,
59 so this has effect only if some other locale is in use. */
60 human_group_digits = 4,
62 /* When autoscaling, suppress ".0" at end. */
63 human_suppress_point_zero = 8,
65 /* Scale output and use SI-style units, ignoring the output block size. */
68 /* Prefer base 1024 to base 1000. */
71 /* Prepend " " before unit symbol. */
72 human_space_before_unit = 64,
74 /* Append SI prefix, e.g. "k" or "M". */
77 /* Append "B" (if base 1000) or "iB" (if base 1024) to SI prefix. */
81 char *human_readable (uintmax_t, char *, int, uintmax_t, uintmax_t);
83 enum strtol_error human_options (char const *, int *, uintmax_t *);