util.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright (c) 2003-2004, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. /**
  6. * \file util.h
  7. * \brief Headers for util.c
  8. **/
  9. #ifndef TOR_UTIL_H
  10. #define TOR_UTIL_H
  11. #include "orconfig.h"
  12. #include "lib/cc/torint.h"
  13. #include "common/compat.h"
  14. #include "lib/ctime/di_ops.h"
  15. #include "lib/testsupport/testsupport.h"
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #ifdef _WIN32
  19. /* for the correct alias to struct stat */
  20. #include <sys/stat.h>
  21. #endif
  22. #include "lib/err/torerr.h"
  23. #include "lib/malloc/util_malloc.h"
  24. #include "lib/wallclock/approx_time.h"
  25. #include "lib/string/util_string.h"
  26. #include "lib/string/parse_int.h"
  27. #include "lib/string/scanf.h"
  28. #include "lib/intmath/bits.h"
  29. #include "lib/intmath/addsub.h"
  30. #include "lib/intmath/logic.h"
  31. #include "lib/intmath/muldiv.h"
  32. #include "lib/intmath/cmp.h"
  33. #include "lib/log/ratelim.h"
  34. #include "lib/log/util_bug.h"
  35. #include "lib/log/escape.h"
  36. #include "lib/fs/dir.h"
  37. #include "lib/fs/files.h"
  38. #include "lib/fs/path.h"
  39. #include "lib/encoding/time_fmt.h"
  40. #include "lib/encoding/cstring.h"
  41. #include "lib/fs/winlib.h"
  42. /** Macro: yield a pointer to an enclosing structure given a pointer to
  43. * a substructure at offset <b>off</b>. Example:
  44. * <pre>
  45. * struct base { ... };
  46. * struct subtype { int x; struct base b; } x;
  47. * struct base *bp = &x.base;
  48. * struct *sp = SUBTYPE_P(bp, struct subtype, b);
  49. * </pre>
  50. */
  51. #define SUBTYPE_P(p, subtype, basemember) \
  52. ((void*) ( ((char*)(p)) - offsetof(subtype, basemember) ))
  53. /* Math functions */
  54. /* String manipulation */
  55. /* Time helpers */
  56. /* File helpers */
  57. #endif /* !defined(TOR_UTIL_H) */