08e706732530e4f62bc903a67064350bfc7d5601 braney Fri Feb 15 14:20:10 2013 -0800 changes to UDC to support twoBit library using it #8072 diff --git src/inc/udc.h src/inc/udc.h index a36eeb6..763bc05 100644 --- src/inc/udc.h +++ src/inc/udc.h @@ -28,30 +28,33 @@ struct udcFile *udcFileMayOpen(char *url, char *cacheDir); /* Open up a cached file. cacheDir may be null in which case udcDefaultDir() will be * used. Return NULL if file doesn't exist. */ struct udcFile *udcFileOpen(char *url, char *cacheDir); /* Open up a cached file. cacheDir may be null in which case udcDefaultDir() will be * used. Abort if if file doesn't exist. */ void udcFileClose(struct udcFile **pFile); /* Close down cached file. */ bits64 udcRead(struct udcFile *file, void *buf, bits64 size); /* Read a block from file. Return amount actually read. */ +#define udcReadOne(file, var) udcRead(file, &(var), sizeof(var)) +/* Read one variable from file or die. */ + void udcMustRead(struct udcFile *file, void *buf, bits64 size); /* Read a block from file. Abort if any problem, including EOF before size is read. */ #define udcMustReadOne(file, var) udcMustRead(file, &(var), sizeof(var)) /* Read one variable from file or die. */ bits64 udcReadBits64(struct udcFile *file, boolean isSwapped); /* Read and optionally byte-swap 64 bit entity. */ bits32 udcReadBits32(struct udcFile *file, boolean isSwapped); /* Read and optionally byte-swap 32 bit entity. */ bits16 udcReadBits16(struct udcFile *file, boolean isSwapped); /* Read and optionally byte-swap 16 bit entity. */ @@ -71,30 +74,33 @@ /* Read a complete file via UDC. The cacheDir may be null in which case udcDefaultDir() * will be used. If maxSize is non-zero, check size against maxSize * and abort if it's bigger. Returns file data (with an extra terminal for the * common case where it's treated as a C string). If retSize is non-NULL then * returns size of file in *retSize. Do a freeMem or freez of the returned buffer * when done. */ struct lineFile *udcWrapShortLineFile(char *url, char *cacheDir, size_t maxSize); /* Read in entire short (up to maxSize) url into memory and wrap a line file around it. * The cacheDir may be null in which case udcDefaultDir() will be used. If maxSize * is zero then a default value (currently 64 meg) will be used. */ void udcSeek(struct udcFile *file, bits64 offset); /* Seek to a particular (absolute) position in file. */ +void udcSeekCur(struct udcFile *file, bits64 offset); +/* Seek to a particular (from current) position in file. */ + bits64 udcTell(struct udcFile *file); /* Return current file position. */ bits64 udcCleanup(char *cacheDir, double maxDays, boolean testOnly); /* Remove cached files older than maxDays old. If testOnly is set * no clean up is done, but the size of the files that would be * cleaned up is still. */ void udcParseUrlFull(char *url, char **retProtocol, char **retAfterProtocol, char **retColon, char **retAuth); /* Parse the URL into components that udc treats separately. * *retAfterProtocol is Q-encoded to keep special chars out of filenames. * Free all *ret's except *retColon when done. */ char *udcDefaultDir(); @@ -123,21 +129,25 @@ unsigned long udcCacheAge(char *url, char *cacheDir); /* Return the age in seconds of the oldest cache file. If a cache file is * missing, return the current time (seconds since the epoch). */ int udcCacheTimeout(); /* Get cache timeout (if local cache files are newer than this many seconds, * we won't ping the remote server to check the file size and update time). */ void udcSetCacheTimeout(int timeout); /* Set cache timeout (if local cache files are newer than this many seconds, * we won't ping the remote server to check the file size and update time). */ time_t udcUpdateTime(struct udcFile *udc); /* return udc->updateTime */ +boolean udcFastReadString(struct udcFile *f, char buf[256]); +/* Read a string into buffer, which must be long enough + * to hold it. String is in 'writeString' format. */ + #ifdef PROGRESS_METER off_t remoteFileSize(char *url); /* fetch remote file size from given URL */ #endif #endif /* UDC_H */