summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-17 07:31:52 +0000
committermidipix <writeonce@midipix.org>2024-02-17 07:31:52 +0000
commit14302ea489782bd9cefa0fe972ed3ac83b7637b6 (patch)
treec0edf91f7ec57766b106c92354a0bc8856afd61f /src
parent2dc23e0157138d12423ae15f8b18e1e5e56aeb14 (diff)
downloadslibtool-14302ea489782bd9cefa0fe972ed3ac83b7637b6.tar.bz2
slibtool-14302ea489782bd9cefa0fe972ed3ac83b7637b6.tar.xz
archiver output api: added slbt_create_mapfile().
Diffstat (limited to 'src')
-rw-r--r--src/arbits/output/slbt_ar_output_mapfile.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/arbits/output/slbt_ar_output_mapfile.c b/src/arbits/output/slbt_ar_output_mapfile.c
index 90ece3e..09774bd 100644
--- a/src/arbits/output/slbt_ar_output_mapfile.c
+++ b/src/arbits/output/slbt_ar_output_mapfile.c
@@ -18,16 +18,13 @@
static int slbt_ar_output_mapfile_impl(
const struct slbt_driver_ctx * dctx,
struct slbt_archive_meta_impl * mctx,
- const struct slbt_fd_ctx * fdctx)
+ int fdout)
{
- int fdout;
const char * regex;
const char ** symv;
regex_t regctx;
regmatch_t pmatch[2] = {0};
- fdout = fdctx->fdout;
-
if (slbt_dprintf(fdout,"{\n" "\t" "global:\n") < 0)
return SLBT_SYSTEM_ERROR(dctx,0);
@@ -51,11 +48,16 @@ static int slbt_ar_output_mapfile_impl(
return 0;
}
-int slbt_ar_output_mapfile(const struct slbt_archive_meta * meta)
+
+static int slbt_create_mapfile_impl(
+ const struct slbt_archive_meta * meta,
+ const char * path,
+ mode_t mode)
{
struct slbt_archive_meta_impl * mctx;
const struct slbt_driver_ctx * dctx;
struct slbt_fd_ctx fdctx;
+ int fdout;
mctx = slbt_archive_meta_ictx(meta);
dctx = (slbt_archive_meta_ictx(meta))->dctx;
@@ -66,6 +68,31 @@ int slbt_ar_output_mapfile(const struct slbt_archive_meta * meta)
if (!meta->a_memberv)
return 0;
+ if (path) {
+ if ((fdout = openat(
+ fdctx.fdcwd,path,
+ O_WRONLY|O_CREAT|O_TRUNC,
+ mode)) < 0)
+ return SLBT_SYSTEM_ERROR(dctx,0);
+ } else {
+ fdout = fdctx.fdout;
+ }
+
return slbt_ar_output_mapfile_impl(
- dctx,mctx,&fdctx);
+ dctx,mctx,fdout);
+}
+
+
+int slbt_ar_output_mapfile(const struct slbt_archive_meta * meta)
+{
+ return slbt_create_mapfile_impl(meta,0,0);
+}
+
+
+int slbt_create_mapfile(
+ const struct slbt_archive_meta * meta,
+ const char * path,
+ mode_t mode)
+{
+ return slbt_create_mapfile_impl(meta,path,mode);
}