diff options
author | midipix <writeonce@midipix.org> | 2018-06-29 01:16:57 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-06-29 01:37:44 -0400 |
commit | a53a8bf83e839632f938e975ead77d3ef97d7416 (patch) | |
tree | d90fa78cb59479597c6c569f2c4b9115379c64b8 /src/internal | |
parent | 9706faf3b18a3fe231bff70e6d8acd62aaae99df (diff) | |
download | slibtool-a53a8bf83e839632f938e975ead77d3ef97d7416.tar.bz2 slibtool-a53a8bf83e839632f938e975ead77d3ef97d7416.tar.xz |
internals: re-implemented slbt_create_default_library_wrapper() w. pure fdio.
Diffstat (limited to 'src/internal')
-rw-r--r-- | src/internal/slibtool_libmeta_impl.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/internal/slibtool_libmeta_impl.c b/src/internal/slibtool_libmeta_impl.c index c8dd291..bc4fca2 100644 --- a/src/internal/slibtool_libmeta_impl.c +++ b/src/internal/slibtool_libmeta_impl.c @@ -4,10 +4,12 @@ /* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ /*******************************************************************/ +#include <fcntl.h> #include <stdio.h> #include <string.h> #include <stdbool.h> #include <slibtool/slibtool.h> +#include "slibtool_dprintf_impl.h" #include "slibtool_errinfo_impl.h" #include "slibtool_metafile_impl.h" @@ -20,7 +22,7 @@ static int slbt_create_default_library_wrapper( char * solnk) { int ret; - FILE * fout; + int fdout; const char * header; const char * base; bool fnover; @@ -33,7 +35,11 @@ static int slbt_create_default_library_wrapper( (void)ectx; /* create */ - if (!(fout = fopen(dctx->cctx->output,"w"))) + if ((fdout = openat( + AT_FDCWD, + dctx->cctx->output, + O_RDWR|O_CREAT|O_TRUNC, + 0644)) < 0) return SLBT_SYSTEM_ERROR(dctx); /* version info */ @@ -54,7 +60,7 @@ static int slbt_create_default_library_wrapper( base = ""; /* wrapper content */ - ret = fprintf(fout, + ret = slbt_dprintf(fdout, "# %s%s" "# Generated by %s (slibtool %d.%d.%d)\n" "# [commit reference: %s]\n\n" @@ -115,9 +121,9 @@ static int slbt_create_default_library_wrapper( /* libdir */ dctx->cctx->rpath ? dctx->cctx->rpath : ""); - return (ret <= 0) || fclose(fout) - ? SLBT_SYSTEM_ERROR(dctx) - : 0; + close(fdout); + + return (ret < 0) ? SLBT_SYSTEM_ERROR(dctx) : 0; } static int slbt_create_compatible_library_wrapper( |