58 lines
1.1 KiB
C
58 lines
1.1 KiB
C
/*
|
|
* noisebox.h -- interfaces for noise provision.
|
|
*/
|
|
|
|
#include <fuse.h>
|
|
#include <stddef.h>
|
|
|
|
#include <pcg_variants.h>
|
|
|
|
#ifndef NOISEBOX_H
|
|
#define NOISEBOX_H
|
|
|
|
typedef struct {
|
|
char *name;
|
|
uint64_t size;
|
|
} NoiseFile;
|
|
|
|
typedef struct {
|
|
char* name;
|
|
void *state;
|
|
|
|
int noisefile_count;
|
|
NoiseFile **files;
|
|
|
|
int (*get_noise)(size_t, off_t, char*, struct fuse_file_info *);
|
|
|
|
// int (*do_readdir)(const char *path, void *buffer, fuse_fill_dir_t filler,
|
|
// off_t offset, struct fuse_file_info *fi);
|
|
int (*do_open)(const char *, struct fuse_file_info *);
|
|
int (*do_release)(const char *, struct fuse_file_info *);
|
|
} Noiser;
|
|
|
|
typedef union {
|
|
pcg32_random_t *pcg;
|
|
} rng_state_t;
|
|
|
|
// linked list of open file states
|
|
struct file_state {
|
|
char *name;
|
|
rng_state_t rng;
|
|
size_t consumed;
|
|
struct file_state *next;
|
|
// assume prng output is some integral number of chars.
|
|
int char_ratio;
|
|
};
|
|
|
|
struct nb_context {
|
|
Noiser **noisers;
|
|
struct file_state *state_head;
|
|
};
|
|
|
|
|
|
Noiser* zero_init(void);
|
|
Noiser* mersenne_init(void);
|
|
Noiser* pcg_init(void);
|
|
|
|
#endif
|