chiark / gitweb /
docs: Generate grammar and option summaries from manpage.
[fwd] / target.h
1 /* -*-c-*-
2  *
3  * $Id: target.h,v 1.4 2004/04/08 01:36:25 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 #ifndef TARGET_H
30 #define TARGET_H
31
32 #ifdef __cplusplus
33   extern "C" {
34 #endif
35
36 /*----- Header files ------------------------------------------------------*/
37
38 #include <stdio.h>
39
40 #ifndef ENDPT_H
41 #  include "endpt.h"
42 #endif
43
44 #ifndef SCAN_H
45 #  include "scan.h"
46 #endif
47
48 /*----- Data structures ---------------------------------------------------*/
49
50 /* --- A basic target object --- */
51
52 typedef struct target {
53   struct target_ops *ops;
54   char *desc;
55 } target;
56
57 /* --- Forwarding target operations --- */
58
59 typedef struct target_ops {
60   const char *name;                     /* Name of this target */
61
62   /* --- @option@ --- *
63    *
64    * Arguments: @target *t@ = pointer to target object, or zero if global
65    *            @scanner *sc@ = scanner to read from
66    *
67    * Returns:   Nonzero to claim the option.
68    *
69    * Use:       Handles an option string from the configuration file.
70    */
71
72   int (*option)(target */*t*/, scanner */*sc*/);
73
74   /* --- @read@ --- *
75    *
76    * Arguments: @scanner *sc@ = pointer to scanner to read from
77    *
78    * Returns:   Pointer to a target object to claim, null to reject.
79    *
80    * Use:       Parses a target description from the configuration file.
81    *            Only the socket target is allowed to omit the prefix on a
82    *            target specification.
83    */
84
85   target *(*read)(scanner */*sc*/);
86
87   /* --- @confirm@ --- *
88    *
89    * Arguments: @target *t@ = pointer to target
90    *
91    * Returns:   ---
92    *
93    * Use:       Confirms configuration of a target.
94    */
95
96   void (*confirm)(target */*t*/);
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