storage_read_cache.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef STORAGE_READ_CACHE_H_
  2. #define STORAGE_READ_CACHE_H_
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. /**
  6. * storage_read_cache_init(void):
  7. * Allocate and initialize the cache.
  8. */
  9. struct storage_read_cache * storage_read_cache_init(void);
  10. /**
  11. * storage_read_cache_add_name(cache, class, name):
  12. * Add the file ${name} from class ${class} into the ${cache}. No data is
  13. * stored yet.
  14. */
  15. int storage_read_cache_add_name(struct storage_read_cache *, char,
  16. const uint8_t[32]);
  17. /**
  18. * storage_read_cache_add_data(cache, class, name, buf, buflen):
  19. * If the file ${name} with class ${class} has previous been flagged for
  20. * storage in the ${cache} via storage_read_cache_add_name(), add
  21. * ${buflen} data from ${buf} to the cache.
  22. */
  23. void storage_read_cache_add_data(struct storage_read_cache *, char,
  24. const uint8_t[32], uint8_t *, size_t);
  25. /**
  26. * storage_read_cache_set_limit(cache, size):
  27. * Set a limit of ${size} bytes on the ${cache}.
  28. */
  29. void storage_read_cache_set_limit(struct storage_read_cache *, size_t);
  30. /**
  31. * storage_read_cache_find(cache, class, name, buf, buflen):
  32. * Look for a file of class ${class} and name ${name} in the cache.
  33. * If found, set ${buf} to the stored data, and ${buflen} to its length.
  34. * If not found, set ${buf} to NULL.
  35. */
  36. void storage_read_cache_find(struct storage_read_cache *, char,
  37. const uint8_t[32], uint8_t **, size_t *);
  38. /**
  39. * storage_read_cache_free(cache):
  40. * Free the cache ${cache}.
  41. */
  42. void storage_read_cache_free(struct storage_read_cache *);
  43. #endif /* !STORAGE_READ_CACHE_H_ */