From 7c7ea6515ac40f2f41fecc295998bd9ef0cffa78 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 18 Apr 2023 19:48:21 -0400 Subject: opk: Print multiple control files --- (limited to 'src') diff --git a/src/main.c b/src/main.c index b24a2fd..fdfc290 100644 --- a/src/main.c +++ b/src/main.c @@ -35,6 +35,11 @@ main(int argc, char *argv[]) "control") != OPKG_OPK_OK) { goto error0; } + if (opkg_opk_ustar_add_seek_name( + &control_files_head, &control_files_tail, + "md5sums") != OPKG_OPK_OK) { + goto error0; + } /* Initialize outer archive. */ opk = opkg_opk_opk_init_outer(argv[1]); diff --git a/src/opk.c b/src/opk.c index 82aaca3..cd92bd6 100644 --- a/src/opk.c +++ b/src/opk.c @@ -176,26 +176,32 @@ opkg_opk_opk_read_control(struct opkg_opk_opk *opk, { char *buffer; size_t size; - int ret; + int ret_seek; + int ret_read; - if (opk->previously_printed == 1) { - puts(""); + while ((ret_seek = opkg_opk_ustar_seek(opk->inner_ustar, names)) != + OPKG_OPK_ERROR) { + if (opk->previously_printed == 1) { + puts(""); + } + while ((ret_read = opkg_opk_ustar_read(opk->inner_ustar, + &buffer, &size)) == OPKG_OPK_OK) + { + fwrite(buffer, 1, size, stdout); + } + if (ret_read == OPKG_OPK_ERROR) { + fputs("Error: Failed to read control file\n", stderr); + return OPKG_OPK_ERROR; + } + opk->previously_printed = 1; + if (ret_seek == OPKG_OPK_END) { + break; + } } - - if (opkg_opk_ustar_seek(opk->inner_ustar, names) == OPKG_OPK_ERROR) { + if (ret_seek == OPKG_OPK_ERROR) { fputs("Error: Failed to find control file\n", stderr); return OPKG_OPK_ERROR; } - while ((ret = opkg_opk_ustar_read(opk->inner_ustar, &buffer, &size)) == - OPKG_OPK_OK) { - fwrite(buffer, 1, size, stdout); - } - if (ret == OPKG_OPK_ERROR) { - fputs("Error: Failed to read control file\n", stderr); - return OPKG_OPK_ERROR; - } - - opk->previously_printed = 1; return OPKG_OPK_OK; } -- cgit v0.9.1