From: Alan T. DeKok Date: Tue, 16 Nov 2021 00:44:39 +0000 (-0500) Subject: add more data types to "cast to bool" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09adee3bfaff25b6a97ee942ce1228c0af02fc69;p=thirdparty%2Ffreeradius-server.git add more data types to "cast to bool" --- diff --git a/src/lib/util/value.c b/src/lib/util/value.c index b1ddf7dabf..594f1f66ac 100644 --- a/src/lib/util/value.c +++ b/src/lib/util/value.c @@ -54,6 +54,8 @@ RCSID("$Id$") #include #include +#include + /** Sanity checks * * There should never be an instance where these fail. @@ -2676,6 +2678,9 @@ static inline int fr_value_box_cast_to_bool(TALLOC_CTX *ctx, fr_value_box_t *dst NULL, src->tainted); case FR_TYPE_OCTETS: + /* + * This is really "bool from network" + */ return fr_value_box_fixed_size_from_octets(dst, dst_type, dst_enumv, src); default: @@ -2720,6 +2725,22 @@ static inline int fr_value_box_cast_to_bool(TALLOC_CTX *ctx, fr_value_box_t *dst dst->vb_bool = (src->vb_uint64 != 0); break; + case FR_TYPE_SIZE: + dst->vb_bool = (src->vb_size != 0); + break; + + case FR_TYPE_TIME_DELTA: + dst->vb_bool = (fr_time_delta_unwrap(src->vb_time_delta) != 0); + break; + + case FR_TYPE_FLOAT32: + dst->vb_bool = (fpclassify(src->vb_float32) == FP_ZERO); + break; + + case FR_TYPE_FLOAT64: + dst->vb_bool = (fpclassify(src->vb_float64) == FP_ZERO); + break; + default: fr_strerror_printf("Invalid cast from %s to %s. Unsupported", fr_table_str_by_value(fr_value_box_type_table, src->type, ""),