diff options
Diffstat (limited to 'src/extensions/extensions.c')
-rw-r--r-- | src/extensions/extensions.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/extensions/extensions.c b/src/extensions/extensions.c index 02137d31..64574fc2 100644 --- a/src/extensions/extensions.c +++ b/src/extensions/extensions.c @@ -353,4 +353,53 @@ TALER_extensions_load_manifests ( } +enum GNUNET_GenericReturnValue +TALER_extensions_from_policy_details ( + const json_t *policy_details, + const struct TALER_Extension **extension, + char **error_hint) +{ + const json_t *jtype; + const char *type; + + *extension = NULL; + *error_hint = NULL; + + if ((NULL == policy_details) || + (! json_is_object (policy_details))) + { + *error_hint = "invalid policy object"; + return GNUNET_SYSERR; + } + + jtype = json_object_get (policy_details, "type"); + if (NULL == jtype) + { + *error_hint = "no type in policy object"; + return GNUNET_SYSERR; + } + + type = json_string_value (jtype); + if (NULL == type) + { + *error_hint = "invalid type in policy object"; + return GNUNET_SYSERR; + } + + *extension = TALER_extensions_get_by_name (type); + if ((NULL == *extension) || + (NULL == (*extension)->parse_policy_details)) + { + GNUNET_break (0); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Unsupported extension policy '%s' requested\n", + type); + *extension = NULL; + return GNUNET_NO; + } + + return GNUNET_OK; +} + + /* end of extensions.c */ |