slstatus

My fork of https://tools.suckless.org/slstatus/
git clone https://git.inz.fi/slstatus
Log | Files | Refs | README | LICENSE

entropy.c (494B)


      1 /* See LICENSE file for copyright and license details. */
      2 #if defined(__linux__)
      3 	#include <stdint.h>
      4 	#include <stdio.h>
      5 
      6 	#include "../util.h"
      7 
      8 	const char *
      9 	entropy(void)
     10 	{
     11 		uintmax_t num;
     12 
     13 		if (pscanf("/proc/sys/kernel/random/entropy_avail", "%ju", &num)
     14 		    != 1) {
     15 			return NULL;
     16 		}
     17 
     18 		return bprintf("%ju", num);
     19 	}
     20 #elif defined(__OpenBSD__) | defined(__FreeBSD__)
     21 	const char *
     22 	entropy(void)
     23 	{
     24 		/* Unicode Character 'INFINITY' (U+221E) */
     25 		return "\xe2\x88\x9e";
     26 	}
     27 #endif