usaa24/sk1/main.c
2024-12-14 14:51:40 +01:00

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;
}
}