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.

116 lines
2.7 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_TR 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. #define BTPD_L_BAD 0x00000040
  55. extern long btpd_seconds;
  56. void btpd_init(void);
  57. __attribute__((format (printf, 2, 3)))
  58. void btpd_log(uint32_t type, const char *fmt, ...);
  59. __attribute__((format (printf, 1, 2), noreturn))
  60. void btpd_err(const char *fmt, ...);
  61. __attribute__((malloc))
  62. void *btpd_malloc(size_t size);
  63. __attribute__((malloc))
  64. void *btpd_calloc(size_t nmemb, size_t size);
  65. void btpd_ev_new(struct fdev *ev, int fd, uint16_t flags, evloop_cb_t cb,
  66. void *arg);
  67. void btpd_ev_del(struct fdev *ev);
  68. void btpd_ev_enable(struct fdev *ev, uint16_t flags);
  69. void btpd_ev_disable(struct fdev *ev, uint16_t flags);
  70. void btpd_timer_add(struct timeout *to, struct timespec *ts);
  71. void btpd_timer_del(struct timeout *to);
  72. void btpd_shutdown(void);
  73. int btpd_is_stopping(void);
  74. int btpd_id_eq(const void *k1, const void *k2);
  75. uint32_t btpd_id_hash(const void *k);
  76. const uint8_t *btpd_get_peer_id(void);
  77. int btpd_id_eq(const void *id1, const void *id2);
  78. uint32_t btpd_id_hash(const void *id);
  79. void td_acquire_lock(void);
  80. void td_release_lock(void);
  81. void td_post(void (*cb)(void *), void *arg);
  82. void td_post_end();
  83. #define td_post_begin td_acquire_lock
  84. typedef struct ai_ctx * aictx_t;
  85. aictx_t btpd_addrinfo(const char *node, uint16_t port, struct addrinfo *hints,
  86. void (*cb)(void *, int, struct addrinfo *), void *arg);
  87. void btpd_addrinfo_cancel(aictx_t ctx);
  88. typedef struct nameconn *nameconn_t;
  89. nameconn_t btpd_name_connect(const char *name, short port,
  90. void (*cb)(void *, int, int), void *arg);
  91. void btpd_name_connect_cancel(nameconn_t nc);
  92. #endif