summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/skalibs/functypes.h6
-rw-r--r--src/include/skalibs/random.h28
2 files changed, 24 insertions, 10 deletions
diff --git a/src/include/skalibs/functypes.h b/src/include/skalibs/functypes.h
index f839877..0c94532 100644
--- a/src/include/skalibs/functypes.h
+++ b/src/include/skalibs/functypes.h
@@ -58,4 +58,10 @@ typedef create_func *create_func_ref ;
typedef int link_func (char const *, char const *) ;
typedef link_func *link_func_ref ;
+typedef void randomgen_func (char *, size_t) ;
+typedef randomgen_func *randomgen_func_ref ;
+
+typedef uint32_t uint32_func (uint32_t) ;
+typedef uint32_func *uint32_func_ref ;
+
#endif
diff --git a/src/include/skalibs/random.h b/src/include/skalibs/random.h
index 6c9dee0..0391d21 100644
--- a/src/include/skalibs/random.h
+++ b/src/include/skalibs/random.h
@@ -3,21 +3,29 @@
#ifndef SKALIBS_RANDOM_H
#define SKALIBS_RANDOM_H
-#include <sys/types.h>
+#include <stddef.h>
#include <stdint.h>
+#include <skalibs/functypes.h>
#include <skalibs/stralloc.h>
-extern void random_makeseed (char *) ; /* fills 160 bytes */
+extern void random_buf (char *, size_t) ;
+extern void random_buf_early (char *, size_t) ;
-extern int random_init (void) ;
-extern void random_finish (void) ;
+extern uint32_t random_uint32_from (uint32_t, randomgen_func_ref) ;
+#define random_uint32(n) random_uint32_from((n), &random_buf)
+#define random_uint32_early(n) random_uint32_from((n), &random_buf_early)
-extern unsigned char random_char (void) ;
-extern void random_string (char *, size_t) ;
-extern uint32_t random_uint32 (uint32_t) ;
-extern void random_name (char *, size_t) ;
-extern void random_unsort (char *, size_t, size_t) ;
-extern int random_sauniquename (stralloc *, size_t) ;
+extern void random_name_from (char *, size_t, randomgen_func_ref) ;
+#define random_name(s, n) random_name_from(s, (n), &random_buf)
+#define random_name_early(s, n) random_name_from(s, (n), &random_buf_early)
+
+extern void random_unsort_from (char *, size_t, size_t, randomgen_func_ref) ;
+#define random_unsort(s, n, c) random_unsort_from(s, n, (c), &random_buf)
+#define random_unsort_early(s, n, c) random_unsort_from(s, n, (c), &random_buf_early)
+
+extern int random_sauniquename_from (stralloc *, size_t, randomgen_func_ref) ;
+#define random_sauniquename(sa, n) random_sauniquename_from(sa, (n), &random_buf)
+#define random_sauniquename_early(sa, n) random_sauniquename_from(sa, (n), &random_buf_early)
#endif