| 1 | /* -*-c-*- |
| 2 | * |
| 3 | * $Id: selpk.h,v 1.3 2002/01/13 13:33:51 mdw Exp $ |
| 4 | * |
| 5 | * Packet-buffering select handler |
| 6 | * |
| 7 | * (c) 1999 Straylight/Edgeware |
| 8 | */ |
| 9 | |
| 10 | /*----- Licensing notice --------------------------------------------------* |
| 11 | * |
| 12 | * This file is part of the mLib utilities library. |
| 13 | * |
| 14 | * mLib is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU Library General Public License as |
| 16 | * published by the Free Software Foundation; either version 2 of the |
| 17 | * License, or (at your option) any later version. |
| 18 | * |
| 19 | * mLib is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU Library General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU Library General Public |
| 25 | * License along with mLib; if not, write to the Free |
| 26 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 27 | * MA 02111-1307, USA. |
| 28 | */ |
| 29 | |
| 30 | /*----- Revision history --------------------------------------------------* |
| 31 | * |
| 32 | * $Log: selpk.h,v $ |
| 33 | * Revision 1.3 2002/01/13 13:33:51 mdw |
| 34 | * Packet handler functions now have a @typedef@ name. |
| 35 | * |
| 36 | * Revision 1.2 2000/07/16 18:56:00 mdw |
| 37 | * Fix a function declaration which slipped through the net. |
| 38 | * |
| 39 | * Revision 1.1 2000/06/17 10:39:19 mdw |
| 40 | * Experimental new support for packet buffering. |
| 41 | * |
| 42 | */ |
| 43 | |
| 44 | #ifndef MLIB_SELPK_H |
| 45 | #define MLIB_SELPK_H |
| 46 | |
| 47 | #ifdef __cplusplus |
| 48 | extern "C" { |
| 49 | #endif |
| 50 | |
| 51 | /*----- Header files ------------------------------------------------------*/ |
| 52 | |
| 53 | #ifndef MLIB_PKBUF_H |
| 54 | # include "pkbuf.h" |
| 55 | #endif |
| 56 | |
| 57 | #ifndef MLIB_SEL_H |
| 58 | # include "sel.h" |
| 59 | #endif |
| 60 | |
| 61 | /*----- Data structures ---------------------------------------------------*/ |
| 62 | |
| 63 | typedef struct selpk { |
| 64 | sel_file reader; /* File selection object */ |
| 65 | pkbuf pk; /* Packet buffering object */ |
| 66 | } selpk; |
| 67 | |
| 68 | /*----- Functions provided ------------------------------------------------*/ |
| 69 | |
| 70 | /* --- @selpk_enable@ --- * |
| 71 | * |
| 72 | * Arguments: @selpk *pk@ = pointer to buffer block |
| 73 | * |
| 74 | * Returns: --- |
| 75 | * |
| 76 | * Use: Enables a buffer for reading, and emits any queued packets |
| 77 | * to the buffer's owner. |
| 78 | */ |
| 79 | |
| 80 | extern void selpk_enable(selpk */*pk*/); |
| 81 | |
| 82 | /* --- @selpk_disable@ --- * |
| 83 | * |
| 84 | * Arguments: @selpk *pk@ = pointer to a buffer block |
| 85 | * |
| 86 | * Returns: --- |
| 87 | * |
| 88 | * Use: Disables a buffer. It won't be read from until it's |
| 89 | * enabled again. |
| 90 | */ |
| 91 | |
| 92 | extern void selpk_disable(selpk */*pk*/); |
| 93 | |
| 94 | /* --- @selpk_want@ --- * |
| 95 | * |
| 96 | * Arguments: @selpk *pk@ = pointer to buffer block |
| 97 | * @size_t want@ = size of packet to read |
| 98 | * |
| 99 | * Returns: --- |
| 100 | * |
| 101 | * Use: Sets the size of the packet to be read next. |
| 102 | */ |
| 103 | |
| 104 | extern void selpk_want(selpk */*pk*/, size_t /*sz*/); |
| 105 | |
| 106 | /* --- @selpk_init@ --- * |
| 107 | * |
| 108 | * Arguments: @selpk *pk@ = pointer to buffer block |
| 109 | * @sel_state *s@ = pointer to select state to attach to |
| 110 | * @int fd@ = file descriptor to listen to |
| 111 | * @pkbuf_func *func@ = function to call |
| 112 | * @void *p@ = argument for function |
| 113 | * |
| 114 | * Returns: --- |
| 115 | * |
| 116 | * Use: Initializes a buffer block. |
| 117 | */ |
| 118 | |
| 119 | extern void selpk_init(selpk */*pk*/, sel_state */*s*/, int /*fd*/, |
| 120 | pkbuf_func */*func*/, void */*p*/); |
| 121 | |
| 122 | /* --- @selpk_destroy@ --- * |
| 123 | * |
| 124 | * Arguments: @lbuf *b@ = pointer to buffer block |
| 125 | * |
| 126 | * Returns: --- |
| 127 | * |
| 128 | * Use: Deallocates a packet buffer and frees any resources it owned. |
| 129 | */ |
| 130 | |
| 131 | extern void selpk_destroy(selpk */*pk*/); |
| 132 | |
| 133 | /*----- That's all, folks -------------------------------------------------*/ |
| 134 | |
| 135 | #ifdef __cplusplus |
| 136 | } |
| 137 | #endif |
| 138 | |
| 139 | #endif |