From 551500bc329826026634c6ecefa9fcc9074281fd Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 30 Jul 2018 12:04:46 +0000 Subject: mdso_output_export_symbols(): revised API and impl. to use fdctx and pure fdio. --- include/mdso/mdso.h | 2 +- src/driver/mdso_amain.c | 3 +-- src/output/mdso_output_export_symbols.c | 31 +++++++++++++++++++------------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/include/mdso/mdso.h b/include/mdso/mdso.h index 2b09491..a2ac094 100644 --- a/include/mdso/mdso.h +++ b/include/mdso/mdso.h @@ -166,7 +166,7 @@ mdso_api int mdso_main (int, char **, char **, const struct mds mdso_api int mdso_create_implib_archive(const struct mdso_driver_ctx *); mdso_api int mdso_create_implib_sources(const struct mdso_driver_ctx *); mdso_api int mdso_create_implib_objects(const struct mdso_driver_ctx *); -mdso_api int mdso_output_export_symbols(const struct mdso_driver_ctx *, const struct mdso_unit_ctx *, FILE *); +mdso_api int mdso_output_export_symbols(const struct mdso_driver_ctx *, const struct mdso_unit_ctx *); mdso_api int mdso_output_error_record (const struct mdso_driver_ctx *, const struct mdso_error_info *); mdso_api int mdso_output_error_vector (const struct mdso_driver_ctx *); diff --git a/src/driver/mdso_amain.c b/src/driver/mdso_amain.c index 02daefb..ee02363 100644 --- a/src/driver/mdso_amain.c +++ b/src/driver/mdso_amain.c @@ -54,8 +54,7 @@ static void mdso_perform_unit_actions( struct mdso_unit_ctx * uctx) { if (uctx->cctx->fmtflags & MDSO_OUTPUT_EXPORT_SYMS) - mdso_output_export_symbols( - dctx,uctx,stdout); + mdso_output_export_symbols(dctx,uctx); } static int mdso_exit(struct mdso_driver_ctx * dctx, int ret) diff --git a/src/output/mdso_output_export_symbols.c b/src/output/mdso_output_export_symbols.c index 5c8dc66..6f36a6d 100644 --- a/src/output/mdso_output_export_symbols.c +++ b/src/output/mdso_output_export_symbols.c @@ -12,39 +12,46 @@ #include #include +#include "mdso_driver_impl.h" +#include "mdso_dprintf_impl.h" #include "mdso_errinfo_impl.h" -static int pretty_header(const struct mdso_common_ctx * cctx, FILE * fout) +static int pretty_header(int fdout, const struct mdso_common_ctx * cctx) { return (cctx->fmtflags & MDSO_PRETTY_YAML) - ? fputs("exports:\n",fout) + ? mdso_dprintf(fdout,"exports:\n") : 0; } -static int pretty_export_item(const struct mdso_common_ctx * cctx, const char * name, FILE * fout) +static int pretty_export_item( + int fdout, + const struct mdso_common_ctx * cctx, + const char * name) { if (cctx->fmtflags & MDSO_PRETTY_YAML) - return fprintf(fout,"- %s\n",name); + return mdso_dprintf(fdout,"- %s\n",name); else - return fprintf(fout,"%s\n",name); + return mdso_dprintf(fdout,"%s\n",name); } int mdso_output_export_symbols( const struct mdso_driver_ctx * dctx, - const struct mdso_unit_ctx * uctx, - FILE * fout) + const struct mdso_unit_ctx * uctx) { - const char * const * sym; + int fdout; + const char * const * sym; + + fdout = mdso_driver_fdout(dctx); if (!uctx->syms[0]) return 0; - if ((pretty_header(dctx->cctx,fout)) < 0) - return MDSO_FILE_ERROR(dctx); + if ((pretty_header(fdout,dctx->cctx)) < 0) + return MDSO_SYSTEM_ERROR(dctx); for (sym=uctx->syms; *sym; sym++) - if ((pretty_export_item(dctx->cctx,*sym,fout)) < 0) - return MDSO_FILE_ERROR(dctx); + if ((pretty_export_item(fdout,dctx->cctx,*sym)) < 0) + return MDSO_SYSTEM_ERROR(dctx); return 0; } -- cgit v1.2.3