summaryrefslogtreecommitdiff
path: root/src/arbits/slbt_archive_meta.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-01-26 21:08:48 +0000
committermidipix <writeonce@midipix.org>2024-01-26 21:08:48 +0000
commit8567ecfb6516fbb46270886462e46251143c66fd (patch)
tree52524c11bf0774afb4e85edb5de4ce019ba8d45e /src/arbits/slbt_archive_meta.c
parent562b43d4ae67035b58489bbda6362c858b801f53 (diff)
downloadslibtool-8567ecfb6516fbb46270886462e46251143c66fd.tar.bz2
slibtool-8567ecfb6516fbb46270886462e46251143c66fd.tar.xz
archiver internals: added slbt_archive_member_from_offset().
Diffstat (limited to 'src/arbits/slbt_archive_meta.c')
-rw-r--r--src/arbits/slbt_archive_meta.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/arbits/slbt_archive_meta.c b/src/arbits/slbt_archive_meta.c
index 9a5d542..bf7efb0 100644
--- a/src/arbits/slbt_archive_meta.c
+++ b/src/arbits/slbt_archive_meta.c
@@ -698,6 +698,32 @@ static int slbt_ar_parse_primary_armap(
return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_FLOW_ERROR);
}
+struct ar_meta_member_info * slbt_archive_member_from_offset(
+ struct slbt_archive_meta_impl * meta,
+ off_t offset)
+{
+ intptr_t l,r,m;
+ off_t * offsetv;
+
+ l = 0;
+ r = meta->nentries - 1;
+
+ offsetv = meta->offsetv;
+
+ while (l != r) {
+ m = (l + r) / 2;
+ m += (l + 2) % 2;
+
+ if (offsetv[m] > offset) {
+ r = --m;
+ } else {
+ l = m;
+ }
+ }
+
+ return (offsetv[l] == offset) ? meta->memberv[l] : 0;
+}
+
int slbt_get_archive_meta(
const struct slbt_driver_ctx * dctx,
const struct slbt_raw_archive * archive,