chiark / gitweb /
Infrastructure: Split the files into subdirectories.
[mLib] / sel / selpk.h
diff --git a/sel/selpk.h b/sel/selpk.h
new file mode 100644 (file)
index 0000000..c43d8ad
--- /dev/null
@@ -0,0 +1,123 @@
+/* -*-c-*-
+ *
+ * Packet-buffering select handler
+ *
+ * (c) 1999 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of the mLib utilities library.
+ *
+ * mLib is free software; you can redistribute it and/or modify
+ * 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.
+ */
+
+#ifndef MLIB_SELPK_H
+#define MLIB_SELPK_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#ifndef MLIB_PKBUF_H
+#  include "pkbuf.h"
+#endif
+
+#ifndef MLIB_SEL_H
+#  include "sel.h"
+#endif
+
+/*----- Data structures ---------------------------------------------------*/
+
+typedef struct selpk {
+  sel_file reader;                     /* File selection object */
+  pkbuf pk;                            /* Packet buffering object */
+} selpk;
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @selpk_enable@ --- *
+ *
+ * Arguments:  @selpk *pk@ = pointer to buffer block
+ *
+ * Returns:    ---
+ *
+ * Use:                Enables a buffer for reading, and emits any queued packets
+ *             to the buffer's owner.
+ */
+
+extern void selpk_enable(selpk */*pk*/);
+
+/* --- @selpk_disable@ --- *
+ *
+ * Arguments:  @selpk *pk@ = pointer to a buffer block
+ *
+ * Returns:    ---
+ *
+ * Use:                Disables a buffer.  It won't be read from until it's
+ *             enabled again.
+ */
+
+extern void selpk_disable(selpk */*pk*/);
+
+/* --- @selpk_want@ --- *
+ *
+ * Arguments:  @selpk *pk@ = pointer to buffer block
+ *             @size_t want@ = size of packet to read
+ *
+ * Returns:    ---
+ *
+ * Use:                Sets the size of the packet to be read next.
+ */
+
+extern void selpk_want(selpk */*pk*/, size_t /*sz*/);
+
+/* --- @selpk_init@ --- *
+ *
+ * Arguments:  @selpk *pk@ = pointer to buffer block
+ *             @sel_state *s@ = pointer to select state to attach to
+ *             @int fd@ = file descriptor to listen to
+ *             @pkbuf_func *func@ = function to call
+ *             @void *p@ = argument for function
+ *
+ * Returns:    ---
+ *
+ * Use:                Initializes a buffer block.
+ */
+
+extern void selpk_init(selpk */*pk*/, sel_state */*s*/, int /*fd*/,
+                      pkbuf_func */*func*/, void */*p*/);
+
+/* --- @selpk_destroy@ --- *
+ *
+ * Arguments:  @lbuf *b@ = pointer to buffer block
+ *
+ * Returns:    ---
+ *
+ * Use:                Deallocates a packet buffer and frees any resources it owned.
+ */
+
+extern void selpk_destroy(selpk */*pk*/);
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif