Обновить sk1/main.c
This commit is contained in:
parent
cfe455598d
commit
e02241999d
37
sk1/main.c
37
sk1/main.c
@ -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;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user