usaa24/sk1/main.c

54 lines
1.2 KiB
C
Raw Normal View History

2025-01-17 18:08:33 +00:00
#include "compressor.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void print_help()
{
2025-01-17 18:17:52 +00:00
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");
2025-01-17 18:08:33 +00:00
}
int main(int argc, char* argv[])
{
if (argc < 2)
{
print_help();
return 1;
}
if (strcmp(argv[1], "-h") == 0)
{
print_help();
return 0;
}
2025-01-17 18:17:52 +00:00
else if (strcmp(argv[1], "-c") == 0 && argc == 4)
2025-01-17 18:08:33 +00:00
{
const char* infile = argv[2];
const char* outfile = argv[3];
if (compress_2(infile, outfile) < 0)
{
return 1;
}
2025-01-17 18:17:52 +00:00
//printf("Compressed successfully.\n");
2025-01-17 18:08:33 +00:00
}
2025-01-17 18:17:52 +00:00
else if (strcmp(argv[1], "-d") == 0 && argc == 4)
2025-01-17 18:08:33 +00:00
{
const char* compressed = argv[2];
const char* uncompressed = argv[3];
if (decompress_2(compressed, uncompressed) < 0)
{
return 1;
}
2025-01-17 18:17:52 +00:00
//printf("Decompressed successfully.\n");
2025-01-17 18:08:33 +00:00
}
else
{
print_help();
return 1;
}
return 0;
2025-01-18 12:15:16 +00:00
}