home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol250 / whoprts.a86 < prev   
Encoding:
Text File  |  1986-02-11  |  6.0 KB  |  235 lines

  1. ; An article relating to the following code appeared in the Vol 1 No 4
  2. ; issue of Micro/Systems Journal and is presented here with the per-
  3. ; mission of the publisher. The code alone should be sufficient to
  4. ; use the program.  However, back copies of the article are available from
  5. ; Micro/Systems Journal, Box 1192, Mountainside, NJ 07092.
  6. .cs10
  7. ; WHOPRTS.A86    -  Show Owners of the print devices on CCPM
  8. ;
  9. ;
  10. ;                    Alex K.H. Soya - 12/20/84
  11. ;                    PO BOX 121
  12. ;                    Melbourne Beach
  13. ;                    FL. 32951
  14. ;
  15. ;                    Goliath Concurrent RCPM
  16. ;                    (305) 727-0331
  17. ;
  18. ;                    Compuserve [70406,1452]
  19. ;
  20. ;
  21. ;-----------------------------------------------------------------------;
  22. ; WHOPRTS shows which printers on a Concurrent CPM system        ;
  23. ; are attached to a process or to a console by ctrl-P.            ;
  24. ; Tested under CCPM Vers. 3.1 on a CompuPro. But should work on        ;
  25. ; any system including IBM-PC under Concurrent DOS.            ;
  26. ;                                    ;
  27. ; This program may be freely copied and used by anyone as long as    ;
  28. ; no financial/commercial gain is made. OEMs wishing to include        ;
  29. ; this program with their systems software should contact the        ;
  30. ; author for permission.                        ;
  31. ;                                    ;
  32. ;-----------------------------------------------------------------------;
  33. ; 12/20/84  -  Original Version                        ;
  34. ;   1.0                            Alex Soya    ;
  35. ;-----------------------------------------------------------------------;
  36.  
  37.  
  38. Version        equ    1
  39. Revision    equ    0
  40.  
  41.  
  42. cr        equ    13    ; ASCII carriage return
  43. lf        equ    10    ; ASCII line feed
  44.  
  45.  
  46. ; CCPM    Function calls
  47. ;
  48. P_TERMCPM    equ    0    ; Terminate Job
  49. C_WRITESTR    equ    9    ; Write a string to console
  50. S_BDOSVER    equ    12    ; Return BDOS version number
  51. S_SYSDAT    equ    154    ; Return address of system data segment
  52.  
  53.  
  54. ; Some CCPM offsets
  55. ;
  56. CMDLINE        equ    80h    ; Command line is at 80h in the data segment
  57. LCBPTR        equ    86h    ; Pointer to LCB table in SYSDAT segment
  58. NLCB        equ    48h    ; Number of LCB's in the LCB table
  59.  
  60. è
  61. ;  The start of the Program
  62. ;
  63.     Cseg            ; Code segment starts here, using SMALL model
  64.  
  65.     pushf ! pop bx        ; No interrupts during stack switches
  66.     cli            ; under CCPM
  67.     mov    ax,ds
  68.     mov    ss,ax
  69.     mov    sp, offset STACK
  70.     push bx ! popf        ; restore FLAG register
  71.  
  72.  
  73.     cmp    DS:Byte Ptr .CMDLINE, 0        ; Did he request an option,
  74.     jz    verck                ; nope, go check version.
  75.     mov    cl,C_WRITESTR            ; yes, give him a comercial.
  76.     mov    dx,Offset SECMES
  77.     int    224
  78.  
  79. verck:    mov    cl,S_BDOSVER    ; make sure we are running CCPM
  80.     int    224
  81. .paè    cmp    ah,14h        ; 8086 cpu and Concurent CP/M ?
  82.     jz    verok
  83.     cmp    ah,16h        ; 8086 cpu and concurent CP/M w/ networking
  84.     jz    verok
  85.  
  86.     mov    dx, offset BADVERMES    ; else tell him he is not running what
  87.     mov    cl, C_WRITESTR        ; this is for...
  88.     int    224
  89.  
  90.     jmp    exit        ; and get out of here.
  91.  
  92.  
  93. verok:    mov    dx, offset HEADER        ; Got good version so go for it
  94.     mov    cl, C_WRITESTR            ; Print header message
  95.     int    224
  96.  
  97.     mov    cl,S_SYSDAT            ; Get sysdat segment location
  98.     int    224                ; es = sysdat segment on return
  99.     mov    bx, es:Word Ptr .LCBPTR        ; Get LCB offset
  100.     mov    cl, es:Byte Ptr .NLCB        ; Get Number of LCBs in system
  101.  
  102.     xor    ax,ax                ; start with printer 0
  103.     cmp    cl,0                ; make sure we have printers
  104.     jg    shprtlp                ; if No printers then
  105.     mov    dx, offset NOPMES        ; Write " No Printers budy"
  106.     mov    cl, C_WRITESTR
  107.     int    224
  108.     jmp    exit
  109.  
  110. shprtlp:                    ; lets go to work....
  111.     push    ax                ; Save current printer number
  112.     push    cx                ; Save Number of LCBs to go
  113.     push    bx                ; Save offset to this LCB
  114.  
  115.     call    BINASC                ; convert to Ascii
  116.     mov    Word Ptr PRTNUM,ax        ; stuff name in string
  117.     mov    dx, offset PRTNUM        ; and print printer number
  118.     mov    cl, C_WRITESTR
  119.     int    224
  120.  
  121.     pop    bx                ; restore LCB offset
  122.     push    bx
  123.  
  124.     mov    bx, es: Word Ptr [bx]        ; get Owner offset
  125.  
  126.     cmp    bx,0                ; If No Owner then
  127.     jnz    chkcntp
  128.     mov    dx, offset FREEMESS        ;    Write **FREE**
  129.     mov    cl, C_WRITESTR
  130.     int    224
  131.     jmp    nextprt
  132.  
  133. chkcntp:
  134.     cmp    bx,-1                ; If Cntrl-P then
  135.     jnz    findpdè    mov    dx, offset CPMESS        ;    Write ^P
  136.     mov    cl, C_WRITESTR
  137.     int    224
  138.     pop    bx
  139.     push    bx                ;    Get LCB offset back
  140.     mov    al,es:Byte Ptr .9[bx]
  141.     call    BINASC                ;    convert to Ascii
  142.     mov    Word Ptr CONNUM,ax        ;    stuff name in string
  143.     mov    dx, offset CONNUM        ;    and print console number
  144.     mov    cl, C_WRITESTR
  145.     int    224
  146.     jmp    nextprt
  147.                         ; else
  148. findpd:
  149.     mov    cl,8                ;    copy the name of the
  150.     mov    si,0                ;    process that owns the
  151.     push    bx                ;    printer to PDNAM field
  152. coplp:    mov    al,es:Byte Ptr .8[bx]
  153.     mov    Byte Ptr PDNAM[si],al
  154.     inc    si
  155.     inc    bx
  156.     loopnz    coplp
  157.     pop    bx
  158.  
  159.     push    bx
  160.     mov    dx, offset PDNAM        ;    Write PDNAME
  161.     mov    cl, C_WRITESTR
  162.     int    224
  163.     pop    bx
  164.  
  165.     mov    al, es:Byte ptr .20h[bx]    ;    Get Console number of PD
  166.     call    BINASC                ;    convert to Ascii
  167.     mov    Word Ptr CONNUM,ax        ;    stuff name in string
  168.     mov    dx, offset CONNUM        ;    and print console number
  169.     mov    cl, C_WRITESTR
  170.     int    224
  171. nextprt:
  172.     pop    bx
  173.     pop    cx
  174.     pop    ax
  175.     add    bx,10                ;    point to next lcb
  176.     inc    al                ;    next printer number
  177.     loopne    shprtlp                ; Do all LCB's
  178.  
  179.     mov    dx, offset CRLF
  180.     mov    cl, C_WRITESTR            ; send a CR,LF
  181.     int    224
  182.  
  183. exit:    mov    cl,P_TERMCPM            ; and terminate
  184.     int    224
  185.  
  186.  
  187.  
  188.  
  189. èBINASC: xor    ah,ah                ; convert
  190.     aam                    ; AX to ASCII
  191.     add    ax,3030h
  192.     xchg    ah,al                ; put in right order
  193.     ret
  194.  
  195.  
  196.  
  197.  
  198.     DSEG            ; Data segment starts here
  199.  
  200.     org 100h        ; we are using the SMALL model
  201.  
  202.  
  203. BADVERMES db    '+++ Requires Concurent CP/M-86 +++',cr,lf,'$'
  204.  
  205. HEADER    db    cr,lf
  206.     db    'Printer   Owner    Console',cr,lf,cr,lf,'$'
  207.  
  208. NOPMES    db    '+++ No printer found on system +++',cr,lf,'$'
  209.  
  210. PRTNUM    db    'xx   -    ','$'        ; Printer Number
  211.  
  212. PDNAM    db    'xxxxxxxx    ','$'        ; Owners Name
  213.  
  214. CPMESS    db    'Cntrl-P     ','$'        ; Control-P message
  215.  
  216. FREEMESS db    '**FREE** ',cr,lf,'$'        ; Printer is FREE
  217.  
  218. CONNUM    db    'xx',cr,lf,'$'            ; Console Number
  219.  
  220. CRLF    db    cr,lf,cr,lf,'$'
  221.  
  222. SECMES    db    'WHOPRTS ',Version+'0','.',Revision+'0',' '
  223.     db    '- (C) 1984, 1985 Alex K. Soya',cr,lf
  224.     db    'P.O. Box 121, Melbourne Beach, FL 32951, U.S.A.',cr,lf,cr,lf
  225.     db    '$'
  226.  
  227.  
  228.     rw    31
  229. stack    dw    0        ; use DW so GENCMD includes stack space in
  230.                 ; the header.
  231.  
  232.     end            ; that's all folks....time for a beer
  233.  
  234.    
  235.