Example of how read a soundfont from memory (advanced users only)
#include <stdio.h>
#include <string.h>
#include <fluidsynth.h>
void *my_open(const char *filename)
{
void *p;
if(filename[0] != '&')
{
return NULL;
}
sscanf(filename, "&%p", &p);
return p;
}
int my_read(void *buf, int count, void *handle)
{
}
int my_seek(void *handle, long offset, int origin)
{
}
int my_close(void *handle)
{
}
long my_tell(void *handle)
{
return 0;
}
int main()
{
int err = 0;
my_open,
my_read,
my_seek,
my_tell,
my_close);
char abused_filename[64];
const void *pointer_to_sf2_in_mem = 0x1234Beef;
sprintf(abused_filename, "&%p", pointer_to_sf2_in_mem);
{
puts("oops");
err = -1;
goto cleanup;
}
cleanup:
return err;
}