ccache.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef CCACHE_H_
  2. #define CCACHE_H_
  3. #include <sys/stat.h>
  4. #include "multitape.h"
  5. typedef struct ccache_internal CCACHE;
  6. typedef struct ccache_entry CCACHE_ENTRY;
  7. /**
  8. * ccache_read(path):
  9. * Read the chunkification cache (if present) from the directory ${path};
  10. * return a Patricia tree mapping absolute paths to cache entries.
  11. */
  12. CCACHE * ccache_read(const char *);
  13. /**
  14. * ccache_entry_lookup(cache, path, sb, cookie, fullentry):
  15. * An archive entry is being written for the file ${path} with lstat data
  16. * ${sb}, to the multitape with write cookie ${cookie}. Look up the file in
  17. * the chunkification cache ${cache}, and set ${fullentry} to a non-zero
  18. * value iff the cache can provide at least sb->st_size bytes of the archive
  19. * entry. Return a cookie which can be passed to either ccache_entry_write
  20. * or ccache_entry_start depending upon whether ${fullentry} is zero or not.
  21. */
  22. CCACHE_ENTRY * ccache_entry_lookup(CCACHE *, const char *,
  23. const struct stat *, TAPE_W *, int *);
  24. /**
  25. * ccache_entry_write(cce, cookie):
  26. * Write the cached archive entry ${cce} to the multitape with write cookie
  27. * ${cookie}. Note that this may only be called if ${cce} was returned by
  28. * a ccache_entry_lookup which set ${fullentry} to a non-zero value. Return
  29. * the length written.
  30. */
  31. off_t ccache_entry_write(CCACHE_ENTRY *, TAPE_W *);
  32. /**
  33. * ccache_entry_writefile(cce, cookie, notrailer, fd):
  34. * Write data from the file descriptor ${fd} to the multitape with write
  35. * cookie ${cookie}, using the cache entry ${cce} as a hint about how data
  36. * is chunkified; and set up callbacks from the multitape layer so that the
  37. * cache entry will be updated with any further chunks and (if ${notrailer}
  38. * is zero) any trailer. Return the length written.
  39. */
  40. off_t ccache_entry_writefile(CCACHE_ENTRY *, TAPE_W *, int, int);
  41. /**
  42. * ccache_entry_end(cache, cce, cookie, path, snaptime):
  43. * The archive entry is ending; clean up callbacks, insert the cache entry
  44. * into the cache if it isn't already present, and free memory.
  45. */
  46. int ccache_entry_end(CCACHE *, CCACHE_ENTRY *, TAPE_W *, const char *, time_t);
  47. /**
  48. * ccache_entry_free(cce, cookie):
  49. * Free the cache entry and cancel callbacks from the multitape layer.
  50. */
  51. void ccache_entry_free(CCACHE_ENTRY *, TAPE_W *);
  52. /**
  53. * ccache_write(cache, path):
  54. * Write the given chunkification cache into the directory ${path}.
  55. */
  56. int ccache_write(CCACHE *, const char *);
  57. /**
  58. * ccache_free(cache):
  59. * Free the cache and all of its entries.
  60. */
  61. void ccache_free(CCACHE *);
  62. /**
  63. * ccache_remove(path):
  64. * Delete the chunkification cache from the directory ${path}.
  65. */
  66. int ccache_remove(const char *);
  67. #endif /* !CCACHE_H_ */