summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-08 06:44:17 +0000
committermidipix <writeonce@midipix.org>2024-02-08 06:49:09 +0000
commit89caff5866dfb5eac961cb2f8d3c40f67ab43aa6 (patch)
treed59d85fa12ce93dd03f0fad08c44734c5b46af1e /src/helper
parentc8d21a38d6941303527af15b95d887a053aa0df6 (diff)
downloadslibtool-89caff5866dfb5eac961cb2f8d3c40f67ab43aa6.tar.bz2
slibtool-89caff5866dfb5eac961cb2f8d3c40f67ab43aa6.tar.xz
slbt_archive_import(): use slibtool's in-memory archive merging facility.
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/slbt_archive_import.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/helper/slbt_archive_import.c b/src/helper/slbt_archive_import.c
index 620ac3b..924a54f 100644
--- a/src/helper/slbt_archive_import.c
+++ b/src/helper/slbt_archive_import.c
@@ -8,19 +8,55 @@
#include "slibtool_driver_impl.h"
#include "slibtool_errinfo_impl.h"
+/* legacy fallback, no longer in use */
extern int slbt_archive_import_mri(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx,
char * dstarchive,
char * srcarchive);
+/* use slibtool's in-memory archive merging facility */
+static int slbt_archive_import_impl(
+ const struct slbt_driver_ctx * dctx,
+ struct slbt_exec_ctx * ectx,
+ char * dstarchive,
+ char * srcarchive)
+{
+ int ret;
+ struct slbt_archive_ctx * arctxv[3] = {0,0,0};
+ struct slbt_archive_ctx * arctx;
+
+ (void)ectx;
+
+ if (slbt_get_archive_ctx(dctx,dstarchive,&arctxv[0]) < 0)
+ return SLBT_NESTED_ERROR(dctx);
+
+ if (slbt_get_archive_ctx(dctx,srcarchive,&arctxv[1]) < 0) {
+ slbt_free_archive_ctx(arctxv[0]);
+ return SLBT_NESTED_ERROR(dctx);
+ }
+
+ ret = slbt_merge_archives(arctxv,&arctx);
+
+ slbt_free_archive_ctx(arctxv[0]);
+ slbt_free_archive_ctx(arctxv[1]);
+
+ if (ret == 0) {
+ ret = slbt_store_archive(arctx,dstarchive,0644);
+ slbt_free_archive_ctx(arctx);
+ }
+
+ return (ret < 0) ? SLBT_NESTED_ERROR(dctx) : 0;
+}
+
+
int slbt_archive_import(
const struct slbt_driver_ctx * dctx,
struct slbt_exec_ctx * ectx,
char * dstarchive,
char * srcarchive)
{
- return slbt_archive_import_mri(
+ return slbt_archive_import_impl(
dctx,ectx,
dstarchive,
srcarchive);