diff options
-rw-r--r-- | src/opk.c | 28 | ||||
-rw-r--r-- | src/opk.h | 12 |
2 files changed, 37 insertions, 3 deletions
@@ -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) != @@ -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. */ |