summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/slibtool/slibtool.h2
-rw-r--r--src/arbits/output/slbt_ar_output_mapfile.c39
2 files changed, 35 insertions, 6 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h
index 9152ed8..4238dbc 100644
--- a/include/slibtool/slibtool.h
+++ b/include/slibtool/slibtool.h
@@ -402,6 +402,8 @@ slbt_api int slbt_merge_archives (struct slbt_archive_ctx * const [],
slbt_api int slbt_store_archive (struct slbt_archive_ctx *,
const char *, mode_t);
+slbt_api int slbt_create_mapfile (const struct slbt_archive_meta *, const char *, mode_t);
+
/* utility api */
slbt_api int slbt_main (char **, char **,
const struct slbt_fd_ctx *);
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);
}