Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Alternative to POSIX 2008 open_memstream() and/or funopen()

Brian VandenbergAug 4 2015 — edited Aug 4 2015

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

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 1 2015
Added on Aug 4 2015
1 comment
820 views