jwt_helpers_set_grp(3)

NAME
jwt_helpers_set_grp - Setters

SYNOPSIS

  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_value_error_t ret;
jwt_value_t jval;

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);

Macro Definition Documentation

  #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);})

Setup a jwt_value_t to set a boolean value.

Parameters
    __v Pointer to a jwt_value_t object
    __n Name of the value
    __x Value to set

Returns
    No return value

  #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);})

Setup a jwt_value_t to set an integer value.

Parameters
    __v Pointer to a jwt_value_t object
    __n Name of the value
    __x Value to set

Returns
    No return value

  #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);})

Setup a jwt_value_t to set a JSON string.

Parameters
    __v Pointer to a jwt_value_t object
    __n Name of the value
    __x Value to set

Returns
    No return value

  #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);})

Setup a jwt_value_t to set a string value.

Parameters
    __v Pointer to a jwt_value_t object
    __n Name of the value
    __x Value to set

Returns
    No return value

Author

Generated automatically by Doxygen for LibJWT from the source code.