#ifndef WH_STDIO_UTIL_H_f6ab685d_ #define WH_STDIO_UTIL_H_f6ab685d_ #include /* * fwrap_tee * * fwrap_tee(FILE *f1, [FILE *f2, [FILE *f3, ...]], (FLIE *)0) returns * a FILE *. Output sent to the returned stream is fanned out, sent * to all the streams passed in on creation. * * Nothing in particular is done when the wrapper stream is closed. * * If no streams are passed on creation - ie, if the first argument is * nil - then output is discarded. * * Errors when writing output to subsidiary streams are ignored. */ extern FILE *fwrap_tee(FILE *, ...); /* * fwrap_lno * * fwrap_lno(FILE *inner, unsigned long long int flno, unsigned int flags) * returns a FILE *. Output written to this FILE * has each line * prefixed with a line number, in decimal, and ": "; the resulting * lines are written to inner. The number prefixed to the first line * of output is flno. * * If flags has FWLF_CLOSE set, closing the wrapper stream closes the * inner stream as wlel; otherwise, nothing in particular happens when * the wrapper stream is closed. * * Errors when writing output to the inner stream are ignored. */ extern FILE *fwrap_lno(FILE *, unsigned long long int, unsigned int); #define FWLF_CLOSE 0x00000001 /* * fwrap_prefix * * fwrap_prefix(FILE *inner, const char *pfx, unsigned int flags) * returns a FILE *. Output written to this FILE * has each line * prefixed with pfx and is then sent to inner. * * The pfx string must remain valid for the life of the stream. * * If flags has FWPF_CLOSE set, closing the wrapper stream closes the * inner stream as well; otherwise, nothing in particular happens when * the wrapper stream is closed. * * Errors when writing output to the inner stream are ignored. */ extern FILE *fwrap_prefix(FILE *, const char *, unsigned int); #define FWPF_CLOSE 0x00000001 /* * fopen_alloc * * fopen_alloc(char **sp, int *lp) returns a FILE *. Writes to this * FILE * are accumulated. When the stream is closed, *sp is set to * point to the accumulated string and *lp is set to its length. One * NUL is always appended; it is not counted in the length. * * If either pointer is nil, that datum is not returned. */ extern FILE *fopen_alloc(char **, int *); #endif