home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
lan
/
novprt
/
novprt.asm
next >
Wrap
Assembly Source File
|
1988-03-21
|
11KB
|
479 lines
page 75,132
title 'Perform Print Queue Access on a Novell Network'
cr equ 0dh
lf equ 0ah
STACK segment para stack 'STACK'
db 100 dup('stack ')
STACK ends
psp_seg segment
org 128
cmd_info db 0
psp_seg ends
_DATA segment word public 'DATA'
flag db 0
first_time equ 1
prt_spec equ 2
del_flag equ 4
cmd_flag equ 8
cmd_info_sav db 80 dup(0) ; save area for command line
del_data_sav db 8 dup(0) ; save area for job number to delete
xlate_tbl db '0123456789ABCDEF'
htoa_area db 5 dup(0) ; number conversion area
ps_req dw (ps_req_end-$)-2
db 6 ; function = get printer status
ps_num db 0 ; printer number
ps_req_end db 0h
ps_rep dw (ps_rep_end-$)-2
ps_halt db 0 ; Printer Halted
ps_off db 0 ; Printer Offline
ps_form db 0 ; Printer Form Type
db 0 ; Target Printer
ps_rep_end db 0h
pq_req dw (pq_req_end-$)-2
db 4 ; function = get spool queue entry
pr_num db 0 ; printer number
pr_jnum db 0 ; job number
pq_req_end db 0h
pq_rep dw (pq_rep_end-$)-2
pq_jnum db 0 ; job number
db 0,0 ;...unused...
db 14 dup(' ') ; filename
db 0 ; print volume
db 0 ; print flags
db 0 ; tab size
db 0 ; printer
que_copies db 0 ; copies
que_forms db 0 ; form type
que_sta db 0 ; station
db 6 dup(' ') ; spool time
que_username db 15 dup(' ') ; user name
db 14 dup(' ') ; banner name
db 18 dup(' ') ; path name
db 4 dup(' ') ; userid
pq_rep_end db 0h
dl_req dw (dl_req_end-$)-2
db 5 ; function = kill queue entry
dlr_num db 0 ; printer number
dlr_jobnum db 0 ; job number
dl_req_end db 0h
dl_rep dw (dl_rep_end-$)-2
db 0
db 0
db 0
dl_rep_end db 0h
running db 7,'Running'
halted db 7,'Halted '
offline db 7,'Offline'
online db 7,'Online '
stat_disp db 'Printer '
stat_prt_num db '0',' '
stat_prt_halt db 'Running '
stat_prt_off db 'On-line ','Form='
stat_prt_form db '--',cr,lf,'$'
que_disp db 'Username Sta Forms Copies Job Number ',cr,lf
db '--------------- --- ------- -------- ------------',cr,lf,'$'
prt_username db ' '
db ' '
prt_sta db ' '
db ' '
prt_forms db ' '
db ' '
prt_copies db ' '
db ' '
prt_jnum db ' ',cr,lf,'$'
nothing1 db '.......... Nothing in Print Queue ............',cr,lf,'$'
del_failed db '.............. Delete Failed .................',cr,lf,'$'
del_success db '............. Delete Successful ..............',cr,lf,'$'
_DATA ends
page
_TEXT segment para public 'CODE'
assume cs:_TEXT,ds:_DATA,ss:STACK
start proc far
mov ax,_data
mov es,ax
call get_cmd ; see if any command line input
test flag,del_flag ; was deletion specified?
jz st_02 ; no...
call del_job ; do the delete first
st_02:
call get_printer_status
mov ah,4ch ; return to DOS
int 21h ; *
start endp
page
get_cmd proc near
mov cl,cmd_info
or cl,cl
jz get_cmd_exit
sub ch,ch
mov dx,cx ; save the count
lea di,cmd_info_Sav ; point at area to save to
lea si,cmd_info+1 ; point at area to save from
cld ; forward
rep movsb ; save the string
mov cx,dx ; restore the count
push es
pop ds
lea si,cmd_info_Sav ; point at save area
cmd_scan:
lodsb ; get a character
cmp al,' ' ; blank ?
je next_cmd_char ; yes...
test flag,cmd_flag ; command being processed?
jnz chk_cmd2 ; yes...
cmp al,'0' ; is it less than 0?
jb next_cmd_char ; yes...
cmp al,'4' ; is it GT than 4?
ja chk_cmd ; yes...
test flag,prt_spec ; printer specified yet ?
jnz next_cmd_char ; yes... ignore it
or flag,prt_spec ; indicate printer specified
and al,255-'0' ; make it binary
mov ps_num,al ; set all request buffers for this printer
mov pr_num,al ; *
mov dlr_num,al ; *
jmp short next_cmd_char;
get_cmd_exit:
push es
pop ds
ret
chk_cmd:
and al,255-20h ; force uppercase
cmp al,'D' ; is it a delete request ?
jne next_cmd_char ; no... ignore it
or flag,del_flag ; set deletion flag
or flag,cmd_flag ; set command flag
lea di,del_data_sav ; point at save area
jmp short next_cmd_char;
chk_cmd2:
cmp al,' ' ; is it a space ?
jne chk_cmd3 ; no...
and flag,255-cmd_flag; clear command processing
jmp short next_cmd_char
chk_cmd3:
cmp al,'0' ; is it less than 0?
jb next_cmd_char ; yes...
cmp al,'9' ; is it GT than 9?
ja next_cmd_char ; yes...
stosb ; save the value
next_cmd_char:
loop cmd_scan
and flag,255-cmd_flag; clear command processing
test flag,del_flag ; was a delete specified ?
jz get_cmd_exit ; no...
mov al,del_data_sav ; get a byte
or al,al ; insure data
jnz get_cmd_exit ; ok...
and flag,255-del_flag;clear delete flag
jmp get_cmd_exit
get_cmd endp
page
del_job proc near
lea bx,del_data_sav ; point at job number to delete
call atoi ; make it binary (ret in DX)
mov dlr_jobnum,dl ; set up the job number
mov ax,0e000h ; printer functions
lea si,dl_req
lea di,dl_rep
int 21h ; do the delete
lea dx,del_success
or al,al ; see if it worked
jz del_job_02
lea dx,del_failed
del_job_02:
call disp_data
del_job_exit:
ret
del_job endp
page
get_printer_status proc near
mov cx,1 ; set one iteration
test flag,prt_spec ; was a printer specified ?
jnz gps_loop ; yes...
mov al,0
mov ps_num,al
mov pr_num,al
mov cx,5
gps_loop:
call acq_printer
call disp_printer_status
call get_queue_info
inc ps_num
and flag,255-first_time
loop gps_loop
ret
acq_printer:
mov ax,0e000h ;
lea si,ps_req ; point at request buffer
lea di,ps_rep ; point at reply buffer
int 21h ; do it
ret
get_printer_status endp
get_queue_info proc near
call access_queue_info; get an entry
or al,al ; did we get it ?
jnz no_queue ; nope
mov al,pq_jnum ; get the job number
or al,al ; no job number means not on network
jz no_queue ; then exit
mov pr_jnum,al ; put it in the request buffer
call disp_queue_info ; display what we've got
jmp get_queue_info ; loop till all done
no_queue:
test flag,first_time ; first time ?
jnz nq_01 ; no...
lea dx,nothing1
call disp_data
nq_01:
ret
access_queue_info:
mov ax,0e000h ;
lea si,pq_req ; point at request buffer
lea di,pq_rep ; point at reply buffer
int 21h ; do it
ret
get_queue_info endp
page
;-------------------------------------------------------------------------
; Display Printer Status
;-------------------------------------------------------------------------
disp_printer_status proc near
push cx
mov al,ps_num
or al,30h
mov stat_prt_num,al
lea si,running
lea di,stat_prt_halt
mov al,ps_halt
or al,al
jz dp_01
lea si,halted
dp_01:
call set_msg ; put the message in the field
lea si,online
lea di,stat_prt_off
mov al,ps_off
or al,al
jz dp_02
lea si,offline
dp_02:
sub dx,dx
mov dl,ps_form
call hex_to_dec
mov ax,word ptr htoa_area+2
mov word ptr stat_prt_form,ax
call set_msg ; put the message in the field
lea dx,stat_disp ; point at header
call disp_data ; display it
pop cx
ret
set_msg:
push cx
cld ; insure forward direction
lodsb ; get the length to move
cbw ; make it a word
mov cx,ax ; save it
rep movsb ; move the field
pop cx
ret ; return
disp_printer_status endp
page
;-------------------------------------------------------------------------
; Display Printer Queue Status Info
;-------------------------------------------------------------------------
disp_queue_info proc near
push cx
test flag,first_time ; first time ?
jnz dqi_01 ; no...
lea dx,que_disp ; point at header
call disp_data ; display it
or flag,first_time
dqi_01:
lea si,que_username ; move the username
lea di,prt_username ; *
mov cx,15 ;
rep movsb ;
sub dx,dx
mov dl,que_sta
call hex_to_dec
mov ax,word ptr htoa_area+2
mov word ptr prt_sta,ax
mov dl,que_forms
call hex_to_dec
mov ax,word ptr htoa_area+2
mov word ptr prt_forms,ax
mov dl,que_copies
call hex_to_dec
mov ax,word ptr htoa_area+2
mov word ptr prt_copies,ax
mov dl,pq_jnum
call hex_to_dec
mov ax,word ptr htoa_area+2
mov word ptr prt_jnum,ax
lea dx,prt_username ; point at header
call disp_data ; display it
pop cx
ret
disp_queue_info endp
disp_data:
mov ah,9
int 21h
ret
page
;----------------------------------------------------------------------;
; Converts an ASCII number to binary (integer)
;
; Entry: BX => ASCII data
; EXIT : DX == Binary value
;
;----------------------------------------------------------------------;
atoi proc near ;
push ax
push bx
push cx
push si
sub dx,dx ; zero tally reg
mov si,bx ; use si as base
atoi_1: ;
lodsb ; get a byte
CMP AL,' ' ; is it a space ?
je atoi_1 ; if so, loop
;
atoi_2: ;
CMP AL,'0' ; is it less than 0 ?
jb atoi_3 ; yes... done
CMP AL,3AH ; is it > 9 ?
jnb atoi_3 ; yes... done
and AL,0fH ; strip the sign
cbw ; clear ax
MOV cx,6553 ; check limit
cmp cx,dx ; *
jb atoi_4 ; error....
MOV cx,dx ; multiply by 10
shl dx,1 ; *
shl dx,1 ; *
add dx,cx ; *
shl dx,1 ; *
add dx,ax ; add in new digit
lodsb ; get next character
jmp short atoi_2 ; go process it
; Good return
atoi_3: ;
mov bx,si ; restore BX
DEC bx ; back up by 1
OR AL,AL ; set CC
jmp short atoi_5 ; exit
; Error - set carry and return
atoi_4:
STC ; set carry (error) flag
atoi_5:
pop si ; restore regs
pop cx ; *
pop bx ; *
pop ax ; *
RET ; return to caller
atoi endp
page
;------------------------------------------------------------------------
; Convert Hex to ASCII
;
; Input = DX
; Output = htoa_area
;------------------------------------------------------------------------
hex_to_ascii proc near
push cx
push bx
push di
xor ax,ax
lea di,htoa_area+3 ; point at end of area
std ; we want to decrement
mov al,dl
and al,0fh
lea bx,xlate_tbl
xlat xlate_tbl
stosb
mov al,dl
mov cl,4
shr al,cl
xlat xlate_tbl
stosb
mov al,dh
and al,0fh
xlat xlate_tbl
stosb
mov al,dh
mov cl,4
shr al,cl
xlat xlate_tbl
stosb
cld
pop di
pop bx
pop cx
ret
hex_to_ascii endp
;------------------------------------------------------------------------
; Convert Hex to Decimal (Max 999)
;
; Input = DX
; Output = htoa_area
;------------------------------------------------------------------------
hex_to_dec proc near
push cx
mov ax,3030h ;
mov word ptr htoa_area,ax ; zero first 2 bytes
mov word ptr htoa_area+2,ax ; zero next 2 bytes
mov cx,100 ; assume nothing greater than 999
call hex_to_dec_calc ; do the 100's
mov htoa_area+1,al ; store the 100's
mov cx,10 ; now do the 10's
call hex_to_dec_calc ; do the 10's
mov htoa_area+2,al ; store the 10's
mov cx,1 ; now do the units
call hex_to_dec_calc ; do the 1's
mov htoa_area+3,al ; store the units
pop cx
ret ; return to caller
hex_to_dec_calc:
mov al,-1 ; initialize
htd_loop: ;
inc al ; bump counter by 1
sub dx,cx ; see if occurs
jnc htd_loop ; yes... try again
add dx,cx ; else add it back in
or al,30h ; put in the sign
ret ; return to caller
hex_to_dec endp
_TEXT ends
end start