LibJWT 3.2.0
The C JSON Web Token Library +JWK +JWKS
Collaboration diagram for Setters:

Macros

#define jwt_set_SET_INT(__v, __n, __x)
 Setup a jwt_value_t to set an integer value.
 
#define jwt_set_SET_STR(__v, __n, __x)
 Setup a jwt_value_t to set a string value.
 
#define jwt_set_SET_BOOL(__v, __n, __x)
 Setup a jwt_value_t to set a boolean value.
 
#define jwt_set_SET_JSON(__v, __n, __x)
 Setup a jwt_value_t to set a JSON string.
 

Detailed Description

When setting a value, you must set the type, name, and the specific val for the type. If the value already exists, then the function will return JWT_VALUE_ERR_EXISTS and value.error will be set the same. If value.replace is non-zero, then any existing value will be overwritten.

Remarks
When setting a JSON value, you can set value.name = NULL, in which case the entire header will be set to the JSON string pointed to by value.json_val. If value.replace is not set, only values that do not already exist will be set. If replace is set, then existing values will also be updated. There is no indication of which values are or aren't updated in either case.
Note
The replace flag must be set after calling jwt_set_SET_*() macro, as the macros will reset it back to 0.
jwt_set_SET_STR(&jval, "iss", "foo.example.com");
ret = jwt_builder_header_set(jwt, &jval);
if (ret == JWT_VALUE_ERR_NONE)
printf("iss updated to: %s\n", jval.str_val);
jwt_value_error_t jwt_builder_header_set(jwt_builder_t *builder, jwt_value_t *value)
Set a header in a builder object.
jwt_value_error_t
Error values for header and claim requests.
Definition jwt.h:162
@ JWT_VALUE_ERR_NONE
Definition jwt.h:163
#define jwt_set_SET_STR(__v, __n, __x)
Setup a jwt_value_t to set a string value.
Definition jwt.h:787
Data type for get and set actions for JWT headers and claims.
Definition jwt.h:181
const char * str_val
Definition jwt.h:186

Macro Definition Documentation

◆ jwt_set_SET_BOOL

#define jwt_set_SET_BOOL ( __v,
__n,
__x )
Value:
({ \
(__v)->type=JWT_VALUE_BOOL;(__v)->replace=0; \
(__v)->name=(__n);(__v)->bool_val=(__x);(__v)->error=0;\
(__v);})
@ JWT_VALUE_BOOL
Definition jwt.h:154

Setup a jwt_value_t to set a boolean value.

Parameters
__vPointer to a jwt_value_t object
__nName of the value
__xValue to set
Returns
No return value

◆ jwt_set_SET_INT

#define jwt_set_SET_INT ( __v,
__n,
__x )
Value:
({ \
(__v)->type=JWT_VALUE_INT;(__v)->replace=0; \
(__v)->name=(__n);(__v)->int_val=(__x);(__v)->error=0;\
(__v);})
@ JWT_VALUE_INT
Definition jwt.h:152

Setup a jwt_value_t to set an integer value.

Parameters
__vPointer to a jwt_value_t object
__nName of the value
__xValue to set
Returns
No return value

◆ jwt_set_SET_JSON

#define jwt_set_SET_JSON ( __v,
__n,
__x )
Value:
({ \
(__v)->type=JWT_VALUE_JSON;(__v)->replace=0; \
(__v)->name=(__n);(__v)->json_val=(__x);(__v)->error=0; \
(__v);})
@ JWT_VALUE_JSON
Definition jwt.h:155

Setup a jwt_value_t to set a JSON string.

Parameters
__vPointer to a jwt_value_t object
__nName of the value
__xValue to set
Returns
No return value

◆ jwt_set_SET_STR

#define jwt_set_SET_STR ( __v,
__n,
__x )
Value:
({ \
(__v)->type=JWT_VALUE_STR;(__v)->replace=0; \
(__v)->name=(__n);(__v)->str_val=(__x);(__v)->error=0;\
(__v);})
@ JWT_VALUE_STR
Definition jwt.h:153

Setup a jwt_value_t to set a string value.

Parameters
__vPointer to a jwt_value_t object
__nName of the value
__xValue to set
Returns
No return value