home *** CD-ROM | disk | FTP | other *** search
- page 58,132
-
- ;/*
- ;** pntspool.asm
- ;** contains: spoolins(), subfile(), canfile(), getqfile(), filesinq()
- ;**
- ;*/
- ifndef _LCODE
- include model.h
- endif
- include prologue.h
- name pntspool
-
- DOSCALL equ 021h ;MSDOS Software Interrupt #
- DOSVERSION equ 030h ;DOS: Get version number
-
- MULTIPLEXINT equ 02fh ;Multiplex Software Interrupt number
- SPOOLERID equ 001h ;Spooler I.D. (AH Register)
-
- ;==>-- Multiplex Interrupt function numbers (AL register)
- ;
- GETINSSTATE equ 000h ;Get installed state function
- SUBMITFILE equ 001h ;Submit file function
- CANCELFILE equ 002h ;Cancel file function
- CANCELALLFILES equ 003h ;Cancel All files
- STATUS equ 004h ;Get status function
- ENDOFSTATUS equ 005h ;End of status function
-
- ;==>-- Multiplex Interrupt Error Codes
- ;
- PSINVALIDFUNCT equ 001h ;Invalid function
- PSFILENOTFOUND equ 002h ;File not found
- PSPATHNOTFOUND equ 003h ;Path not found
- PSTOOMANYFILES equ 004h ;Too many open files
- PSACCESSDENIED equ 005h ;Access denied
- PSQUEUEFULL equ 008h ;Print queue is full
- PSBUSY equ 009h ;Busy
- PSNAMETOOLONG equ 00ch ;Name too long
- PSINVALIDDRIVE equ 00fh ;Invalid drive
-
- SPOOLERPACKET struc
- Level db ?
- Filename dd ?
- SPOOLERPACKET ends
-
- dseg dpntspool
-
- spkt SPOOLERPACKET <0,0>
-
- endds
-
-
- pseg cpntspool
-
- ;/*
- ;** int
- ;** spoolins(void)
- ;**
- ;** ARGUMENT(s)
- ;** None.
- ;**
- ;** DESCRIPTION
- ;** Determines whether or not the print spooler is installed.
- ;**
- ;**
- ;** RETURNS
- ;** TRUE (1) if print spooler is installed, FALSE (0) if it has not
- ;** been installed or if the DOS major version number is less than 3.
- ;**
- ;** AUTHOR
- ;** "" Thu 10-Nov-1988 15:00:04
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc spoolins
- mov ah,DOSVERSION ;Get Dos version number to
- int DOSCALL ;AX (major in AL)
- cmp al,3
- mov ax,0 ;assume not above version 3
- jb spoolinsexit ;check assumption if ok jump
- mov ax,SPOOLERID*256+GETINSSTATE
- int MULTIPLEXINT ;see if spooler installed
- cmp al,0ffh ;if so AL==0xff
- mov ax,0 ;assume not
- jnz spoolinsexit ;check assumption
- inc ax ;else say is installed
- spoolinsexit:
- cproce
-
-
-
- ;/*
- ;** int
- ;** subfile(char *filename)
- ;**
- ;** ARGUMENT(s)
- ;** filename - ASCIIZ string describing filename to be
- ;** added to the print queue. The filename CANNOT
- ;** contain global (wildcard) characters.
- ;**
- ;** DESCRIPTION
- ;** Adds a file to the print queue.
- ;**
- ;** RETURNS
- ;** 0 if successful otherwise a spooler error code.
- ;**
- ;** AUTHOR
- ;** "" Thu 10-Nov-1988 15:29:22
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc subfile
- if _LDATA
- push es
- les bx,parm1_
- mov word ptr spkt.Filename,bx
- mov word ptr spkt.Filename+2,es
- pop es
- else
- mov bx,parm1_
- mov word ptr spkt.Filename,bx
- mov word ptr spkt.Filename+2,ds
- endif
- mov spkt.Level,0
- lea dx,spkt
- mov ax,SPOOLERID*256+SUBMITFILE
- int MULTIPLEXINT
- jc submitexit ;if error code exit with it
- xor ax,ax ;else indicate success
- submitexit:
- cproce
-
- ;/*
- ;** int
- ;** canfile(char *filename)
- ;**
- ;** ARGUMENT(s)
- ;** filename - points to ASCIIZ string of filename to be
- ;** canceled from the print queue.
- ;**
- ;** DESCRIPTION
- ;** Cancels or removes filenames from the print queue. If the filename is
- ;** NULL then all files will be removed. Global filename characters ARE
- ;** allowed in the filename.
- ;**
- ;** RETURNS
- ;** 0 if successful otherwise a spooler error code.
- ;**
- ;** AUTHOR
- ;** "" Thu 10-Nov-1988 14:53:00
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc canfile
- if _LDATA
- push ds
- lds dx,parm1_ ;DS:DX points to string
- mov ax,ds
- or ax,dx ;ZF=1 if NULL pointer
- else
- mov dx,parm1_ ;DS:DX points to string
- mov ax,dx
- or ax,ax ;ZF=1 if NULL pointer
- endif
- mov al,CANCELALLFILES ;assume cancel all files
- jz iscancelall
- mov al,CANCELFILE ;bad assumption cancel one
- iscancelall: mov ah,SPOOLERID ;call spooler
- int MULTIPLEXINT
- if _LDATA
- pop ds
- endif
- jc cancelexit ;if error leave with it
- xor ax,ax ;else return success
- cancelexit:
- cproce
-
- ;/*
- ;** int
- ;** getqfile(int number, char *buffer)
- ;**
- ;** ARGUMENT(s)
- ;** number - Which of the files in the queue to get, 0
- ;** represents the file that is currently
- ;** being printed.
- ;**
- ;** buffer - Buffer in user memory to copy the filename
- ;** into.
- ;**
- ;** DESCRIPTION
- ;** Copies the requested filename from the spooler queue to the users
- ;** buffer. File number 0 is the file that is currently being printed.
- ;**
- ;** RETURNS
- ;** 0 if successful, 1 if the number parameter is greater than the
- ;** number of files in the print queue.
- ;**
- ;** AUTHOR
- ;** "" Thu 10-Nov-1988 16:58:10
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc getqfile
- call GetFilesInQueue
- mov si,parm1_ ;get requested file number
- cmp ax,si
- ja reqisok
- mov ax,SPOOLERID*256+ENDOFSTATUS
- int MULTIPLEXINT ;free queue back up
- mov ax,1 ;say error
- jmp short getqueuedexit
- reqisok: push es
- mov es,bx ;ES:CX points to queue start
- mov ax,64 ;each entry is 64 bytes long
- mul si ;si has the entry number
- add cx,ax ;adjust the offset
- mov di,cx ;and put in di, ES:DI has source
- if _LDATA
- push ds
- lds bx,parm2_
- else
- mov bx,parm2_
- endif
- mov cx,64 ;move 64 bytes the hard way
- movloop: mov al,es:[di]
- mov [bx],al
- inc bx
- inc di
- loop movloop
- if _LDATA
- pop ds
- endif
- pop es
- mov ax,SPOOLERID*256+ENDOFSTATUS
- int MULTIPLEXINT ;free queue back up
- xor ax,ax ;indicate success
- getqueuedexit:
- cproce
-
- ;/*
- ;** int
- ;** filesinq(void)
- ;**
- ;** ARGUMENT(s)
- ;** None.
- ;**
- ;** DESCRIPTION
- ;** Disables the print queue, counts the number of files in the queue,
- ;** then re-enables the print queue for printing.
- ;**
- ;** RETURNS
- ;** Number of files in the queue.
- ;**
- ;** AUTHOR
- ;** "" Thu 10-Nov-1988 16:55:26
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc filesinq
- call GetFilesInQueue
- push ax
- mov ax,SPOOLERID*256+ENDOFSTATUS
- int MULTIPLEXINT ;free queue back up
- pop ax ;return count
- cproce
-
-
- ;/*
- ;** DESCRIPTION
- ;** Helper function to return the number of files in the print queue.
- ;** This function leaves the jobs on hold, you must issue ENDOFSTATUS
- ;** call to release the queue. NOTE: This is not callable from C.
- ;**
- ;** RETURNS
- ;** AX=number of files in the print queue
- ;**
- ;** AUTHOR
- ;** "" Thu 10-Nov-1988 16:20:08
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- GetFilesInQueue proc near
- push ds
- push si
- mov ax,SPOOLERID*256+STATUS ;get pointer to DS:SI
- int MULTIPLEXINT
- mov ax,si ;promote offset to segment
- mov cl,4
- shr ax,cl
- mov bx,ds
- add ax,bx
- mov ds,ax
- and si,0fh
- mov bx,ds
- mov cx,si ;return with BX:CX pointing to start
- xor ax,ax ;counter = 0
- countloop: cmp byte ptr [si],0
- jz countexit
- inc ax
- add si,64
- jmp short countloop
- countexit: pop si
- pop ds
- ret
- GetFilesInQueue endp
- endps
- end
-