-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
72 lines (63 loc) · 1.23 KB
/
main.c
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
64
65
66
67
68
69
70
71
72
/*************************/
/* |\ /| /\ | |\ | */
/* | \/ | /__\ | | \ | */
/* | | / \ | | \| */
/*************************/
#include <kex.h>
#include <utility.h>
GUIMenu guiMain =
{
0,
{
{ " New ", new_file , 5},
{ " Open ", open_file , 6},
{ " Save ", save_file , 6},
{ " Build ", build_file , 7},
{ " Exit ", KeX_exit , 6},
{ "", NULL, 0 }
}
};
// _Static_assert(sizeof(guiMain) == 8, "Check");
int main(int argc, char *argv[]) {
int i = 1, opened = 0, build = 0;
while(i < argc) {
char *par = argv[i];
if(*par == '-') {
par++;
switch(*par) {
case 'b':
build = 1;
break;
case 'h':
printf(
"Usage: %s [options] [input]\n\
List of options:\n\
-b Open and build file\n\
-v Print program version\n\
-h Show this help\n",
*argv
);
return 0;
case 'v':
printf(KEX_CAPTION);
return 0;
default:
printf("usage: %s [options] [input]\n", *argv);
return 0;
}
}
else if(!opened) {
strcpy(file_name, argv[i]);
opened = 1;
}
++i;
}
KeX_init(WIDTH, HEIGHT, TITLEH, MENUH, ROWSW, KEX_CAPTION, &guiMain); // All defines are placed in "utility.h"
if(opened) {
load_file();
if(build)
build_file();
}
KeX_loop();
return 0;
}