home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_01 / 1n01042a < prev    next >
Text File  |  1990-05-17  |  3KB  |  113 lines

  1.         PAGE ,132
  2.  
  3. ;  Figure 5
  4. ;
  5. ;  Print spooler routines
  6. ;
  7. ;  All rountines return an error code in AX as follows:
  8. ;
  9. ;       0000 - No error
  10. ;       0001 - Function invalid
  11. ;       0002 - File not found
  12. ;       0003 - Path not found
  13. ;       0004 - Too many open files
  14. ;       0005 - Access denied
  15. ;       0008 - Queue full
  16. ;       0009 - Spooler busy
  17. ;       000C - Name too long
  18. ;       000F - Invalid drive
  19. ;       FFFF - Spooler not installed
  20.  
  21.  
  22. %       .MODEL  memodel,lang            ;Add model and language support via
  23.                                         ;command line macros, e.g.
  24.                                         ;MASM /Dmemodel=LARGE /Dlang=C
  25.  
  26.         .DATA
  27.  
  28. packet  db      0
  29. p_ofs   dw      ?
  30. p_seg   dw      ?
  31.  
  32.         .CODE
  33.  
  34. ;
  35. ;  Call this to add a file to the PRINT.COM spool queue
  36. ;
  37.  
  38. spoolcheck:
  39.         mov     ax,0100h                ;Is spooler installed?
  40.         int     2Fh
  41.         cmp     AL,0FFh
  42.         ret
  43.  
  44. SpoolAdd        PROC    USES ES DX, filename:PTR
  45.         call    spoolcheck
  46.         jz      addin                   ;Yes, continue
  47.         mov     ax,-1                   ;No, return an error
  48.         jmp     addbye
  49. addin:
  50.         IF      @DataSize               ;Put filename pointer in packet
  51.         les     dx,filename
  52.         mov     p_seg,ES
  53.         mov     p_ofs,DX
  54.         ELSE
  55.         mov     p_seg,DS
  56.         mov     dx,filename
  57.         mov     p_ofs,dx
  58.         ENDIF
  59.         mov     AX,0101h                ;Call the spooler
  60.         mov     DX,offset packet
  61.         int     2Fh
  62.         jc      addbye                  ;Error?
  63.         xor     AX,AX                   ;No, return zero
  64. addbye:  
  65.         ret                             ;Yes, return error code
  66.  
  67. SpoolAdd        ENDP
  68.  
  69. ;
  70. ;  Call this to delete a file or files from the PRINT.COM spool queue
  71. ;
  72.  
  73. SpoolDel        PROC    USES DX, filename:PTR
  74.         call    spoolcheck
  75.         jz      delin                   ;Yes, continue
  76.         mov     ax,-1                   ;No, return an error
  77.         jmp     delbye;
  78. delin:
  79.         IF      @DataSize               ;Put filename pointer in packet
  80.         lds     dx,filename
  81.         ELSE
  82.         mov     dx,filename
  83.         ENDIF
  84.         mov     AX,0102h                ;Call the spooler
  85.         int     2Fh
  86.         jc      delbye                  ;Error?
  87.         xor     AX,AX                   ;No, return zero
  88. delbye:  
  89.         ret                             ;Yes, return error code
  90.  
  91. SpoolDel        ENDP
  92.  
  93. ;
  94. ;  Call this to cancel all pending files from the PRINT.COM spool queue
  95. ;
  96.  
  97. SpoolCan        PROC
  98.         call    spoolcheck
  99.         jz      canin                   ;Yes, continue
  100.         mov     ax,-1                   ;No, return an error
  101.         jmp     canbye
  102. canin:
  103.         mov     AX,0103h                ;Call the spooler
  104.         int     2Fh
  105.         jc      canbye                  ;Error?
  106.         xor     AX,AX                   ;No, return zero
  107. canbye:  
  108.         ret                             ;Yes, return error code
  109.  
  110. SpoolCan        ENDP
  111.  
  112.         end
  113.