39 lines
767 B
C
39 lines
767 B
C
#include "compressor.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
static void print_help(void) {
|
|
printf("Binary compressor using Huffman coding\n");
|
|
printf("Usage:\n");
|
|
printf(" ./compressor -c input output\n");
|
|
printf(" ./compressor -d input output\n");
|
|
printf(" ./compressor -h\n");
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
if (argc < 2) {
|
|
print_help();
|
|
return 1;
|
|
}
|
|
|
|
if (strcmp(argv[1], "-h") == 0) {
|
|
print_help();
|
|
return 0;
|
|
}
|
|
|
|
if (argc != 4) {
|
|
print_help();
|
|
return 1;
|
|
}
|
|
|
|
if (strcmp(argv[1], "-c") == 0)
|
|
return pack_binary(argv[2], argv[3]);
|
|
|
|
if (strcmp(argv[1], "-d") == 0)
|
|
return unpack_binary(argv[2], argv[3]);
|
|
|
|
print_help();
|
|
return 1;
|
|
}
|
|
|