-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.h
executable file
·104 lines (99 loc) · 1.69 KB
/
user.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
char input[30][300];
char forans[30][300];
char forback[30][300];
int functionforcronjob(char args[][300],char cwd[]);
void foreverything(char arr[],char cwd[])
{
int i=0;
char cur[255];
char *array=arr;
char *token;
for(i=0;i<30;i++)
{
memset(forback,0,300);
memset(input,0,300);
memset(forans,0,300);
}
i=0;
while ((token = strtok_r(array,";", &array)))
{
strcpy(input[i],token);
i++;
}
int j=0;
while(j<i)
{
array=input[j];
int k=0;
for(int ik=0;ik<30;ik++)
memset(forans[ik],0,300);
while ((token = strtok_r(array," ", &array)))
{
strcpy(forans[k],token);
k++;
}
if(strcmp(forans[0],"cronjob")==0)
{
if(functionforcronjob(forans,cwd))
j++;
}
else if(builtinfunction(forans,cwd))
j++;
else if (unbuiltfunctions(forans,cwd))
j++;
else
break;
}
return ;
}
void delay(int number_of_seconds)
{
int milli_seconds = 1000 * number_of_seconds;
clock_t start_time = clock();
while (clock() < start_time + milli_seconds)
;
}
int functionforcronjob(char args[][300],char cwd[])
{
int i,l=0,k;
int f=0,b=0,c=0;
char ans[1000]={0};
for(i=0;strcmp(args[i],"")!=0;i++)
{
if(strcmp(args[i],"-c")==0)
f=1;
if(strcmp(args[i],"-t")==0)
b=1;
if(strcmp(args[i],"-p")==0)
c=1;
}
if(f==1&&b==1&&c==1)
{
for(i=2;strcmp(args[i],"-t")!=0;i++)
{
strcat(ans,args[i]);
strcat(ans," ");
}
i++;
int a=atoi(args[i++]);
i++;
int b=atoi(args[i++]);
for (i = 1; i*a <= b; i++)
{
delay(a*1000);
printf("\n");
int pid=fork();
if(pid==0)
{
foreverything(ans,cwd);
_exit(0);
}
else
{
wait(NULL);
}
}
return 1;
}
return 0;
}