home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name PRSPOOL -- Use DOS print spooler to print a file.
- *
- * Synopsis ret = prspool (pfile);
- *
- * int ret Return code -- PR_OK if no error.
- *
- * const char *pfile Filename to send to spooler for
- * printing.
- *
- * Description This function submits the specified file to the DOS
- * print spooler (usually PRINT.COM) for printing. If the
- * spooler has already been installed, this is the same as
- * typing
- *
- * PRINT file
- *
- * on the DOS command line.
- *
- * The DOS filename expansion characters ('*' and '?') are
- * not allowed.
- *
- * Special If the DOS the machine is running is an earlier version
- * Cases than 3.00, the return code is PR_INSTAL (1).
- *
- * Returns ret 0 (PR_OK) if no error, otherwise
- * one of the following values:
- *
- * 0 (PR_OK) File successfully submitted to
- * spooler.
- *
- * 1 (PR_INSTAL) Spooler not installed (or)
- * MS/PC-DOS older than 3.00.
- *
- * 2 (PR_EXIST) The file submitted does not exist.
- *
- * 3 (PR_PATH) Path to submitted file does not
- * exist.
- *
- * 4 (PR_HANDLES) Too many files open (not enough
- * handles available).
- *
- * 5 (PR_ACCESS) Access denied (usually caused by
- * attempting to spool unprintable
- * files (directories, volume labels,
- * etc)).
- *
- * 8 (PR_FULL) Spooler queue full. Try again
- * later.
- *
- * 9 (PR_BUSY) Spooler busy; unable to get its
- * attention. Try again later.
- *
- * 12 (PR_NAMELEN) Path too long. This usually
- * means that the path is not
- * NUL-terminated.
- *
- * 15 (PR_DRIVE) Disk drive specified in path is
- * invalid.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- **/
-
-
- #include <dos.h>
-
- #include <bprint.h>
- #include <butil.h>
-
-
- int prspool (pfile)
- const char *pfile;
- {
- union REGS regs;
- struct SREGS sregs;
-
- /* This structure is a "request packet," of the type*/
- /* needed to communicate with the spooler. (but only*/
- /* for spool-file requests) */
- struct {
- /* The "filler" makes for unconditional structure */
- /* alignment. */
- unsigned char filler;
-
- /* "Level" of a packet. Undocumented, but Microsoft*/
- /* says it should be 0. */
- unsigned char level;
-
- /* Pointer to the name of the file to spool. */
- const char far *pfile;
- } packet;
-
-
- /* If spooler is not installed, exit. */
- if (! prinstld ())
- return (PR_INSTAL);
-
- /* Set up spooler request packet. */
- packet.pfile = pfile;
- packet.level = 0;
-
- /* Point to packet with registers. */
- sregs.ds = utseg (&packet.level);
- regs.x.dx = utoff (&packet.level);
-
- /* When we put 0x0101 in AX, we are telling the */
- /* request processor that we mean device 1 (print */
- /* spooler), request 1 (submit file). */
- regs.x.ax = 0x0101;
-
- /* Do the request. */
- int86x (PR_DOS_INT, ®s, ®s, &sregs);
-
- /* If there was an error, return it. */
- if (regs.x.cflag)
- return (regs.x.ax);
-
- return (PR_OK);
- }