Обновить sk1/main.c

This commit is contained in:
Yevhen Kozirovskyi 2025-01-19 14:08:36 +00:00
parent cfe455598d
commit e02241999d

View File

@ -1,3 +1,36 @@
int main(){
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;
}