31 lines
726 B
C
31 lines
726 B
C
#include "compressor.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
void print_usage() {
|
|
printf("Usage:\n");
|
|
printf(" ./compressor -c infile outfile Compress infile into outfile\n");
|
|
printf(" ./compressor -d compressed uncompressed Decompress compressed into uncompressed\n");
|
|
}
|
|
|
|
int main(int argc, char* argv[]) {
|
|
if (argc != 4) {
|
|
print_usage();
|
|
return 1;
|
|
}
|
|
|
|
const char* mode = argv[1];
|
|
const char* infile = argv[2];
|
|
const char* outfile = argv[3];
|
|
|
|
if (strcmp(mode, "-c") == 0) {
|
|
return compress(infile, outfile);
|
|
} else if (strcmp(mode, "-d") == 0) {
|
|
return decompress(infile, outfile);
|
|
} else {
|
|
print_usage();
|
|
return 1;
|
|
}
|
|
}
|
|
|