--- a/src/lib/cache.h Sun Dec 27 22:01:17 2009 +0200
+++ b/src/lib/cache.h Sun Dec 27 23:14:10 2009 +0200
@@ -8,14 +8,37 @@
*/
#include "image.h"
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <png.h>
+
/**
* State for cache access
*/
struct pt_cache {
+ /** Filesystem path to cache file */
+ char *path;
+ /** The mode we are operating in, bitmask of PT_IMG_* */
+ int mode;
+
+ /** Opened file */
+ int fd;
+
+ /** Memory-mapped file data, from the second page on */
+ uint8_t *mmap;
+
+ /** Size of the mmap'd segment in bytes */
+ size_t size;
};
/**
+ * Size of a cache file page in bytes
+ */
+#define PT_CACHE_PAGE 4096
+
+/**
* On-disk header
*/
struct pt_cache_header {
@@ -32,16 +55,21 @@
/**
* Construct the image cache info object associated with the given image.
*/
-int pt_cache_open (struct pt_cache **cache_ptr, struct pt_image *img, int mode);
+int pt_cache_open (struct pt_cache **cache_ptr, const char *path, int mode);
/**
- * Verify if the cached data is still fresh compared to the original.
+ * Verify if the cached data has become stale compared to the given original file.
*/
-bool pt_cache_fresh (struct pt_cache *cache);
+int pt_cache_stale (struct pt_cache *cache, const char *orig_path);
/**
* Update the cache data from the given PNG image.
*/
int pt_cache_update_png (struct pt_cache *cache, png_structp png, png_infop info);
+/**
+ * Release all resources associated with the given cache object without any cleanup.
+ */
+void pt_cache_destroy (struct pt_cache *cache);
+
#endif