2
0
mirror of https://github.com/vasi/pixz synced 2024-11-03 09:40:24 +00:00
pixz/list.c
2010-10-10 20:07:13 -04:00

50 lines
1.1 KiB
C

#include "pixz.h"
#include <getopt.h>
#pragma mark FUNCTION DEFINITIONS
int main(int argc, char **argv) {
char *progname = argv[0];
int ch;
bool tar = false;
while ((ch = getopt(argc, argv, "t")) != -1) {
switch (ch) {
case 't':
tar = true;
break;
default:
die("Unknown option");
}
}
argc -= optind - 1;
argv += optind - 1;
if (argc != 2)
die("Usage: %s [-t] file", progname);
if (!(gInFile = fopen(argv[1], "r")))
die("Can't open input file");
decode_index();
lzma_index_iter iter;
lzma_index_iter_init(&iter, gIndex);
while (!lzma_index_iter_next(&iter, LZMA_INDEX_ITER_BLOCK)) {
fprintf(stderr, "%9"PRIuMAX" / %9"PRIuMAX"\n",
(uintmax_t)iter.block.unpadded_size,
(uintmax_t)iter.block.uncompressed_size);
}
if (tar) {
fprintf(stderr, "\n");
read_file_index();
dump_file_index();
free_file_index();
}
lzma_index_end(gIndex, NULL);
lzma_end(&gStream);
return 0;
}