diff options
Diffstat (limited to 'src/librandom/unidevurandom.c')
-rw-r--r-- | src/librandom/unidevurandom.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/librandom/unidevurandom.c b/src/librandom/unidevurandom.c new file mode 100644 index 0000000..d601ea0 --- /dev/null +++ b/src/librandom/unidevurandom.c @@ -0,0 +1,38 @@ +/* ISC license. */ + +#include <skalibs/sysdeps.h> +#include <skalibs/unirandomdev.h> +#include <skalibs/unirandom.h> + +#ifdef SKALIBS_HASDEVURANDOM + +#include "random-internal.h" + +int unidevurandom_init (union unirandominfo *u) +{ + return unirandomdev_sinit(u, "/dev/urandom") ; +} + +int unirandom_register_devurandom (unirandom *u) +{ + unirandom_register(u, &unidevurandom_init, &unirandomdev_finish, &unirandomdev_readb, &unirandomdev_readnb) ; + return 1 ; +} + +#else + +#include <errno.h> + +int unidevurandom_init (union unirandominfo *u) +{ + (void)u ; + return (errno = ENOSYS, 0) ; +} + +int unirandom_register_devurandom (unirandom *u) +{ + (void)u ; + return (errno = ENOSYS, 0) ; +} + +#endif |