3 * $Id: source.h,v 1.1 1999/07/26 23:33:01 mdw Exp $
5 * Description of forwarding sources
7 * (c) 1999 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the `fw' port forwarder.
14 * `fw' is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * `fw' 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 General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with `fw'; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.1 1999/07/26 23:33:01 mdw
33 * Infrastructure for the new design.
44 /*----- Header files ------------------------------------------------------*/
56 /*----- Data structures ---------------------------------------------------*/
58 /* --- A basic source object --- */
60 typedef struct source
{
61 struct source
*next
, *prev
;
62 struct source_ops
*ops
;
66 /* --- Forwarding source operations --- */
68 typedef struct source_ops
{
69 const char *name
; /* Name of this source */
73 * Arguments: @scanner *sc@ = scanner to read from
74 * @source *s@ = pointer to source object, or zero if global
76 * Returns: Nonzero to claim the option.
78 * Use: Handles an option string from the configuration file.
81 int (*option
)(source */
*s*/
, scanner */
*sc*/
);
85 * Arguments: @scanner *sc@ = pointer to scanner to read from
87 * Returns: Pointer to a source object to claim, null to reject.
89 * Use: Parses a source description from the configuration file.
90 * Only the socket source is allowed to omit the prefix on a
91 * source specification.
94 source
*(*read
)(scanner */
*sc*/
);
98 * Arguments: @source *s@ = pointer to source
99 * @scanner *sc@ = scanner (for error reporting)
100 * @target *t@ = pointer to target to attach
104 * Use: Attaches a target to a source.
107 void (*attach
)(source */
*s*/
, scanner */
*sc*/
, target */
*t*/
);
109 /* --- @destroy@ --- *
111 * Arguments: @source *s@ = pointer to source
115 * Use: Destroys a source. Used when closing the system down, for
116 * example as a result of a signal.
119 void (*destroy
)(source */
*s*/
);
123 /*----- Functions provided ------------------------------------------------*/
125 /* --- @source_add@ --- *
127 * Arguments: @source *s@ = pointer to a source
131 * Use: Adds a source to the master list. Only do this for passive
132 * sources (e.g., listening sockets), not active sources (e.g.,
133 * executable programs).
136 extern void source_add(source */
*s*/
);
138 /* --- @source_remove@ --- *
140 * Arguments: @source *s@ = pointer to a source
144 * Use: Removes a source from the master list.
147 extern void source_remove(source */
*s*/
);
149 /* --- @source_killall@ --- *
155 * Use: Frees all sources.
158 extern void source_killall(void);
160 /*----- That's all, folks -------------------------------------------------*/