22#include <winpr/config-readers.h>
25#define TAG WINPR_TAG("utils.config-readers")
27BOOL winpr_config_apply_bool(
const char* config, WINPR_JSON* json,
const char* name, BOOL* dst)
37 WLog_WARN(TAG,
"[%s] Invalid setting %s: must be of type bool", config, name);
45BOOL winpr_config_apply_string(
const char* config, WINPR_JSON* json,
const char* name,
char** dst)
55 WLog_WARN(TAG,
"[%s] Invalid setting %s: must be of type string", config, name);
71BOOL winpr_config_apply_uint32(
const char* config, WINPR_JSON* json,
const char* name, UINT32* dst)
81 WLog_WARN(TAG,
"[%s] Invalid setting %s: must be of type bool", config, name);
88 const double fractional = modf(val, &integer);
89 if (signbit(val) || isnan(val) || isinf(val) || (val > UINT32_MAX) ||
90 (fabs(fractional) > DBL_EPSILON))
92 WLog_WARN(TAG,
"[%s] Invalid setting %s: value must be 0 <= %f <= %" PRIu32, config, name,
97 *dst = (UINT32)integer;
WINPR_ATTR_NODISCARD WINPR_API BOOL WINPR_JSON_IsBool(const WINPR_JSON *item)
Check if JSON item is of type BOOL.
WINPR_ATTR_NODISCARD WINPR_API BOOL WINPR_JSON_IsNumber(const WINPR_JSON *item)
Check if JSON item is of type Number.
WINPR_ATTR_NODISCARD WINPR_API BOOL WINPR_JSON_IsTrue(const WINPR_JSON *item)
Check if JSON item is BOOL value True.
WINPR_ATTR_NODISCARD WINPR_API WINPR_JSON * WINPR_JSON_GetObjectItemCaseSensitive(const WINPR_JSON *object, const char *string)
Same as WINPR_JSON_GetObjectItem but with case sensitive matching.
WINPR_ATTR_NODISCARD WINPR_API BOOL WINPR_JSON_IsString(const WINPR_JSON *item)
Check if JSON item is of type String.
WINPR_ATTR_NODISCARD WINPR_API double WINPR_JSON_GetNumberValue(const WINPR_JSON *item)
Return the Number value of a JSON item.
WINPR_ATTR_NODISCARD WINPR_API const char * WINPR_JSON_GetStringValue(WINPR_JSON *item)
Return the String value of a JSON item.