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