diff --git a/sk1/main.c b/sk1/main.c new file mode 100644 index 0000000..01c6ca1 --- /dev/null +++ b/sk1/main.c @@ -0,0 +1,32 @@ +#include "compressor.h" +#include + +int main(int argc, char* argv[]) { + if (argc != 4 || (argv[1][1] != 'c' && argv[1][1] != 'd')) { + printf("Usage: %s -c input output\n", argv[0]); + printf("Usage: %s -d output input\n", argv[0]); + return 1; + } + + FILE* infile = fopen(argv[2], "rb"); + FILE* outfile = fopen(argv[3], "wb"); + + if (infile == NULL || outfile == NULL) { + perror("Error opening files"); + return 1; + } + + if (strcmp(argv[1], "-c") == 0) { + compress(infile, outfile); + } else if (strcmp(argv[1], "-d") == 0) { + decompress(infile, outfile); + } else { + fprintf(stderr, "Invalid option: %s\n", argv[1]); + return 1; + } + + fclose(infile); + fclose(outfile); + + return 0; +}