diff options
Diffstat (limited to 'src/include/gnunet_reclaim_attribute_lib.h')
-rw-r--r-- | src/include/gnunet_reclaim_attribute_lib.h | 103 |
1 files changed, 66 insertions, 37 deletions
diff --git a/src/include/gnunet_reclaim_attribute_lib.h b/src/include/gnunet_reclaim_attribute_lib.h index db009da3f..e96937ea8 100644 --- a/src/include/gnunet_reclaim_attribute_lib.h +++ b/src/include/gnunet_reclaim_attribute_lib.h | |||
@@ -24,16 +24,15 @@ | |||
24 | * @file | 24 | * @file |
25 | * Identity attribute definitions | 25 | * Identity attribute definitions |
26 | * | 26 | * |
27 | * @defgroup identity-provider Identity Provider service | 27 | * @defgroup reclaim-attribute reclaim attributes |
28 | * @{ | 28 | * @{ |
29 | */ | 29 | */ |
30 | #ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H | 30 | #ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H |
31 | #define GNUNET_RECLAIM_ATTRIBUTE_LIB_H | 31 | #define GNUNET_RECLAIM_ATTRIBUTE_LIB_H |
32 | 32 | ||
33 | #ifdef __cplusplus | 33 | #ifdef __cplusplus |
34 | extern "C" | 34 | extern "C" { |
35 | { | 35 | #if 0 /* keep Emacsens' auto-indent happy */ |
36 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
37 | } | 36 | } |
38 | #endif | 37 | #endif |
39 | #endif | 38 | #endif |
@@ -52,7 +51,6 @@ extern "C" | |||
52 | #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1 | 51 | #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1 |
53 | 52 | ||
54 | 53 | ||
55 | |||
56 | /** | 54 | /** |
57 | * An attribute. | 55 | * An attribute. |
58 | */ | 56 | */ |
@@ -76,7 +74,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_Claim | |||
76 | * The name of the attribute. Note "name" must never be individually | 74 | * The name of the attribute. Note "name" must never be individually |
77 | * free'd | 75 | * free'd |
78 | */ | 76 | */ |
79 | const char* name; | 77 | const char *name; |
80 | 78 | ||
81 | /** | 79 | /** |
82 | * Number of bytes in @e data. | 80 | * Number of bytes in @e data. |
@@ -89,9 +87,12 @@ struct GNUNET_RECLAIM_ATTRIBUTE_Claim | |||
89 | * existing data area. | 87 | * existing data area. |
90 | */ | 88 | */ |
91 | const void *data; | 89 | const void *data; |
92 | |||
93 | }; | 90 | }; |
94 | 91 | ||
92 | |||
93 | /** | ||
94 | * A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures. | ||
95 | */ | ||
95 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList | 96 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList |
96 | { | 97 | { |
97 | /** | 98 | /** |
@@ -105,6 +106,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList | |||
105 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_tail; | 106 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_tail; |
106 | }; | 107 | }; |
107 | 108 | ||
109 | |||
108 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry | 110 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry |
109 | { | 111 | { |
110 | /** | 112 | /** |
@@ -123,6 +125,7 @@ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry | |||
123 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 125 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
124 | }; | 126 | }; |
125 | 127 | ||
128 | |||
126 | /** | 129 | /** |
127 | * Create a new attribute claim. | 130 | * Create a new attribute claim. |
128 | * | 131 | * |
@@ -133,9 +136,9 @@ struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry | |||
133 | * @return the new attribute | 136 | * @return the new attribute |
134 | */ | 137 | */ |
135 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * | 138 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * |
136 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char* attr_name, | 139 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, |
137 | uint32_t type, | 140 | uint32_t type, |
138 | const void* data, | 141 | const void *data, |
139 | size_t data_size); | 142 | size_t data_size); |
140 | 143 | ||
141 | 144 | ||
@@ -143,57 +146,73 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char* attr_name, | |||
143 | * Get required size for serialization buffer | 146 | * Get required size for serialization buffer |
144 | * | 147 | * |
145 | * @param attrs the attribute list to serialize | 148 | * @param attrs the attribute list to serialize |
146 | * | ||
147 | * @return the required buffer size | 149 | * @return the required buffer size |
148 | */ | 150 | */ |
149 | size_t | 151 | size_t |
150 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | 152 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size ( |
153 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | ||
154 | |||
151 | 155 | ||
156 | /** | ||
157 | * Destroy claim list | ||
158 | * | ||
159 | * @param attrs list to destroy | ||
160 | */ | ||
152 | void | 161 | void |
153 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | 162 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy ( |
163 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | ||
164 | |||
154 | 165 | ||
166 | /** | ||
167 | * Add a new attribute to a claim list | ||
168 | * | ||
169 | * @param attr_name the name of the new attribute claim | ||
170 | * @param type the type of the claim | ||
171 | * @param data claim payload | ||
172 | * @param data_size claim payload size | ||
173 | */ | ||
155 | void | 174 | void |
156 | GNUNET_RECLAIM_ATTRIBUTE_list_add (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 175 | GNUNET_RECLAIM_ATTRIBUTE_list_add ( |
157 | const char* attr_name, | 176 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
158 | uint32_t type, | 177 | const char *attr_name, |
159 | const void* data, | 178 | uint32_t type, |
160 | size_t data_size); | 179 | const void *data, |
180 | size_t data_size); | ||
181 | |||
161 | 182 | ||
162 | /** | 183 | /** |
163 | * Serialize an attribute list | 184 | * Serialize an attribute list |
164 | * | 185 | * |
165 | * @param attrs the attribute list to serialize | 186 | * @param attrs the attribute list to serialize |
166 | * @param result the serialized attribute | 187 | * @param result the serialized attribute |
167 | * | ||
168 | * @return length of serialized data | 188 | * @return length of serialized data |
169 | */ | 189 | */ |
170 | size_t | 190 | size_t |
171 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 191 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( |
172 | char *result); | 192 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
193 | char *result); | ||
194 | |||
173 | 195 | ||
174 | /** | 196 | /** |
175 | * Deserialize an attribute list | 197 | * Deserialize an attribute list |
176 | * | 198 | * |
177 | * @param data the serialized attribute list | 199 | * @param data the serialized attribute list |
178 | * @param data_size the length of the serialized data | 200 | * @param data_size the length of the serialized data |
179 | * | ||
180 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller | 201 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller |
181 | */ | 202 | */ |
182 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * | 203 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * |
183 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char* data, | 204 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size); |
184 | size_t data_size); | ||
185 | 205 | ||
186 | 206 | ||
187 | /** | 207 | /** |
188 | * Get required size for serialization buffer | 208 | * Get required size for serialization buffer |
189 | * | 209 | * |
190 | * @param attr the attribute to serialize | 210 | * @param attr the attribute to serialize |
191 | * | ||
192 | * @return the required buffer size | 211 | * @return the required buffer size |
193 | */ | 212 | */ |
194 | size_t | 213 | size_t |
195 | GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr); | 214 | GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size ( |
196 | 215 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr); | |
197 | 216 | ||
198 | 217 | ||
199 | /** | 218 | /** |
@@ -201,12 +220,13 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBU | |||
201 | * | 220 | * |
202 | * @param attr the attribute to serialize | 221 | * @param attr the attribute to serialize |
203 | * @param result the serialized attribute | 222 | * @param result the serialized attribute |
204 | * | ||
205 | * @return length of serialized data | 223 | * @return length of serialized data |
206 | */ | 224 | */ |
207 | size_t | 225 | size_t |
208 | GNUNET_RECLAIM_ATTRIBUTE_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, | 226 | GNUNET_RECLAIM_ATTRIBUTE_serialize ( |
209 | char *result); | 227 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, |
228 | char *result); | ||
229 | |||
210 | 230 | ||
211 | /** | 231 | /** |
212 | * Deserialize an attribute | 232 | * Deserialize an attribute |
@@ -217,11 +237,18 @@ GNUNET_RECLAIM_ATTRIBUTE_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim | |||
217 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | 237 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller |
218 | */ | 238 | */ |
219 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * | 239 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * |
220 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char* data, | 240 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size); |
221 | size_t data_size); | 241 | |
242 | |||
243 | /** | ||
244 | * Make a (deep) copy of a claim list | ||
245 | * @param attrs claim list to copy | ||
246 | * @return copied claim list | ||
247 | */ | ||
248 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * | ||
249 | GNUNET_RECLAIM_ATTRIBUTE_list_dup ( | ||
250 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | ||
222 | 251 | ||
223 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList* | ||
224 | GNUNET_RECLAIM_ATTRIBUTE_list_dup (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); | ||
225 | 252 | ||
226 | /** | 253 | /** |
227 | * Convert a type name to the corresponding number | 254 | * Convert a type name to the corresponding number |
@@ -248,6 +275,7 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, | |||
248 | void **data, | 275 | void **data, |
249 | size_t *data_size); | 276 | size_t *data_size); |
250 | 277 | ||
278 | |||
251 | /** | 279 | /** |
252 | * Convert the 'claim' of an attribute to a string | 280 | * Convert the 'claim' of an attribute to a string |
253 | * | 281 | * |
@@ -258,20 +286,21 @@ GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, | |||
258 | */ | 286 | */ |
259 | char * | 287 | char * |
260 | GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, | 288 | GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, |
261 | const void* data, | 289 | const void *data, |
262 | size_t data_size); | 290 | size_t data_size); |
263 | 291 | ||
292 | |||
264 | /** | 293 | /** |
265 | * Convert a type number to the corresponding type string | 294 | * Convert a type number to the corresponding type string |
266 | * | 295 | * |
267 | * @param type number of a type | 296 | * @param type number of a type |
268 | * @return corresponding typestring, NULL on error | 297 | * @return corresponding typestring, NULL on error |
269 | */ | 298 | */ |
270 | const char* | 299 | const char * |
271 | GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type); | 300 | GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type); |
272 | 301 | ||
273 | 302 | ||
274 | #if 0 /* keep Emacsens' auto-indent happy */ | 303 | #if 0 /* keep Emacsens' auto-indent happy */ |
275 | { | 304 | { |
276 | #endif | 305 | #endif |
277 | #ifdef __cplusplus | 306 | #ifdef __cplusplus |
@@ -282,6 +311,6 @@ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type); | |||
282 | /* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */ | 311 | /* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */ |
283 | #endif | 312 | #endif |
284 | 313 | ||
285 | /** @} */ /* end of group identity */ | 314 | /** @} */ /* end of group reclaim-attribute */ |
286 | 315 | ||
287 | /* end of gnunet_reclaim_attribute_lib.h */ | 316 | /* end of gnunet_reclaim_attribute_lib.h */ |