From 3b42f99f60194a4afea5bf04b9f1439ffde4d666 Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 21 Dec 2015 07:33:01 -0500 Subject: mdso_create_output(): initial implementation. --- src/output/mdso_create_output.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/output/mdso_create_output.c (limited to 'src') diff --git a/src/output/mdso_create_output.c b/src/output/mdso_create_output.c new file mode 100644 index 0000000..3ecde61 --- /dev/null +++ b/src/output/mdso_create_output.c @@ -0,0 +1,37 @@ +/****************************************************************/ +/* mdso: midipix dso scavenger */ +/* Copyright (C) 2015 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */ +/****************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include +#include "mdso_driver_impl.h" + +FILE * mdso_create_output( + const struct mdso_driver_ctx * dctx, + const char * asmname) +{ + struct mdso_driver_ctx_impl * ictx; + uintptr_t addr; + int fdout; + + if (!dctx->cctx->dstdir) + return stdout; + + addr = (uintptr_t)dctx - offsetof(struct mdso_driver_ctx_impl,ctx); + ictx = (struct mdso_driver_ctx_impl *)addr; + + if ((fdout = openat(ictx->fddst,asmname, + O_CREAT|O_TRUNC|O_WRONLY|O_NOCTTY|O_NOFOLLOW, + S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) + return 0; + + return fdopen(fdout,"w"); +} -- cgit v1.2.3