A tool for adding anime to your anidb list.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

52 lignes
1.1KB

  1. #ifndef _UTIL_H
  2. #define _UTIL_H
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #include <stdbool.h>
  6. #define MS_TO_TIMESPEC(ts, ms) { \
  7. ts->tv_sec = ms / 1000; \
  8. ts->tv_nsec = (ms % 1000) * 1000000; \
  9. }
  10. #define MS_TO_TIMESPEC_L(ts, ms) { \
  11. ts.tv_sec = ms / 1000; \
  12. ts.tv_nsec = (ms % 1000) * 1000000; \
  13. }
  14. /*
  15. * Convert bytes to a hex string
  16. * out needs to be at least (bytes_len * 2 + 1) bytes
  17. */
  18. void util_byte2hex(const uint8_t* bytes, size_t bytes_len,
  19. bool uppercase, char* out);
  20. /*
  21. * Return the user's home directory
  22. */
  23. const char *util_get_home();
  24. /*
  25. * Return the filename part of the path
  26. * This will return a pointer in fullpath
  27. * !! ONLY WORKS FOR FILES !!
  28. */
  29. char *util_basename(const char *fullpath);
  30. /*
  31. * Calculate the difference between 2 timespec structs in miliseconds
  32. *
  33. * future cannot be more in the past than past
  34. * if that makes any sense
  35. */
  36. uint64_t util_timespec_diff(const struct timespec *past,
  37. const struct timespec *future);
  38. /*
  39. * Convert a date and optionally time string into unix time
  40. * Returns 0 on error
  41. */
  42. uint64_t util_iso2unix(const char *isotime);
  43. #endif /* _UTIL_H */