From: Stephan Bosch Date: Sat, 11 Nov 2023 03:19:10 +0000 (+0100) Subject: lib-oauth2: oauth2-jwt - Split off get_field_node() X-Git-Tag: 2.4.0~2371 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1345f4ddfdb49c71f308692bd6910f79ec35748a;p=thirdparty%2Fdovecot%2Fcore.git lib-oauth2: oauth2-jwt - Split off get_field_node() --- diff --git a/src/lib-oauth2/oauth2-jwt.c b/src/lib-oauth2/oauth2-jwt.c index b1bbda7745..67d9f3099b 100644 --- a/src/lib-oauth2/oauth2-jwt.c +++ b/src/lib-oauth2/oauth2-jwt.c @@ -21,9 +21,8 @@ #include -static const char * -get_field(const struct json_tree *tree, const char *key, - enum json_type *type_r) +static const struct json_tree_node * +get_field_node(const struct json_tree *tree, const char *key) { const struct json_tree_node *root = json_tree_root(tree); const struct json_tree_node *value_node = json_tree_find_key(root, key); @@ -31,6 +30,18 @@ get_field(const struct json_tree *tree, const char *key, if (value_node == NULL || value_node->value_type == JSON_TYPE_OBJECT || value_node->value_type == JSON_TYPE_ARRAY) return NULL; + + return value_node; +} + +static const char * +get_field(const struct json_tree *tree, const char *key, + enum json_type *type_r) +{ + const struct json_tree_node *value_node = get_field_node(tree, key); + + if (value_node == NULL) + return NULL; if (type_r != NULL) *type_r = value_node->value_type; return json_tree_get_value_str(value_node);