diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-07-10 10:06:06 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-07-29 12:18:45 +0200 |
commit | 6588fb13b6db1b8bb1e970b0e9cdfa1545d09314 (patch) | |
tree | 0c4e3048070e1e6e5e5625039756254fa8594d46 /src/kyclogic | |
parent | b45be8fd69052a93dbe92a6e6de8e537d8c82e8b (diff) |
-bump gana
Diffstat (limited to 'src/kyclogic')
-rw-r--r-- | src/kyclogic/kyclogic_api.c | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c index c984388df..724c64b0e 100644 --- a/src/kyclogic/kyclogic_api.c +++ b/src/kyclogic/kyclogic_api.c @@ -2334,8 +2334,67 @@ TALER_KYCLOGIC_select_measure ( const char **prog_name, const json_t **context) { - // parse jmeasures - // check measure_index is valid (in bounds and of right type) + const json_t *jmeasure; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_array_const ("measures", + &jmeasures), + GNUNET_JSON_spec_end () + }; + struct GNUNET_JSON_Specification ispec[] = { + GNUNET_JSON_spec_string ("check_name", + check_name), + GNUNET_JSON_spec_string ("prog_name", + prog_name), + GNUNET_JSON_spec_object_const ("context", + context), + GNUNET_JSON_spec_end () + }; + + *check_name = NULL; + *prog_name = NULL; + *context = NULL; + if (GNUNET_OK != + GNUNET_JSON_parse (jmeasures, + spec, + NULL, NULL)) + { + GNUNET_break (0); + return TALER_EC_EXCHANGE_KYC_MEASURES_MALFORMED; + } + if (measure_index >= json_array_size (jmeasures)) + { + GNUNET_break_op (0); + return TALER_EC_EXCHANGE_KYC_MEASURES_INDEX_INVALID; + } + jmeasure = json_array_get (jmeasures, + measure_index); + if (GNUNET_OK != + GNUNET_JSON_parse (jmeasure, + ispec, + NULL, NULL)) + { + GNUNET_break (0); + return TALER_EC_EXCHANGE_KYC_MEASURES_MALFORMED; + } + return TALER_EC_NONE; +} + + +const struct TALER_KYCLOGIC_KycProvider * +TALER_KYCLOGIC_check_to_provider (const char *check_name) +{ + struct TALER_KYCLOGIC_KycCheck *kc; + + kc = find_check (check_name); + switch (kc->type) + { + case TALER_KYCLOGIC_CT_FORM: + case TALER_KYCLOGIC_CT_INFO: + return TALER_EC_EXCHANGE_KYC_INVALID_LOGIC_TO_CHECK; + case TALER_KYCLOGIC_CT_LINK: + break; + } + return kc->details.link.provider; } |