-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
48 lines (41 loc) · 1.08 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
#include "main.h"
int main(int argc, char *argv[])
{
notmon_t *notmon = malloc(sizeof(notmon_t));
if(notmon)
{
Construct(notmon);
for(int st0 = 1; st0 < argc; ++st0)
{
if(argv[st0] != NULL)
{
char *save_str = malloc(sizeof(char) * (strlen(argv[st0]) + 1));
strcpy(save_str, argv[st0]);
char *stage0 = strtok(save_str, "=");
if(strcmp(stage0, "-config") == 0)
{
stage0 = strtok(NULL, "=");
if(stage0)
{
notmon->config->locate = malloc(sizeof(char) * (strlen(stage0) + 1));
strcpy(notmon->config->locate, stage0);
}
}
if(strcmp(stage0, "-terminal") == 0)
{
stage0 = strtok(NULL, "=");
if(stage0 && strcmp(stage0, "enable") == 0)
notmon->config->terminal_enable = 1;
else
notmon->config->terminal_enable = 0;
}
free(save_str);
}
}
DaemonStart(notmon);
Destruct(notmon);
}
else
printf("-> Error: cant allocate memory for this pattern\n");
return 0;
}