54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
#include "compressor.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
void print_help()
|
|
{
|
|
printf("# skomprimuje infile do súboru outfile\n./compressor -c infile outfile\n");
|
|
printf("# dekomprimuje sUbor compressed a zapise do suboru uncompressed.\n./compressor -d compressed uncompressed\n");
|
|
printf("./compressor -h # Vypíše pomoc");
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
if (argc < 2)
|
|
{
|
|
print_help();
|
|
return 1;
|
|
}
|
|
|
|
if (strcmp(argv[1], "-h") == 0)
|
|
{
|
|
print_help();
|
|
return 0;
|
|
}
|
|
else if (strcmp(argv[1], "-c") == 0 && argc == 4)
|
|
{
|
|
const char* infile = argv[2];
|
|
const char* outfile = argv[3];
|
|
if (compress_2(infile, outfile) < 0)
|
|
{
|
|
return 1;
|
|
}
|
|
//printf("Compressed successfully.\n");
|
|
}
|
|
else if (strcmp(argv[1], "-d") == 0 && argc == 4)
|
|
{
|
|
const char* compressed = argv[2];
|
|
const char* uncompressed = argv[3];
|
|
if (decompress_2(compressed, uncompressed) < 0)
|
|
{
|
|
return 1;
|
|
}
|
|
//printf("Decompressed successfully.\n");
|
|
}
|
|
else
|
|
{
|
|
print_help();
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|