#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <unistd.h>
#include "defines.h"
extern u32 gr;
extern int random_fd;
extern u32 *rand_buf,*rand_current;
+extern char random_file[MAX_CHARS_RANDOM_FILE];
/* return random integer between 0 - max-1 */
u32 rand_get(u32 max)
printfd("debug: reading new random bytes\n");
if(read(random_fd,rand_buf,RAND_BUF_SIZE)!=RAND_BUF_SIZE)
{
- puts("failed reading 1 mega bytes of random data");
- return -23;
+ if(!strcmp(random_file,""))
+ {
+ puts("random file end, starting over ...");
+ lseek(random_fd,0,SEEK_SET);
+ } else
+ {
+ puts("failed reading 1 mega bytes of random data");
+ return -23;
+ }
}
+ printfd("debug: finished reading random bytes\n");
rand_current=rand_buf;
}
/* cells numbered 0...max-1 */