src: for every AGPL3.0 file, add SPDX identifier.
[oweals/gnunet.git] / src / include / gnunet_reclaim_attribute_plugin.h
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 the idp database backend
26  *
27  * @defgroup identity-provider-plugin  IdP service plugin API
28  * Plugin API for the idp database backend
29  * @{
30  */
31 #ifndef GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H
32 #define GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H
33
34 #include "gnunet_util_lib.h"
35 #include "gnunet_reclaim_attribute_lib.h"
36
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #if 0                           /* keep Emacsens' auto-indent happy */
41 }
42 #endif
43 #endif
44
45
46 /**
47  * Function called to convert the binary value @a data of an attribute of
48  * type @a type to a human-readable string.
49  *
50  * @param cls closure
51  * @param type type of the attribute
52  * @param data value in binary encoding
53  * @param data_size number of bytes in @a data
54  * @return NULL on error, otherwise human-readable representation of the value
55  */
56 typedef char * (*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) (void *cls,
57                                                           uint32_t type,
58                                                           const void *data,
59                                                           size_t data_size);
60
61
62 /**
63  * Function called to convert human-readable version of the value @a s
64  * of an attribute of type @a type to the respective binary
65  * representation.
66  *
67  * @param cls closure
68  * @param type type of the attribute
69  * @param s human-readable string
70  * @param data set to value in binary encoding (will be allocated)
71  * @param data_size set to number of bytes in @a data
72  * @return #GNUNET_OK on success
73  */
74 typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) (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_ATTRIBUTE_TypenameToNumberFunction) (void *cls,
90                                                                const char *typename);
91
92
93 /**
94  * Function called to convert a type number (i.e. 1) to the
95  * corresponding type string
96  *
97  * @param cls closure
98  * @param type number of a type to convert
99  * @return corresponding typestring, NULL on error
100  */
101 typedef const char * (*GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction) (void *cls,
102                                                                    uint32_t type);
103
104
105 /**
106  * Each plugin is required to return a pointer to a struct of this
107  * type as the return value from its entry point.
108  */
109 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions
110 {
111
112   /**
113    * Closure for all of the callbacks.
114    */
115   void *cls;
116
117   /**
118    * Conversion to string.
119    */
120   GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction value_to_string;
121
122   /**
123    * Conversion to binary.
124    */
125   GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction string_to_value;
126
127   /**
128    * Typename to number.
129    */
130   GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction typename_to_number;
131
132   /**
133    * Number to typename.
134    */
135   GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename;
136
137 };
138
139
140 #if 0                           /* keep Emacsens' auto-indent happy */
141 {
142 #endif
143 #ifdef __cplusplus
144 }
145 #endif
146
147 #endif
148
149 /** @} */  /* end of group */