1
0
Fork 0
slstatus/components/entropy.c
NRK 28ef0b242c components/*.c: include slstatus.h
this gives the compiler a chance to check weather the prototype and
definiton matches or not, which would catch issues like 3c47701.
2022-10-26 23:32:07 +02:00

29 lines
519 B
C

/* See LICENSE file for copyright and license details. */
#include "../slstatus.h"
#if defined(__linux__)
#include <stdint.h>
#include <stdio.h>
#include "../util.h"
const char *
entropy(void)
{
uintmax_t num;
if (pscanf("/proc/sys/kernel/random/entropy_avail", "%ju", &num)
!= 1) {
return NULL;
}
return bprintf("%ju", num);
}
#elif defined(__OpenBSD__) | defined(__FreeBSD__)
const char *
entropy(void)
{
/* Unicode Character 'INFINITY' (U+221E) */
return "\xe2\x88\x9e";
}
#endif