#include <xtend/fast-file.h>
-lxtend
ffstdout() is a simple wrapper function for connecting file descriptor 1
to an ffile_t object using ffdopen(3). This is useful for high-performance
filter programs, where using the traditional FILE *stdout would cause a
bottleneck.
The ffile_t system is simpler than and several times as fast as
FILE on typical systems. It is intended for processing large files
character-by-character, where low-level block I/O is not convenient, but
FILE I/O causes a bottleneck.
Pointer to an ffile_t object if successful, NULL otherwise
ffile_t *stream;
// "-" as a filename argument traditionally indicates stdout
if ( strcmp(argv[arg], "-") == 0 )
stream = ffstdout();
else
stream = ffopen(argv[arg], O_WRONLY|O_CREAT|O_TRUNC);