author | Olivier Brunel
<jjk@jjacky.com> 2023-07-04 16:23:45 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-07-24 10:16:42 UTC |
parent | 658092a934d9cdc04f32cf25aa9a980f44e20ba4 |
src/doc/random.h.0.md | +28 | -0 |
src/doc/random.h/random_buf.3.md | +24 | -0 |
src/doc/random.h/random_name.3.md | +1 | -0 |
src/liblimb/include/limb/random.h | +9 | -0 |
src/liblimb/posixplz.h/mkfiletempat.c | +1 | -1 |
src/liblimb/shldata.h/shldata_initw.c | +1 | -1 |
diff --git a/src/doc/random.h.0.md b/src/doc/random.h.0.md new file mode 100644 index 0000000..934b49f --- /dev/null +++ b/src/doc/random.h.0.md @@ -0,0 +1,28 @@ +% limb manual +% random.h(0) + +# NAME + +random.h - getting pseudo-random data + + +# SYNOPSIS + + #include <limb/random.h> + + +# DESCRIPTION + +The header defines the helper functions to gather pseudo-random data. + +<inc skalibs.md> + +## Functions + +The following functions/macros are defined : + +: [random_buf](3) +:: Fill memory with pseudo-random data. + +: [random_name](3) +:: Fill memory with a pseudo-random file name. diff --git a/src/doc/random.h/random_buf.3.md b/src/doc/random.h/random_buf.3.md new file mode 100644 index 0000000..30fc211 --- /dev/null +++ b/src/doc/random.h/random_buf.3.md @@ -0,0 +1,24 @@ +% limb manual +% random_buf(3) + +# NAME + +random_buf, random_name + +# SYNOPSIS + + #include <limb/random.h> + +```pre hl +void random_buf(char *dst, size_t dlen) +void random_name(char *dst, size_t dlen) +``` + +# DESCRIPTION + +The `random_buf`() function will write `dlen` bytes of pseudo-random data into +the memory pointed by `dst`. + +The `random_name`() macro is similar to `random_buf`() except it will ensure all +written bytes are actually ASCII printable characters, thus forming a valid file +name (that won't contain any slashes (`/`) nor dots (`.`)). diff --git a/src/doc/random.h/random_name.3.md b/src/doc/random.h/random_name.3.md new file mode 120000 index 0000000..b3645f4 --- /dev/null +++ b/src/doc/random.h/random_name.3.md @@ -0,0 +1 @@ +random_buf.3.md \ No newline at end of file diff --git a/src/liblimb/include/limb/random.h b/src/liblimb/include/limb/random.h new file mode 100644 index 0000000..08d5589 --- /dev/null +++ b/src/liblimb/include/limb/random.h @@ -0,0 +1,9 @@ +/* This file is part of limb https://lila.oss/limb + * Copyright (C) 2023 Olivier Brunel jjk@jjacky.com */ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef LIMB_RANDOM_H +#define LIMB_RANDOM_H + +#include <skalibs/random.h> + +#endif /* LIMB_RANDOM_H */ diff --git a/src/liblimb/posixplz.h/mkfiletempat.c b/src/liblimb/posixplz.h/mkfiletempat.c index 679a933..b78f3f3 100644 --- a/src/liblimb/posixplz.h/mkfiletempat.c +++ b/src/liblimb/posixplz.h/mkfiletempat.c @@ -3,8 +3,8 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include <errno.h> #include <string.h> -#include <skalibs/random.h> #include <limb/posixplz.h> +#include <limb/random.h> int mkfiletempat(int bfd, char *name, createat_fn fn, mode_t mode, void *data) diff --git a/src/liblimb/shldata.h/shldata_initw.c b/src/liblimb/shldata.h/shldata_initw.c index 163e4e1..d833bb4 100644 --- a/src/liblimb/shldata.h/shldata_initw.c +++ b/src/liblimb/shldata.h/shldata_initw.c @@ -3,11 +3,11 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include <errno.h> #include <string.h> -#include <skalibs/random.h> #include <limb/bytestr.h> #include <limb/hasher.h> #include <limb/patrim.h> #include <limb/pbkdf2.h> +#include <limb/random.h> #include <limb/shldata.h> #include "shldata.h"