udi_strtou32(3udi)


Convert string to unsigned 32-bit value

SYNOPSIS

#include <udi.h>

udi_ubit32_t udi_strtou32 (

	const char *s,

	char **endptr,

	int base );
 

ARGUMENTS s is a pointer to the null-terminated string to be converted.

endptr optionally points to a character pointer in which a pointer to the first unconverted character is stored.

base is the base radix for interpretation of the numeric string.

DESCRIPTION The udi_strtou32 function is similar to its ISO C strtoul counterpart in that it converts the string pointed to by s to an unsigned 32-bit integer value according to the given base radix which must be between 2 and 36 inclusive, or be the special value of 0.

The string must begin with an arbitrary amount of whitespace (zero or more space, tab, carriage-return, or line-feed characters in any order) followed by a single optional `+' or `-' sign.

If base is between 2 and 36, inclusive, it is used as the base for conversion. After an optional leading sign, leading zeros are ignored, and "0x" or "0X" is ignored if base is 16.

If base is zero, the string itself determines the base as follows: After an optional leading sign, one or more leading zeros indicates octal conversion, and a leading "0x" or "0X" indicates hexadecimal conversion. Otherwise, decimal conversion is used.

The remainder of the string is converted to an unsigned 32-bit integer value in the obvious manner, stopping at the first character that is not a valid digit in the given base. (In bases above 10, the letter `A' in either upper or lower case represents 10, `B' represents 11, and so forth, with `Z' representing 35.)

If endptr is not NULL, udi_strtoul stores a pointer to the first invalid character into *endptr. (Thus, if *s is not `\0' but **endptr is `\0' on return, the entire string was a valid numeric.)

RETURN VALUE The udi_strtoul function returns the result of the conversion as an unsigned 32-bit value. If the input string contained a leading minus sign (`-'), the result will be as the appropriate negative number cast to a udi_ubit32_t unsigned type.

If the numeric string would cause a 32-bit integer overflow then the resulting value is unspecified.


UDI Core Specification Contents