MCPcopy Create free account
hub / github.com/OpenIPC/firmware / doscript

Function doscript

general/package/comgt/src/comgt.c:1379–1543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1377}
1378
1379int doscript(void) {
1380 int a,b;
1381 int exitcode=0;
1382 char line[STRINGL];
1383 pc=0;
1384 while(script[pc]) {
1385 if(script[pc]=='\n') pc++;
1386 lastpc=pc;
1387 skipspaces();
1388 if(verbose) printwhere();
1389 if(gettoken()) serror("Could not gettoken()",5);
1390 if(strcmp(token,"rem")==0) {
1391 skipline();
1392 }
1393 else if (strcmp(token,"label")==0) {
1394 skiptoken(); /* Get rid of keyword */
1395 }
1396 else if(strcmp(token,"open")==0) {
1397 doopen();
1398 }
1399 else if(strcmp(token,"opengt")==0) {
1400 opengt();
1401 }
1402 else if(strcmp(token,"close")==0) {
1403 doclose();
1404 }
1405 else if(strcmp(token,"exec")==0) {
1406 getstring();
1407 strcpy(msg,"exec ");
1408 strcat(msg,string); /* Let sh do all the command line work! */
1409 execl("/bin/sh","sh","-c",msg,(char *)0);
1410 serror("Could not execl /bin/sh!",8);
1411 }
1412 else if(strcmp(token,"exit")==0) {
1413 ext(getvalue());
1414 }
1415 else if(strcmp(token,"testkey")==0) {
1416 dotestkey();
1417 }
1418 else if(strcmp(token,"kill")==0) {
1419 a=getvalue();
1420 resultcode=kill(getvalue(),a);
1421 }
1422 else if(strcmp(token,"fork")==0) {
1423 resultcode=fork();
1424 }
1425 else if(strcmp(token,"hset")==0) {
1426 hset=0;
1427 hstart=time(0);
1428 hset=htime()-getvalue();
1429 }
1430 else if(strcmp(token,"cd")==0) {
1431 getstring();
1432 resultcode=chdir(string);
1433 }
1434 else if(strcmp(token,"putenv")==0) {
1435 getstring();
1436 strcpy(line,string);

Callers 1

mainFunction · 0.85

Calls 15

skipspacesFunction · 0.85
printwhereFunction · 0.85
gettokenFunction · 0.85
serrorFunction · 0.85
skiplineFunction · 0.85
skiptokenFunction · 0.85
doopenFunction · 0.85
opengtFunction · 0.85
docloseFunction · 0.85
getstringFunction · 0.85
extFunction · 0.85
getvalueFunction · 0.85

Tested by

no test coverage detected