mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-20 13:22:07 +03:00
Add a sample program
This commit is contained in:
parent
16451c769c
commit
4d89cad020
2
ent.c
2
ent.c
@ -14,7 +14,7 @@ ent_getentropy(void* buf, size_t len)
|
||||
{
|
||||
int fd;
|
||||
ssize_t ret;
|
||||
char* cuf;
|
||||
char* cuf = buf;
|
||||
|
||||
assert(len <= 256);
|
||||
if (-1 == (fd = open("/dev/urandom", O_RDONLY))) {
|
||||
|
@ -23,3 +23,7 @@ pkg_mod.generate(libraries : libent,
|
||||
name : 'libent',
|
||||
filebase : 'ent',
|
||||
description : 'A library to get entropy.')
|
||||
|
||||
ent_sample = executable('sample',
|
||||
['sample.c'],
|
||||
dependencies : [ent_dep])
|
||||
|
22
sample.c
Normal file
22
sample.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ent/ent.h>
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
char buf[256];
|
||||
int i;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if (0 != ent_getentropy(buf, sizeof(buf))) {
|
||||
perror("getentropy");
|
||||
}
|
||||
for (i = 0; i < sizeof buf; ++i) {
|
||||
printf("%02hhx", buf[i]);
|
||||
}
|
||||
puts("");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user