Spooler Programmer's Guide

Sample Perusal Process
Spooler Programmer’s Guide522287-002
B-9
END;
?page
! jobchange changes the current job to the one specified in the
! parameter. If jobnum is not owned by the current user, then no change
! is made.
PROC jobchange (jobnum);
INT jobnum;
BEGIN
INT error^code,
temp;
! Get the status of the specified job
job.number := jobnum;
error^code := SPOOLERSTATUS(supernum, 2, 0, job);
IF error^code <> 0 THEN
BEGIN
CALL err(error^code);
! Error handling
END
ELSE
BEGIN
! If owner ID matches, then make the specified job the current job.
IF job.owner^id = userid THEN
current^job := jobnum
ELSE
BEGIN
CALL err(6156);
! 6156 = security violation
END;
END;
END;
?page
! dev displays the status of a device and the jobs in its queue.
PROC dev(device);
INT .device;
BEGIN
INT error^code,
temp,
line^total := 0;
! Prepare the header line of the display
line[0] := " ";
line[1] ':=' line[0] FOR 79;
line[0] ':=' "DEVICE STATE: ";
line[28] ':=' "FORM:";
dev^stat.name ':=' device FOR 16;
! Get the status of the specified device
error^code := SPOOLERSTATUS(supernum, 1, 0, dev^stat);
IF error^code <> 0 THEN call err(error^code)
ELSE
! Produce the display
BEGIN
CASE dev^stat.state OF
BEGIN
!0! call err(dev^stat.state);
!1! line[14] ':=' "WAITING";
!2! line[14] ':=' "PRINTING";
!3! line[14] ':=' "SUSPENDED";
!4! line[14] ':=' "DEVERROR";
!5! line[14] ':=' "OFFLINE";
!6! line[14] ':=' "PROCERROR";
OTHERWISE CALL err (dev^stat.state);
END;