.enabl lc .title fspool - Queue file for print (P/OS) .ident "POS001" .nlist bex,cnd,toc ; ;+ ; index fspool - Queue file for print (P/OS) ; ; Usage ; ; fspool(fp); ; FILE *fp; /* Open file IOV */ ; ; Description ; ; This function may be called in lieu of fclose() when it is ; desired to send the file to the P/OS print services for printing. ; ; Fspool() returns zero if the file was queued for printing by ; P/OS, or an error code if the file could not be printed. The ; error codes returned are those issued by the P/OS "callable ; print service", unless the 'file' was not really a file, in ; which case fspool() returns -1 if the 'file' closes normally. ; ; If the file was opened via the fwild()/fnext() services, the ; internal buffers are not freed, allowing the program to call ; fnext() for subsequent files. ; ; WARNING - Uses over 200 bytes of stack to maintain re-entrancy. ; ; Internal ; ; This routine is the replacement for FSPOOL for P/OS use. Since ; it requires making a call to a routine in the P/OS SYSLIB that ; is not present in RSX-flavor SYSLIBs, there is no easy way to ; make the difference transparent at run-time. This module should ; replace FSPOOL in P/OS libraries. ; ; Bugs ; ;- ; ; Edits: ; ; POS001 02-Jan-84 RBD Initial edit on P/OS ; .psect c$code fspool:: jsr r5,csv$ ; Link environments clr $$ferr ; No errors (yet) mov C$PMTR(r5),r4 ; R4 --> IOV bit #VF$FIL,V$FLAG(r4) ; Is it a real file? bne 10$ ; (yes) ; ; Non-files are handled nicely. ; The call is converted into an fclose(). ; clr r0 ; Signal normal close call $$clos ; Close the 'file' br 100$ ; ; Fill in an automatic buffer with the full filespec. ; 10$: sub #64.,sp ; Make a filename buffer mov sp,r3 ; r3 --> filename buffer mov r3,-(sp) ; Push buffer address mov r4,-(sp) ; Push IOV call fgetname ; Get the full filename cmp (sp)+,(sp)+ ; Strip off arguments ; ; Close the file, preserving buffers if it's on an fwild/fnext ; roll. ; clr r0 ; R0 = zero means "real" close bit #VF$WLD,V$WFLG(r4) ; File engaged in wildcarding? beq 20$ ; (no) mov r4,r0 ; Yes, close fnext-style 20$: call $$clos ; ; Call P/OS print system to print the file ; mov r5,-(sp) ; Save r5 sub #4,sp ; Make a status block mov sp,r2 ; r2 --> status sub #<75.*2>,sp ; Make request array mov sp,r1 ; r1 --> request array mov #1,(r1) ; Request "print file" mov r1,-(sp) ; Save r1 mov r3,-(sp) ; Push filespec string address call strlen ; r0 = length of filespec mov (sp)+,r3 ; (Not really necessary) mov (sp),r1 ; Restore r1 mov r0,(sp) ; sp --> length mov sp,r0 ; r0 --> length ; ; At this point: ; r0 --> filespec length ; r1 --> request array ; r2 --> status block ; r3 --> filespec ; Now we push a FORTRAN-style argument block ; mov r0,-(sp) ; Push the address of the length mov r3,-(sp) ; Push the filespec address mov r1,-(sp) ; Push the request array address mov r2,-(sp) ; Push the status block address mov #4,-(sp) ; Push argument count mov sp,r5 ; R5 --> argument block call cprnt ; Queue for printing tst (sp)+ ; Pop count mov (sp)+,r2 ; r2 --> status block add #162.,sp ; Cut back stack mov (sp)+,r5 ; Restore frame pointer ; ; If it succeeded, return 0, else return 2nd status word. ; clr r0 ; Assume success tst (r2) ; Well? bpl 100$ ; (OK) mov 2(r2),r0 ; Error, return status[1] 100$: jmp cret$ .end