I'm attempting to port libvde to solaris 10, but they're making use of a libc routine FILE* open_memstream(char **ptr, size_t *sizeloc) (used for dynamic string building ala std::stringstream) that can be summarized as:
- Delayed return through the parameters passed in
- Returns a FILE* that can be used for writing with stream oriented routines (fprintf, etc)
- Each write to the stream ptr potentially causes changes to the parameters originally passed in
- When the stream is closed the memory pointed at by the char* passed earlier is owned by the caller and must be free()d
This routine can be implemented in terms of a BSD specific routine, FILE* funopen( /*...*/ ), that takes callbacks for operations like read/write, etc.
Does solaris 10 have anything I can use to write an alternate implementation of open_memstream? The only idea I've come up with so far is to create file with something like tmpfile() or mkstemp(), mmap() it, and if needed/possible: associate the file descriptor with a real-time signal to do the necessary hand-holding. However, this seems like a dirty hack, so I hope someone has a better suggestion.
-Brian