summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-02 18:09:21 +0000
committermidipix <writeonce@midipix.org>2018-08-03 21:13:30 -0400
commit3d38ce6b746e9d6f4e0b7dc251d88dba78fb0a47 (patch)
treecb1070f5b5afae8755dda27ecb8f379203e6adbd /src
parent512db453eaf1b98c5b6c3dbbaf96f9f41be86166 (diff)
downloadmdso-3d38ce6b746e9d6f4e0b7dc251d88dba78fb0a47.tar.bz2
mdso-3d38ce6b746e9d6f4e0b7dc251d88dba78fb0a47.tar.xz
internals: mdso_create_output(): prepare for removal of stream objects.
Diffstat (limited to 'src')
-rw-r--r--src/helper/mdso_create_output.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/helper/mdso_create_output.c b/src/helper/mdso_create_output.c
index 484e59b..f94524b 100644
--- a/src/helper/mdso_create_output.c
+++ b/src/helper/mdso_create_output.c
@@ -15,22 +15,32 @@
#include "mdso_driver_impl.h"
#include "mdso_errinfo_impl.h"
-static FILE * mdso_create_output(
+static int mdso_create_output(
const struct mdso_driver_ctx * dctx,
const char * name)
{
- int fddst;
- int fdout;
- FILE * fout;
+ int fddst;
+ int fdout;
fddst = mdso_driver_fddst(dctx);
if ((fdout = openat(fddst,name,
O_CREAT|O_TRUNC|O_WRONLY|O_NOCTTY|O_NOFOLLOW,
- S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) {
- MDSO_SYSTEM_ERROR(dctx);
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
+ return MDSO_SYSTEM_ERROR(dctx);
+
+ return fdout;
+}
+
+static FILE * mdso_create_output_stream(
+ const struct mdso_driver_ctx * dctx,
+ const char * name)
+{
+ int fdout;
+ FILE * fout;
+
+ if ((fdout = mdso_create_output(dctx,name)) < 0)
return 0;
- }
if (!(fout = fdopen(fdout,"w"))) {
close(fdout);
@@ -45,7 +55,7 @@ FILE * mdso_create_archive(
const struct mdso_driver_ctx * dctx,
const char * arname)
{
- return mdso_create_output(dctx,arname);
+ return mdso_create_output_stream(dctx,arname);
}
FILE * mdso_create_asmsrc(
@@ -53,7 +63,7 @@ FILE * mdso_create_asmsrc(
const char * asmname)
{
return dctx->cctx->dstdir
- ? mdso_create_output(dctx,asmname)
+ ? mdso_create_output_stream(dctx,asmname)
: stdout;
}
@@ -61,5 +71,5 @@ FILE * mdso_create_object(
const struct mdso_driver_ctx * dctx,
const char * objname)
{
- return mdso_create_output(dctx,objname);
+ return mdso_create_output_stream(dctx,objname);
}