Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / u32.h / u32_scan.3.md

% limb manual
% u32_scan(3)
% limb 0.1.0
% 2023-07-24

# NAME

u32_scan, u32_scan0 - Read an u32 value from a decimal string

u32_xscan, u32_xscan0 - Read an u32 value from an hexadecimal string

u32_oscan, u32_oscan0 - Read an u32 value from an octal string

u32_bscan, u32_bscan0 - Read an u32 value from a binary string


# SYNOPSIS

    #include <limb/u32.h>

```pre hl
size_t u32_scan(u32 *<em>dst</em>, const char *<em>s</em>)
size_t u32_scan0(u32 *<em>dst</em>, const char *<em>s</em>)

size_t u32_xscan(u32 *<em>dst</em>, const char *<em>s</em>)
size_t u32_xscan0(u32 *<em>dst</em>, const char *<em>s</em>)

size_t u32_oscan(u32 *<em>dst</em>, const char *<em>s</em>)
size_t u32_oscan0(u32 *<em>dst</em>, const char *<em>s</em>)

size_t u32_bscan(u32 *<em>dst</em>, const char *<em>s</em>)
size_t u32_bscan0(u32 *<em>dst</em>, const char *<em>s</em>)
```

# DESCRIPTION

The `u32_scan`() function will place into `dst` the number read as a decimal
value from the string `s`, stopping as soon as a character isn't valid.

The `u32_scan0`() function is similar but expects the string to contain a valid
value and nothing else, stopping with a NUL-terminating byte.

The `u32_xscan`() and `u32_xscan0`() functions are similar, but expecting an
hexadecimal value in `s`.

The `u32_oscan`() and `u32_oscan0`() functions are similar, but expecting an
octal value in `s`.

The `u32_bscan`() and `u32_bscan0`() functions are similar, but expecting a
binary value in `s`.


# RETURN VALUE

The `u32_*scan` family of functions return the number of characters read from
`s` (starting at 0 when the first character is invalid).

The `u32_*scan0` family of functions return the number of characters read from
`s` or 0 on error.

# ERRORS

The `u32_*scan0` family of functions may fail and set `errno` if :

: *EINVAL*
:: Invalid character in `s`

: *ERANGE*
:: The value in `s` is too large