Here is the third file:
naivepq.h
Code:
const int MAX_JOBS = 100;
/* User-defined type definitions */
typedef char string80[81];
/* define jobtype enumerated type and job struct below. */
typedef enum _jobtype {TEXT, IMAGE, HTML, POSTSCRIPT, OTHERS} jobtype;
typedef struct _job
{
int id;
jobtype kind;
long int duration;
int pages;
string80 who;
}job;
/* public functions: Implementation for these functions are in
naivepq.c */
/**
Function: addjob
Usage: retval = addjob(printq,numjobs);
This function assigns adds a new job to the printq. If there
are already MAX_JOBS in the print queue, the retval is set
to 0 indicating failure: the queue is full and a new job
cannot be added and numjobs remains unchanged.
If the queue is not full, the function calls assignjobid
to obtain a unique id for the new job. The user is then prompted
for other details about the job:
kind -> TEXT, IMAGE, HTML, POSTSCRIPT or OTHERS
pages -> number of pages
who -> job owner
duration -> calculated as follows: TEXT 3 seconds/page, IMAGE 6
seconds/page, HTML 3 seconds/page, POSTSCRIPT 4
seconds/page, OTHERS 7 seconds/page
The numjobs reference parameter is incremented by 1 and all other
jobs are shifted one position to the right. The new job is placed
at the back of the queue (index 0). The function returns 1.
@param printq the array that represents the printer queue
@param numjobs the current number of jobs in the queue
@return returns 1 on success or 0 on failure.
*/
int addjob(job printq[], int& numjobs);
/**
Function: canceljob
Usage: retval = canceljob(printq,numjobs, jobid);
This function cancels a job that has been submitted
to the print queue. The function checks to determine
whether the job id exists. If the job id is invalid, the
function returns 0. Otherwise, it deletes the job from
the queue by shifting every job succeeding the job one
position back, reduces the reference parameter numjobs
by 1 and returns 1 indicating success.
@param printq the array that represents the printer queue
@param numjobs the current number of jobs in the queue
@param jobid a unique integer between 1 and 0 representng
the job identification number.
@return returns 1 on success or 0 on failure.
*/
int canceljob(job printq[], int& numjobs, int jobid);
/**
Function: servicejob
Usage: retval = servicejob(printq,numjobs);
This function removes the job at the front of
the print queue. If the queue is empty, the
the function returns 0 indicating failure.
Otherwise, it deletes the job from the queue by
reducing the reference parameter numjobs
by 1 and returns 1 indicating success.
@param printq the array that represents the printer queue
@param numjobs a reference parameter representing the
current number of jobs in the queue
@return returns 1 on success or 0 on failure.
*/
int servicejob(job printq[], int& numjobs);
/**
Function: printjoblist
Usage: printjoblist(printq,numjobs);
This function prints a listing of all jobs
currently on the queue, one job per line
using the following format:
id -- who -- pages -- duration -- kind (in words)
If the queue is empty, the function prints a
message indicating that there aren't any jobs on
the queue.
@param printq the array that represents the printer queue
@param numjobs the current number of jobs in the queue
@return none.
*/
void printjoblist(job printq[], int numjobs);