#ifndef LBIO_H
#define LBIO_H

struct LineBuffer {
	char *lb_cpFirst;		/* absolute pointer to start of buffer	*/
	char *lb_cpLast;		/* absolute pointer to end of buffer	*/
	char **lb_cppLnFirst;	/* pointer to first line pointer		*/
	char **lb_cppLnCur;		/* pointer to current line pointer		*/
	char **lb_cppLnLast;	/* pointer to last line pointer			*/
	int   lb_nLnMax;		/* total number of lines				*/
	int   lb_nLnCur;		/* current line number					*/
	char *lb_cpLnCur;		/* pointer to current line				*/
	int   lb_wLnCur;		/* len of current line (excl. NL)		*/
};

typedef struct LineBuffer LB;

struct LineBuffer *lbopen(char *cpFirst, char *cpLast);
void lbfree(struct LineBuffer *LB);
int lbseek(struct LineBuffer *LB, signed long wOffs, short wMode);

#define LBSEEK_SET 0
#define LBSEEK_CUR 1
#define LBSEEK_END 2

#define LBSEEKFIRST(lb) lbseek(lb, 0L, LBSEEK_SET);
#define LBSEEKLAST(lb) lbseek(lb, 0L, LBSEEK_END);
#define LBSEEKNEXT(lb) lbseek(lb, 1L, LBSEEK_CUR);
#define LBSEEKPREV(lb) lbseek(lb, (-1)L, LBSEEK_CUR);

#endif /* LBIO_H */
