summaryrefslogtreecommitdiffstats
path: root/src/opk.c
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-19 11:06:57 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-19 11:06:57 (EDT)
commitda0e44cd2b78d4c1d4439c23a842fa3952ebe893 (patch)
tree75ce531d5e5370201f14f5797d7473784a915455 /src/opk.c
parent25978e5d7ffe57a9d05f0693ca7e8bd3c4cbbfd2 (diff)
ustar: Make seek names struct opaque
Simplify main() a little and fix memory leak on success.
Diffstat (limited to 'src/opk.c')
-rw-r--r--src/opk.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/opk.c b/src/opk.c
index cdb3f58..45da6fd 100644
--- a/src/opk.c
+++ b/src/opk.c
@@ -59,8 +59,7 @@ _opkg_opk_opk_file_read(void *user_data, char **buffer, size_t *size)
struct opkg_opk_opk *
opkg_opk_opk_init_outer(const char *file_name)
{
- struct opkg_opk_opk *opk;
- struct opkg_opk_ustar_seek_name seek_name;
+ struct opkg_opk_opk *opk;
opk = malloc(sizeof(*opk));
if (opk == NULL) {
@@ -90,11 +89,8 @@ opkg_opk_opk_init_outer(const char *file_name)
}
/* Check package version. */
- seek_name.name = "debian-binary";
- seek_name.found = 0;
- seek_name.next = NULL;
- if (opkg_opk_ustar_seek(opk->outer_ustar, &seek_name) == OPKG_OPK_ERROR)
- {
+ if (opkg_opk_ustar_seek_one(opk->outer_ustar, "debian-binary") !=
+ OPKG_OPK_OK) {
fputs("Error: Failed to find \"debian-binary\" in archive\n",
stderr);
goto error3;
@@ -129,8 +125,7 @@ opkg_opk_opk_init_outer(const char *file_name)
int
opkg_opk_opk_init_inner(struct opkg_opk_opk *opk, const char *member)
{
- int ret;
- struct opkg_opk_ustar_seek_name seek_name;
+ int ret;
/* Finish reading previous inner archive, if any. */
while ((ret = opkg_opk_ustar_read(opk->outer_ustar, NULL, NULL)) ==
@@ -141,11 +136,7 @@ opkg_opk_opk_init_inner(struct opkg_opk_opk *opk, const char *member)
}
/* Find requested inner archive. */
- seek_name.name = member;
- seek_name.found = 0;
- seek_name.next = NULL;
- if (opkg_opk_ustar_seek(opk->outer_ustar, &seek_name) == OPKG_OPK_ERROR)
- {
+ if (opkg_opk_ustar_seek_one(opk->outer_ustar, member) != OPKG_OPK_OK) {
fprintf(stderr, "Error: Failed to find \"%s\" in archive\n",
member);
return OPKG_OPK_ERROR;