diff --git a/src/cache.c b/src/cache.c index 0f749a6..e2496f2 100644 --- a/src/cache.c +++ b/src/cache.c @@ -234,7 +234,7 @@ static int Meta_read(Cache *cf) } fread(&(cf->time), sizeof(long), 1, fp); - fread(&(cf->content_length), sizeof(long), 1, fp); + fread(&(cf->content_length), sizeof(off_t), 1, fp); fread(&(cf->blksz), sizeof(int), 1, fp); fread(&(cf->segbc), sizeof(long), 1, fp); @@ -282,7 +282,7 @@ static int Meta_write(const Cache *cf) } fwrite(&(cf->time), sizeof(long), 1, fp); - fwrite(&(cf->content_length), sizeof(long), 1, fp); + fwrite(&(cf->content_length), sizeof(off_t), 1, fp); fwrite(&(cf->blksz), sizeof(int), 1, fp); fwrite(&(cf->segbc), sizeof(long), 1, fp); fwrite(cf->seg, sizeof(Seg), cf->segbc, fp); @@ -355,9 +355,9 @@ static long Data_read(const Cache *cf, long offset, long len, return -1; } - if (fseek(fp, offset, SEEK_SET)) { - /* fseek failed */ - fprintf(stderr, "Data_read(): fseek(): %s\n", strerror(errno)); + if (fseeko(fp, offset, SEEK_SET)) { + /* fseeko failed */ + fprintf(stderr, "Data_read(): fseeko(): %s\n", strerror(errno)); goto cleanup; } @@ -405,9 +405,9 @@ static long Data_write(const Cache *cf, long offset, long len, return -1; } - if (fseek(fp, offset, SEEK_SET)) { - /* fseek failed */ - fprintf(stderr, "Data_write(): fseek(): %s\n", strerror(errno)); + if (fseeko(fp, offset, SEEK_SET)) { + /* fseeko failed */ + fprintf(stderr, "Data_write(): fseeko(): %s\n", strerror(errno)); goto cleanup; } @@ -556,6 +556,7 @@ static void Cache_delete(const char *fn) Cache *Cache_open(const char *fn) { + int res = 0; /* Check if both metadata and data file exist */ if (Cache_exist(fn)) { return NULL; diff --git a/src/cache.h b/src/cache.h index 4a11dcc..94c27d5 100644 --- a/src/cache.h +++ b/src/cache.h @@ -8,19 +8,8 @@ * \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) - * - CURLINFO_FILETIME - * - segment count (int) - * - individual segments (array of seg) - * \note - * - 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, i.e. i386 vs amd64 + * separate folders. */ /** @@ -34,7 +23,7 @@ typedef uint8_t Seg; typedef struct { char *p_url; /**< the filename from the http server */ long time; /**