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.

75 lines
1.5KB

  1. #ifndef _CACHE_H
  2. #define _CACHE_H
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "error.h"
  6. #include "ed2k.h"
  7. #include "api.h"
  8. enum cache_select {
  9. CACHE_S_ALL = 0,
  10. CACHE_S_LID = 1 << 0,
  11. CACHE_S_FNAME = 1 << 1,
  12. CACHE_S_FSIZE = 1 << 2,
  13. CACHE_S_ED2K = 1 << 3,
  14. CACHE_S_WATCHDATE = 1 << 4,
  15. CACHE_S_STATE = 1 << 5,
  16. CACHE_S_MODDATE = 1 << 6,
  17. };
  18. struct cache_entry {
  19. uint64_t lid, fsize, wdate, moddate;
  20. /* free() if requested */
  21. char *fname;
  22. uint8_t ed2k[ED2K_HASH_SIZE];
  23. uint16_t state;
  24. };
  25. /*
  26. * Init tha cache
  27. */
  28. enum error cache_init();
  29. /*
  30. * Is the cache already setup or not?
  31. */
  32. bool cache_is_init();
  33. /*
  34. * Free tha cache
  35. */
  36. void cache_free();
  37. /*
  38. * Add a new mylist entry to the cache
  39. */
  40. enum error cache_add(uint64_t lid, const char *fname,
  41. uint64_t fsize, const uint8_t *ed2k, uint64_t watchdate,
  42. enum mylist_state state);
  43. /*
  44. * Update an already existing cache entry by lid
  45. */
  46. enum error cache_update(uint64_t lid, const struct api_mylistadd_opts *mods);
  47. /*
  48. * Get a cache entry
  49. *
  50. * sel is the columns to select
  51. * If 0, everything is selected and returned.
  52. * Can be ORed together
  53. *
  54. * out_ce can be NULL. Useful, if we only want
  55. * to check if the entry exists or not.
  56. */
  57. enum error cache_get(const char *fname, uint64_t fsize, enum cache_select sel,
  58. struct cache_entry *out_ce);
  59. /*
  60. * Does an entry exists?
  61. */
  62. bool cache_exists(const char *fname, uint64_t size);
  63. #endif /* _CACHE_H */