qh_str_to_bool()

QNX SDP8.0QNX Helpers Developer's GuideAPIDeveloper

Safely converts a string into a boolean

Synopsis:

#include <qh/string.h>
int qh_str_to_bool(const char *str,
                   bool *out,
                   size_t *end_offset)

Arguments:

str
The string to convert into a bool.
out
Pointer to where the bool can be stored.
end_offset
The offset where parsing stopped.

Library:

qh

Description:

The string passed (str) is interpreted as either a string of a predetermined set (t or true for true, f or false for false) or as a number. It evaluates as false if the number passed is equal to zero, or true otherwise. If str matches one of the above specific cases, it evaluates to the respective value. The case of str passed does not matter and string literals are supported.

For more information on using this function, see the documentation for strtoull().

Returns:

EOK on success or a standard errno on failure (errno is also set, and out is unchanged).

ERANGE
The number value is larger than LLONG_MAX (and true is returned) or less than LLONG_MIN (and true is returned).
Page updated: