chiark / gitweb /
hash: Trivial whitespace cleanups.
[mLib] / selbuf.c
index b8b11611c69c7ec8e6e7452fd20cbe1ce5a67b0a..6fe97eef1c7407af0cb106d4832ed1c25eba2822 100644 (file)
--- a/selbuf.c
+++ b/selbuf.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: selbuf.c,v 1.3 1999/05/22 13:41:00 mdw Exp $
+ * $Id: selbuf.c,v 1.6 2004/04/08 01:36:13 mdw Exp $
  *
  * Line-buffering select handler
  *
  * MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: selbuf.c,v $
- * Revision 1.3  1999/05/22 13:41:00  mdw
- * Fix end-of-file detection and error handling.
- *
- * Revision 1.2  1999/05/17 20:36:50  mdw
- * Make the magical constants for the buffer flags uppercase.
- *
- * Revision 1.1  1999/05/14 21:01:15  mdw
- * Integrated `select' handling bits from the background resolver project.
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include <errno.h>
@@ -131,12 +117,27 @@ static void selbuf_read(int fd, unsigned mode, void *vp)
   }
 }
 
+/* --- @selbuf_setsize@ --- *
+ *
+ * Arguments:  @selbuf *b@ = pointer to buffer block
+ *             @size_t sz@ = size of buffer
+ *
+ * Returns:    ---
+ *
+ * Use:                Sets the size of the buffer used for reading lines.
+ */
+
+void selbuf_setsize(selbuf *b, size_t sz)
+{
+  lbuf_setsize(&b->b, sz);
+}
+
 /* --- @selbuf_init@ --- *
  *
  * Arguments:  @selbuf *b@ = pointer to buffer block
  *             @sel_state *s@ = pointer to select state to attach to
  *             @int fd@ = file descriptor to listen to
- *             @void (*func)(char *s, void *p)@ = function to call
+ *             @lbuf_func *func@ = function to call
  *             @void *p@ = argument for function
  *
  * Returns:    ---
@@ -144,11 +145,7 @@ static void selbuf_read(int fd, unsigned mode, void *vp)
  * Use:                Initializes a buffer block.
  */
 
-void selbuf_init(selbuf *b,
-                sel_state *s,
-                int fd,
-                void (*func)(char */*s*/, void */*p*/),
-                void *p)
+void selbuf_init(selbuf *b, sel_state *s, int fd, lbuf_func *func, void *p)
 {
   lbuf_init(&b->b, func, p);
   b->b.f &= ~LBUF_ENABLE;
@@ -156,4 +153,19 @@ void selbuf_init(selbuf *b,
   selbuf_enable(b);
 }
 
+/* --- @selbuf_destroy@ --- *
+ *
+ * Arguments:  @selbuf *b@ = pointer to buffer block
+ *
+ * Returns:    ---
+ *
+ * Use:                Deallocates a line buffer and frees any resources it owned.
+ */
+
+void selbuf_destroy(selbuf *b)
+{
+  selbuf_disable(b);
+  lbuf_destroy(&b->b);
+}
+
 /*----- That's all, folks -------------------------------------------------*/