Blame src/internal/perk_output_impl.h

7cd8bc
#include <perk/perk.h>
7cd8bc
2b7f36
static inline FILE * pe_output_prolog(
2b7f36
	const struct pe_common_ctx *	cctx,
2b7f36
	FILE *				fout,
2b7f36
	FILE **				ftmp)
7cd8bc
{
7cd8bc
	int fdout;
7cd8bc
7cd8bc
	*ftmp = (FILE *)0;
7cd8bc
7cd8bc
	if (fout)
7cd8bc
		return fout;
7cd8bc
	else if (!cctx)
7cd8bc
		return 0;
7cd8bc
	else if (cctx->fdout < 0)
7cd8bc
		return stdout;
7cd8bc
7cd8bc
	if ((fdout = dup(cctx->fdout)) < 0)
7cd8bc
		return 0;
7cd8bc
7cd8bc
	if ((*ftmp = fdopen(fdout,"a")))
7cd8bc
		return *ftmp;
7cd8bc
7cd8bc
	close(fdout);
7cd8bc
	return 0;
7cd8bc
}
7cd8bc
7cd8bc
static inline int pe_output_epilog(int ret, FILE * f)
7cd8bc
{
7cd8bc
	if (f)
7cd8bc
		fclose(f);
7cd8bc
	return ret;
7cd8bc
}