home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / PRSPOOL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  3.1 KB  |  122 lines

  1. /**
  2. *
  3. * Name        PRSPOOL -- Use DOS print spooler to print a file.
  4. *
  5. * Synopsis    ret = prspool (pfile);
  6. *
  7. *        int ret        Return code -- PR_OK if no error.
  8. *
  9. *        const char *pfile  Filename to send to spooler for
  10. *                   printing.
  11. *
  12. * Description    This function submits the specified file to the DOS
  13. *        print spooler (usually PRINT.COM) for printing.  If the
  14. *        spooler has already been installed, this is the same as
  15. *        typing
  16. *
  17. *            PRINT file
  18. *
  19. *        on the DOS command line.
  20. *
  21. *        The DOS filename expansion characters ('*' and '?') are
  22. *        not allowed.
  23. *
  24. * Special    If the DOS the machine is running is an earlier version
  25. * Cases     than 3.00, the return code is PR_INSTAL (1).
  26. *
  27. * Returns    ret            0 (PR_OK) if no error, otherwise
  28. *                    one of the following values:
  29. *
  30. *            0 (PR_OK)        File successfully submitted to
  31. *                    spooler.
  32. *
  33. *            1 (PR_INSTAL)   Spooler not installed (or)
  34. *                    MS/PC-DOS older than 3.00.
  35. *
  36. *            2 (PR_EXIST)    The file submitted does not exist.
  37. *
  38. *            3 (PR_PATH)     Path to submitted file does not
  39. *                    exist.
  40. *
  41. *            4 (PR_HANDLES)  Too many files open (not enough
  42. *                    handles available).
  43. *
  44. *            5 (PR_ACCESS)   Access denied (usually caused by
  45. *                    attempting to spool unprintable
  46. *                    files (directories, volume labels,
  47. *                    etc)).
  48. *
  49. *            8 (PR_FULL)     Spooler queue full.  Try again
  50. *                    later.
  51. *
  52. *            9 (PR_BUSY)     Spooler busy; unable to get its
  53. *                    attention.    Try again later.
  54. *
  55. *            12 (PR_NAMELEN) Path too long.  This usually
  56. *                    means that the path is not
  57. *                    NUL-terminated.
  58. *
  59. *            15 (PR_DRIVE)   Disk drive specified in path is
  60. *                    invalid.
  61. *
  62. * Version    6.00 (C)Copyright Blaise Computing Inc. 1987,1989
  63. *
  64. **/
  65.  
  66.  
  67. #include <dos.h>
  68.  
  69. #include <bprint.h>
  70. #include <butil.h>
  71.  
  72.  
  73. int prspool (pfile)
  74. const char *pfile;
  75. {
  76.     union  REGS  regs;
  77.     struct SREGS sregs;
  78.  
  79.         /* This structure is a "request packet," of the type*/
  80.         /* needed to communicate with the spooler. (but only*/
  81.         /* for spool-file requests)                */
  82.     struct {
  83.         /* The "filler"  makes for unconditional structure  */
  84.         /* alignment.                        */
  85.     unsigned char filler;
  86.  
  87.         /* "Level" of a packet.  Undocumented, but Microsoft*/
  88.         /* says it should be 0.                 */
  89.     unsigned char level;
  90.  
  91.         /* Pointer to the name of the file to spool.        */
  92.     const char far *pfile;
  93.     } packet;
  94.  
  95.  
  96.         /* If spooler is not installed, exit.            */
  97.     if (! prinstld ())
  98.     return (PR_INSTAL);
  99.  
  100.         /* Set up spooler request packet.            */
  101.     packet.pfile = pfile;
  102.     packet.level = 0;
  103.  
  104.         /* Point to packet with registers.            */
  105.     sregs.ds  = utseg (&packet.level);
  106.     regs.x.dx = utoff (&packet.level);
  107.  
  108.         /* When we put 0x0101 in AX, we are telling the     */
  109.         /* request processor that we mean device 1 (print   */
  110.         /* spooler), request 1 (submit file).            */
  111.     regs.x.ax     = 0x0101;
  112.  
  113.         /* Do the request.                    */
  114.     int86x (PR_DOS_INT, ®s, ®s, &sregs);
  115.  
  116.         /* If there was an error, return it.            */
  117.     if (regs.x.cflag)
  118.     return (regs.x.ax);
  119.  
  120.     return (PR_OK);
  121. }
  122.