summaryrefslogtreecommitdiff
path: root/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c')
-rw-r--r--src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
index 8999bcadf..c47148c19 100644
--- a/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
+++ b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c
@@ -16,7 +16,7 @@
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c 22 * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c
@@ -42,19 +42,19 @@
42 * @return NULL on error, otherwise human-readable representation of the value 42 * @return NULL on error, otherwise human-readable representation of the value
43 */ 43 */
44static char * 44static char *
45gnuid_value_to_string (void *cls, 45gnuid_value_to_string(void *cls,
46 uint32_t type, 46 uint32_t type,
47 const void *data, 47 const void *data,
48 size_t data_size) 48 size_t data_size)
49{ 49{
50
51 switch (type) 50 switch (type)
52 { 51 {
53 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: 52 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
54 return GNUNET_strndup (data, data_size); 53 return GNUNET_strndup(data, data_size);
54
55 default: 55 default:
56 return NULL; 56 return NULL;
57 } 57 }
58} 58}
59 59
60 60
@@ -70,24 +70,24 @@ gnuid_value_to_string (void *cls,
70 * @return #GNUNET_OK on success 70 * @return #GNUNET_OK on success
71 */ 71 */
72static int 72static int
73gnuid_string_to_value (void *cls, 73gnuid_string_to_value(void *cls,
74 uint32_t type, 74 uint32_t type,
75 const char *s, 75 const char *s,
76 void **data, 76 void **data,
77 size_t *data_size) 77 size_t *data_size)
78{ 78{
79 if (NULL == s) 79 if (NULL == s)
80 return GNUNET_SYSERR; 80 return GNUNET_SYSERR;
81 switch (type) 81 switch (type)
82 { 82 {
83
84 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: 83 case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING:
85 *data = GNUNET_strdup (s); 84 *data = GNUNET_strdup(s);
86 *data_size = strlen (s); 85 *data_size = strlen(s);
87 return GNUNET_OK; 86 return GNUNET_OK;
87
88 default: 88 default:
89 return GNUNET_SYSERR; 89 return GNUNET_SYSERR;
90 } 90 }
91} 91}
92 92
93 93
@@ -95,12 +95,11 @@ gnuid_string_to_value (void *cls,
95 * Mapping of attribute type numbers to human-readable 95 * Mapping of attribute type numbers to human-readable
96 * attribute type names. 96 * attribute type names.
97 */ 97 */
98static struct 98static struct {
99{
100 const char *name; 99 const char *name;
101 uint32_t number; 100 uint32_t number;
102} gnuid_name_map[] = {{"STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING}, 101} gnuid_name_map[] = { { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING },
103 {NULL, UINT32_MAX}}; 102 { NULL, UINT32_MAX } };
104 103
105 104
106/** 105/**
@@ -111,13 +110,13 @@ static struct
111 * @return corresponding number, UINT32_MAX on error 110 * @return corresponding number, UINT32_MAX on error
112 */ 111 */
113static uint32_t 112static uint32_t
114gnuid_typename_to_number (void *cls, const char *gnuid_typename) 113gnuid_typename_to_number(void *cls, const char *gnuid_typename)
115{ 114{
116 unsigned int i; 115 unsigned int i;
117 116
118 i = 0; 117 i = 0;
119 while ((NULL != gnuid_name_map[i].name) && 118 while ((NULL != gnuid_name_map[i].name) &&
120 (0 != strcasecmp (gnuid_typename, gnuid_name_map[i].name))) 119 (0 != strcasecmp(gnuid_typename, gnuid_name_map[i].name)))
121 i++; 120 i++;
122 return gnuid_name_map[i].number; 121 return gnuid_name_map[i].number;
123} 122}
@@ -131,7 +130,7 @@ gnuid_typename_to_number (void *cls, const char *gnuid_typename)
131 * @return corresponding typestring, NULL on error 130 * @return corresponding typestring, NULL on error
132 */ 131 */
133static const char * 132static const char *
134gnuid_number_to_typename (void *cls, uint32_t type) 133gnuid_number_to_typename(void *cls, uint32_t type)
135{ 134{
136 unsigned int i; 135 unsigned int i;
137 136
@@ -149,11 +148,11 @@ gnuid_number_to_typename (void *cls, uint32_t type)
149 * @return the exported block API 148 * @return the exported block API
150 */ 149 */
151void * 150void *
152libgnunet_plugin_reclaim_attribute_gnuid_init (void *cls) 151libgnunet_plugin_reclaim_attribute_gnuid_init(void *cls)
153{ 152{
154 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api; 153 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api;
155 154
156 api = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions); 155 api = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions);
157 api->value_to_string = &gnuid_value_to_string; 156 api->value_to_string = &gnuid_value_to_string;
158 api->string_to_value = &gnuid_string_to_value; 157 api->string_to_value = &gnuid_string_to_value;
159 api->typename_to_number = &gnuid_typename_to_number; 158 api->typename_to_number = &gnuid_typename_to_number;
@@ -169,11 +168,11 @@ libgnunet_plugin_reclaim_attribute_gnuid_init (void *cls)
169 * @return NULL 168 * @return NULL
170 */ 169 */
171void * 170void *
172libgnunet_plugin_reclaim_attribute_gnuid_done (void *cls) 171libgnunet_plugin_reclaim_attribute_gnuid_done(void *cls)
173{ 172{
174 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = cls; 173 struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = cls;
175 174
176 GNUNET_free (api); 175 GNUNET_free(api);
177 return NULL; 176 return NULL;
178} 177}
179 178