summaryrefslogtreecommitdiffstats
path: root/src/ustar.h
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-18 16:41:42 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-18 19:47:12 (EDT)
commitb65c075d13990383f30b27aeafacdd4575fafdee (patch)
treec338c3db137405b98bf74091d9c9965d5c92d7cf /src/ustar.h
parent25ce512c39f578def257f81e10e22b06123a069d (diff)
ustar: Use linked list instead of varargs in seek
Also indicate when all sought member files are found.
Diffstat (limited to 'src/ustar.h')
-rw-r--r--src/ustar.h39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/ustar.h b/src/ustar.h
index 47f3efa..d2317b6 100644
--- a/src/ustar.h
+++ b/src/ustar.h
@@ -21,6 +21,7 @@
#define OPKG_OPK_USTAR_H_
#include <stdint.h>
+#include "gzip.h"
#define OPKG_OPK_USTAR_RECORD_SIZE 512
#define OPKG_OPK_USTAR_NAME_MAX_LEN 257 /* prefix[155] + '/' + name[100] + '\0'
@@ -40,6 +41,12 @@ struct opkg_opk_ustar_member {
struct opkg_opk_ustar_member *next;
};
+struct opkg_opk_ustar_seek_name {
+ const char *name;
+ int found;
+ struct opkg_opk_ustar_seek_name *next;
+};
+
/*
* Allocates and initializes an archive structure.
* Parameters:
@@ -68,18 +75,38 @@ opkg_opk_ustar_list(struct opkg_opk_ustar *ustar,
struct opkg_opk_ustar_member **member);
/*
- * Advances to a named member file.
+ * Adds a name to a list of names to find with opkg_opk_ustar_seek(). List is
+ * dynamically allocated; free with free().
* Parameters:
- * - ustar: Archive structure.
- * - num_keys: Number of search keys to follow.
- * - ...: Search keys of type (const char *).
+ * - head: Address in which to store address of list head.
+ * - tail: Address in which to store address of list tail.
+ * - name: Name of member file to find.
+ * Returns:
+ * - OPKG_OPK_OK if the name was added to the list.
+ * - OPKG_OPK_ERROR on memory exhaustion.
+ */
+int
+opkg_opk_ustar_add_seek_name(struct opkg_opk_ustar_seek_name **head,
+ struct opkg_opk_ustar_seek_name **tail, const char *name);
+
+/*
+ * Advances to a named member file. May be called multiple times until all
+ * requested members are found.
+ * Parameters:
+ * - ustar: Archive structure.
+ * - names: Name(s) to find. Member "found" will be set to "1" on the first
+ * name found.
* Returns:
- * - OPKG_OPK_OK if a member matching one of the search keys is found.
+ * - OPKG_OPK_OK if a member matching one of the requested names is found but
+ * more names remain to be found.
+ * - OPKG_OPK_END if a member matching one of the requested names is found and
+ * no more names remain to be found.
* - OPKG_OPK_ERROR if no matching member is found or on decompression error, an
* invalid header, or unsupported file type.
*/
int
-opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar, int num_keys, ...);
+opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar,
+ struct opkg_opk_ustar_seek_name *names);
/*
* Reads up to a record (512 octets) of member file data at a time.