diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-12-08 15:10:09 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-12-08 15:10:09 +0000 |
commit | 30d0c173d87b92a9ad2f3c1b643463a894abb1d9 (patch) | |
tree | 544c0917404a5ee3bf1c5f4faceeb51cff084b8d /src/librandom | |
parent | 2f017fbdd689e025437783cc8d675a7d304b37c3 (diff) | |
download | skalibs-30d0c173d87b92a9ad2f3c1b643463a894abb1d9.tar.gz skalibs-30d0c173d87b92a9ad2f3c1b643463a894abb1d9.tar.xz skalibs-30d0c173d87b92a9ad2f3c1b643463a894abb1d9.zip |
Really add mkfootemp and autosurf, I guess ?
Diffstat (limited to 'src/librandom')
-rw-r--r-- | src/librandom/autosurf.c | 18 | ||||
-rw-r--r-- | src/librandom/autosurf_name.c | 10 | ||||
-rw-r--r-- | src/librandom/random_oklist.c | 6 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/librandom/autosurf.c b/src/librandom/autosurf.c new file mode 100644 index 0000000..8775bef --- /dev/null +++ b/src/librandom/autosurf.c @@ -0,0 +1,18 @@ +/* ISC license. */ + +#include <skalibs/random.h> +#include <skalibs/surf.h> + +void autosurf (char *s, size_t n) +{ + static SURFSchedule ctx = SURFSCHEDULE_ZERO ; + static int need4seed = 1 ; + if (need4seed) + { + char tmp[160] ; + random_makeseed(tmp) ; + surf_init(&ctx, tmp) ; + need4seed = 0 ; + } + return surf(&ctx, s, n) ; +} diff --git a/src/librandom/autosurf_name.c b/src/librandom/autosurf_name.c new file mode 100644 index 0000000..d80e1f8 --- /dev/null +++ b/src/librandom/autosurf_name.c @@ -0,0 +1,10 @@ +/* ISC license. */ + +#include <skalibs/surf.h> +#include "random-internal.h" + +void autosurf_name (char *s, size_t n) +{ + autosurf(s, n) ; + while (n--) s[n] = random_oklist[s[n] & 63] ; +} diff --git a/src/librandom/random_oklist.c b/src/librandom/random_oklist.c new file mode 100644 index 0000000..d79f745 --- /dev/null +++ b/src/librandom/random_oklist.c @@ -0,0 +1,6 @@ +/* ISC license. */ + +#include "random-internal.h" + +static char const random_oklist_[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz-_0123456789abcdef" ; +char const *random_oklist = random_oklist_ ; |