diff options
author | Tristan Schwieren <tristan.schwieren@tum.de> | 2022-07-08 12:47:36 +0200 |
---|---|---|
committer | Tristan Schwieren <tristan.schwieren@tum.de> | 2022-07-08 12:47:36 +0200 |
commit | fe80bcfb8c0ff189fc625e72eb38a6617d419dd7 (patch) | |
tree | 4ca0651b5ed870e1a340555ae73a210c4b3f90bc /src/reclaim | |
parent | 3b4032ef5138bf630d830218a0f29c9032cc35d4 (diff) | |
download | gnunet-fe80bcfb8c0ff189fc625e72eb38a6617d419dd7.tar.gz gnunet-fe80bcfb8c0ff189fc625e72eb38a6617d419dd7.zip |
- DID lib; renamed vars and moved a free
Diffstat (limited to 'src/reclaim')
-rw-r--r-- | src/reclaim/did_core.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/reclaim/did_core.c b/src/reclaim/did_core.c index 645ba0cd4..574e3938d 100644 --- a/src/reclaim/did_core.c +++ b/src/reclaim/did_core.c | |||
@@ -62,19 +62,19 @@ DID_resolve_gns_lookup_cb ( | |||
62 | { | 62 | { |
63 | char *did_document; | 63 | char *did_document; |
64 | DID_resolve_callback *cb = ((struct DID_resolve_return *) cls)->cb; | 64 | DID_resolve_callback *cb = ((struct DID_resolve_return *) cls)->cb; |
65 | void *cls2 = ((struct DID_resolve_return *) cls)->cls; | 65 | void *cls_did_resolve_cb = ((struct DID_resolve_return *) cls)->cls; |
66 | free (cls); | 66 | free (cls); |
67 | 67 | ||
68 | if (rd_count != 1) | 68 | if (rd_count != 1) |
69 | cb (GNUNET_NO, "An ego should only have one DID Document", cls2); | 69 | cb (GNUNET_NO, "An ego should only have one DID Document", cls_did_resolve_cb); |
70 | 70 | ||
71 | if (rd[0].record_type == GNUNET_DNSPARSER_TYPE_TXT) | 71 | if (rd[0].record_type == GNUNET_DNSPARSER_TYPE_TXT) |
72 | { | 72 | { |
73 | did_document = (char *) rd[0].data; | 73 | did_document = (char *) rd[0].data; |
74 | cb (GNUNET_OK, did_document, cls2); | 74 | cb (GNUNET_OK, did_document, cls_did_resolve_cb); |
75 | } | 75 | } |
76 | else | 76 | else |
77 | cb (GNUNET_NO, "DID Document is not a TXT record\n", cls2); | 77 | cb (GNUNET_NO, "DID Document is not a TXT record\n", cls_did_resolve_cb); |
78 | } | 78 | } |
79 | 79 | ||
80 | /** | 80 | /** |
@@ -100,13 +100,13 @@ DID_resolve (const char *did, | |||
100 | return GNUNET_NO; | 100 | return GNUNET_NO; |
101 | 101 | ||
102 | // Create closure for lookup callback | 102 | // Create closure for lookup callback |
103 | struct DID_resolve_return *cls2 = malloc (sizeof(struct DID_resolve_return)); | 103 | struct DID_resolve_return *cls_gns_lookup_cb = malloc (sizeof(struct DID_resolve_return)); |
104 | cls2->cb = cont; | 104 | cls_gns_lookup_cb->cb = cont; |
105 | cls2->cls = cls; | 105 | cls_gns_lookup_cb->cls = cls; |
106 | 106 | ||
107 | GNUNET_GNS_lookup (gns_handle, DID_DOCUMENT_LABEL, &pkey, | 107 | GNUNET_GNS_lookup (gns_handle, DID_DOCUMENT_LABEL, &pkey, |
108 | GNUNET_DNSPARSER_TYPE_TXT, | 108 | GNUNET_DNSPARSER_TYPE_TXT, |
109 | GNUNET_GNS_LO_DEFAULT, &DID_resolve_gns_lookup_cb, cls2); | 109 | GNUNET_GNS_LO_DEFAULT, &DID_resolve_gns_lookup_cb, cls_gns_lookup_cb); |
110 | 110 | ||
111 | return GNUNET_OK; | 111 | return GNUNET_OK; |
112 | } | 112 | } |
@@ -121,18 +121,18 @@ DID_create_did_store_cb (void *cls, | |||
121 | const char *emsg) | 121 | const char *emsg) |
122 | { | 122 | { |
123 | DID_action_callback *cb = ((struct DID_action_return *) cls)->cb; | 123 | DID_action_callback *cb = ((struct DID_action_return *) cls)->cb; |
124 | void *cls2 = ((struct DID_action_return *) cls)->cls; | 124 | void *cls_did_create_cb = ((struct DID_action_return *) cls)->cls; |
125 | free (cls); | 125 | free (cls); |
126 | 126 | ||
127 | if (GNUNET_OK == success) | 127 | if (GNUNET_OK == success) |
128 | { | 128 | { |
129 | cb (GNUNET_OK, (void *) cls2); | 129 | cb (GNUNET_OK, (void *) cls_did_create_cb); |
130 | } | 130 | } |
131 | else | 131 | else |
132 | { | 132 | { |
133 | // TODO: Log emsg. Not writing it to STDOUT | 133 | // TODO: Log emsg. Not writing it to STDOUT |
134 | printf ("%s\n", emsg); | 134 | printf ("%s\n", emsg); |
135 | cb (GNUNET_NO, (void *) cls2); | 135 | cb (GNUNET_NO, (void *) cls_did_create_cb); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
@@ -175,13 +175,12 @@ DID_create_namestore_lookup_cb (void *cls, | |||
175 | { | 175 | { |
176 | printf ("Ego already has a DID Document. Abort.\n"); | 176 | printf ("Ego already has a DID Document. Abort.\n"); |
177 | cont (GNUNET_NO, cls1); | 177 | cont (GNUNET_NO, cls1); |
178 | return; | ||
179 | } | 178 | } |
180 | else { | 179 | else { |
181 | // Get public key | 180 | // Get public key |
182 | GNUNET_IDENTITY_key_get_public (zone, &pkey); | 181 | GNUNET_IDENTITY_key_get_public (zone, &pkey); |
183 | 182 | ||
184 | // No DID Document is given a default one is created | 183 | // If no DID Document is given a default one is created |
185 | if (did_document != NULL) | 184 | if (did_document != NULL) |
186 | printf ( | 185 | printf ( |
187 | "DID Docuement is read from \"DID-document\" argument (EXPERIMENTAL)\n"); | 186 | "DID Docuement is read from \"DID-document\" argument (EXPERIMENTAL)\n"); |
@@ -196,9 +195,9 @@ DID_create_namestore_lookup_cb (void *cls, | |||
196 | record_data.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 195 | record_data.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
197 | 196 | ||
198 | // Create closure for record store callback | 197 | // Create closure for record store callback |
199 | struct DID_action_return *cls2 = malloc (sizeof(struct DID_action_return)); | 198 | struct DID_action_return *cls_record_store_cb = malloc (sizeof(struct DID_action_return)); |
200 | cls2->cb = cont; | 199 | cls_record_store_cb->cb = cont; |
201 | cls2->cls = cls1; | 200 | cls_record_store_cb->cls = cls1; |
202 | 201 | ||
203 | // Store record | 202 | // Store record |
204 | GNUNET_NAMESTORE_records_store (namestore_handle, | 203 | GNUNET_NAMESTORE_records_store (namestore_handle, |
@@ -207,11 +206,11 @@ DID_create_namestore_lookup_cb (void *cls, | |||
207 | 1, // FIXME what if GNUNET_GNS_EMPTY_LABEL_AT has records | 206 | 1, // FIXME what if GNUNET_GNS_EMPTY_LABEL_AT has records |
208 | &record_data, | 207 | &record_data, |
209 | &DID_create_did_store_cb, | 208 | &DID_create_did_store_cb, |
210 | (void *) cls2); | 209 | (void *) cls_record_store_cb); |
211 | 210 | ||
212 | free(cls); | ||
213 | } | 211 | } |
214 | 212 | ||
213 | free(cls); | ||
215 | } | 214 | } |
216 | 215 | ||
217 | /** | 216 | /** |
@@ -249,13 +248,13 @@ DID_create (const struct GNUNET_IDENTITY_Ego *ego, | |||
249 | return GNUNET_NO; | 248 | return GNUNET_NO; |
250 | } | 249 | } |
251 | 250 | ||
252 | struct DID_create_namestore_lookup_closure *cls2 | 251 | struct DID_create_namestore_lookup_closure *cls_name_store_lookup_cb |
253 | = malloc (sizeof(struct DID_create_namestore_lookup_closure)); | 252 | = malloc (sizeof(struct DID_create_namestore_lookup_closure)); |
254 | cls2->did_document = did_document; | 253 | cls_name_store_lookup_cb->did_document = did_document; |
255 | cls2->expire_time = (*expire_time); | 254 | cls_name_store_lookup_cb->expire_time = (*expire_time); |
256 | cls2->namestore_handle = namestore_handle; | 255 | cls_name_store_lookup_cb->namestore_handle = namestore_handle; |
257 | cls2->cont = cont; | 256 | cls_name_store_lookup_cb->cont = cont; |
258 | cls2->cls = cls; | 257 | cls_name_store_lookup_cb->cls = cls; |
259 | 258 | ||
260 | // Check if ego already has a DID Document | 259 | // Check if ego already has a DID Document |
261 | GNUNET_NAMESTORE_records_lookup (namestore_handle, | 260 | GNUNET_NAMESTORE_records_lookup (namestore_handle, |
@@ -264,7 +263,7 @@ DID_create (const struct GNUNET_IDENTITY_Ego *ego, | |||
264 | NULL, | 263 | NULL, |
265 | NULL, | 264 | NULL, |
266 | DID_create_namestore_lookup_cb, | 265 | DID_create_namestore_lookup_cb, |
267 | (void *) cls2); | 266 | (void *) cls_name_store_lookup_cb); |
268 | 267 | ||
269 | return GNUNET_OK; | 268 | return GNUNET_OK; |
270 | } | 269 | } |