From 42bd39bb6e4157fb9c2aa27cf7b02ddc05d001bb Mon Sep 17 00:00:00 2001 From: Oleksandr Hryshchenko Date: Sun, 9 Jan 2022 20:20:31 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB(=D0=B0)=20?= =?UTF-8?q?'sk2a/main.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sk2a/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 sk2a/main.c diff --git a/sk2a/main.c b/sk2a/main.c new file mode 100644 index 0000000..c4d3bc0 --- /dev/null +++ b/sk2a/main.c @@ -0,0 +1,24 @@ +#include "compressor.h" + +int main(int argc,char** argv){ + if (argc != 4 || (argv[1][1] != 'c' && argv[1][1] != 'd')){ + printf("Usage: \n"); + printf(" Compress ./compress -c infile.txt outfile.compress\n"); + printf(" decompress ./compress -d outfile.compress infile.txt\n"); + return 0; + } + char* action = argv[1]; + char* infile = argv[2]; + char* outfile = argv[3]; + FILE* inf = fopen(infile,"r"); + FILE* outf = fopen(outfile,"w"); + if (action[1] == 'c'){ + compress(inf,outf); + } + else if (action[1] == 'd'){ + decompress(inf,outf); + } + fclose(inf); + fclose(outf); +} +