#include <xtend/fast-file.h>
-lxtend
ffstdin() is a simple wrapper function for connecting file descriptor 0
to an ffile_t object using ffdopen(3). This is useful for high-performance
filter programs, where using the traditional FILE *stdin 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 stdin
if ( strcmp(argv[arg], "-") == 0 )
stream = ffstdin();
else
stream = ffopen(argv[arg], O_RDONLY);