#include #include #include #include "compressor.h" void print_help() { printf("Usage:\n"); printf(" ./compressor -c1 infile outfile Compress using algorithm 1 (Huffman)\n"); printf(" ./compressor -d1 infile outfile Decompress using algorithm 1 (Huffman)\n"); printf(" ./compressor -c2 infile outfile Compress using algorithm 2 (RLE)\n"); printf(" ./compressor -d2 infile outfile Decompress using algorithm 2 (RLE)\n"); printf(" ./compressor -h Show this help message\n"); } int main(int argc, char* argv[]) { if (argc < 2) { print_help(); return 1; } if (strcmp(argv[1], "-h") == 0) { print_help(); return 0; } if (argc != 4) { fprintf(stderr, "Error: Invalid number of arguments.\n"); print_help(); return 1; } const char* mode = argv[1]; const char* infile = argv[2]; const char* outfile = argv[3]; if (strcmp(mode, "-c1") == 0) { compress_1(infile, outfile); } else if (strcmp(mode, "-d1") == 0) { decompress_1(infile, outfile); } else if (strcmp(mode, "-c2") == 0) { compress_2(infile, outfile); } else if (strcmp(mode, "-d2") == 0) { decompress_2(infile, outfile); } else { fprintf(stderr, "Error: Unknown mode '%s'.\n", mode); print_help(); return 1; } return 0; }