ast_comparator/test/student_data/handout/shlab-handout/cases/53_tsh.c
/* add_job - Add a job to the job list
 * Returns newly added job structure if success, NULL if not.
 */
Add a job to the job list
Returns newly added job structure if success, NULL if not.
Add a job to the job list Returns newly added job structure if success NULL if not .
struct job_t *add_job(struct job_t *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(jobs[i].cmdline, cmdline);
			if (verbose)
			{
				printf("Added job [%d] %d %s", jobs[i].jid, jobs[i].pid, jobs[i].cmdline);
			}
			return &jobs[i];
		}
	}
	printf("Tried to create too many jobs\n");
	return NULL;
}
struct job_t * add_job ( struct job_t * 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 ( jobs [ i ] . cmdline , cmdline ) ; if ( verbose ) { printf ( " " , jobs [ i ] . jid , jobs [ i ] . pid , jobs [ i ] . cmdline ) ; } return & jobs [ i ] ; } } printf ( " \n " ) ; return NULL ; }
add_job - Add a job to the job list
 Returns newly added job structure if success, NULL if not.
add_job - Add a job to the job list Returns newly added job structure if success NULL if not .