23#include <gsl/gsl_rng.h>
29#if __has_include(<unistd.h>)
39 unsigned long int seed;
42 if ((devrandom = fopen(
"/dev/urandom",
"r")) == NULL) {
46 seed = tv.tv_sec + tv.tv_usec;
51 fread(&seed,
sizeof(seed), 1, devrandom);
62 struct dirent **namelist;
67 lang = getenv(
"LANG");
73 strcat(dir,
"/recipes");
78 printf(
"Directory does not exist: %s", dir);
82 for (ii = 0; ii < nn; ii++)
83 if (strncmp(lang, namelist[ii]->d_name, 2) == 0) {
85 strcat(dir, namelist[ii]->d_name);
93 for (ii = 0; ii < nn; ii++)
102 rng = gsl_rng_alloc(gsl_rng_default);
104 ii = gsl_rng_uniform_int(rng, nn - 2);
108 strcat(dir, namelist[ii + 2]->d_name);
111 for (ii = 0; ii < nn; ii++)
115 strcpy(filename, dir);
118 printf(
"Sorry, recipes cannot be printed unless scandir and alphasort are "
119 "available with your C compiler.\n");
int scandir(const char *__restrict __dir, struct dirent ***__restrict __namelist, int(*__selector)(const struct dirent *), int(*__cmp)(const struct dirent **, const struct dirent **)) __attribute__((__nonnull__(1
int gettimeofday(struct timeval *__restrict __tv, void *__restrict __tz) __attribute__((__nothrow__
unsigned long int random_seed()
int fclose(FILE *__stream)
void oct_print_recipe(char *dir_, char *filename)
int int alphasort(const struct dirent **__e1, const struct dirent **__e2) __attribute__((__nothrow__