/**
 ** LLFILE: files whose length can be as long as the maximum "long long" int,
 ** which currently under gcc is 64 bits.
 **
 ** I assume that you'll never try to read or write more than 2GB at once.
 ** This is reasonable assuming your buffer is from a 32-bit address space.
 ** However, any read or write can straddle more than one sub-file (that is,
 ** you can start a large read or write half-way through a subfile, and it'll
 ** transparently stradle any sub-file boundaries necessary to get your operation
 ** done).
 ** This means we can use "size_t" (rather than "long long") as the "size" and
 ** "nitems" parameters to llfread and llfwrite.  However, we do use "long
 ** long"s for llfseek and llftell.
 **/

typedef struct _lfile LLFILE;

/* Use this to create an LLFILE* from an existing FILE* (eg., stdin).
 * This LLFILE will be treated like a pipe, ie., an un-named file with
 * no size.  All I/O will be passed directly to the underlying FILE*,
 * with no size checks or any other restrictions.
 */
extern LLFILE *llFromFILE(FILE *fp);

extern LLFILE *llfopen(const char *filename, const char *mode);
extern int llfclose(LLFILE *lfstream);

extern LLFILE *llpopen(const char *command, const char *mode);
int llpclose(LLFILE *llfp);

extern size_t llfread(void *ptr, size_t size, size_t nitems, LLFILE *stream);

extern size_t llfwrite(const void *ptr, size_t size, size_t nitems, LLFILE *stream);

extern int llfseek(LLFILE *stream, long long offset, int whence);

extern long long llftell(LLFILE *stream);

extern int llfflush(LLFILE *stream);

extern int llfprintf(LLFILE *stream, const char *fmt, ...);

extern int llfscanf(LLFILE *stream, const char *fmt, ...);


/* Use are mostly for internal use.  Use at your own risk
 * to explicitly go to the next or previous subfile.
 */
FILE *llfileNextSubfile(LLFILE *llfp);
FILE *llfilePrevSubfile(LLFILE *llfp);

