diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-04 18:42:04 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-09 20:38:10 +0100 |
commit | 55f6d26b7424d660c99bc89f3677b20294e87a27 (patch) | |
tree | a8080fdcf0d9688c154417e50c58055e364f8b6b /src/include/gnunet_reclaim_plugin.h | |
parent | 5b6bb2ce4d60635b2af950d72b45f12686fd5218 (diff) | |
download | gnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.tar.gz gnunet-55f6d26b7424d660c99bc89f3677b20294e87a27.zip |
Refactoring reclaim attestations
Diffstat (limited to 'src/include/gnunet_reclaim_plugin.h')
-rw-r--r-- | src/include/gnunet_reclaim_plugin.h | 247 |
1 files changed, 247 insertions, 0 deletions
diff --git a/src/include/gnunet_reclaim_plugin.h b/src/include/gnunet_reclaim_plugin.h new file mode 100644 index 000000000..4dd5252d2 --- /dev/null +++ b/src/include/gnunet_reclaim_plugin.h | |||
@@ -0,0 +1,247 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2012, 2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @author Martin Schanzenbach | ||
23 | * | ||
24 | * @file | ||
25 | * Plugin API for reclaim attribute types | ||
26 | * | ||
27 | * @defgroup reclaim-attribute-plugin reclaim plugin API for attributes/claims | ||
28 | * @{ | ||
29 | */ | ||
30 | #ifndef GNUNET_RECLAIM_AttributePLUGIN_H | ||
31 | #define GNUNET_RECLAIM_AttributePLUGIN_H | ||
32 | |||
33 | #include "gnunet_util_lib.h" | ||
34 | #include "gnunet_reclaim_attribute_lib.h" | ||
35 | |||
36 | #ifdef __cplusplus | ||
37 | extern "C" { | ||
38 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
39 | } | ||
40 | #endif | ||
41 | #endif | ||
42 | |||
43 | |||
44 | /** | ||
45 | * Function called to convert the binary value @a data of an attribute of | ||
46 | * type @a type to a human-readable string. | ||
47 | * | ||
48 | * @param cls closure | ||
49 | * @param type type of the attribute | ||
50 | * @param data value in binary encoding | ||
51 | * @param data_size number of bytes in @a data | ||
52 | * @return NULL on error, otherwise human-readable representation of the value | ||
53 | */ | ||
54 | typedef char *(*GNUNET_RECLAIM_AttributeValueToStringFunction) ( | ||
55 | void *cls, | ||
56 | uint32_t type, | ||
57 | const void *data, | ||
58 | size_t data_size); | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Function called to convert human-readable version of the value @a s | ||
63 | * of an attribute of type @a type to the respective binary | ||
64 | * representation. | ||
65 | * | ||
66 | * @param cls closure | ||
67 | * @param type type of the attribute | ||
68 | * @param s human-readable string | ||
69 | * @param data set to value in binary encoding (will be allocated) | ||
70 | * @param data_size set to number of bytes in @a data | ||
71 | * @return #GNUNET_OK on success | ||
72 | */ | ||
73 | typedef int (*GNUNET_RECLAIM_AttributeStringToValueFunction) ( | ||
74 | void *cls, | ||
75 | uint32_t type, | ||
76 | const char *s, | ||
77 | void **data, | ||
78 | size_t *data_size); | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Function called to convert a type name to the | ||
83 | * corresponding number. | ||
84 | * | ||
85 | * @param cls closure | ||
86 | * @param typename name to convert | ||
87 | * @return corresponding number, UINT32_MAX on error | ||
88 | */ | ||
89 | typedef uint32_t (*GNUNET_RECLAIM_AttributeTypenameToNumberFunction) ( | ||
90 | void *cls, | ||
91 | const char *typename); | ||
92 | |||
93 | |||
94 | /** | ||
95 | * Function called to convert a type number (i.e. 1) to the | ||
96 | * corresponding type string | ||
97 | * | ||
98 | * @param cls closure | ||
99 | * @param type number of a type to convert | ||
100 | * @return corresponding typestring, NULL on error | ||
101 | */ | ||
102 | typedef const char *(*GNUNET_RECLAIM_AttributeNumberToTypenameFunction) ( | ||
103 | void *cls, | ||
104 | uint32_t type); | ||
105 | |||
106 | /** | ||
107 | * Function called to convert the binary value @a data of an attribute of | ||
108 | * type @a type to a human-readable string. | ||
109 | * | ||
110 | * @param cls closure | ||
111 | * @param type type of the attribute | ||
112 | * @param data value in binary encoding | ||
113 | * @param data_size number of bytes in @a data | ||
114 | * @return NULL on error, otherwise human-readable representation of the value | ||
115 | */ | ||
116 | typedef char *(*GNUNET_RECLAIM_AttestationValueToStringFunction) ( | ||
117 | void *cls, | ||
118 | uint32_t type, | ||
119 | const void *data, | ||
120 | size_t data_size); | ||
121 | |||
122 | |||
123 | /** | ||
124 | * Function called to convert human-readable version of the value @a s | ||
125 | * of an attribute of type @a type to the respective binary | ||
126 | * representation. | ||
127 | * | ||
128 | * @param cls closure | ||
129 | * @param type type of the attribute | ||
130 | * @param s human-readable string | ||
131 | * @param data set to value in binary encoding (will be allocated) | ||
132 | * @param data_size set to number of bytes in @a data | ||
133 | * @return #GNUNET_OK on success | ||
134 | */ | ||
135 | typedef int (*GNUNET_RECLAIM_AttestationStringToValueFunction) ( | ||
136 | void *cls, | ||
137 | uint32_t type, | ||
138 | const char *s, | ||
139 | void **data, | ||
140 | size_t *data_size); | ||
141 | |||
142 | |||
143 | /** | ||
144 | * Function called to convert a type name to the | ||
145 | * corresponding number. | ||
146 | * | ||
147 | * @param cls closure | ||
148 | * @param typename name to convert | ||
149 | * @return corresponding number, UINT32_MAX on error | ||
150 | */ | ||
151 | typedef uint32_t (*GNUNET_RECLAIM_AttestationTypenameToNumberFunction) ( | ||
152 | void *cls, | ||
153 | const char *typename); | ||
154 | |||
155 | |||
156 | /** | ||
157 | * Function called to convert a type number (i.e. 1) to the | ||
158 | * corresponding type string | ||
159 | * | ||
160 | * @param cls closure | ||
161 | * @param type number of a type to convert | ||
162 | * @return corresponding typestring, NULL on error | ||
163 | */ | ||
164 | typedef const char *(*GNUNET_RECLAIM_AttestationNumberToTypenameFunction) ( | ||
165 | void *cls, | ||
166 | uint32_t type); | ||
167 | |||
168 | |||
169 | |||
170 | /** | ||
171 | * Each plugin is required to return a pointer to a struct of this | ||
172 | * type as the return value from its entry point. | ||
173 | */ | ||
174 | struct GNUNET_RECLAIM_AttributePluginFunctions | ||
175 | { | ||
176 | /** | ||
177 | * Closure for all of the callbacks. | ||
178 | */ | ||
179 | void *cls; | ||
180 | |||
181 | /** | ||
182 | * Conversion to string. | ||
183 | */ | ||
184 | GNUNET_RECLAIM_AttributeValueToStringFunction value_to_string; | ||
185 | |||
186 | /** | ||
187 | * Conversion to binary. | ||
188 | */ | ||
189 | GNUNET_RECLAIM_AttributeStringToValueFunction string_to_value; | ||
190 | |||
191 | /** | ||
192 | * Typename to number. | ||
193 | */ | ||
194 | GNUNET_RECLAIM_AttributeTypenameToNumberFunction typename_to_number; | ||
195 | |||
196 | /** | ||
197 | * Number to typename. | ||
198 | */ | ||
199 | GNUNET_RECLAIM_AttributeNumberToTypenameFunction number_to_typename; | ||
200 | |||
201 | }; | ||
202 | |||
203 | /** | ||
204 | * Each plugin is required to return a pointer to a struct of this | ||
205 | * type as the return value from its entry point. | ||
206 | */ | ||
207 | struct GNUNET_RECLAIM_AttestationPluginFunctions | ||
208 | { | ||
209 | /** | ||
210 | * Closure for all of the callbacks. | ||
211 | */ | ||
212 | void *cls; | ||
213 | |||
214 | /** | ||
215 | * Conversion to string. | ||
216 | */ | ||
217 | GNUNET_RECLAIM_AttestationValueToStringFunction value_to_string; | ||
218 | |||
219 | /** | ||
220 | * Conversion to binary. | ||
221 | */ | ||
222 | GNUNET_RECLAIM_AttestationStringToValueFunction string_to_value; | ||
223 | |||
224 | /** | ||
225 | * Typename to number. | ||
226 | */ | ||
227 | GNUNET_RECLAIM_AttestationTypenameToNumberFunction typename_to_number; | ||
228 | |||
229 | /** | ||
230 | * Number to typename. | ||
231 | */ | ||
232 | GNUNET_RECLAIM_AttestationNumberToTypenameFunction number_to_typename; | ||
233 | |||
234 | }; | ||
235 | |||
236 | |||
237 | |||
238 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
239 | { | ||
240 | #endif | ||
241 | #ifdef __cplusplus | ||
242 | } | ||
243 | #endif | ||
244 | |||
245 | #endif | ||
246 | |||
247 | /** @} */ /* end of group */ | ||