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