pm

barely a pack manager
git clone git://z3bra.org/pm
Log | Files | Refs | README | LICENSE

commit 96d5fa5f539e7b9efff7b2e243a652c0ef12a830
Author: z3bra <willyatmailoodotorg>
Date:   Fri Dec 18 12:48:07 2015

List the content of an archive

Diffstat:
 makefile | 10 ++++++++++
 pack.c   | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/makefile b/makefile @@ -0,0 +1,10 @@ +CC = cc +LD = $(CC) + +CFLAGS = -Wall +LDFLAGS = -larchive + +all: pack + +clean: + rm -f pack+ \ No newline at end of file diff --git a/pack.c b/pack.c @@ -0,0 +1,44 @@ +#include <stdio.h> +#include <archive.h> +#include <archive_entry.h> + +/* + * output the content of an archive + */ +int +pack_list(char *filename) +{ + struct archive *a; + struct archive_entry *e; + int r; + + a = archive_read_new(); + archive_read_support_filter_all(a); + archive_read_support_format_all(a); + + /* set blocksize to 0 as libarchive will choose the best size anyway */ + r = archive_read_open_filename(a, filename, 0); + + if (r != ARCHIVE_OK) + return 1; + + while(archive_read_next_header(a, &e) == ARCHIVE_OK) { + puts(archive_entry_pathname(e)); + } + + r = archive_read_free(a); + + if (r != ARCHIVE_OK) + return 1; + + return 0; +} + +int +main (int argc, char **argv) +{ + while (*(++argv)) + pack_list(*argv); + + return 0; +}+ \ No newline at end of file