summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-19 01:40:07 +0000
committermidipix <writeonce@midipix.org>2024-02-19 02:59:31 +0000
commit51c276fbf1686c340588660a754ea04e6099cd37 (patch)
tree34b1854e72246acbe76033e32506563ffd94309a /src
parent3fa3e3256e30f62d24889b572e3ae65ffb63876a (diff)
downloadslibtool-51c276fbf1686c340588660a754ea04e6099cd37.tar.bz2
slibtool-51c276fbf1686c340588660a754ea04e6099cd37.tar.xz
library api's: _ar_ (in-memory archiver) namespace overhaul.
Diffstat (limited to 'src')
-rw-r--r--src/arbits/output/slbt_ar_output_mapfile.c8
-rw-r--r--src/arbits/slbt_archive_ctx.c16
-rw-r--r--src/arbits/slbt_archive_merge.c22
-rw-r--r--src/arbits/slbt_archive_meta.c54
-rw-r--r--src/arbits/slbt_archive_store.c4
-rw-r--r--src/helper/slbt_archive_import.c16
-rw-r--r--src/logic/slbt_exec_ar.c10
7 files changed, 65 insertions, 65 deletions
diff --git a/src/arbits/output/slbt_ar_output_mapfile.c b/src/arbits/output/slbt_ar_output_mapfile.c
index 6bf974a..2859558 100644
--- a/src/arbits/output/slbt_ar_output_mapfile.c
+++ b/src/arbits/output/slbt_ar_output_mapfile.c
@@ -62,7 +62,7 @@ static int slbt_au_output_mapfile_impl(
}
-static int slbt_create_mapfile_impl(
+static int slbt_ar_create_mapfile_impl(
const struct slbt_archive_meta * meta,
const char * path,
mode_t mode)
@@ -98,14 +98,14 @@ static int slbt_create_mapfile_impl(
int slbt_au_output_mapfile(const struct slbt_archive_meta * meta)
{
- return slbt_create_mapfile_impl(meta,0,0);
+ return slbt_ar_create_mapfile_impl(meta,0,0);
}
-int slbt_create_mapfile(
+int slbt_ar_create_mapfile(
const struct slbt_archive_meta * meta,
const char * path,
mode_t mode)
{
- return slbt_create_mapfile_impl(meta,path,mode);
+ return slbt_ar_create_mapfile_impl(meta,path,mode);
}
diff --git a/src/arbits/slbt_archive_ctx.c b/src/arbits/slbt_archive_ctx.c
index 6e93a70..777b0d5 100644
--- a/src/arbits/slbt_archive_ctx.c
+++ b/src/arbits/slbt_archive_ctx.c
@@ -47,10 +47,10 @@ static int slbt_unmap_raw_archive(struct slbt_raw_archive * map)
return slbt_unmap_input(&mapinfo);
}
-static int slbt_free_archive_ctx_impl(struct slbt_archive_ctx_impl * ctx, int ret)
+static int slbt_ar_free_archive_ctx_impl(struct slbt_archive_ctx_impl * ctx, int ret)
{
if (ctx) {
- slbt_free_archive_meta(ctx->meta);
+ slbt_ar_free_archive_meta(ctx->meta);
slbt_unmap_raw_archive(&ctx->map);
free(ctx);
}
@@ -58,7 +58,7 @@ static int slbt_free_archive_ctx_impl(struct slbt_archive_ctx_impl * ctx, int re
return ret;
}
-int slbt_get_archive_ctx(
+int slbt_ar_get_archive_ctx(
const struct slbt_driver_ctx * dctx,
const char * path,
struct slbt_archive_ctx ** pctx)
@@ -77,11 +77,11 @@ int slbt_get_archive_ctx(
: PROT_READ;
if (slbt_map_raw_archive(dctx,-1,path,prot,&ctx->map))
- return slbt_free_archive_ctx_impl(ctx,
+ return slbt_ar_free_archive_ctx_impl(ctx,
SLBT_NESTED_ERROR(dctx));
- if (slbt_get_archive_meta(dctx,&ctx->map,&ctx->meta))
- return slbt_free_archive_ctx_impl(ctx,
+ if (slbt_ar_get_archive_meta(dctx,&ctx->map,&ctx->meta))
+ return slbt_ar_free_archive_ctx_impl(ctx,
SLBT_NESTED_ERROR(dctx));
ctx->dctx = dctx;
@@ -94,7 +94,7 @@ int slbt_get_archive_ctx(
return 0;
}
-void slbt_free_archive_ctx(struct slbt_archive_ctx * ctx)
+void slbt_ar_free_archive_ctx(struct slbt_archive_ctx * ctx)
{
struct slbt_archive_ctx_impl * ictx;
uintptr_t addr;
@@ -102,6 +102,6 @@ void slbt_free_archive_ctx(struct slbt_archive_ctx * ctx)
if (ctx) {
addr = (uintptr_t)ctx - offsetof(struct slbt_archive_ctx_impl,actx);
ictx = (struct slbt_archive_ctx_impl *)addr;
- slbt_free_archive_ctx_impl(ictx,0);
+ slbt_ar_free_archive_ctx_impl(ictx,0);
}
}
diff --git a/src/arbits/slbt_archive_merge.c b/src/arbits/slbt_archive_merge.c
index 374fced..82eaed5 100644
--- a/src/arbits/slbt_archive_merge.c
+++ b/src/arbits/slbt_archive_merge.c
@@ -112,7 +112,7 @@ static off_t slbt_armap_write_le_64(unsigned char * mark, uint64_t val)
}
-static int slbt_merge_archives_fail(
+static int slbt_ar_merge_archives_fail(
struct slbt_archive_ctx * arctx,
struct armap_buffer_32 * bsdmap32,
struct armap_buffer_64 * bsdmap64,
@@ -125,13 +125,13 @@ static int slbt_merge_archives_fail(
free(bsdmap64);
if (arctx)
- slbt_free_archive_ctx(arctx);
+ slbt_ar_free_archive_ctx(arctx);
return ret;
}
-int slbt_merge_archives(
+int slbt_ar_merge_archives(
struct slbt_archive_ctx * const arctxv[],
struct slbt_archive_ctx ** arctxm)
{
@@ -360,7 +360,7 @@ int slbt_merge_archives(
: 0;
if (nwritten < 0)
- return slbt_merge_archives_fail(
+ return slbt_ar_merge_archives_fail(
arctx,0,0,
SLBT_SYSTEM_ERROR(dctx,0));
@@ -372,7 +372,7 @@ int slbt_merge_archives(
sarname + sarmap + ssymstrs);
if (nwritten < 0)
- return slbt_merge_archives_fail(
+ return slbt_ar_merge_archives_fail(
arctx,0,0,
SLBT_SYSTEM_ERROR(dctx,0));
@@ -402,7 +402,7 @@ int slbt_merge_archives(
: 0;
if (nwritten < 0)
- return slbt_merge_archives_fail(
+ return slbt_ar_merge_archives_fail(
arctx,0,0,
SLBT_SYSTEM_ERROR(dctx,0));
@@ -414,7 +414,7 @@ int slbt_merge_archives(
snamestrs);
if (nwritten < 0)
- return slbt_merge_archives_fail(
+ return slbt_ar_merge_archives_fail(
arctx,0,0,
SLBT_SYSTEM_ERROR(dctx,0));
@@ -471,7 +471,7 @@ int slbt_merge_archives(
if (armap_write_uint32) {
if (!(bsdmap32 = calloc(2*nsymrefs,sizeof(struct armap_buffer_32))))
- return slbt_merge_archives_fail(
+ return slbt_ar_merge_archives_fail(
arctx,0,0,
SLBT_SYSTEM_ERROR(dctx,0));
@@ -479,7 +479,7 @@ int slbt_merge_archives(
} else {
if (!(bsdmap64 = calloc(2*nsymrefs,sizeof(struct armap_buffer_64))))
- return slbt_merge_archives_fail(
+ return slbt_ar_merge_archives_fail(
arctx,0,0,
SLBT_SYSTEM_ERROR(dctx,0));
@@ -684,8 +684,8 @@ int slbt_merge_archives(
struct slbt_archive_ctx_impl * ictx;
ictx = slbt_get_archive_ictx(arctx);
- if (slbt_get_archive_meta(dctx,arctx->map,&ictx->meta) < 0)
- return slbt_merge_archives_fail(
+ if (slbt_ar_get_archive_meta(dctx,arctx->map,&ictx->meta) < 0)
+ return slbt_ar_merge_archives_fail(
arctx,0,0,
SLBT_NESTED_ERROR(dctx));
diff --git a/src/arbits/slbt_archive_meta.c b/src/arbits/slbt_archive_meta.c
index 7279602..a966c26 100644
--- a/src/arbits/slbt_archive_meta.c
+++ b/src/arbits/slbt_archive_meta.c
@@ -25,7 +25,7 @@ struct ar_header_info {
static const char ar_signature[] = AR_SIGNATURE;
-static int slbt_free_archive_meta_impl(struct slbt_archive_meta_impl * meta, int ret)
+static int slbt_ar_free_archive_meta_impl(struct slbt_archive_meta_impl * meta, int ret)
{
if (meta) {
if (meta->armaps.armap_symrefs_32)
@@ -306,7 +306,7 @@ slbt_hidden struct ar_meta_member_info * slbt_archive_member_from_offset(
return (offsetv[l] == offset) ? meta->memberv[l] : 0;
}
-int slbt_get_archive_meta(
+int slbt_ar_get_archive_meta(
const struct slbt_driver_ctx * dctx,
const struct slbt_raw_archive * archive,
struct slbt_archive_meta ** meta)
@@ -389,7 +389,7 @@ int slbt_get_archive_meta(
if (cap < &mark[sizeof(*arhdr)])
for (ch=mark; ch<cap; ch++)
if (*ch)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_HEADER));
@@ -403,7 +403,7 @@ int slbt_get_archive_meta(
arhdr->ar_file_size,
sizeof(arhdr->ar_file_size),
&filesize)) < 0)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_HEADER));
@@ -417,7 +417,7 @@ int slbt_get_archive_meta(
if ((arhdr->ar_file_id[0] == '/') && (arhdr->ar_file_id[1] == '/')) {
for (ch=&arhdr->ar_file_id[2]; ch<fldcap; ch++)
if (*ch != AR_DEC_PADDING)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_HEADER));
@@ -426,7 +426,7 @@ int slbt_get_archive_meta(
arhdr->ar_file_size,
sizeof(arhdr->ar_file_size),
&namelen) < 0)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_HEADER));
@@ -434,7 +434,7 @@ int slbt_get_archive_meta(
/* duplicate long names member? */
if (arlongnames)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_DUPLICATE_LONG_NAMES));
@@ -453,7 +453,7 @@ int slbt_get_archive_meta(
} else if (!strncmp(arhdr->ar_file_id,"/SYM64/",7)) {
for (ch=&arhdr->ar_file_id[7]; ch<fldcap; ch++)
if (*ch != AR_DEC_PADDING)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_HEADER));
@@ -467,7 +467,7 @@ int slbt_get_archive_meta(
&arhdr->ar_file_id[1],
sizeof(arhdr->ar_file_id)-1,
&nameoff) < 0)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_HEADER));
@@ -488,7 +488,7 @@ int slbt_get_archive_meta(
&arhdr->ar_file_id[3],
sizeof(arhdr->ar_file_id)-3,
&namelen) < 0)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_HEADER));
@@ -513,7 +513,7 @@ int slbt_get_archive_meta(
for (; ch<fldcap; )
if (*ch++ != AR_DEC_PADDING)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_HEADER));
@@ -522,7 +522,7 @@ int slbt_get_archive_meta(
/* truncated data? */
if (cap < &mark[filesize])
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_TRUNCATED_DATA));
@@ -538,7 +538,7 @@ int slbt_get_archive_meta(
if (cap < &mark[sizeof(*arhdr)])
for (; mark<cap; )
if (*mark++)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_HEADER));
@@ -549,7 +549,7 @@ int slbt_get_archive_meta(
? (nelements << 4) : (nelements << 1);
if (!(hdrinfov_next = calloc(nelements,sizeof(*hdrinfov))))
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_TRUNCATED_DATA));
@@ -573,19 +573,19 @@ int slbt_get_archive_meta(
/* allocate name strings, member vector */
if (!(m->namestrs = calloc(1,stblsize)))
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_SYSTEM_ERROR(dctx,0));
if (!(m->offsetv = calloc(nentries+1,sizeof(*m->offsetv))))
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_SYSTEM_ERROR(dctx,0));
if (!(m->memberv = calloc(nentries+1,sizeof(*m->memberv))))
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_SYSTEM_ERROR(dctx,0));
if (!(m->members = calloc(nentries,sizeof(*m->members))))
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_SYSTEM_ERROR(dctx,0));
/* archive signature reference */
@@ -736,12 +736,12 @@ int slbt_get_archive_meta(
/* armap member must be the first */
if ((memberp->ar_member_attr == AR_MEMBER_ATTR_ARMAP) && (idx > 0)) {
if (m->members[0].ar_member_attr == AR_MEMBER_ATTR_ARMAP)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_DUPLICATE_ARMAP_MEMBER));
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_MISPLACED_ARMAP_MEMBER));
@@ -753,7 +753,7 @@ int slbt_get_archive_meta(
/* primary armap (first linker member) */
if (slbt_ar_parse_primary_armap(dctx,m) < 0)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_NESTED_ERROR(dctx));
for (idx=0,ch=m->symstrs; idx<m->armaps.armap_nsyms; idx++) {
@@ -770,7 +770,7 @@ int slbt_get_archive_meta(
symrefs_32[idx].ar_name_offset = m->symstrv[idx] - m->symstrv[0];
if (!slbt_archive_member_from_offset(m,symrefs_32[idx].ar_member_offset))
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_ARMAP_MEMBER_OFFSET));
@@ -779,7 +779,7 @@ int slbt_get_archive_meta(
ch = &m->symstrs[symrefs_32[idx].ar_name_offset];
if ((ch > m->symstrv[m->armaps.armap_nsyms - 1]) || *--ch)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_ARMAP_NAME_OFFSET));
@@ -796,7 +796,7 @@ int slbt_get_archive_meta(
symrefs_64[idx].ar_name_offset = m->symstrv[idx] - m->symstrv[0];
if (!slbt_archive_member_from_offset(m,symrefs_64[idx].ar_member_offset))
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_ARMAP_MEMBER_OFFSET));
@@ -805,7 +805,7 @@ int slbt_get_archive_meta(
ch = &m->symstrs[symrefs_64[idx].ar_name_offset];
if ((ch > m->symstrv[m->armaps.armap_nsyms - 1]) || *--ch)
- return slbt_free_archive_meta_impl(
+ return slbt_ar_free_archive_meta_impl(
m,SLBT_CUSTOM_ERROR(
dctx,
SLBT_ERR_AR_INVALID_ARMAP_NAME_OFFSET));
@@ -868,12 +868,12 @@ int slbt_get_archive_meta(
return 0;
}
-void slbt_free_archive_meta(struct slbt_archive_meta * meta)
+void slbt_ar_free_archive_meta(struct slbt_archive_meta * meta)
{
struct slbt_archive_meta_impl * m;
if (meta) {
m = slbt_archive_meta_ictx(meta);
- slbt_free_archive_meta_impl(m,0);
+ slbt_ar_free_archive_meta_impl(m,0);
}
}
diff --git a/src/arbits/slbt_archive_store.c b/src/arbits/slbt_archive_store.c
index a70e307..cbf2704 100644
--- a/src/arbits/slbt_archive_store.c
+++ b/src/arbits/slbt_archive_store.c
@@ -27,12 +27,12 @@
/* interfaces. In the case of archives, that means */
/* passing dctx->fdctx->fdcwd as the _fdat_ param, */
/* where dctx is the driver context which was used */
-/* with slbt_get_archive_ctx(). */
+/* with slbt_ar_get_archive_ctx(). */
/************************************************** */
#define PPRIX64 "%"PRIx64
-int slbt_store_archive(
+int slbt_ar_store_archive(
struct slbt_archive_ctx * arctx,
const char * path,
mode_t mode)
diff --git a/src/helper/slbt_archive_import.c b/src/helper/slbt_archive_import.c
index 95c6c7d..d339f78 100644
--- a/src/helper/slbt_archive_import.c
+++ b/src/helper/slbt_archive_import.c
@@ -29,22 +29,22 @@ static int slbt_archive_import_impl(
(void)ectx;
- if (slbt_get_archive_ctx(dctx,dstarchive,&arctxv[0]) < 0)
+ if (slbt_ar_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]);
+ if (slbt_ar_get_archive_ctx(dctx,srcarchive,&arctxv[1]) < 0) {
+ slbt_ar_free_archive_ctx(arctxv[0]);
return SLBT_NESTED_ERROR(dctx);
}
- ret = slbt_merge_archives(arctxv,&arctx);
+ ret = slbt_ar_merge_archives(arctxv,&arctx);
- slbt_free_archive_ctx(arctxv[0]);
- slbt_free_archive_ctx(arctxv[1]);
+ slbt_ar_free_archive_ctx(arctxv[0]);
+ slbt_ar_free_archive_ctx(arctxv[1]);
if (ret == 0) {
- ret = slbt_store_archive(arctx,dstarchive,0644);
- slbt_free_archive_ctx(arctx);
+ ret = slbt_ar_store_archive(arctx,dstarchive,0644);
+ slbt_ar_free_archive_ctx(arctx);
}
return (ret < 0) ? SLBT_NESTED_ERROR(dctx) : 0;
diff --git a/src/logic/slbt_exec_ar.c b/src/logic/slbt_exec_ar.c
index 7614ee7..95db043 100644
--- a/src/logic/slbt_exec_ar.c
+++ b/src/logic/slbt_exec_ar.c
@@ -110,11 +110,11 @@ static int slbt_exec_ar_perform_archive_actions(
}
if (dctx->cctx->drvflags & SLBT_DRIVER_MODE_AR_MERGE) {
- if (slbt_merge_archives(arctxv,&arctx) < 0)
+ if (slbt_ar_merge_archives(arctxv,&arctx) < 0)
return SLBT_NESTED_ERROR(dctx);
/* (defer mode to umask) */
- if (slbt_store_archive(arctx,dctx->cctx->output,0666) < 0)
+ if (slbt_ar_store_archive(arctx,dctx->cctx->output,0666) < 0)
return SLBT_NESTED_ERROR(dctx);
}
@@ -380,9 +380,9 @@ int slbt_exec_ar(
/* archive context vector initialization */
for (unitp=unitv,arctxp=arctxv; *unitp; unitp++,arctxp++) {
- if (slbt_get_archive_ctx(dctx,*unitp,arctxp) < 0) {
+ if (slbt_ar_get_archive_ctx(dctx,*unitp,arctxp) < 0) {
for (arctxp=arctxv; *arctxp; arctxp++)
- slbt_free_archive_ctx(*arctxp);
+ slbt_ar_free_archive_ctx(*arctxp);
free(unitv);
free(arctxv);
@@ -398,7 +398,7 @@ int slbt_exec_ar(
/* all done */
for (arctxp=arctxv; *arctxp; arctxp++)
- slbt_free_archive_ctx(*arctxp);
+ slbt_ar_free_archive_ctx(*arctxp);
free(unitv);
free(arctxv);