From 3534b428629be185e096be99e3bd5fdfe32d5544 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 18 Sep 2014 18:55:44 +0000 Subject: initial commit with rc for skalibs-2.0.0.0 --- src/librandom/unirandomegd.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/librandom/unirandomegd.c (limited to 'src/librandom/unirandomegd.c') diff --git a/src/librandom/unirandomegd.c b/src/librandom/unirandomegd.c new file mode 100644 index 0000000..a340f06 --- /dev/null +++ b/src/librandom/unirandomegd.c @@ -0,0 +1,37 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include + +int unirandomegd_sinit (union unirandominfo *u, char const *path) +{ + register int s = randomegd_open(path) ; + if (s == -1) return 0 ; + if (coe(s) == -1) + { + register int e = errno ; + fd_close(s) ; + errno = e ; + return 0 ; + } + u->egd.fd = s ; + return 1 ; +} + +int unirandomegd_finish (union unirandominfo *u) +{ + return !fd_close(u->egd.fd) ; +} + +unsigned int unirandomegd_readb (union unirandominfo *u, char *s, unsigned int n) +{ + return randomegd_readb(u->egd.fd, s, n) ; +} + +unsigned int unirandomegd_readnb (union unirandominfo *u, char *s, unsigned int n) +{ + return randomegd_readnb(u->egd.fd, s, n) ; +} -- cgit v1.2.3