summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-18 11:00:54 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-18 11:00:54 (EDT)
commit5f4f2ed0b58332796f621be55f6110b497c11050 (patch)
tree137a81198e30505c6eb5b5422a6d0c9b249ebfed /src/main.c
parent3366d4988f9f93b0ee0d97bac8277fe83ed8f4ea (diff)
main, ustar: Add comments
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 332ac0d..e2496aa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -62,6 +62,7 @@ _opkg_opk_main_extract(const char *file_name, const char *outer_member,
struct opkg_opk_gzip *inner_gzip;
struct opkg_opk_ustar *inner_ustar;
+ /* Open outer archive. */
file.file = fopen(file_name, "rb");
if (file.file == NULL) {
fprintf(stderr, "Error: Failed to open file \"%s\"\n",
@@ -69,18 +70,21 @@ _opkg_opk_main_extract(const char *file_name, const char *outer_member,
goto error0;
}
+ /* Initialize outer gzip decompressor. */
outer_gzip = opkg_opk_gzip_init(&_opkg_opk_main_file_read, &file);
if (outer_gzip == NULL) {
fputs("Error: Failed to initialize\n", stderr);
goto error1;
}
+ /* Initialize outer ustar unarchiver. */
outer_ustar = opkg_opk_ustar_init(outer_gzip);
if (outer_ustar == NULL) {
fputs("Error: Failed to initialize\n", stderr);
goto error2;
}
+ /* Check package version. */
if (opkg_opk_ustar_seek(outer_ustar, 1, "debian-binary") !=
OPKG_OPK_OK) {
fputs("Error: Failed to find \"debian-binary\" in archive\n",
@@ -97,12 +101,14 @@ _opkg_opk_main_extract(const char *file_name, const char *outer_member,
goto error3;
}
+ /* Find requested inner archive. */
if (opkg_opk_ustar_seek(outer_ustar, 1, outer_member) != OPKG_OPK_OK) {
fprintf(stderr, "Error: Failed to find \"%s\" in archive\n",
outer_member);
goto error3;
}
+ /* Initialize inner gzip decompressor. */
inner_gzip = opkg_opk_gzip_init(
(opkg_opk_gzip_read_func *) &opkg_opk_ustar_read,
outer_ustar);
@@ -111,12 +117,14 @@ _opkg_opk_main_extract(const char *file_name, const char *outer_member,
goto error3;
}
+ /* Initialize inner ustar unarchiver. */
inner_ustar = opkg_opk_ustar_init(inner_gzip);
if (inner_ustar == NULL) {
fputs("Error: Failed to initialize\n", stderr);
goto error4;
}
+ /* Read control file or list data files. */
if (inner_action(inner_ustar) != OPKG_OPK_OK) {
goto error5;
}
@@ -183,6 +191,7 @@ _opkg_opk_main_list_members(struct opkg_opk_ustar *ustar)
char mode[10];
char mtime[20];
+ /* Build singly-linked list and find maximum column widths. */
head = NULL;
uname_len_max = 0;
gname_len_max = 0;
@@ -212,6 +221,7 @@ _opkg_opk_main_list_members(struct opkg_opk_ustar *ustar)
}
tail->next = NULL;
+ /* Print and free members. */
snprintf(fmt, sizeof(fmt), "%%c%%s %%-%zus/%%-%zus %%%lid %%s %%s\n",
uname_len, gname_len, lrint(ceil(log10(size_max))));
for (member = head; member != NULL;) {