chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Pass line length to line handler function. Provide a @typedef@ for
[mLib]
/
lbuf.h
diff --git
a/lbuf.h
b/lbuf.h
index fb04b5f83630ae5ddff09b3410934dc95518e0db..df8fdffd29fd72991b0c3c4766d02cd83c40def5 100644
(file)
--- a/
lbuf.h
+++ b/
lbuf.h
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: lbuf.h,v 1.
6 2001/02/03 16:23:33
mdw Exp $
+ * $Id: lbuf.h,v 1.
7 2002/01/13 13:32:52
mdw Exp $
*
* Block-to-line buffering
*
*
* Block-to-line buffering
*
@@
-30,6
+30,10
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: lbuf.h,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: lbuf.h,v $
+ * Revision 1.7 2002/01/13 13:32:52 mdw
+ * Pass line length to line handler function. Provide a @typedef@ for
+ * handler functions. Allow run-time configuration of line delimiters.
+ *
* 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.6 2001/02/03 16:23:33 mdw
* Bug fix: handle a disable during a close-induced flush without dumping
* core.
@@
-116,11
+120,16
@@
* that.
*/
* that.
*/
+struct lbuf;
+
+typedef void lbuf_func(char */*s*/, size_t /*len*/, void */*p*/);
+
typedef struct lbuf {
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 */
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 */
unsigned f; /* Various useful state flags */
arena *a; /* Memory allocation arena */
char *buf; /* The actual buffer */
@@
-130,6
+139,11
@@
typedef struct lbuf {
#define LBUF_ENABLE 2u /* Buffer is currently enabled */
#define LBUF_CLOSE 4u /* Buffer is now closed */
#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@ --- *
/*----- Functions provided ------------------------------------------------*/
/* --- @lbuf_flush@ --- *
@@
-216,7
+230,7
@@
extern void lbuf_setsize(lbuf */*b*/, size_t /*sz*/);
/* --- @lbuf_init@ --- *
*
* Arguments: @lbuf *b@ = pointer to buffer block
/* --- @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: ---
* @void *p@ = argument pointer for @func@
*
* Returns: ---
@@
-225,9
+239,7
@@
extern void lbuf_setsize(lbuf */*b*/, size_t /*sz*/);
* passed to @func@ for processing.
*/
* 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@ --- *
*
/* --- @lbuf_destroy@ --- *
*