A tool for adding anime to your anidb list.
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.

34 lines
963B

  1. #ifndef _ED2K_UTIL_H
  2. #define _ED2K_UTIL_H
  3. #include <sys/stat.h>
  4. #include <stdint.h>
  5. #include "error.h"
  6. typedef enum error (*ed2k_util_fn)(const char *path, const uint8_t *hash,
  7. const struct stat *st, void *data);
  8. /*
  9. * If this returns ED2KUTIL_DONTHASH, then skip the hashing,
  10. * and the post_hash function
  11. */
  12. typedef enum error (*ed2k_util_prehash_fn)(const char *path,
  13. const struct stat *st, void *data);
  14. struct ed2k_util_opts {
  15. ed2k_util_fn post_hash_fn;
  16. ed2k_util_prehash_fn pre_hash_fn;
  17. void *data;
  18. };
  19. /*
  20. * Given a path (file or directory) calculate the ed2k
  21. * hash for the file(s), and call opts.post_hash_fn if not NULL
  22. * if opts.pre_hash_fn is not NULL, then also call that before the hashing
  23. *
  24. * If fn returns any error, the iteration will stop, and this
  25. * function will return with that error code.
  26. */
  27. enum error ed2k_util_iterpath(const char *path, const struct ed2k_util_opts *opts);
  28. #endif /* _ED2K_UTIL_H */