-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolver.c
More file actions
166 lines (121 loc) · 3.87 KB
/
solver.c
File metadata and controls
166 lines (121 loc) · 3.87 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include "header.h"
/*#include<stdio.h>
#include "spec1.c"
#include "spec2.c"
#include "spec9.c"
#include "spec4.c"
#include "spec7.c"
#include "spec8.c"
#include "spec11.c"
#include "spec12activities.c"
#include "spec13.c"
#include "spec14.c"
#include "spec15.c"
#include"spec16.c"*/
void delay(){
for(int i=0;i<10000;i++);
}
int givecount(char *st,char ch){
int tot=0;
for(int i=0;i<=strlen(st)-1;i++){
if(st[i]==ch){tot++;}
//printf(" %c",st[i]);
}
//printf(" total & are :%d\n",tot);
return tot;
}
void solve(char *command){
//printf("time should 1 solve\n");
char input[strlen(command)+1];
strcpy(input,command);
char orig[strlen(command)+1];
strcpy(orig,command);
//printf("orig %s",orig);
//input contains single command ,as seperated by ; earlier
//1
const char *para=" ";//parameter parsing ' cd Copies ',para=" "
char *tok;
char* cd="warp"; //just change to warp
char *saveptr3 = NULL;
tok = strtok_r(input, para,&saveptr3);
//see strtok.c
if((strstr(orig,"<")!=NULL || strstr(orig,">")!=NULL ||strstr(orig,">>")!=NULL) && strstr(orig,"|")==NULL ){ //not for piping
//printf("comeleted io in solver\n");
io(orig);
return;
//function again calls part 1 in solve() , >,>> ,part 2 inn taht file
}
else if(strstr(orig,"|")!=NULL){
//printf("in pipe solver\n");
pipe_io(orig);
return;
}
else if (strcmp(tok, cd) == 0) {//after cd
tok = strtok_r(NULL, para,&saveptr3); //skipped cd
//tok=strtok(0,para);
while(tok!=NULL ){
//printf("time should 1 solver:%s\n",tok);
extractchangedir(tok);
tok = strtok_r(NULL, para,&saveptr3); //next part
}
//tok = strtok(NULL, para); //next part
//extractchangedir(tok);
//if starts with cd ___
return;
}////// use tok only strstr(strstr,"cd")
// peek - ls command specification 4
else if(strstr(tok,"peek")!=NULL){
execute_ls(orig); //send full command to func
return;
}
// pastevents command specification 5
//directly in main
/// proclore
else if(strstr(tok,"proclore")!=NULL){
execute_proclore(orig);
return;
}
////seek
else if(strstr(tok,"seek")!=NULL){
execute_seek(orig);
return;
}
else if(strstr(tok,"activities")!=NULL){
activities();
return; //some warnings
}
else if (strstr(input, "ping") != NULL) {
execute_ping(orig);
return;
}
else if (strstr(input, "fg") != NULL ||strstr(input, "bg") != NULL){
fgbg(orig);
return;
}
else if(strstr(tok,"iMan")!=NULL){
iMan_comm(orig);
return; //some warnings
}
else if(strstr(tok,"neonate")!=NULL){
neonate(orig);
return; //some warnings
}
else if(strstr(orig,"pastevent")!=NULL){
execute_pastevents(orig,1);
return; //some warnings
}
//2echo
//orig is original command ,as input-> next word
//int bg=0; //default fg foreground
//int len=strlen(orig);
//if(orig[len-1]=='&'){//
// bg=1; //in bg
// orig[len-1]='\0';//system() dosent recognize '&' so handle explicitly
//}
//*********all system commands supporting & bg should come down *******//
//printf("solver :%d %s\n",bg,orig);
//printf("aboev comm %s\n",orig);
else{
command_execute(orig);
}//
}