Make syslog a separate option, and do it better.
[fwd] / source.h
1 /* -*-c-*-
2 *
3 * $Id: source.h,v 1.1 1999/07/26 23:33:01 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 /*----- Revision history --------------------------------------------------*
30 *
31 * $Log: source.h,v $
32 * Revision 1.1 1999/07/26 23:33:01 mdw
33 * Infrastructure for the new design.
34 *
35 */
36
37 #ifndef SOURCE_H
38 #define SOURCE_H
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /*----- Header files ------------------------------------------------------*/
45
46 #include <stdio.h>
47
48 #ifndef SCAN_H
49 # include "scan.h"
50 #endif
51
52 #ifndef TARGET_H
53 # include "target.h"
54 #endif
55
56 /*----- Data structures ---------------------------------------------------*/
57
58 /* --- A basic source object --- */
59
60 typedef struct source {
61 struct source *next, *prev;
62 struct source_ops *ops;
63 char *desc;
64 } source;
65
66 /* --- Forwarding source operations --- */
67
68 typedef struct source_ops {
69 const char *name; /* Name of this source */
70
71 /* --- @option@ --- *
72 *
73 * Arguments: @scanner *sc@ = scanner to read from
74 * @source *s@ = pointer to source object, or zero if global
75 *
76 * Returns: Nonzero to claim the option.
77 *
78 * Use: Handles an option string from the configuration file.
79 */
80
81 int (*option)(source */*s*/, scanner */*sc*/);
82
83 /* --- @read@ --- *
84 *
85 * Arguments: @scanner *sc@ = pointer to scanner to read from
86 *
87 * Returns: Pointer to a source object to claim, null to reject.
88 *
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.
92 */
93
94 source *(*read)(scanner */*sc*/);
95
96 /* --- @attach@ --- *
97 *
98 * Arguments: @source *s@ = pointer to source
99 * @scanner *sc@ = scanner (for error reporting)
100 * @target *t@ = pointer to target to attach
101 *
102 * Returns: ---
103 *
104 * Use: Attaches a target to a source.
105 */
106
107 void (*attach)(source */*s*/, scanner */*sc*/, target */*t*/);
108
109 /* --- @destroy@ --- *
110 *
111 * Arguments: @source *s@ = pointer to source
112 *
113 * Returns: ---
114 *
115 * Use: Destroys a source. Used when closing the system down, for
116 * example as a result of a signal.
117 */
118
119 void (*destroy)(source */*s*/);
120
121 } source_ops;
122
123 /*----- Functions provided ------------------------------------------------*/
124
125 /* --- @source_add@ --- *
126 *
127 * Arguments: @source *s@ = pointer to a source
128 *
129 * Returns: ---
130 *
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).
134 */
135
136 extern void source_add(source */*s*/);
137
138 /* --- @source_remove@ --- *
139 *
140 * Arguments: @source *s@ = pointer to a source
141 *
142 * Returns: ---
143 *
144 * Use: Removes a source from the master list.
145 */
146
147 extern void source_remove(source */*s*/);
148
149 /* --- @source_killall@ --- *
150 *
151 * Arguments: ---
152 *
153 * Returns: ---
154 *
155 * Use: Frees all sources.
156 */
157
158 extern void source_killall(void);
159
160 /*----- That's all, folks -------------------------------------------------*/
161
162 #ifdef __cplusplus
163 }
164 #endif
165
166 #endif