mirror of
https://github.com/jlowellwofford/entropy.git
synced 2025-04-04 20:50:17 -05:00
34 lines
1.1 KiB
C
34 lines
1.1 KiB
C
// This simple program writes constants.go
|
|
// It uses the Linux headers to generate these contatns.
|
|
|
|
#include <fcntl.h>
|
|
#include <linux/random.h>
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
|
|
const char * filename = "constants_linux.go";
|
|
|
|
int main() {
|
|
int fd;
|
|
printf("Generating constants for entropy IOCTLs.\n");
|
|
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0644);
|
|
if( fd == -1 ) {
|
|
printf("Failed to open output file: %s\n", filename);
|
|
return -1;
|
|
}
|
|
dprintf(fd, "// generated by gen_constants.c\n\n");
|
|
dprintf(fd, "package entropy\n\n");
|
|
dprintf(fd, "const (\n");
|
|
dprintf(fd, "\tRNDGETENTCNT = %#x\n", RNDGETENTCNT);
|
|
dprintf(fd, "\tRNDADDTOENTCNT = %#x\n", RNDADDTOENTCNT);
|
|
dprintf(fd, "\tRNDGETPOOL = %#x\n", RNDGETPOOL);
|
|
dprintf(fd, "\tRNDADDENTROPY = %#x\n", RNDADDENTROPY);
|
|
dprintf(fd, "\tRNDZAPENTCNT = %#x\n", RNDZAPENTCNT);
|
|
dprintf(fd, "\tRNDCLEARPOOL = %#x\n", RNDCLEARPOOL);
|
|
dprintf(fd, "\tRNDRESEEDCRNG = %#x\n", RNDRESEEDCRNG);
|
|
dprintf(fd, ")\n\n");
|
|
close(fd);
|
|
return 0;
|
|
} |