diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 5 | ||||
-rw-r--r-- | src/ustar.c | 15 | ||||
-rw-r--r-- | src/ustar.h | 2 |
3 files changed, 16 insertions, 6 deletions
@@ -76,7 +76,7 @@ _opkg_opk_main_extract(const char *file_name, const char *outer_member, goto error2; } - if (opkg_opk_ustar_seek(outer_ustar, outer_member) != OPKG_OPK_OK) { + if (opkg_opk_ustar_seek(outer_ustar, 1, outer_member) != OPKG_OPK_OK) { fprintf(stderr, "Error: Failed to find \"%s\" in archive\n", outer_member); goto error3; @@ -128,7 +128,8 @@ _opkg_opk_main_read_control(struct opkg_opk_ustar *ustar) size_t size; int ret; - if (opkg_opk_ustar_seek(ustar, "./control") != OPKG_OPK_OK) { + if (opkg_opk_ustar_seek(ustar, 2, "control", "./control") != + OPKG_OPK_OK) { fputs("Error: Failed to find control file\n", stderr); return OPKG_OPK_ERROR; } diff --git a/src/ustar.c b/src/ustar.c index 21d41eb..d728cf5 100644 --- a/src/ustar.c +++ b/src/ustar.c @@ -17,6 +17,7 @@ * along with opkg-opk. If not, see <http://www.gnu.org/licenses/>. */ +#include <stdarg.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -128,10 +129,13 @@ opkg_opk_ustar_list(struct opkg_opk_ustar *ustar, } int -opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar, const char *member) +opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar, int num_keys, ...) { static struct _opkg_opk_ustar_header header; static unsigned char name[OPKG_OPK_USTAR_NAME_MAX_LEN]; + va_list ap; + int key; + const char *member; for (;;) { if (_opkg_opk_ustar_next(ustar, &header) != OPKG_OPK_OK) { @@ -146,9 +150,14 @@ opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar, const char *member) name[sizeof(header.name)] = '\0'; } - if (strcmp((char *) name, member) == 0) { - return OPKG_OPK_OK; /* Member found */ + va_start(ap, num_keys); + for (key = 0; key < num_keys; ++key) { + member = va_arg(ap, const char *); + if (strcmp((char *) name, member) == 0) { + return OPKG_OPK_OK; /* Member found */ + } } + va_end(ap); while (ustar->data_size_remaining > 0) { if (opkg_opk_ustar_read(ustar, NULL, NULL) == diff --git a/src/ustar.h b/src/ustar.h index d199063..de782b8 100644 --- a/src/ustar.h +++ b/src/ustar.h @@ -38,7 +38,7 @@ opkg_opk_ustar_list(struct opkg_opk_ustar *ustar, struct opkg_opk_ustar_member *member); int -opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar, const char *member); +opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar, int num_keys, ...); int opkg_opk_ustar_read(struct opkg_opk_ustar *ustar, char **buffer, size_t *size); |