Single driver

pull/2/head
Dave Vasilevsky 14 years ago
parent e675206a8e
commit 4713b32cf1

@ -17,8 +17,8 @@ CC = gcc
COMPILE = $(CC) $(CFLAGS) -c -o
LD = $(CC) $(LDFLAGS) -o
PROGS = write read list
COMMON = common.o endian.o cpu.o
PROGS = pixz
COMMON = common.o endian.o cpu.o read.o write.o list.o
all: $(PROGS)

@ -2,40 +2,8 @@
#include <getopt.h>
void pixz_list(bool tar);
#pragma mark FUNCTION DEFINITIONS
int main(int argc, char **argv) {
char *progname = argv[0];
bool tar = true;
int ch;
while ((ch = getopt(argc, argv, "t")) != -1) {
switch (ch) {
case 't':
tar = false;
break;
default:
die("Unknown option");
}
}
argc -= optind - 1;
argv += optind - 1;
if (argc == 1) {
gInFile = stdin;
} else if (argc == 2) {
if (!(gInFile = fopen(argv[1], "r")))
die("Can't open input file");
} else {
die("Usage: %s -f [FILE]", progname);
}
pixz_list(tar);
return 0;
}
void pixz_list(bool tar) {
decode_index();
lzma_index_iter iter;

@ -28,6 +28,13 @@
#endif
#pragma mark OPERATIONS
void pixz_list(bool tar);
void pixz_write(bool tar, uint32_t level);
void pixz_read(bool verify, size_t nspecs, char **specs);
#pragma mark UTILS
FILE *gInFile, *gOutFile;

@ -58,35 +58,9 @@ static size_t gBlockInSize = 0, gBlockOutSize = 0;
static void set_block_sizes(void);
void pixz_read(bool verify, size_t nspecs, char **specs);
#pragma mark MAIN
int main(int argc, char **argv) {
gInFile = stdin;
gOutFile = stdout;
bool verify = true;
int ch;
while ((ch = getopt(argc, argv, "i:o:v")) != -1) {
switch (ch) {
case 'i':
if (!(gInFile = fopen(optarg, "r")))
die ("Can't open input file");
break;
case 'o':
if (!(gOutFile = fopen(optarg, "w")))
die ("Can't open output file");
break;
case 'v': verify = false; break;
default:
die("Unknown option");
}
}
pixz_read(verify, argc - optind, argv + optind);
return 0;
}
void pixz_read(bool verify, size_t nspecs, char **specs) {
decode_index();
if (verify)

@ -57,48 +57,9 @@ static void write_file_index(void);
static void write_file_index_bytes(size_t size, uint8_t *buf);
static void write_file_index_buf(lzma_action action);
void pixz_write(bool tar, uint32_t level);
#pragma mark FUNCTION DEFINITIONS
int main(int argc, char **argv) {
char *progname = argv[0];
uint32_t level = LZMA_PRESET_DEFAULT;
bool tar = true;
debug("launch");
int ch;
while ((ch = getopt(argc, argv, "t0123456789")) != -1) {
switch (ch) {
case 't':
tar = false;
break;
default:
if (optopt >= '0' && optopt <= '9') {
level = optopt - '0';
} else {
die("Unknown option");
}
}
}
argc -= optind - 1;
argv += optind - 1;
if (argc == 1) {
gInFile = stdin;
gOutFile = stdout;
} else if (argc == 3) {
if (!(gInFile = fopen(argv[1], "r")))
die("Can't open input file");
if (!(gOutFile = fopen(argv[2], "w")))
die("Can't open output file");
} else {
die("Usage: %s [-t] [INPUT OUTPUT]", progname);
}
pixz_write(tar, level);
}
void pixz_write(bool tar, uint32_t level) {
gTar = tar;

Loading…
Cancel
Save