summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-29 00:18:39 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-29 00:23:46 (EDT)
commit558630f3d34a8f8aa54fe6821980de3ba1b6668e (patch)
treef36bb8d0c829e127b8f3993a110308a46861e69e /src
parent4961785e1745a4b9216dc9dcb600acb1fab6012b (diff)
opk: List control files
Diffstat (limited to 'src')
-rw-r--r--src/opk.c28
-rw-r--r--src/opk.h12
2 files changed, 37 insertions, 3 deletions
diff --git a/src/opk.c b/src/opk.c
index f98f088..f594876 100644
--- a/src/opk.c
+++ b/src/opk.c
@@ -37,6 +37,7 @@ struct _opkg_opk_opk_seek_name {
struct opkg_opk_opk {
struct _opkg_opk_opk_seek_name *print_control_head;
struct _opkg_opk_opk_seek_name *print_control_tail;
+ int list_control;
int list_data;
FILE *file;
char file_buffer[8192];
@@ -59,6 +60,7 @@ opkg_opk_opk_init(void)
opk->print_control_head = NULL;
opk->print_control_tail = NULL;
+ opk->list_control = 0;
opk->list_data = 0;
opk->previously_printed = 0;
@@ -102,6 +104,13 @@ opkg_opk_opk_print_control(struct opkg_opk_opk *opk, const char *name)
}
int
+opkg_opk_opk_list_control(struct opkg_opk_opk *opk)
+{
+ opk->list_control = 1;
+ return OPKG_OPK_OK;
+}
+
+int
opkg_opk_opk_list_data(struct opkg_opk_opk *opk)
{
opk->list_data = 1;
@@ -200,8 +209,8 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk)
size_t size;
struct _opkg_opk_opk_seek_name *seek_name;
- if (opk->print_control_head == NULL) {
- /* No control files requested. */
+ if (opk->list_control == 0 && opk->print_control_head == NULL) {
+ /* Not listing or printing any control files. */
return OPKG_OPK_OK;
}
@@ -211,6 +220,21 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk)
while ((ret_list = opkg_opk_ustar_list(opk->inner_ustar, &member)) ==
OPKG_OPK_OK) {
+ if (opk->list_control > 0) {
+ buffer = member->name;
+ if (buffer[0] == '.' && buffer[1] == '/') {
+ buffer += 2;
+ }
+ if (buffer[0] != '\0') {
+ puts(buffer);
+ opk->previously_printed = 1;
+ }
+ }
+
+ if (opk->print_control_head == NULL) {
+ free(member);
+ continue;
+ }
if (_opkg_opk_opk_check_name(member->name,
&opk->print_control_head,
&opk->print_control_tail) !=
diff --git a/src/opk.h b/src/opk.h
index bf60808..20579bf 100644
--- a/src/opk.h
+++ b/src/opk.h
@@ -47,9 +47,19 @@ int
opkg_opk_opk_print_control(struct opkg_opk_opk *opk, const char *name);
/*
+ * Lists control files when opkg_opk_opk_read() is called.
+ * Parameters:
+ * - opk: Package structure.
+ * Returns:
+ * - OPKG_OPK_OK.
+ */
+int
+opkg_opk_opk_list_control(struct opkg_opk_opk *opk);
+
+/*
* Lists data files when opkg_opk_opk_read() is called.
* Parameters:
- * - opk: Package structure.
+ * - opk: Package structure.
* Returns:
* - OPKG_OPK_OK.
*/