int benchmark (void) { prep1((CHARTYPE *) search, 3); exec1((CHARTYPE *) buf, strlen(buf)); prep2((CHARTYPE *) search, 3); exec2((CHARTYPE *) buf, strlen(buf)); return 0; }
int main(int argc, char *argv[], char *envp[]) { char line[256]; char ch; char *pwd; int i; cmd_ptr *cmdptr = NULL; pwd = malloc(sizeof(char) * 1024); jlist = jobs_init(); //signal(SIGCHLD, SIG_DFL); signal(SIGINT, SIG_IGN); signal(SIGTERM, SIG_IGN); signal(SIGQUIT, SIG_IGN); signal(SIGTSTP, SIG_IGN); signal(SIGSTOP, SIG_IGN); for (;;) { struct task *newtask; struct tnode *nodelist; strcpy(pwd, getenv("PWD")); printf("[CSC3150 shell:%s]$", pwd); line[0] = 0; i = 0; while ((ch = getchar()) != '\n') line[i++] = ch; line[i] = 0; if (line[0] == 0) continue; //temp=malloc(sizeof(char)*(strlen(line)+1)); //strcpy(temp,line); if (!firstck(line)) { printf("Error: invalid input command line\n"); continue; } //printf("Error\n"); cmdptr = malloc(sizeof(cmd_ptr)); initialize2(cmdptr); newtask = malloc(sizeof(struct task)); newtask->cmd = malloc(sizeof(char) * (strlen(line) + 1)); strcpy(newtask->cmd, line); jlist->job[jlist->n++] = newtask; if (start_chk(line) == 2) { nodelist = bnode(line); exec1(nodelist); continue; } if (start_chk(line) == 3) getcmd3(line, cmdptr); else if (start_chk(line) == 4) getcmd4(line, cmdptr); else if (start_chk(line) == 5) getcmd5(line, cmdptr); else if (start_chk(line) == 6) getcmd6(line, cmdptr); else if (start_chk(line) == 7) getcmd7(line, cmdptr); else if (start_chk(line) == 8) getcmd8(line, cmdptr); else { printf("Error: invalid input command line\n"); continue; } nodelist = newnode(cmdptr); newtask->tids = execute(nodelist, NULL, NULL); if (newtask->tids != NULL) { jlist->job[jlist->n] = newtask; jlist->n++; } lwait(newtask->tids); } return 0; }