diff --git a/sk1/main.c b/sk1/main.c index 294989d..3871b00 100644 --- a/sk1/main.c +++ b/sk1/main.c @@ -1,3 +1,36 @@ -int main(){ - +#include +#include +#include +#include "compressor.h" + +void print_help() { + printf("Usage:\n"); + printf(" ./compressor -c infile outfile # Compress infile to outfile\n"); + printf(" ./compressor -d compressed uncompressed # Decompress compressed to uncompressed\n"); + printf(" ./compressor -h # Print this help message\n"); +} + +int main(int argc, char *argv[]) { + if (argc < 2) { + print_help(); + return 1; + } + + const char *command = argv[1]; + + if (strcmp(command, "-h") == 0) { + print_help(); + } else if (strcmp(command, "-c") == 0 && argc == 4) { + const char *input_file = argv[2]; + const char *output_file = argv[3]; + compress_1(input_file, output_file); + } else if (strcmp(command, "-d") == 0 && argc == 4) { + const char *input_file = argv[2]; + const char *output_file = argv[3]; + decompress_1(input_file, output_file); + } else { + print_help(); + return 1; + } + return 0; } \ No newline at end of file