Welcome to little lamb

Code » limb » master » tree

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

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

# NAME

u32_pack, u32_unpack, u32_pack_big, u32_unpack_big - store/read an u32 into/from
a byte array

# SYNOPSIS

    #include <limb/u32.h>

```pre hl
void u32_pack(void *<em>dst</em>, u32 <em>val</em>)
void u32_unpack(u32 *<em>val</em>, const void *<em>sce</em>)

void u32_pack_big(void *<em>dst</em>, u32 <em>val</em>)
void u32_unpack_big(u32 *<em>val</em>, const void *<em>sce</em>)
```

# DESCRIPTION

All of these aim to either store the given number `val` into the specified
byte array `dst`, or read a number from the specified byte array `sce` and set
the value pointed by `val` to its value.

The `u32_pack`() function stores the number `val` into the 4 bytes pointed by
`dst`, encoded as little endian.

The `u32_unpack`() function reads 4 bytes pointed by `sce` as little endian
encoded number, setting the value pointed by `val` to its value.

The `u32_pack_big`() function is similar to `u32_pack`() only as big endian.

The `u32_unpack_big`() function is similar to `u32_unpack`() only as big endian.