home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / PNTSPOOL.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  7.4 KB  |  320 lines

  1.         page    58,132
  2.  
  3. ;/*
  4. ;** pntspool.asm
  5. ;** contains: spoolins(), subfile(), canfile(), getqfile(), filesinq()
  6. ;**
  7. ;*/
  8.         ifndef    _LCODE
  9.          include model.h
  10.         endif
  11.         include prologue.h
  12.         name    pntspool
  13.  
  14. DOSCALL     equ    021h            ;MSDOS Software Interrupt #
  15. DOSVERSION    equ    030h            ;DOS: Get version number
  16.  
  17. MULTIPLEXINT    equ    02fh            ;Multiplex Software Interrupt number
  18. SPOOLERID    equ    001h            ;Spooler I.D. (AH Register)
  19.  
  20. ;==>--    Multiplex Interrupt function numbers (AL register)
  21. ;
  22. GETINSSTATE    equ    000h            ;Get installed state function
  23. SUBMITFILE    equ    001h            ;Submit file function
  24. CANCELFILE    equ    002h            ;Cancel file function
  25. CANCELALLFILES    equ    003h            ;Cancel All files
  26. STATUS        equ    004h            ;Get status function
  27. ENDOFSTATUS    equ    005h            ;End of status function
  28.  
  29. ;==>--    Multiplex Interrupt Error Codes
  30. ;
  31. PSINVALIDFUNCT    equ    001h            ;Invalid function
  32. PSFILENOTFOUND    equ    002h            ;File not found
  33. PSPATHNOTFOUND    equ    003h            ;Path not found
  34. PSTOOMANYFILES    equ    004h            ;Too many open files
  35. PSACCESSDENIED    equ    005h            ;Access denied
  36. PSQUEUEFULL    equ    008h            ;Print queue is full
  37. PSBUSY        equ    009h            ;Busy
  38. PSNAMETOOLONG    equ    00ch            ;Name too long
  39. PSINVALIDDRIVE    equ    00fh            ;Invalid drive
  40.  
  41. SPOOLERPACKET    struc
  42.     Level        db    ?
  43.     Filename    dd    ?
  44. SPOOLERPACKET    ends
  45.  
  46.         dseg    dpntspool
  47.  
  48. spkt        SPOOLERPACKET <0,0>
  49.  
  50.         endds
  51.  
  52.  
  53.         pseg    cpntspool
  54.  
  55. ;/*
  56. ;**  int
  57. ;** spoolins(void)
  58. ;**
  59. ;** ARGUMENT(s)
  60. ;**  None.
  61. ;**
  62. ;** DESCRIPTION
  63. ;**  Determines whether or not the print spooler is installed.
  64. ;**
  65. ;**
  66. ;** RETURNS
  67. ;**  TRUE (1) if print spooler is installed, FALSE (0) if it has not
  68. ;**  been installed or if the DOS major version number is less than 3.
  69. ;**
  70. ;** AUTHOR
  71. ;**  ""   Thu 10-Nov-1988    15:00:04
  72. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  73. ;**
  74. ;** MODIFICATIONS
  75. ;**
  76. ;*/
  77.         cproc    spoolins
  78.         mov    ah,DOSVERSION        ;Get Dos version number to
  79.         int    DOSCALL         ;AX (major in AL)
  80.         cmp    al,3
  81.         mov    ax,0            ;assume not above version 3
  82.         jb    spoolinsexit        ;check assumption if ok jump
  83.         mov    ax,SPOOLERID*256+GETINSSTATE
  84.         int    MULTIPLEXINT        ;see if spooler installed
  85.         cmp    al,0ffh         ;if so AL==0xff
  86.         mov    ax,0            ;assume not
  87.         jnz    spoolinsexit        ;check assumption
  88.         inc    ax            ;else say is installed
  89. spoolinsexit:
  90.         cproce
  91.  
  92.  
  93.  
  94. ;/*
  95. ;**  int
  96. ;** subfile(char *filename)
  97. ;**
  98. ;** ARGUMENT(s)
  99. ;**    filename    -    ASCIIZ string describing filename to be
  100. ;**                added to the print queue.  The filename CANNOT
  101. ;**                contain global (wildcard) characters.
  102. ;**
  103. ;** DESCRIPTION
  104. ;**  Adds a file to the print queue.
  105. ;**
  106. ;** RETURNS
  107. ;**  0 if successful otherwise a spooler error code.
  108. ;**
  109. ;** AUTHOR
  110. ;**  ""   Thu 10-Nov-1988    15:29:22
  111. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  112. ;**
  113. ;** MODIFICATIONS
  114. ;**
  115. ;*/
  116.         cproc    subfile
  117.         if    _LDATA
  118.          push    es
  119.          les    bx,parm1_
  120.          mov    word ptr spkt.Filename,bx
  121.          mov    word ptr spkt.Filename+2,es
  122.          pop    es
  123.         else
  124.          mov    bx,parm1_
  125.          mov    word ptr spkt.Filename,bx
  126.          mov    word ptr spkt.Filename+2,ds
  127.         endif
  128.         mov    spkt.Level,0
  129.         lea    dx,spkt
  130.         mov    ax,SPOOLERID*256+SUBMITFILE
  131.         int    MULTIPLEXINT
  132.         jc    submitexit        ;if error code exit with it
  133.         xor    ax,ax            ;else indicate success
  134. submitexit:
  135.         cproce
  136.  
  137. ;/*
  138. ;**  int
  139. ;** canfile(char *filename)
  140. ;**
  141. ;** ARGUMENT(s)
  142. ;**  filename        -    points to ASCIIZ string of filename to be
  143. ;**                canceled from the print queue.
  144. ;**
  145. ;** DESCRIPTION
  146. ;**  Cancels or removes filenames from the print queue.  If the filename is
  147. ;**  NULL then all files will be removed.  Global filename characters ARE
  148. ;**  allowed in the filename.
  149. ;**
  150. ;** RETURNS
  151. ;**  0 if successful otherwise a spooler error code.
  152. ;**
  153. ;** AUTHOR
  154. ;**  ""   Thu 10-Nov-1988    14:53:00
  155. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  156. ;**
  157. ;** MODIFICATIONS
  158. ;**
  159. ;*/
  160.         cproc    canfile
  161.         if    _LDATA
  162.          push    ds
  163.          lds    dx,parm1_        ;DS:DX points to string
  164.          mov    ax,ds
  165.          or    ax,dx            ;ZF=1 if NULL pointer
  166.         else
  167.          mov    dx,parm1_        ;DS:DX points to string
  168.          mov    ax,dx
  169.          or    ax,ax            ;ZF=1 if NULL pointer
  170.         endif
  171.         mov    al,CANCELALLFILES    ;assume cancel all files
  172.         jz    iscancelall
  173.         mov    al,CANCELFILE        ;bad assumption cancel one
  174. iscancelall:    mov    ah,SPOOLERID        ;call spooler
  175.         int    MULTIPLEXINT
  176.         if    _LDATA
  177.          pop    ds
  178.         endif
  179.         jc    cancelexit        ;if error leave with it
  180.         xor    ax,ax            ;else return success
  181. cancelexit:
  182.         cproce
  183.  
  184. ;/*
  185. ;**  int
  186. ;** getqfile(int number, char *buffer)
  187. ;**
  188. ;** ARGUMENT(s)
  189. ;**    number        -    Which of the files in the queue to get, 0
  190. ;**                represents the file that is currently
  191. ;**                being printed.
  192. ;**
  193. ;**    buffer        -    Buffer in user memory to copy the filename
  194. ;**                into.
  195. ;**
  196. ;** DESCRIPTION
  197. ;**  Copies the requested filename from the spooler queue to the users
  198. ;**  buffer.  File number 0 is the file that is currently being printed.
  199. ;**
  200. ;** RETURNS
  201. ;**  0 if successful, 1 if the number parameter is greater than the
  202. ;**  number of files in the print queue.
  203. ;**
  204. ;** AUTHOR
  205. ;**  ""   Thu 10-Nov-1988    16:58:10
  206. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  207. ;**
  208. ;** MODIFICATIONS
  209. ;**
  210. ;*/
  211.         cproc    getqfile
  212.         call    GetFilesInQueue
  213.         mov    si,parm1_        ;get requested file number
  214.         cmp    ax,si
  215.         ja    reqisok
  216.         mov    ax,SPOOLERID*256+ENDOFSTATUS
  217.         int    MULTIPLEXINT        ;free queue back up
  218.         mov    ax,1            ;say error
  219.         jmp    short getqueuedexit
  220. reqisok:    push    es
  221.         mov    es,bx            ;ES:CX points to queue start
  222.         mov    ax,64            ;each entry is 64 bytes long
  223.         mul    si            ;si has the entry number
  224.         add    cx,ax            ;adjust the offset
  225.         mov    di,cx            ;and put in di, ES:DI has source
  226.         if    _LDATA
  227.          push    ds
  228.          lds    bx,parm2_
  229.         else
  230.          mov    bx,parm2_
  231.         endif
  232.         mov    cx,64            ;move 64 bytes the hard way
  233. movloop:    mov    al,es:[di]
  234.         mov    [bx],al
  235.         inc    bx
  236.         inc    di
  237.         loop    movloop
  238.         if    _LDATA
  239.          pop    ds
  240.         endif
  241.         pop    es
  242.         mov    ax,SPOOLERID*256+ENDOFSTATUS
  243.         int    MULTIPLEXINT        ;free queue back up
  244.         xor    ax,ax            ;indicate success
  245. getqueuedexit:
  246.         cproce
  247.  
  248. ;/*
  249. ;**  int
  250. ;** filesinq(void)
  251. ;**
  252. ;** ARGUMENT(s)
  253. ;**  None.
  254. ;**
  255. ;** DESCRIPTION
  256. ;**  Disables the print queue, counts the number of files in the queue,
  257. ;**  then re-enables the print queue for printing.
  258. ;**
  259. ;** RETURNS
  260. ;**  Number of files in the queue.
  261. ;**
  262. ;** AUTHOR
  263. ;**  ""   Thu 10-Nov-1988    16:55:26
  264. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  265. ;**
  266. ;** MODIFICATIONS
  267. ;**
  268. ;*/
  269.         cproc    filesinq
  270.         call    GetFilesInQueue
  271.         push    ax
  272.         mov    ax,SPOOLERID*256+ENDOFSTATUS
  273.         int    MULTIPLEXINT        ;free queue back up
  274.         pop    ax            ;return count
  275.         cproce
  276.  
  277.  
  278. ;/*
  279. ;** DESCRIPTION
  280. ;**  Helper function to return the number of files in the print queue.
  281. ;**  This function leaves the jobs on hold, you must issue ENDOFSTATUS
  282. ;**  call to release the queue.  NOTE: This is not callable from C.
  283. ;**
  284. ;** RETURNS
  285. ;**  AX=number of files in the print queue
  286. ;**
  287. ;** AUTHOR
  288. ;**  ""   Thu 10-Nov-1988    16:20:08
  289. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  290. ;**
  291. ;** MODIFICATIONS
  292. ;**
  293. ;*/
  294. GetFilesInQueue proc    near
  295.         push    ds
  296.         push    si
  297.         mov    ax,SPOOLERID*256+STATUS ;get pointer to DS:SI
  298.         int    MULTIPLEXINT
  299.         mov    ax,si            ;promote offset to segment
  300.         mov    cl,4
  301.         shr    ax,cl
  302.         mov    bx,ds
  303.         add    ax,bx
  304.         mov    ds,ax
  305.         and    si,0fh
  306.         mov    bx,ds
  307.         mov    cx,si            ;return with BX:CX pointing to start
  308.         xor    ax,ax            ;counter = 0
  309. countloop:    cmp    byte ptr [si],0
  310.         jz    countexit
  311.         inc    ax
  312.         add    si,64
  313.         jmp    short countloop
  314. countexit:    pop    si
  315.         pop    ds
  316.         ret
  317. GetFilesInQueue endp
  318.         endps
  319.         end
  320.