Blame src/internal/perk_output.h

7cd8bc
#include <perk/perk.h>
7cd8bc
7cd8bc
static inline FILE * pe_output_prolog(const struct pe_common_ctx * cctx, FILE * fout, 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
}