diff options
author | midipix <writeonce@midipix.org> | 2015-12-20 03:13:29 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-11-11 00:22:29 -0500 |
commit | 8cfad6a6b15e97d7a753558ebd34f8a9798196f6 (patch) | |
tree | faf7cbfb1bc9024db578fad55c8929991677c42a /src/output | |
parent | 7770733c95046ac92b98c632374eaf7642eb1e5d (diff) | |
download | mdso-8cfad6a6b15e97d7a753558ebd34f8a9798196f6.tar.bz2 mdso-8cfad6a6b15e97d7a753558ebd34f8a9798196f6.tar.xz |
output, mdso_output_export_symbols(): initial implementation.
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/mdso_output_export_symbols.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/output/mdso_output_export_symbols.c b/src/output/mdso_output_export_symbols.c new file mode 100644 index 0000000..eaac241 --- /dev/null +++ b/src/output/mdso_output_export_symbols.c @@ -0,0 +1,49 @@ +/****************************************************************/ +/* mdso: midipix dso scavenger */ +/* Copyright (C) 2015 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */ +/****************************************************************/ + +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> + +#include <mdso/mdso.h> +#include <mdso/mdso_output.h> + +static int pretty_header(const struct mdso_common_ctx * cctx, FILE * fout) +{ + return (cctx->fmtflags & MDSO_PRETTY_YAML) + ? fputs("exports:\n",fout) + : 0; +} + +static int pretty_export_item(const struct mdso_common_ctx * cctx, const char * name, FILE * fout) +{ + if (cctx->fmtflags & MDSO_PRETTY_YAML) + return fprintf(fout,"- %s\n",name); + else + return fprintf(fout,"%s\n",name); +} + +int mdso_output_export_symbols( + const struct mdso_unit_ctx * uctx, + const struct mdso_common_ctx * cctx, + FILE * fout) +{ + const char * const * sym; + + if (!uctx->syms[0]) + return 0; + + if ((pretty_header(cctx,fout)) < 0) + return -1; + + for (sym=uctx->syms; *sym; sym++) + if ((pretty_export_item(cctx,*sym,fout)) < 0) + return -1; + + return 0; +} |