From 558630f3d34a8f8aa54fe6821980de3ba1b6668e Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 29 Apr 2023 00:18:39 -0400 Subject: opk: List control files --- (limited to 'src/opk.c') 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) != -- cgit v0.9.1