#ifndef _STDIO_UTIL_H_ef3170d3_ #define _STDIO_UTIL_H_ef3170d3_ /* This file is in the public domain. */ #include /* * Stdio-related utilities. */ /* * fopen_alloc() returns a stream which can be written to. Stuff * written is remembered; when the stream is closed, the accumulated * string and its length are written through the pointers passed to * fopen_alloc(). Either pointer may be nil, in which case that * information is not returned; if the string pointer is not wanted, * the bytes are not actually remembered, since they aren't needed. * (Actually, the pointers may both be nil, but that is not a very * useful case.) * * No automatic trailing \0 is provided; if you want a trailing \0, you * must write one to the stream. */ extern FILE *fopen_alloc(char **, int *); /* * Open a block of data for read. The return FILE * is a read-only * stream open on the data (which is passed as pointer-and-length; * 0x00 octets in it have no particular significance). */ extern FILE *fopen_rstr(const char *, int); /* * Returns a data-sink stream. This is a write-only stream which * accept anything and throws it away - a stdio analog of /dev/null. */ extern FILE *fopen_null(void); /* * Prints the argument string, but with tolower(3) applied to each * character before printing it. The string is a canonical C * \0-terminated string. */ extern void print_lower(FILE *, const char *); /* * Returns the next input character from the argument stream, but * ungetc()s it so that it is effectively not read. (If EOF is read, * no attempt is made to ungetc() it.) */ extern int peekc(FILE *); #endif