A clone of btpd with my configuration changes.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.5 KiB

  1. #ifndef BTPD_H
  2. #define BTPD_H
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <sys/time.h>
  6. #include <sys/socket.h>
  7. #include <netinet/in.h>
  8. #include <arpa/inet.h>
  9. #include <netdb.h>
  10. #ifndef AI_ADDRCONFIG
  11. #define AI_ADDRCONFIG 0
  12. #endif
  13. #include <assert.h>
  14. #include <errno.h>
  15. #include <fcntl.h>
  16. #include <math.h>
  17. #include <inttypes.h>
  18. #include <limits.h>
  19. #include <stddef.h>
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <strings.h>
  24. #include <unistd.h>
  25. #include <benc.h>
  26. #define DAEMON
  27. #include <btpd_if.h>
  28. #undef DAEMON
  29. #include <evloop.h>
  30. #include <metainfo.h>
  31. #include <queue.h>
  32. #include <subr.h>
  33. #include "active.h"
  34. #include "hashtable.h"
  35. #include "net_buf.h"
  36. #include "net_types.h"
  37. #include "net.h"
  38. #include "peer.h"
  39. #include "tlib.h"
  40. #include "torrent.h"
  41. #include "download.h"
  42. #include "upload.h"
  43. #include "content.h"
  44. #include "opts.h"
  45. #include "tracker_req.h"
  46. #define BTPD_VERSION PACKAGE_NAME "/" PACKAGE_VERSION
  47. #define BTPD_L_ALL 0xffffffff
  48. #define BTPD_L_ERROR 0x00000001
  49. #define BTPD_L_TRACKER 0x00000002
  50. #define BTPD_L_CONN 0x00000004
  51. #define BTPD_L_MSG 0x00000008
  52. #define BTPD_L_BTPD 0x00000010
  53. #define BTPD_L_POL 0x00000020
  54. extern long btpd_seconds;
  55. void btpd_init(void);
  56. __attribute__((format (printf, 2, 3)))
  57. void btpd_log(uint32_t type, const char *fmt, ...);
  58. __attribute__((format (printf, 1, 2), noreturn))
  59. void btpd_err(const char *fmt, ...);
  60. __attribute__((malloc))
  61. void *btpd_malloc(size_t size);
  62. __attribute__((malloc))
  63. void *btpd_calloc(size_t nmemb, size_t size);
  64. void btpd_ev_new(struct fdev *ev, int fd, uint16_t flags, evloop_cb_t cb,
  65. void *arg);
  66. void btpd_ev_del(struct fdev *ev);
  67. void btpd_ev_enable(struct fdev *ev, uint16_t flags);
  68. void btpd_ev_disable(struct fdev *ev, uint16_t flags);
  69. void btpd_timer_add(struct timeout *to, struct timespec *ts);
  70. void btpd_timer_del(struct timeout *to);
  71. void btpd_shutdown(int grace_seconds);
  72. int btpd_is_stopping(void);
  73. const uint8_t *btpd_get_peer_id(void);
  74. void td_acquire_lock(void);
  75. void td_release_lock(void);
  76. void td_post(void (*cb)(void *), void *arg);
  77. void td_post_end();
  78. #define td_post_begin td_acquire_lock
  79. typedef struct ai_ctx * aictx_t;
  80. aictx_t btpd_addrinfo(const char *node, short port, struct addrinfo *hints,
  81. void (*cb)(void *, int, struct addrinfo *), void *arg);
  82. void btpd_addrinfo_cancel(aictx_t ctx);
  83. typedef struct nameconn *nameconn_t;
  84. nameconn_t btpd_name_connect(const char *name, short port,
  85. void (*cb)(void *, int, int), void *arg);
  86. void btpd_name_connect_cancel(nameconn_t nc);
  87. #endif