.TITLE QUEUESCAN .IDENT /V01.00/ ; ; Author: Chris Chaundy ; Date: 06-Jul-1981 ; ;+ ; Return a list of jobs in a specified queue along with their usernames. ; ; Calling sequence: ; ; CALL QUEUESCAN (retadr, queuename, maxnum, number, entrynum, username) ; ; Inputs: ; retadr - address range that JBCSYSQUE is mapped into ; queuename - name of queue to be scanned ; maxnum - maximum number of entries handled ; ; Outputs: ; number - number of entries found ; entrynum - entry numbers for jobs found ; username - usernames for job found ; ; Side-effects: ; none ; ; Please note that a large quantity of the code in this procedure came from ; SHOWQUE.LIS (M/F 15, N12). ;- ; Equated symbols $SQHDEF $SMQDEF $SJHDEF NAME_SIZ = 12 ; Length of username RETADR = 4 ; Argument offsets QUEUENAME = 8 MAXNUM = 12 NUMBER = 16 ENTRYNUM = 20 USERNAME = 24 ; Main routine .PSECT QUEUESCAN_CODE_,NOWRT,EXE .ENTRY QUEUESCAN,^M ; Look for head of the specified queue MOVL @RETADR(AP),R10 ; Base of queue structure RESTART: ADDL3 #SQH$K_SIZE,R10,R6 ; Address of first que header CLRL @NUMBER(AP) ; Init job count MOVL #1,R7 ; Init queue counter 10$: BBC #SMQ$V_INUSE,SMQ$B_FLAGS(R6),20$ ; Branch if not inuse MOVQ @QUEUENAME(AP),R0 ; Get queue name descriptor MOVAB SMQ$T_NAME(R6),R2 ; Point at queue name CMPB R0,(R2)+ ; Same number of characters? BNEQ 20$ ; No - cannot be equal CMPC3 R0,(R1),(R2) ; Name the same? BEQL JOBSCAN ; Found queue - scan for jobs 20$: ADDL #SMQ$K_SIZE,R6 ; Advance to next header ACBB SQH$B_MAXQUE(R10),#1,R7,10$ ; Loop if more MOVL #1,R0 ; Show success and return RET ; Search current, pending, holding and holding-until queues for jobs JOBSCAN: PUSHAB SRCHQUEUE ; Init coroutine to search q's 10$: JSB @(SP)+ ; Get next job from queue BLBC R0,20$ ; No more current jobs BSBW JOBSTORE ; Store job data BRB 10$ ; Look for another job 20$: MOVL R6,R11 ; Save queue header pointer MOVAQ SQH$K_SIZE(R10),R6 ; Point beyond active queues 30$: CMPL -(R6),-(R6) ; Back up to next queue PUSHAB SRCHQUEUE ; Init coroutine 40$: JSB @(SP)+ ; Next job please BLBC R0,50$ ; That's all for this queue SUBL3 R10,R11,R0 ; Find queue index CMPW R0,SJH$W_QINDEX(R8) ; Is this job in current queue BNEQ 40$ ; Branch if not BSBW JOBSTORE ; Store job data BRB 40$ ; Back for next 50$: MOVAB SQH$Q_QUEUE(R10),R0 ; Get lowest queue address CMPL R6,R0 ; Check against last queue BGTRU 30$ ; Branch if more to do ADDL3 #SMQ$L_HOLDLST,R11,R6 ; Point to hold list PUSHAB SRCHQUEUE ; Init coroutine 60$: JSB @(SP)+ ; Find next job in queue BLBC R0,70$ ; No more in hold list BSBW JOBSTORE ; Store job data BRB 60$ ; Get the next 70$: MOVAB SQH$L_TIMQUE(R10),R6 ; List head for time queue PUSHAB SRCHQUEUE ; Init coroutine 80$: JSB @(SP)+ ; Get next job BLBC R0,90$ ; Branch when no more jobs SUBL3 R10,R11,R0 ; Find queue index CMPW R0,SJH$W_QINDEX(R8) ; Is this job in current queue BNEQ 80$ ; Branch if not BSBW JOBSTORE ; Store job data BRB 80$ ; Back for next 90$: MOVL #1,R0 ; Show success and return RET ; Subroutine to search a queue for the next job (see M/F) SRCHQUEUE: MOVL R6,R7 ; Copy head of que as last seen CLRQ R8 ; Clr last job idx and seq num 10$: CMPW SQH$W_QUESEQ(R10),R9 ; Has queue changed since look BEQL 40$ ; Br if not MOVW SQH$W_QUESEQ(R10),R9 ; Set new sequence MOVL R6,R0 ; Set address of queue header 20$: CMPL R0,R7 ; Found the previous link adr? BEQL 10$ ; If yes - continue with search MOVL (R0),R1 ; Get offset to next job BEQL 70$ ; Br if not found - restart ADDL R10,R1 ; Find address of job CMPL R1,R8 ; Was this job just processed? BNEQ 30$ ; Br if no - must keep looking MOVL R0,R7 ; Previous job gone - set new BRB 10$ ; Continue scan 30$: MOVAL SJH$L_NEXTJOB(R1),R0 ; Set link to next job BRB 20$ ; Continue trying to find place 40$: MOVL (R7),R0 ; Get link to next job BEQL 60$ ; Br if job is gone ADDL R10,R0 ; Find address of job CMPL R0,R8 ; Is this last one processed? BNEQ 50$ ; No, this is a new one, get it MOVAL SJH$L_NEXTJOB(R8),R7 ; Get link address to next job BRB 40$ ; Try for next 50$: CMPW SQH$W_QUESEQ(R10),R9 ; Has queue changed recently? BNEQ 10$ ; Br if yes - resync this op MOVL R0,R8 ; Set address of job processed MOVL #1,R0 ; Set normal status JSB @(SP)+ ; Coroutine return BRW 10$ ; Get next 60$: RSB ; No more jobs 70$: BRW RESTART ; Unable to resync, restart ; Subroutine to store required job information JOBSTORE: MOVL @NUMBER(AP),R0 ; Get job entry index MOVZWL SJH$W_JOBSEQ(R8),@ENTRYNUM(AP)[R0] ; Save seq number MULL #NAME_SIZ,R0 ; Offset into username list ADDL USERNAME(AP),R0 ; Get address in list MOVC3 #NAME_SIZ,SJH$T_USERNAM(R8),(R0) ; Copy job username AOBLSS @MAXNUM(AP),@NUMBER(AP),10$ ; Bump count, check limit MOVL #1,R0 ; Tables full, return RET 10$: RSB .END