summaryrefslogtreecommitdiffhomepage
path: root/src/internal/perk_output_impl.h
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-11-25 10:06:38 -0500
committermidipix <writeonce@midipix.org>2016-11-10 23:35:27 -0500
commitbd5676e7016bede788b6b1ea174cce06c1a71cce (patch)
tree25e8f2d118fa43d4fa0d7c644920d0cbc69dbdb8 /src/internal/perk_output_impl.h
parent2a42e14f0eef84cfc98c629198f09c1d18f07f52 (diff)
downloadperk-bd5676e7016bede788b6b1ea174cce06c1a71cce.tar.bz2
perk-bd5676e7016bede788b6b1ea174cce06c1a71cce.tar.xz
internal header rename: perk_output.h --> perk_output_impl.h.
Diffstat (limited to 'src/internal/perk_output_impl.h')
-rw-r--r--src/internal/perk_output_impl.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/internal/perk_output_impl.h b/src/internal/perk_output_impl.h
new file mode 100644
index 0000000..d60d78d
--- /dev/null
+++ b/src/internal/perk_output_impl.h
@@ -0,0 +1,31 @@
+#include <perk/perk.h>
+
+static inline FILE * pe_output_prolog(const struct pe_common_ctx * cctx, FILE * fout, FILE ** ftmp)
+{
+ int fdout;
+
+ *ftmp = (FILE *)0;
+
+ if (fout)
+ return fout;
+ else if (!cctx)
+ return 0;
+ else if (cctx->fdout < 0)
+ return stdout;
+
+ if ((fdout = dup(cctx->fdout)) < 0)
+ return 0;
+
+ if ((*ftmp = fdopen(fdout,"a")))
+ return *ftmp;
+
+ close(fdout);
+ return 0;
+}
+
+static inline int pe_output_epilog(int ret, FILE * f)
+{
+ if (f)
+ fclose(f);
+ return ret;
+}