ast_comparator/test/student_data/handout/shlab-handout/cases/42_tsh.c
/* addjob - Add a job to the job list */
Add a job to the job list
Add a job to the job list
int addjob(struct job_t *jobs, pid_t pid, int state, char *cmdline)
{
  int i;
  if (pid < 1)
    return 0;
  for (i = 0; i < MAXJOBS; i++) {
    if (jobs[i].pid == 0) {
      jobs[i].pid = pid;
      jobs[i].state = state;
      jobs[i].jid = nextjid++;
      if (nextjid > MAXJOBS)
        nextjid = 1;
      strcpy(jobs[i].cmdline, cmdline);
      if(verbose){
        printf("Added job [%d] %d %s\n", jobs[i].jid, jobs[i].pid, jobs[i].cmdline);
      }
      return 1;
    }
  }
  printf("Tried to create too many jobs\n");
  return 0;
}
int addjob ( struct job_t * jobs , pid_t pid , int state , char * cmdline ) { int i ; if ( pid < 1 ) return 0 ; for ( i = 0 ; i < MAXJOBS ; i ++ ) { if ( jobs [ i ] . pid == 0 ) { jobs [ i ] . pid = pid ; jobs [ i ] . state = state ; jobs [ i ] . jid = nextjid ++ ; if ( nextjid > MAXJOBS ) nextjid = 1 ; strcpy ( jobs [ i ] . cmdline , cmdline ) ; if ( verbose ) { printf ( " \n " , jobs [ i ] . jid , jobs [ i ] . pid , jobs [ i ] . cmdline ) ; } return 1 ; } } printf ( " \n " ) ; return 0 ; }
addjob - Add a job to the job list
addjob - Add a job to the job list
// fixed!! > printf