blob: 7eab23fd73c1a78f491c167d7cf7f8f715358f63 (
plain)
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
34
35
36
37
38
39
40
41
|
/* SPDX-License-Identifier: LGPL-2.1-only */
/* Copyright (C) 2020 Gediminas Jakutis */
#include <unistd.h>
#include <stddef.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#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;
}
|