update from prep
[gnulib.git] / lib / human.h
1 #ifndef HUMAN_H_
2 # define HUMAN_H_ 1
3
4 # if HAVE_CONFIG_H
5 #  include <config.h>
6 # endif
7
8 # if HAVE_INTTYPES_H
9 #  include <inttypes.h>
10 # else
11 #  if HAVE_STDINT_H
12 #   include <stdint.h>
13 #  endif
14 # endif
15
16 /* A conservative bound on the maximum length of a human-readable string.
17    The output can be the product of the largest uintmax_t and the largest int,
18    so add their sizes before converting to a bound on digits.  */
19 # define LONGEST_HUMAN_READABLE ((sizeof (uintmax_t) + sizeof (int)) \
20                                  * CHAR_BIT / 3)
21
22 # ifndef PARAMS
23 #  if defined PROTOTYPES || (defined __STDC__ && __STDC__)
24 #   define PARAMS(Args) Args
25 #  else
26 #   define PARAMS(Args) ()
27 #  endif
28 # endif
29
30 enum human_inexact_style
31 {
32   human_floor = -1,
33   human_round_to_even = 0,
34   human_ceiling = 1
35 };
36
37 char *human_readable PARAMS ((uintmax_t, char *, int, int));
38 char *human_readable_inexact PARAMS ((uintmax_t, char *, int, int,
39                                       enum human_inexact_style));
40
41 void human_block_size PARAMS ((char const *, int, int *));
42
43 #endif /* HUMAN_H_ */