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.2 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. int set_nonblocking(int fd);
  9. int set_blocking(int fd);
  10. int mkdirs(char *path, int mode);
  11. __attribute__((format (printf, 3, 0)))
  12. int vaopen(int *resfd, int flags, const char *fmt, va_list ap);
  13. __attribute__((format (printf, 3, 4)))
  14. int vopen(int *resfd, int flags, const char *fmt, ...);
  15. __attribute__((format (printf, 3, 4)))
  16. int vfopen(FILE **ret, const char *mode, const char *fmt, ...);
  17. int vfsync(const char *fmt, ...);
  18. void set_bit(uint8_t *bits, unsigned long index);
  19. int has_bit(const uint8_t *bits, unsigned long index);
  20. void clear_bit(uint8_t *bits, unsigned long index);
  21. char *bin2hex(const uint8_t *bin, char *hex, size_t bsize);
  22. uint8_t *hex2bin(const char *hex, uint8_t *bin, size_t bsize);
  23. uint8_t hex2i(char c);
  24. int ishex(char *str);
  25. long rand_between(long min, long max);
  26. int read_fully(int fd, void *buf, size_t len);
  27. int write_fully(int fd, const void *buf, size_t len);
  28. void *read_file(const char *path, void *buf, size_t *size);
  29. char *find_btpd_dir(void);
  30. int make_abs_path(const char *in, char *out);
  31. #endif