summaryrefslogtreecommitdiffstats
path: root/src/ustar.c
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-28 19:03:41 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-28 20:52:12 (EDT)
commiteffcd79eb38e3ab125a0eaf64850f52df914e965 (patch)
treeefbdd7823c7c3f56073af2e869e187ff00b7d67d /src/ustar.c
parentf6a6b1c9dae1538b9fed7ab52b5ffd31cc411326 (diff)
opk: Absorb seek list management from ustar
Diffstat (limited to 'src/ustar.c')
-rw-r--r--src/ustar.c117
1 files changed, 0 insertions, 117 deletions
diff --git a/src/ustar.c b/src/ustar.c
index 1bc8261..1a2858b 100644
--- a/src/ustar.c
+++ b/src/ustar.c
@@ -54,12 +54,6 @@ 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)
{
@@ -236,117 +230,6 @@ opkg_opk_ustar_list(struct opkg_opk_ustar *ustar,
}
int
-opkg_opk_ustar_add_seek_name(struct opkg_opk_ustar_seek_name **names,
- const char *name)
-{
- struct opkg_opk_ustar_seek_name *seek_name;
-
- seek_name = malloc(sizeof(*seek_name));
- if (seek_name == NULL) {
- return OPKG_OPK_ERROR;
- }
- seek_name->name = name;
- seek_name->found = 0;
- 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)
-{
- char name[OPKG_OPK_USTAR_NAME_SIZE];
- int found;
- int found_all;
- struct opkg_opk_ustar_seek_name *seek_name;
-
- for (;;) {
- /* Get next header record. */
- if (_opkg_opk_ustar_next(ustar) != OPKG_OPK_OK) {
- return OPKG_OPK_ERROR; /* Error or end (not found) */
- }
-
- /* Prepare name (with prefix if any) for check. */
- if (ustar->header.prefix[0] != '\0') {
- sprintf(name, "%s/%s", ustar->header.prefix,
- ustar->header.name);
- } else {
- /* Use memcpy() because ustar->header.name may not be
- * NUL-terminated. */
- memcpy(name, ustar->header.name,
- sizeof(ustar->header.name));
- name[sizeof(ustar->header.name)] = '\0';
- }
-
- /* Check each requested name. */
- found = 0;
- found_all = 1;
- for (seek_name = names; seek_name != NULL;
- seek_name = seek_name->next) {
- if (seek_name->found == 1) {
- continue; /* Previously found this member */
- }
- if (strcmp(name, seek_name->name) == 0) {
- if (found == 0) {
- seek_name->found = 1;
- found = 1;
- continue;
- }
- }
- if (name[0] == '.' && name[1] == '/' &&
- strcmp(name + 2, seek_name->name) == 0)
- {
- if (found == 0) {
- seek_name->found = 1;
- found = 1;
- continue;
- }
- }
- found_all = 0;
- }
- if (found == 1) {
- if (found_all == 1) {
- /* All requested members found */
- return OPKG_OPK_END;
- }
- return OPKG_OPK_OK; /* Member found, but more remain */
- }
- }
-
- return OPKG_OPK_ERROR; /* Member not found */
-}
-
-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) {