about summary refs log tree commit diff
path: root/lib/util/randsysrand.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util/randsysrand.c')
-rw-r--r--lib/util/randsysrand.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/util/randsysrand.c b/lib/util/randsysrand.c
new file mode 100644
index 00000000..f97a5d3c
--- /dev/null
+++ b/lib/util/randsysrand.c
@@ -0,0 +1,39 @@
+#include <stdlib.h>
+
+#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) {
+
+    srand(seed);
+}
+
+
+
+static unsigned long int
+vrand(struct pm_randSt * const randStP) {
+
+    return rand();
+}
+
+
+
+struct pm_rand_vtable const pm_randsysrand_vtable = {
+    &vinit,
+    &vsrand,
+    &vrand
+};
+
+