-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
63 lines (52 loc) · 2.06 KB
/
main.c
File metadata and controls
63 lines (52 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include "global.h"
#include "file.h"
#include "shell.h"
void print_label();
/**
* Vstupní funkce, která se spustí jako první. Zkontroluje
* počet vstupních parametrů, načte(naformátuje) vstupní soubor
* a spustí shell pro naslouchání příkazů.
* @param argc počet vstupních parametrů
* @param argv pole vstupních parametrů
* @return
*/
int main(int argc, char *argv[]) {
//zda zadaný vstupní soubor existuje nebo ne
int return_value;
//kontrola vstupních paramterů
if(argc != 2){
print_message("Wrong count of parameters!");
print_message("EXIT");
exit(EXIT_FAILURE);
}
print_label();
global_file_name = argv[1];
//pokus o načtení souboru
return_value = read_file(argv[1]);
//start shellu pro naformátování nového souboru (pouze pokud neexistuje)
if(return_value == -1){
shell_format(argv[1]);
}
//načtení souboru, ted už existuje
read_file(argv[1]);
//start shellu pro naslouchání příkazů
shell(argv[1]);
return EXIT_SUCCESS;
}
void print_label(){
printf("\t __ __ ________ ________ ______ \n");
printf("\t / \\ / / / / \\ \n");
printf("\t _____ ____ __ __$$ \\ $$ $$$$$$$$/$$$$$$$$/$$$$$$ |\n");
printf("\t/ \\/ \\/ | / $$$ \\$$ | $$ | $$ |__ $$ \\__$$/ \n");
printf("\t$$$$$$ $$$$ $$ | $$ $$$$ $$ | $$ | $$ | $$ \\ \n");
printf("\t$$ | $$ | $$ $$ | $$ $$ $$ $$ | $$ | $$$$$/ $$$$$$ |\n");
printf("\t$$ | $$ | $$ $$ \\__$$ $$ |$$$$ | $$ | $$ | / \\__$$ |\n");
printf("\t$$ | $$ | $$ $$ $$ $$ | $$$ | $$ | $$ | $$ $$/ \n");
printf("\t$$/ $$/ $$/ $$$$$$$ $$/ $$/ $$/ $$/ $$$$$$/ \n");
printf("\t / \\__$$ | \n");
printf("\t $$ $$/ \n");
printf("\t $$$$$$/ \n");
}