36 lines
1023 B
C
36 lines
1023 B
C
#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;
|
|
} |