summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-02-20 18:41:52 -0500
committermidipix <writeonce@midipix.org>2019-02-20 23:31:15 -0500
commitc6570d037a1def5d7d25d832b28ca3ce7398657c (patch)
treeedd6a14f15582f0cdbdcfea8c0a8f5933e64e437
parent54e94f38f5e4d9e4ad51766ea5ca97ec8839114c (diff)
downloadmdso-c6570d037a1def5d7d25d832b28ca3ce7398657c.tar.bz2
mdso-c6570d037a1def5d7d25d832b28ca3ce7398657c.tar.xz
utility api's: added mdso_output_expsyms_crc32(), mdso_output_expsyms_crc64().
-rw-r--r--project/common.mk1
-rw-r--r--src/output/mdso_output_expsyms_crc.c76
2 files changed, 77 insertions, 0 deletions
diff --git a/project/common.mk b/project/common.mk
index 2b0edaa..a52f593 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -13,6 +13,7 @@ API_SRCS = \
src/object/mdso_objgen_symentry.c \
src/output/mdso_output_error.c \
src/output/mdso_output_export_symbols.c \
+ src/output/mdso_output_expsyms_crc.c \
src/skin/mdso_skin_default.c \
src/util/mdso_create_implib_archive.c \
src/util/mdso_create_implib_objects.c \
diff --git a/src/output/mdso_output_expsyms_crc.c b/src/output/mdso_output_expsyms_crc.c
new file mode 100644
index 0000000..45ff702
--- /dev/null
+++ b/src/output/mdso_output_expsyms_crc.c
@@ -0,0 +1,76 @@
+/****************************************************************/
+/* mdso: midipix dso scavenger */
+/* Copyright (C) 2015--2019 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 <inttypes.h>
+
+#include <mdso/mdso.h>
+#include <mdso/mdso_output.h>
+#include "mdso_driver_impl.h"
+#include "mdso_dprintf_impl.h"
+#include "mdso_errinfo_impl.h"
+
+static int pretty_expsym_crc32(
+ int fdout,
+ const char * name)
+{
+ return mdso_dprintf(
+ fdout,"%" PRIx32 " %s\n",
+ mdso_crc32_mbstr((const unsigned char *)name,0),
+ name);
+}
+
+static int pretty_expsym_crc64(
+ int fdout,
+ const char * name)
+{
+ return mdso_dprintf(
+ fdout,"%" PRIx64 " %s\n",
+ mdso_crc64_mbstr((const unsigned char *)name,0),
+ name);
+}
+
+int mdso_output_expsyms_crc32(
+ const struct mdso_driver_ctx * dctx,
+ const struct mdso_unit_ctx * uctx)
+{
+ int fdout;
+ const char * const * sym;
+
+ fdout = mdso_driver_fdout(dctx);
+
+ if (!uctx->syms[0])
+ return 0;
+
+ for (sym=uctx->syms; *sym; sym++)
+ if ((pretty_expsym_crc32(fdout,*sym)) < 0)
+ return MDSO_SYSTEM_ERROR(dctx);
+
+ return 0;
+}
+
+int mdso_output_expsyms_crc64(
+ const struct mdso_driver_ctx * dctx,
+ const struct mdso_unit_ctx * uctx)
+{
+ int fdout;
+ const char * const * sym;
+
+ fdout = mdso_driver_fdout(dctx);
+
+ if (!uctx->syms[0])
+ return 0;
+
+ for (sym=uctx->syms; *sym; sym++)
+ if ((pretty_expsym_crc64(fdout,*sym)) < 0)
+ return MDSO_SYSTEM_ERROR(dctx);
+
+ return 0;
+}