util.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* See LICENSE file for copyright and license details. */
  2. #include "arg.h"
  3. #define UTF8_POINT(c) (((c) & 0xc0) != 0x80)
  4. #undef MIN
  5. #define MIN(x,y) ((x) < (y) ? (x) : (y))
  6. #undef MAX
  7. #define MAX(x,y) ((x) > (y) ? (x) : (y))
  8. #undef LIMIT
  9. #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
  10. #define LEN(x) (sizeof (x) / sizeof *(x))
  11. /* eprintf.c */
  12. extern char *argv0;
  13. /* agetcwd.c */
  14. char *agetcwd(void);
  15. /* apathmax.c */
  16. void apathmax(char **, long *);
  17. /* ealloc.c */
  18. void *ecalloc(size_t, size_t);
  19. void *emalloc(size_t size);
  20. void *erealloc(void *, size_t);
  21. char *estrdup(const char *);
  22. /* eprintf.c */
  23. void enprintf(int, const char *, ...);
  24. void eprintf(const char *, ...);
  25. void weprintf(const char *, ...);
  26. /* estrtol.c */
  27. long estrtol(const char *, int);
  28. /* estrtoul.c */
  29. unsigned long estrtoul(const char *, int);
  30. /* explicit_bzero.c */
  31. #undef explicit_bzero
  32. void explicit_bzero(void *, size_t);
  33. /* putword.c */
  34. void putword(const char *);
  35. /* recurse.c */
  36. void recurse(const char *, void (*)(const char *));
  37. /* strlcat.c */
  38. #undef strlcat
  39. size_t strlcat(char *, const char *, size_t);
  40. size_t estrlcat(char *, const char *, size_t);
  41. /* strlcpy.c */
  42. #undef strlcpy
  43. size_t strlcpy(char *, const char *, size_t);
  44. size_t estrlcpy(char *, const char *, size_t);
  45. /* strtonum.c */
  46. #undef strtonum
  47. long long strtonum(const char *, long long, long long, const char **);
  48. long long enstrtonum(int, const char *, long long, long long);
  49. long long estrtonum(const char *, long long, long long);
  50. /* tty.c */
  51. void devtotty(int, int *, int *);
  52. int ttytostr(int, int, char *, size_t);