sk1
This commit is contained in:
parent
e4f772058e
commit
f542d93d35
18
sk1/main.c
18
sk1/main.c
@ -13,21 +13,21 @@ void print_help() {
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int result = 1;
|
||||
int res = 1;
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Chyba: Chybaju argumenty. Pouzite -h pre zobrazenie pomoci.\n");
|
||||
result = 0;
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "-h") == 0) {
|
||||
print_help();
|
||||
result = 0;
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if ((strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "-d") == 0 ||
|
||||
strcmp(argv[1], "-c2") == 0 || strcmp(argv[1], "-d2") == 0) && argc != 4) {
|
||||
fprintf(stderr, "Chyba: Nespravny pocet argumentov. Pouzite -h pre zobrazenie pomoci.\n");
|
||||
result = 0;
|
||||
res = 0;
|
||||
}
|
||||
|
||||
const char* input_file = argv[2];
|
||||
@ -38,29 +38,29 @@ int main(int argc, char* argv[]) {
|
||||
result = compress_1(input_file, output_file);
|
||||
if (result < 0) {
|
||||
fprintf(stderr, "Chyba: Kompresia zlyhala.\n");
|
||||
result = 0;
|
||||
res = 0;
|
||||
}
|
||||
} else if (strcmp(argv[1], "-d") == 0) {
|
||||
result = decompress_1(input_file, output_file);
|
||||
if (result < 0) {
|
||||
fprintf(stderr, "Chyba: Dekompresia zlyhala.\n");
|
||||
result = 0;
|
||||
res = 0;
|
||||
}
|
||||
} else if (strcmp(argv[1], "-c2") == 0) {
|
||||
result = compress_2(input_file, output_file);
|
||||
if (result < 0) {
|
||||
fprintf(stderr, "Chyba: Kompresia zlyhala.\n");
|
||||
result = 0;
|
||||
res = 0;
|
||||
}
|
||||
} else if (strcmp(argv[1], "-d2") == 0) {
|
||||
result = decompress_2(input_file, output_file);
|
||||
if (result < 0) {
|
||||
fprintf(stderr, "Chyba: Dekompresia zlyhala.\n");
|
||||
result = 0;
|
||||
res = 0;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Chyba: Neznámy argument. Použite -h pre zobrazenie pomoci.\n");
|
||||
result = 0;
|
||||
res = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user