23#include <gsl/gsl_rng.h>
29#if __has_include(<unistd.h>)
40unsigned long int random_seed() {
41 unsigned long int seed;
44 if ((devrandom = fopen(
"/dev/urandom",
"r")) == NULL) {
48 seed = tv.tv_sec + tv.tv_usec;
53 fread(&seed,
sizeof(seed), 1, devrandom);
60void FC_FUNC_(oct_printrecipe, OCT_PRINTRECIPE)(STR_F_TYPE _dir,
61 STR_F_TYPE filename STR_ARG2) {
64 char *lang, *tmp, dir[512];
65 struct dirent **namelist;
70 lang = getenv(
"LANG");
79 strcat(dir,
"/recipes");
84 printf(
"Directory does not exist: %s", dir);
88 for (ii = 0; ii < nn; ii++)
89 if (strncmp(lang, namelist[ii]->d_name, 2) == 0) {
91 strcat(dir, namelist[ii]->d_name);
99 for (ii = 0; ii < nn; ii++)
108 rng = gsl_rng_alloc(gsl_rng_default);
109 gsl_rng_set(rng, random_seed());
110 ii = gsl_rng_uniform_int(rng, nn - 2);
114 strcat(dir, namelist[ii + 2]->d_name);
117 for (ii = 0; ii < nn; ii++)
121 TO_F_STR2(dir, filename);
124 printf(
"Sorry, recipes cannot be printed unless scandir and alphasort are "
125 "available with your C compiler.\n");
int fclose(FILE *__stream)
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__
int int alphasort(const struct dirent **__e1, const struct dirent **__e2) __attribute__((__nothrow__