From e02241999db2d1d24c5f7c8268de6bbbd635f258 Mon Sep 17 00:00:00 2001 From: Yevhen Kozirovskyi Date: Sun, 19 Jan 2025 14:08:36 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20sk1/main.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sk1/main.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) 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