Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_bios_printer() access printer services</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _bios_printer()         Access printer services

 #include   <bios.h>

 unsigned _bios_printer(service, printer, outbyte);
  unsigned service; Printer service desired -- use one of the manifest
                         constants described below.
  unsigned printer; Parallel printer number (0 = LPT1, 1 = LPT2,  etc.)
  unsigned outbyte; Character to print

    _bios_printer() uses ROM-BIOS interrupt 17h to access printer
    services to check printer status, initialize it, and output a byte to
    it. Specify the service desired by using one of the following
    manifest constants defined in bios.h:

 _PRINTER_WRITE Sends the low-order byte of 'outbyte' to the selected
                printer. If the printer is busy or off-line
                _PRINTER_WRITE halts normal processing until the printer
                is free or the situation is corrected. The low-order byte
                of the return value indicates the printer status after
                the operation. See Returns, below, for the meaning of
                each bit.

 _PRINTER_INIT  Initializes the printer by sending the values 08h and 0Ch
                to the printer's control port, which resets it and sets
                the top of page to the current position of the paper. The
                'outbyte' argument is ignored by this service. The low-
                order byte of the return value indicates the printer
                status after the operation. See Returns, below, for
                meaning of each bit.

 _PRINTER_STATUS    Returns the current status of the printer in the low-
                order byte of the return value. See Returns, below, for
                the meaning of each bit. The 'outbyte' argument is
                ignored by this service. Since this service executes
                immediately regardless of the status of the printer, it
                can be used before sending any output to be printed so a
                warning message can be displayed for the operator in case
                of problems. This avoids the problem of locking up the
                system when the printer is off-line or out of paper, etc.

   Returns:     An unsigned int with the bits of the low-order byte
                set as follows:

                    Low-order byte       Printer Status
                    7 6 5 4 3 2 1 0
                    1 . . . . . . .      Printer is ready (0 = not ready)
                    . 1 . . . . . .      Acknowledgement of last
                                         character
                    . . 1 . . . . .      Printer is out of paper
                    . . . 1 . . . .      Printer is selected
                    . . . . 1 . . .      I/O error
                    . . . . . 0 0 .      Not used
                    . . . . . . . 1      Time-out error

   Notes:    _bios_printer() is useful for checking the printer
                status before using the conventional C functions for stream
                and low-level printer output. This way if there is a printer
                problem a warning can be issued to the operator to correct it
                before attempting output, which would lock the system until
                the printer problem was corrected.

                A time-out error needs to be treated with care, because
                it may result from a routine operation rather than a true
                error. In particular, a page eject can take a
                surprisingly long time to complete, and any output to the
                printer during the process will be halted with a time-out
                error. Allow a sufficient time for it to complete before
                issuing a warning to the operator.

 Portability:   MS-DOS and true PC compatibles only.

 ------------------------------ Example --------------------------------

 This program checks the status of the printer and issues an appropriate
 operator warning if it is not ready for printing. Then it prints a line of
 text. To test it put the printer off-line, or remove the paper, then run
 this program.

           #include <bios.h>
           #include <stdio.h>
           #define LPT1 0

           main()
           {
              union {
                  unsigned rtrn;
                  struct {
                      unsigned time_out : 1;
                      unsigned not_used : 2;
                      unsigned io_error : 1;
                      unsigned selected : 1;
                      unsigned no_paper : 1;
                      unsigned acknowledge : 1;
                      unsigned ready : 1;
                      unsigned high_byte : 8;
                  } s;
              } status;
              unsigned outbyte;

              status.rtrn = _bios_printer ( _PRINTER_STATUS, LPT1, outbyte);

              if (!status.s.ready)
                  printf("\n\tPrinter not ready. Please check power and place
           on-line");

              if (status.s.no_paper)
                  printf("\n\tPrinter out of paper. Please insert some
           now.");

              printf("\n\tStatus return byte = %u", status.rtrn);
              printf("\n\n\tPress any character key when ready to print . .
           .");
              getch();

              fputs ("The printer is ready for output\n", stdprn);

           }


See Also: int86() int86x()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson