/* SPDX-License-Identifier: LGPL-2.1-only */ /* Copyright (C) 2020 Gediminas Jakutis */ #include #include #include #include #include #include #include "datagen.h" #include "defs.h" static struct entry_l buf; struct entry_l *gen_get_array(struct stream * const in) { struct entry_l *ret; int errn; if (read(in->fd, &buf.val, sizeof(buf.val)) == sizeof(buf.val)) { ret = &buf; } else { errn = errno; ret = NULL; rin_err("error reading /dev/urandom: %s", strerror(errn)); } return ret; } struct entry_l *gen_get_list(struct stream * const in) { struct entry_l *ret; try_s((ret = gen_get_array(in)), err); ret->next = 0; err: return ret; }