human.h 958 B

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