-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetenv.c
More file actions
43 lines (35 loc) · 700 Bytes
/
setenv.c
File metadata and controls
43 lines (35 loc) · 700 Bytes
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
#include"global.h"
void call_setenv(char **karsh,int len,int time,int freq)
{
int y;
if(time==-1 || freq==-1)
{
time=0;
freq=0;
y=1;
}
else
{
y = (freq/time);
}
int i=0;
while(i<y)
{
sleep(time);
if(len>=2 && len<=3)
{
if(karsh[2]==NULL)
setenv(karsh[1],"",1);
else
setenv(karsh[1],karsh[2],1);
}
else if(len<2)
fprintf(stderr,"Error: Too few arguements\n");
else if(len>3)
fprintf(stderr,"Error: Too many arguements\n");
int xx=freq-(time*(i+1));
if(xx<time)
sleep(xx);
i++;
}
}