Provide a `--pidfile' option in `fw'.
[fwd] / source.h
1 /* -*-c-*-
2 *
3 * $Id: source.h,v 1.2 2004/04/08 01:36:25 mdw Exp $
4 *
5 * Description of forwarding sources
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of the `fw' port forwarder.
13 *
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.
18 *
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.
23 *
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.
27 */
28
29 #ifndef SOURCE_H
30 #define SOURCE_H
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /*----- Header files ------------------------------------------------------*/
37
38 #include <stdio.h>
39
40 #ifndef SCAN_H
41 # include "scan.h"
42 #endif
43
44 #ifndef TARGET_H
45 # include "target.h"
46 #endif
47
48 /*----- Data structures ---------------------------------------------------*/
49
50 /* --- A basic source object --- */
51
52 typedef struct source {
53 struct source *next, *prev;
54 struct source_ops *ops;
55 char *desc;
56 } source;
57
58 /* --- Forwarding source operations --- */
59
60 typedef struct source_ops {
61 const char *name; /* Name of this source */
62
63 /* --- @option@ --- *
64 *
65 * Arguments: @scanner *sc@ = scanner to read from
66 * @source *s@ = pointer to source object, or zero if global
67 *
68 * Returns: Nonzero to claim the option.
69 *
70 * Use: Handles an option string from the configuration file.
71 */
72
73 int (*option)(source */*s*/, scanner */*sc*/);
74
75 /* --- @read@ --- *
76 *
77 * Arguments: @scanner *sc@ = pointer to scanner to read from
78 *
79 * Returns: Pointer to a source object to claim, null to reject.
80 *
81 * Use: Parses a source description from the configuration file.
82 * Only the socket source is allowed to omit the prefix on a
83 * source specification.
84 */
85
86 source *(*read)(scanner */*sc*/);
87
88 /* --- @attach@ --- *
89 *
90 * Arguments: @source *s@ = pointer to source
91 * @scanner *sc@ = scanner (for error reporting)
92 * @target *t@ = pointer to target to attach
93 *
94 * Returns: ---
95 *
96 * Use: Attaches a target to a source.
97 */
98
99 void (*attach)(source */*s*/, scanner */*sc*/, target */*t*/);
100
101 /* --- @destroy@ --- *
102 *
103 * Arguments: @source *s@ = pointer to source
104 *
105 * Returns: ---
106 *
107 * Use: Destroys a source. Used when closing the system down, for
108 * example as a result of a signal.
109 */
110
111 void (*destroy)(source */*s*/);
112
113 } source_ops;
114
115 /*----- Functions provided ------------------------------------------------*/
116
117 /* --- @source_add@ --- *
118 *
119 * Arguments: @source *s@ = pointer to a source
120 *
121 * Returns: ---
122 *
123 * Use: Adds a source to the master list. Only do this for passive
124 * sources (e.g., listening sockets), not active sources (e.g.,
125 * executable programs).
126 */
127
128 extern void source_add(source */*s*/);
129
130 /* --- @source_remove@ --- *
131 *
132 * Arguments: @source *s@ = pointer to a source
133 *
134 * Returns: ---
135 *
136 * Use: Removes a source from the master list.
137 */
138
139 extern void source_remove(source */*s*/);
140
141 /* --- @source_killall@ --- *
142 *
143 * Arguments: ---
144 *
145 * Returns: ---
146 *
147 * Use: Frees all sources.
148 */
149
150 extern void source_killall(void);
151
152 /*----- That's all, folks -------------------------------------------------*/
153
154 #ifdef __cplusplus
155 }
156 #endif
157
158 #endif