#ifndef CACHE_H #define CACHE_H #include /** * \file cache.h * \brief cache related structures and functions * \details * Metadata: * - We store the metadata and the actual data separately in two * different folders. * - The metadata file should follow the following format: * - file length (long) * - segment count (int) * - individual segments (array of seg) * * \note * - apologies for whoever is going to be reading this. Sorry for being so * verbose in this header file, this is probably one of the most challenging * thing I have ever written so far! Yes I am doing a PhD in computer science, * but it doesn't imply that I am good at computer science or programming! * - We are using 'long' to store file size, because the offset in fseek() is * in long, because the way we use the cache system, you cannot seek past * long. So the biggest file size has to be able to be stored in long. This * makes this program architecturally dependent, but this is due to the * dependency to fseek(). */ /** * \brief a cache segment */ typedef struct { long start; long end; } Seg; /** * \brief cache metadata structure * \note fanf2@cam.ac.uk told me to use an array rather than linked list! */ typedef struct { const char *filename; /**< the filename from the http server */ const char *metapath; /**< the path to the metadata file*/ const char *datapath; /**< the path to the cache file */ long len; /**