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