about summary refs log tree commit diff
path: root/lib/util/randsysrandom.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util/randsysrandom.c')
-rw-r--r--lib/util/randsysrandom.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/util/randsysrandom.c b/lib/util/randsysrandom.c
new file mode 100644
index 00000000..97a1376e
--- /dev/null
+++ b/lib/util/randsysrandom.c
@@ -0,0 +1,34 @@
+#include "netpbm/rand.h"
+
+static void
+vinit(struct pm_randSt * const randStP) {
+
+    randStP->max    = RAND_MAX;
+    randStP->stateP = NULL;
+}
+
+
+
+static void
+vsrand(struct pm_randSt * const randStP,
+       unsigned int       const seed) {
+
+    srandom(seed);
+}
+
+
+
+static unsigned long int
+vrand(struct pm_randSt * const randStP) {
+
+    return random();
+}
+
+
+struct pm_rand_vtable const pm_randsysrandom_vtable = {
+    &vinit,
+    &vsrand,
+    &vrand
+};
+
+