compat_libevent.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Copyright (c) 2009, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #ifndef _TOR_COMPAT_LIBEVENT_H
  4. #define _TOR_COMPAT_LIBEVENT_H
  5. #include "orconfig.h"
  6. struct event;
  7. struct event_base;
  8. #ifdef HAVE_EVENT2_EVENT_H
  9. #include <event2/util.h>
  10. #else
  11. #define evutil_socket_t int
  12. #endif
  13. void configure_libevent_logging(void);
  14. void suppress_libevent_log_msg(const char *msg);
  15. #ifdef HAVE_EVENT2_EVENT_H
  16. #define tor_event_new event_new
  17. #define tor_evtimer_new evtimer_new
  18. #define tor_evsignal_new evsignal_new
  19. #define tor_event_free event_free
  20. #else
  21. struct event *tor_event_new(struct event_base * base, evutil_socket_t sock,
  22. short what, void (*cb)(evutil_socket_t, short, void *), void *arg);
  23. struct event *tor_evtimer_new(struct event_base * base,
  24. void (*cb)(evutil_socket_t, short, void *), void *arg);
  25. struct event *tor_evsignal_new(struct event_base * base, int sig,
  26. void (*cb)(evutil_socket_t, short, void *), void *arg);
  27. void tor_event_free(struct event *ev);
  28. #endif
  29. /* XXXX022 If we can drop support for Libevent before 1.1, we can
  30. * do without this wrapper. */
  31. #ifdef HAVE_EVENT_BASE_LOOPEXIT
  32. #define tor_event_base_loopexit event_base_loopexit
  33. #else
  34. struct timeval;
  35. int tor_event_base_loopexit(struct event_base *base, struct timeval *tv);
  36. #endif
  37. void tor_libevent_initialize(void);
  38. struct event_base *tor_libevent_get_base(void);
  39. const char *tor_libevent_get_method(void);
  40. void tor_check_libevent_version(const char *m, int server,
  41. const char **badness_out);
  42. void tor_check_libevent_header_compatibility(void);
  43. const char *tor_libevent_get_version_str(void);
  44. #endif