X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/3fd896a441c904c3f3608dba41d5e1db84fad776..3bc429127d05ea3c84e3c151d53ad3546bea5e9b:/lbuf.h diff --git a/lbuf.h b/lbuf.h index fb04b5f..a9c72a0 100644 --- a/lbuf.h +++ b/lbuf.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: lbuf.h,v 1.6 2001/02/03 16:23:33 mdw Exp $ + * $Id: lbuf.h,v 1.8 2004/04/08 01:36:13 mdw Exp $ * * Block-to-line buffering * @@ -27,30 +27,6 @@ * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: lbuf.h,v $ - * Revision 1.6 2001/02/03 16:23:33 mdw - * Bug fix: handle a disable during a close-induced flush without dumping - * core. - * - * Revision 1.5 2001/01/20 12:06:01 mdw - * Define flags with macros, to ensure unsignedness. - * - * Revision 1.4 2000/06/17 10:38:14 mdw - * Add support for variable buffer sizes. - * - * Revision 1.3 1999/12/10 23:42:04 mdw - * Change header file guard names. - * - * Revision 1.2 1999/05/17 20:36:08 mdw - * Make the magical constants for the buffer flags uppercase. - * - * Revision 1.1 1999/05/14 21:01:14 mdw - * Integrated `select' handling bits from the background resolver project. - * - */ - #ifndef MLIB_LBUF_H #define MLIB_LBUF_H @@ -116,11 +92,16 @@ * that. */ +struct lbuf; + +typedef void lbuf_func(char */*s*/, size_t /*len*/, void */*p*/); + typedef struct lbuf { - void (*func)(char */*s*/, void */*p*/); /* Handler function */ + lbuf_func *func; /* Handler function */ void *p; /* Argument for handler */ size_t len; /* Length of data in buffer */ size_t sz; /* Buffer size */ + unsigned delim; /* Delimiter to look for */ unsigned f; /* Various useful state flags */ arena *a; /* Memory allocation arena */ char *buf; /* The actual buffer */ @@ -130,6 +111,11 @@ typedef struct lbuf { #define LBUF_ENABLE 2u /* Buffer is currently enabled */ #define LBUF_CLOSE 4u /* Buffer is now closed */ +enum { + LBUF_CRLF = 256, + LBUF_STRICTCRLF = 257 +}; + /*----- Functions provided ------------------------------------------------*/ /* --- @lbuf_flush@ --- * @@ -216,7 +202,7 @@ extern void lbuf_setsize(lbuf */*b*/, size_t /*sz*/); /* --- @lbuf_init@ --- * * * Arguments: @lbuf *b@ = pointer to buffer block - * @void (*func)(char *s, void *p)@ = handler function + * @lbuf_func *func@ = handler function * @void *p@ = argument pointer for @func@ * * Returns: --- @@ -225,9 +211,7 @@ extern void lbuf_setsize(lbuf */*b*/, size_t /*sz*/); * passed to @func@ for processing. */ -extern void lbuf_init(lbuf */*b*/, - void (*/*func*/)(char */*s*/, void */*p*/), - void */*p*/); +extern void lbuf_init(lbuf */*b*/, lbuf_func */*func*/, void */*p*/); /* --- @lbuf_destroy@ --- * *