aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/json_reclaim.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim/json_reclaim.c')
-rw-r--r--src/reclaim/json_reclaim.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/src/reclaim/json_reclaim.c b/src/reclaim/json_reclaim.c
index c470ea567..8a3479b8a 100644
--- a/src/reclaim/json_reclaim.c
+++ b/src/reclaim/json_reclaim.c
@@ -46,7 +46,7 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
46 const char *val_str = NULL; 46 const char *val_str = NULL;
47 const char *type_str = NULL; 47 const char *type_str = NULL;
48 const char *id_str = NULL; 48 const char *id_str = NULL;
49 const char *attest_str = NULL; 49 const char *cred_str = NULL;
50 const char *flag_str = NULL; 50 const char *flag_str = NULL;
51 char *data; 51 char *data;
52 int unpack_state; 52 int unpack_state;
@@ -68,8 +68,8 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
68 &name_str, 68 &name_str,
69 "id", 69 "id",
70 &id_str, 70 &id_str,
71 "attestation", 71 "credential",
72 &attest_str, 72 &cred_str,
73 "type", 73 "type",
74 &type_str, 74 &type_str,
75 "value", 75 "value",
@@ -95,12 +95,12 @@ parse_attr (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
95 } 95 }
96 attr = GNUNET_RECLAIM_attribute_new (name_str, NULL, 96 attr = GNUNET_RECLAIM_attribute_new (name_str, NULL,
97 type, data, data_size); 97 type, data, data_size);
98 if ((NULL != attest_str) && (0 != strlen (attest_str))) 98 if ((NULL != cred_str) && (0 != strlen (cred_str)))
99 { 99 {
100 GNUNET_STRINGS_string_to_data (attest_str, 100 GNUNET_STRINGS_string_to_data (cred_str,
101 strlen (attest_str), 101 strlen (cred_str),
102 &attr->attestation, 102 &attr->credential,
103 sizeof(attr->attestation)); 103 sizeof(attr->credential));
104 } 104 }
105 if ((NULL == id_str) || (0 == strlen (id_str))) 105 if ((NULL == id_str) || (0 == strlen (id_str)))
106 memset (&attr->id, 0, sizeof (attr->id)); 106 memset (&attr->id, 0, sizeof (attr->id));
@@ -142,7 +142,7 @@ clean_attr (void *cls, struct GNUNET_JSON_Specification *spec)
142 * @return JSON Specification 142 * @return JSON Specification
143 */ 143 */
144struct GNUNET_JSON_Specification 144struct GNUNET_JSON_Specification
145GNUNET_RECLAIM_JSON_spec_claim (struct GNUNET_RECLAIM_Attribute **attr) 145GNUNET_RECLAIM_JSON_spec_attribute (struct GNUNET_RECLAIM_Attribute **attr)
146{ 146{
147 struct GNUNET_JSON_Specification ret = { .parser = &parse_attr, 147 struct GNUNET_JSON_Specification ret = { .parser = &parse_attr,
148 .cleaner = &clean_attr, 148 .cleaner = &clean_attr,
@@ -279,7 +279,7 @@ GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket)
279 279
280 280
281/** 281/**
282 * Parse given JSON object to an attestation claim 282 * Parse given JSON object to a credential claim
283 * 283 *
284 * @param cls closure, NULL 284 * @param cls closure, NULL
285 * @param root the json object representing data 285 * @param root the json object representing data
@@ -287,9 +287,9 @@ GNUNET_RECLAIM_JSON_spec_ticket (struct GNUNET_RECLAIM_Ticket **ticket)
287 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error 287 * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
288 */ 288 */
289static int 289static int
290parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) 290parse_credential (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
291{ 291{
292 struct GNUNET_RECLAIM_Attestation *attr; 292 struct GNUNET_RECLAIM_Credential *cred;
293 const char *name_str = NULL; 293 const char *name_str = NULL;
294 const char *val_str = NULL; 294 const char *val_str = NULL;
295 const char *type_str = NULL; 295 const char *type_str = NULL;
@@ -325,26 +325,26 @@ parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
325 "Error json object has a wrong format!\n"); 325 "Error json object has a wrong format!\n");
326 return GNUNET_SYSERR; 326 return GNUNET_SYSERR;
327 } 327 }
328 type = GNUNET_RECLAIM_attestation_typename_to_number (type_str); 328 type = GNUNET_RECLAIM_credential_typename_to_number (type_str);
329 if (GNUNET_SYSERR == 329 if (GNUNET_SYSERR ==
330 (GNUNET_RECLAIM_attestation_string_to_value (type, 330 (GNUNET_RECLAIM_credential_string_to_value (type,
331 val_str, 331 val_str,
332 (void **) &data, 332 (void **) &data,
333 &data_size))) 333 &data_size)))
334 { 334 {
335 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attestation value invalid!\n"); 335 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Credential value invalid!\n");
336 return GNUNET_SYSERR; 336 return GNUNET_SYSERR;
337 } 337 }
338 attr = GNUNET_RECLAIM_attestation_new (name_str, type, data, data_size); 338 cred = GNUNET_RECLAIM_credential_new (name_str, type, data, data_size);
339 if ((NULL == id_str) || (0 == strlen (id_str))) 339 if ((NULL == id_str) || (0 == strlen (id_str)))
340 memset (&attr->id, 0, sizeof (attr->id)); 340 memset (&cred->id, 0, sizeof (cred->id));
341 else 341 else
342 GNUNET_STRINGS_string_to_data (id_str, 342 GNUNET_STRINGS_string_to_data (id_str,
343 strlen (id_str), 343 strlen (id_str),
344 &attr->id, 344 &cred->id,
345 sizeof(attr->id)); 345 sizeof(cred->id));
346 346
347 *(struct GNUNET_RECLAIM_Attestation **) spec->ptr = attr; 347 *(struct GNUNET_RECLAIM_Credential **) spec->ptr = cred;
348 return GNUNET_OK; 348 return GNUNET_OK;
349} 349}
350 350
@@ -356,11 +356,11 @@ parse_attest (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
356 * @param[out] spec where to free the data 356 * @param[out] spec where to free the data
357 */ 357 */
358static void 358static void
359clean_attest (void *cls, struct GNUNET_JSON_Specification *spec) 359clean_credential (void *cls, struct GNUNET_JSON_Specification *spec)
360{ 360{
361 struct GNUNET_RECLAIM_Attestation **attr; 361 struct GNUNET_RECLAIM_Credential **attr;
362 362
363 attr = (struct GNUNET_RECLAIM_Attestation **) spec->ptr; 363 attr = (struct GNUNET_RECLAIM_Credential **) spec->ptr;
364 if (NULL != *attr) 364 if (NULL != *attr)
365 { 365 {
366 GNUNET_free (*attr); 366 GNUNET_free (*attr);
@@ -370,23 +370,23 @@ clean_attest (void *cls, struct GNUNET_JSON_Specification *spec)
370 370
371 371
372/** 372/**
373 * JSON Specification for Reclaim attestation claims. 373 * JSON Specification for credential claims.
374 * 374 *
375 * @param ticket struct of GNUNET_RECLAIM_ATTESTATION_Claim to fill 375 * @param attr struct of GNUNET_RECLAIM_Credential to fill
376 * @return JSON Specification 376 * @return JSON Specification
377 */ 377 */
378struct GNUNET_JSON_Specification 378struct GNUNET_JSON_Specification
379GNUNET_RECLAIM_JSON_spec_claim_attest (struct 379GNUNET_RECLAIM_JSON_spec_credential (struct
380 GNUNET_RECLAIM_Attestation **attr) 380 GNUNET_RECLAIM_Credential **cred)
381{ 381{
382 struct GNUNET_JSON_Specification ret = { .parser = &parse_attest, 382 struct GNUNET_JSON_Specification ret = { .parser = &parse_credential,
383 .cleaner = &clean_attest, 383 .cleaner = &clean_credential,
384 .cls = NULL, 384 .cls = NULL,
385 .field = NULL, 385 .field = NULL,
386 .ptr = attr, 386 .ptr = cred,
387 .ptr_size = 0, 387 .ptr_size = 0,
388 .size_ptr = NULL }; 388 .size_ptr = NULL };
389 389
390 *attr = NULL; 390 *cred = NULL;
391 return ret; 391 return ret;
392} 392}