07d71f34 |
1 | /* -*-c-*- |
2 | * |
07d71f34 |
3 | * Description of forwarding targets |
4 | * |
5 | * (c) 1999 Straylight/Edgeware |
6 | */ |
7 | |
206212ca |
8 | /*----- Licensing notice --------------------------------------------------* |
07d71f34 |
9 | * |
10 | * This file is part of the `fw' port forwarder. |
11 | * |
12 | * `fw' is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by |
14 | * the Free Software Foundation; either version 2 of the License, or |
15 | * (at your option) any later version. |
206212ca |
16 | * |
07d71f34 |
17 | * `fw' is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | * GNU General Public License for more details. |
206212ca |
21 | * |
07d71f34 |
22 | * You should have received a copy of the GNU General Public License |
23 | * along with `fw'; if not, write to the Free Software Foundation, |
24 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | */ |
26 | |
07d71f34 |
27 | #ifndef TARGET_H |
28 | #define TARGET_H |
29 | |
30 | #ifdef __cplusplus |
31 | extern "C" { |
32 | #endif |
33 | |
34 | /*----- Header files ------------------------------------------------------*/ |
35 | |
36 | #include <stdio.h> |
37 | |
38 | #ifndef ENDPT_H |
39 | # include "endpt.h" |
40 | #endif |
41 | |
42 | #ifndef SCAN_H |
43 | # include "scan.h" |
44 | #endif |
45 | |
46 | /*----- Data structures ---------------------------------------------------*/ |
47 | |
48 | /* --- A basic target object --- */ |
49 | |
50 | typedef struct target { |
51 | struct target_ops *ops; |
52 | char *desc; |
53 | } target; |
54 | |
55 | /* --- Forwarding target operations --- */ |
56 | |
57 | typedef struct target_ops { |
58 | const char *name; /* Name of this target */ |
59 | |
60 | /* --- @option@ --- * |
61 | * |
0ac54f22 |
62 | * Arguments: @target *t@ = pointer to target object, or zero if global |
63 | * @scanner *sc@ = scanner to read from |
07d71f34 |
64 | * |
65 | * Returns: Nonzero to claim the option. |
66 | * |
67 | * Use: Handles an option string from the configuration file. |
68 | */ |
69 | |
70 | int (*option)(target */*t*/, scanner */*sc*/); |
71 | |
72 | /* --- @read@ --- * |
73 | * |
74 | * Arguments: @scanner *sc@ = pointer to scanner to read from |
75 | * |
76 | * Returns: Pointer to a target object to claim, null to reject. |
77 | * |
78 | * Use: Parses a target description from the configuration file. |
79 | * Only the socket target is allowed to omit the prefix on a |
80 | * target specification. |
81 | */ |
82 | |
83 | target *(*read)(scanner */*sc*/); |
84 | |
ee599f55 |
85 | /* --- @confirm@ --- * |
86 | * |
87 | * Arguments: @target *t@ = pointer to target |
88 | * |
89 | * Returns: --- |
90 | * |
91 | * Use: Confirms configuration of a target. |
92 | */ |
93 | |
94 | void (*confirm)(target */*t*/); |
95 | |
07d71f34 |
96 | /* --- @create@ --- * |
97 | * |
98 | * Arguments: @target *t@ = pointer to target |
99 | * @const char *desc@ = description of connection |
100 | * |
101 | * Returns: Pointer to a created endpoint. |
102 | * |
103 | * Use: Generates a target endpoint for communication. |
104 | */ |
105 | |
106 | endpt *(*create)(target */*t*/, const char */*desc*/); |
107 | |
108 | /* --- @destroy@ --- * |
109 | * |
110 | * Arguments: @target *t@ = pointer to target |
111 | * |
112 | * Returns: --- |
113 | * |
114 | * Use: Destroys a target. |
115 | */ |
116 | |
117 | void (*destroy)(target */*t*/); |
118 | |
119 | } target_ops; |
120 | |
121 | /*----- That's all, folks -------------------------------------------------*/ |
122 | |
123 | #ifdef __cplusplus |
124 | } |
125 | #endif |
126 | |
127 | #endif |