summaryrefslogtreecommitdiff
path: root/src/librandom
diff options
context:
space:
mode:
Diffstat (limited to 'src/librandom')
-rw-r--r--src/librandom/autosurf.c18
-rw-r--r--src/librandom/autosurf_name.c10
-rw-r--r--src/librandom/random_oklist.c6
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_ ;