/*
 *  texfile.h - a text file reader
 *  Copyright (C) 2010 Martin Broadhurst
 *  www.martinbroadhurst.com
 */

#ifndef TEXTFILE_H
#define TEXTFILE_H

#include <stdio.h>

typedef struct {
    FILE *fptr;        /* The file */
    char *inbuf;       /* Input buffer */
    size_t inbufsize;  /* Size of input buffer */
    char *outbuf;      /* Contains the line to return */
    size_t outbufsize; /* Size of the output buffer */
    size_t count;      /* Number of bytes in the input buffer */
    unsigned int eof;  /* At end of file, and the in-buffer is empty */
} MBtextfile;

MBtextfile * MBtextfile_create(FILE *fptr);
MBtextfile * MBtextfile_open(const char *filename);
void MBtextfile_delete(MBtextfile *file);
void MBtextfile_close(MBtextfile *file);
const char *MBtextfile_read(MBtextfile *file);

#endif /* TEXTFILE_H */