942664daefc452c28bb86f3623774ffcebfc5e90 kent Wed Oct 27 17:54:38 2010 -0700 Adding new functions udcFileReadAll and udcWrapShortLineFile diff --git src/inc/udc.h src/inc/udc.h index a089f65..a07e7b7 100644 --- src/inc/udc.h +++ src/inc/udc.h @@ -55,30 +55,43 @@ bits16 udcReadBits16(struct udcFile *file, boolean isSwapped); /* Read and optionally byte-swap 16 bit entity. */ float udcReadFloat(struct udcFile *file, boolean isSwapped); /* Read and optionally byte-swap floating point number. */ double udcReadDouble(struct udcFile *file, boolean isSwapped); /* Read and optionally byte-swap double-precision floating point number. */ int udcGetChar(struct udcFile *file); /* Get next character from file or die trying. */ char *udcReadStringAndZero(struct udcFile *file); /* Read in zero terminated string from file. Do a freeMem of result when done. */ +char *udcFileReadAll(char *url, char *cacheDir, size_t maxSize, size_t *retSize); +/* 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. */ 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.