Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / base32.h / base32_fmt.3.md

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

# NAME

base32_fmt, base32_scan - base32 encode/decode a byte array

# SYNOPSIS

    #include <limb/base32.h>

```pre hl
size_t base32_fmt(char *<em>dst</em>, const void *<em>data</em>, size_t <em>dlen</em>, int <em>strict</em>)
ssize_t base32_scan(char *<em>dst</em>, const char *<em>data</em>, size_t <em>dlen</em>, int <em>strict</em>)
```

# DESCRIPTION

The `base32_fmt`() function will encode the byte array pointed to by `data` of
length `dlen` bytes into the byte array pointed to by `dst` using the base32
algorithm as described in [RFC 4648][rfc4648], unless `strict` is zero in which
case when padding is needed, only one padding character is used.

Refer to [base_fmt](3) for more details.

The `base32_scan`() function will decode the byte array pointed to by `data` of
length `dlen` into the byte array pointed to be `dst` using the base32 algorithm
as described in [RFC 4648][rfc4648], unless `strict` is zero if which case it
accepts a single padding character to indicate padding.

Refer to [base_scan](3) for more details.

[rfc4648]: https://datatracker.ietf.org/doc/html/rfc4648

# RETURN VALUE

The `base32_fmt`() function return the length written into `dst` - or that
would have been when `dst` is *NULL*.

The `base32_scan`() function return the length written into `dst` - or that
would have been when `dst` is *NULL* - on success. Otherwise it returns -1 and
sets `errno` to indicate the error.

# ERRORS

The `base32_scan`() function may fail for any of the errors described for
[base_scan](3) except *ERANGE*.

# SEE ALSO

[base64_fmt](3)