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.

subr.h 1.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef BTPD_SUBR_H
  2. #define BTPD_SUBR_H
  3. #include <stdio.h>
  4. #include <stdarg.h>
  5. #define max(x, y) ((x) >= (y) ? (x) : (y))
  6. #define min(x, y) ((x) <= (y) ? (x) : (y))
  7. #define SHAHEXSIZE 41
  8. uint32_t dec_be32(const void *buf);
  9. uint64_t dec_be64(const void *buf);
  10. void enc_be32(void *buf, uint32_t num);
  11. void enc_be64(void *buf, uint64_t num);
  12. int set_nonblocking(int fd);
  13. int set_blocking(int fd);
  14. int mkdirs(char *path, int mode);
  15. __attribute__((format (printf, 3, 0)))
  16. int vaopen(int *resfd, int flags, const char *fmt, va_list ap);
  17. __attribute__((format (printf, 3, 4)))
  18. int vopen(int *resfd, int flags, const char *fmt, ...);
  19. __attribute__((format (printf, 3, 4)))
  20. int vfopen(FILE **ret, const char *mode, const char *fmt, ...);
  21. int vfsync(const char *fmt, ...);
  22. void set_bit(uint8_t *bits, unsigned long index);
  23. int has_bit(const uint8_t *bits, unsigned long index);
  24. void clear_bit(uint8_t *bits, unsigned long index);
  25. char *bin2hex(const uint8_t *bin, char *hex, size_t bsize);
  26. uint8_t *hex2bin(const char *hex, uint8_t *bin, size_t bsize);
  27. uint8_t hex2i(char c);
  28. int ishex(char *str);
  29. long rand_between(long min, long max);
  30. int read_fully(int fd, void *buf, size_t len);
  31. int write_fully(int fd, const void *buf, size_t len);
  32. void *read_file(const char *path, void *buf, size_t *size);
  33. char *find_btpd_dir(void);
  34. int make_abs_path(const char *in, char *out);
  35. #endif