chiark / gitweb /
And a typo fix.
[fwd] / target.h
1 /* -*-c-*-
2  *
3  * $Id: target.h,v 1.3 2003/11/29 20:36:07 mdw Exp $
4  *
5  * Description of forwarding targets
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: target.h,v $
32  * Revision 1.3  2003/11/29 20:36:07  mdw
33  * Privileged outgoing connections.
34  *
35  * Revision 1.2  2003/11/25 14:08:23  mdw
36  * Debianization.  Socket target options.  Internet binding.
37  *
38  * Revision 1.1  1999/07/26 23:33:01  mdw
39  * Infrastructure for the new design.
40  *
41  */
42
43 #ifndef TARGET_H
44 #define TARGET_H
45
46 #ifdef __cplusplus
47   extern "C" {
48 #endif
49
50 /*----- Header files ------------------------------------------------------*/
51
52 #include <stdio.h>
53
54 #ifndef ENDPT_H
55 #  include "endpt.h"
56 #endif
57
58 #ifndef SCAN_H
59 #  include "scan.h"
60 #endif
61
62 /*----- Data structures ---------------------------------------------------*/
63
64 /* --- A basic target object --- */
65
66 typedef struct target {
67   struct target_ops *ops;
68   char *desc;
69 } target;
70
71 /* --- Forwarding target operations --- */
72
73 typedef struct target_ops {
74   const char *name;                     /* Name of this target */
75
76   /* --- @option@ --- *
77    *
78    * Arguments: @target *t@ = pointer to target object, or zero if global
79    *            @scanner *sc@ = scanner to read from
80    *
81    * Returns:   Nonzero to claim the option.
82    *
83    * Use:       Handles an option string from the configuration file.
84    */
85
86   int (*option)(target */*t*/, scanner */*sc*/);
87
88   /* --- @read@ --- *
89    *
90    * Arguments: @scanner *sc@ = pointer to scanner to read from
91    *
92    * Returns:   Pointer to a target object to claim, null to reject.
93    *
94    * Use:       Parses a target description from the configuration file.
95    *            Only the socket target is allowed to omit the prefix on a
96    *            target specification.
97    */
98
99   target *(*read)(scanner */*sc*/);
100
101   /* --- @confirm@ --- *
102    *
103    * Arguments: @target *t@ = pointer to target
104    *
105    * Returns:   ---
106    *
107    * Use:       Confirms configuration of a target.
108    */
109
110   void (*confirm)(target */*t*/);
111
112   /* --- @create@ --- *
113    *
114    * Arguments: @target *t@ = pointer to target
115    *            @const char *desc@ = description of connection
116    *
117    * Returns:   Pointer to a created endpoint.
118    *
119    * Use:       Generates a target endpoint for communication.
120    */
121
122   endpt *(*create)(target */*t*/, const char */*desc*/);
123
124   /* --- @destroy@ --- *
125    *
126    * Arguments: @target *t@ = pointer to target
127    *
128    * Returns:   ---
129    *
130    * Use:       Destroys a target.
131    */
132
133   void (*destroy)(target */*t*/);
134
135 } target_ops;
136
137 /*----- That's all, folks -------------------------------------------------*/
138
139 #ifdef __cplusplus
140   }
141 #endif
142
143 #endif