sk1 edit
This commit is contained in:
parent
eab4543e3c
commit
46a15ce65a
39
sk1/main.c
39
sk1/main.c
@ -5,10 +5,9 @@
|
|||||||
|
|
||||||
void print_help()
|
void print_help()
|
||||||
{
|
{
|
||||||
printf("Usage:\n");
|
printf("# skomprimuje infile do súboru outfile\n./compressor -c infile outfile\n");
|
||||||
printf(" ./compressor -c1/-c2 infile outfile\t\tCompress infile to outfile\n\t\t\t\t\t\t-c1 Compress using LZ77\n\t\t\t\t\t\t-c2 Compress using huffman coding\n\n");
|
printf("# dekomprimuje sUbor compressed a zapise do suboru uncompressed.\n./compressor -d compressed uncompressed\n");
|
||||||
printf(" ./compressor -d1/-d2 compressed uncompressed\tDecompress compressed to uncompressed\n\t\t\t\t\t\t-d1 Decompress ONLY for LZ77\n\t\t\t\t\t\t-d2 Decompress ONLY for huffman coding\n\n");
|
printf("./compressor -h # Vypíše pomoc");
|
||||||
printf(" ./compressor -h\t\t\t\tShow this help message\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
@ -24,49 +23,25 @@ int main(int argc, char* argv[])
|
|||||||
print_help();
|
print_help();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "-c1") == 0 && argc == 4)
|
else if (strcmp(argv[1], "-c") == 0 && argc == 4)
|
||||||
{
|
|
||||||
const char* infile = argv[2];
|
|
||||||
const char* outfile = argv[3];
|
|
||||||
if (compress_1(infile, outfile) < 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Compression failed\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
printf("Compressed successfully.\n");
|
|
||||||
}
|
|
||||||
else if (strcmp(argv[1], "-d1") == 0 && argc == 4)
|
|
||||||
{
|
|
||||||
const char* compressed = argv[2];
|
|
||||||
const char* uncompressed = argv[3];
|
|
||||||
if (decompress_1(compressed, uncompressed) < 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Decompression failed\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
printf("Decompressed successfully.\n");
|
|
||||||
}
|
|
||||||
else if (strcmp(argv[1], "-c2") == 0 && argc == 4)
|
|
||||||
{
|
{
|
||||||
const char* infile = argv[2];
|
const char* infile = argv[2];
|
||||||
const char* outfile = argv[3];
|
const char* outfile = argv[3];
|
||||||
if (compress_2(infile, outfile) < 0)
|
if (compress_2(infile, outfile) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Compression failed\n");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
printf("Compressed successfully.\n");
|
//printf("Compressed successfully.\n");
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "-d2") == 0 && argc == 4)
|
else if (strcmp(argv[1], "-d") == 0 && argc == 4)
|
||||||
{
|
{
|
||||||
const char* compressed = argv[2];
|
const char* compressed = argv[2];
|
||||||
const char* uncompressed = argv[3];
|
const char* uncompressed = argv[3];
|
||||||
if (decompress_2(compressed, uncompressed) < 0)
|
if (decompress_2(compressed, uncompressed) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Decompression failed\n");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
printf("Decompressed successfully.\n");
|
//printf("Decompressed successfully.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user