diff options
Diffstat (limited to 'src/ustar.c')
-rw-r--r-- | src/ustar.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/src/ustar.c b/src/ustar.c index 9d95052..47e0dfa 100644 --- a/src/ustar.c +++ b/src/ustar.c @@ -53,6 +53,12 @@ struct opkg_opk_ustar { char read_record[OPKG_OPK_USTAR_RECORD_SIZE]; }; +struct opkg_opk_ustar_seek_name { + const char *name; + int found; + struct opkg_opk_ustar_seek_name *next; +}; + struct opkg_opk_ustar * opkg_opk_ustar_init(struct opkg_opk_gzip *gzip) { @@ -226,8 +232,8 @@ opkg_opk_ustar_list(struct opkg_opk_ustar *ustar, } int -opkg_opk_ustar_add_seek_name(struct opkg_opk_ustar_seek_name **head, - struct opkg_opk_ustar_seek_name **tail, const char *name) +opkg_opk_ustar_add_seek_name(struct opkg_opk_ustar_seek_name **names, + const char *name) { struct opkg_opk_ustar_seek_name *seek_name; @@ -237,18 +243,24 @@ opkg_opk_ustar_add_seek_name(struct opkg_opk_ustar_seek_name **head, } seek_name->name = name; seek_name->found = 0; - seek_name->next = NULL; - - if (*head == NULL) { - *head = seek_name; - } else { - (*tail)->next = seek_name; - } - *tail = seek_name; + seek_name->next = *names; + *names = seek_name; return OPKG_OPK_OK; } +void +opkg_opk_ustar_free_seek_names(struct opkg_opk_ustar_seek_name *names) +{ + struct opkg_opk_ustar_seek_name *name; + + while (names != NULL) { + name = names; + names = names->next; + free(name); + } +} + int opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar, struct opkg_opk_ustar_seek_name *names) @@ -321,6 +333,22 @@ opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar, } int +opkg_opk_ustar_seek_one(struct opkg_opk_ustar *ustar, const char *name) +{ + struct opkg_opk_ustar_seek_name seek_name; + + seek_name.name = name; + seek_name.found = 0; + seek_name.next = NULL; + + if (opkg_opk_ustar_seek(ustar, &seek_name) == OPKG_OPK_END) { + return OPKG_OPK_OK; + } else { + return OPKG_OPK_ERROR; + } +} + +int opkg_opk_ustar_read(struct opkg_opk_ustar *ustar, char **buffer, size_t *size) { if (ustar->data_size_remaining == 0) { |