From b65c075d13990383f30b27aeafacdd4575fafdee Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 18 Apr 2023 16:41:42 -0400 Subject: ustar: Use linked list instead of varargs in seek Also indicate when all sought member files are found. --- (limited to 'src/ustar.h') 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 +#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. -- cgit v0.9.1