1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
// stripped down from tests/dnet/rand.c
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dumbnet.h>
int
main(int argc, char *argv[])
{
rand_t *r;
int len;
u_char *p;
if ((len = atoi(argv[1])) == 0)
err(1, "length");
if ((p = malloc(len)) == NULL)
err(1, "malloc");
if ((r = rand_open()) == NULL)
err(1, "rand_init");
if (rand_get(r, p, len) < 0)
err(1, "rand_get");
if (write(STDOUT_FILENO, p, len) != len)
err(1, "write");
return (0);
}
|