int main(void) { static unsigned x; initprg(); initgame(); clrscr(); printf("Alpha test AR-Chess V 1.0\n" "Copyright November 30, 1992\n" "\nMr. Carey Bloodworth\n" "\nThis program may be freely\n" "copied and modified as long\n" "as my name is present as the\n" "original author.\n" "Sharp 7xx port: A.R. Pruss"); ozdelay64hz(200); /* ozsendscreen(); */ while (! quit) { if ( /* (breakpress) || */ (draw) || (mate) || ((tomove==human) && (!bothsides)) ) inputcommand(); printboard(); /* if (pvsflag) { currow=7; atright(); printf(pvsmsg); } */ if (status[0]) { currow=8; atright(); printf(status); } currow=6; atright(); printf(msg); if (! (quit || mate || draw)) selectmove(tomove); /* if (! breakpress) */ tomove=chngcolor(tomove); }; endprg(); return 0; }
int execute_builtin(char** Newargs, int newSize, struct Status *newStatus) { char dir[100]; int i, exitval; //Check arguments for I/O redirection symbols. Execute I/O redirection function if symbols are found. for(i = 0; i < newSize; i++) { if (strcmp(Newargs[i], ">") == 0) { //call function output outputcommand(Newargs, newStatus, i, newSize); return 0; } else if (strcmp(Newargs[i], "<") == 0) { //call function input inputcommand(Newargs, newStatus, i, newSize); return 0; } } //Check and execute built in commands: cd, exit, status. Check for comments: "#" if(strcmp(Newargs[0], "cd") == 0) { if(Newargs[1] == NULL) { chdir(getenv("HOME")); } else { getcwd(dir, sizeof(dir)); strcat(dir, "/"); strcat(dir, Newargs[1]); if(chdir(dir) == -1) { perror("smallsh"); return 1; } } return 0; } //Exit smallsh if exit command is entered (exit or Exit). else if(strcmp(Newargs[0], "exit") == 0 || strcmp(Newargs[0], "Exit") == 0) { exit(EXIT_SUCCESS); } //Check and print exit status or terminating signal else if(strcmp(Newargs[0], "status") == 0) { checkstatus(newStatus); return 0; } //Return if the line is a comment "#". else if(strcmp(Newargs[0], "#") == 0) { return 0; } //Execute commands by starting and running a new process via fork() and execvp(). else exitval = execute_command(Newargs, newSize, newStatus); return exitval; }