diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-04-18 19:48:21 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-04-18 19:48:21 (EDT) |
commit | 7c7ea6515ac40f2f41fecc295998bd9ef0cffa78 (patch) | |
tree | 16a94207c04400dafc489c202f4ecabc487c9937 | |
parent | b65c075d13990383f30b27aeafacdd4575fafdee (diff) |
opk: Print multiple control files
-rw-r--r-- | src/main.c | 5 | ||||
-rw-r--r-- | src/opk.c | 36 |
2 files changed, 26 insertions, 15 deletions
@@ -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]); @@ -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; } |