X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/3fd896a441c904c3f3608dba41d5e1db84fad776..bb1cbbe82a40a9cffb8d143bed2e3aa245595450:/pkbuf.h diff --git a/pkbuf.h b/pkbuf.h index 00c437b..d55ae50 100644 --- a/pkbuf.h +++ b/pkbuf.h @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: pkbuf.h,v 1.3 2001/02/03 16:23:33 mdw Exp $ + * $Id: pkbuf.h,v 1.5 2004/04/08 01:36:13 mdw Exp $ * * Simple packet buffering * * (c) 2000 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of the mLib utilities library. * @@ -15,33 +15,18 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * mLib is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with mLib; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: pkbuf.h,v $ - * Revision 1.3 2001/02/03 16:23:33 mdw - * Bug fix: handle a disable during a close-induced flush without dumping - * core. - * - * Revision 1.2 2001/01/20 12:06:01 mdw - * Define flags with macros, to ensure unsignedness. - * - * Revision 1.1 2000/06/17 10:39:19 mdw - * Experimental new support for packet buffering. - * - */ - #ifndef MLIB_PKBUF_H #define MLIB_PKBUF_H @@ -63,14 +48,18 @@ /*----- Data structures ---------------------------------------------------*/ +struct pkbuf; + +typedef void pkbuf_func(octet */*b*/, size_t /*sz*/, + struct pkbuf */*pk*/, size_t */*keep*/, + void */*p*/); + typedef struct pkbuf { size_t sz; /* Size of current buffer */ size_t len; /* Length of data in the buffer */ size_t want; /* Want this many bytes for packet */ unsigned f; /* Various state flags */ - void (*func)(octet */*b*/, size_t /*sz*/, - struct pkbuf */*pk*/, size_t */*keep*/, - void */*p*/); /* Handler function */ + pkbuf_func *func; /* Handler function */ void *p; /* Argument for handler */ arena *a; /* Memory allocation arena */ octet *buf; /* Actual buffer space */ @@ -164,9 +153,7 @@ extern void pkbuf_want(pkbuf */*pk*/, size_t /*want*/); /* --- @pkbuf_init@ --- * * * Arguments: @pkbuf *pk@ = pointer to buffer block - * @void (*func)(octet *b, size_t sz, pkbuf *pk,@ - * @size_t *keep, void *p)@ = - * handler function + * @pkbuf_func *func@ = handler function * @void *p@ = argument pointer for @func@ * * Returns: --- @@ -175,11 +162,7 @@ extern void pkbuf_want(pkbuf */*pk*/, size_t /*want*/); * the provided function for handling. */ -extern void pkbuf_init(pkbuf */*pk*/, - void (*/*func*/)(octet */*b*/, size_t /*sz*/, - pkbuf */*pk*/, size_t */*keep*/, - void */*p*/), - void */*p*/); +extern void pkbuf_init(pkbuf */*pk*/, pkbuf_func */*func*/, void */*p*/); /* --- @pkbuf_destroy@ --- * *