util.h 808 B

1234567891011121314151617181920212223
  1. #ifndef _UTIL_H
  2. #define _UTIL_H
  3. #include <unistd.h>
  4. #include <stdint.h>
  5. #include <tox/tox.h>
  6. #define countof(x) (sizeof(x)/sizeof(*(x)))
  7. #define char_t unsigned char
  8. void writechecksum(uint8_t *address);
  9. void to_hex(char_t *a, const char_t *p, int size);
  10. void id_to_string(char_t *dest, const char_t *src);
  11. int string_to_id(char_t *w, char_t *a);
  12. void* file_raw(char *path, uint32_t *size);
  13. const char *readable_connection_status(TOX_CONNECTION status);
  14. int parse_local_port_forward(char *string, int *local_port, char **hostname, int *remote_port);
  15. int parse_pipe_port_forward(char *string, char **hostname, int *remote_port);
  16. size_t hex_string_to_bin(const char *hex_string, size_t hex_len, uint8_t *bytes);
  17. bool is_valid_ipv4(const char *ip_address);
  18. bool is_valid_ipv6(const char *ip_address);
  19. #endif