#include "compressor.h" #include #include void print_help() { printf("Usage:\n"); printf(" ./compressor -c infile outfile Compress using default algorithm (Huffman)\n"); printf(" ./compressor -d infile outfile Decompress using default algorithm (Huffman)\n"); printf(" ./compressor -h Print help\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* input_file = argv[2]; const char* output_file = argv[3]; int result = -1; if (strcmp(argv[1], "-c") == 0) { result = compress_1(input_file, output_file); } else if (strcmp(argv[1], "-d") == 0) { result = decompress_1(input_file, output_file); } else { fprintf(stderr, "Error: Unknown option '%s'.\n", argv[1]); print_help(); return 1; } if (result < 0) { fprintf(stderr, "Error: Operation failed.\n"); return 1; } printf("Operation completed successfully.\n"); return 0; }