This depends on fopencookie, which is linux-specific. For BSD, there is a similar function called funopen, which can be used as a drop-in replacement.