ast_comparator/test/student_data/handout/shlab-handout/cases/reference_22_tsh.c
/*
 * Requires:
 *   "jobs" points to an array of MAXJOBS job structures, and "cmdline" is
 *   a properly terminated string.
 *
 * Effects: 
 *   Adds a job to the jobs list. 
 */
"jobs" points to an array of MAXJOBS job structures, and "cmdline" is
a properly terminated string.

Adds a job to the jobs list.
" jobs " points to an array of MAXJOBS job structures and " cmdline " is a properly terminated string . Adds a job to the jobs list .
static int
addjob(JobP jobs, pid_t pid, int state, const 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((char *)jobs[i].cmdline, cmdline);
			if (verbose) {
				printf("Added job [%d] %d %s\n", jobs[i].jid,
				    (int)jobs[i].pid, jobs[i].cmdline);
			}
			return (1);
		}
	}
	printf("Tried to create too many jobs\n");
	return (0);
}
static int addjob ( JobP jobs , pid_t pid , int state , const 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 ( ( char * ) jobs [ i ] . cmdline , cmdline ) ; if ( verbose ) { printf ( " \n " , jobs [ i ] . jid , ( int ) jobs [ i ] . pid , jobs [ i ] . cmdline ) ; } return ( 1 ) ; } } printf ( " \n " ) ; return ( 0 ) ; }
Requires:
   "jobs" points to an array of MAXJOBS job structures, and "cmdline" is
   a properly terminated string.
Requires : " jobs " points to an array of MAXJOBS job structures and " cmdline " is a properly terminated string .
// Remove the "volatile" qualifier using a cast.