home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / HPLIST.ZIP / HPRESET.C < prev    next >
Text File  |  1988-08-05  |  2KB  |  54 lines

  1. /***
  2. *
  3. *
  4. *  hpreset.c
  5. *
  6. *  Sends the HP PCL printer reset command to the printer.
  7. *
  8. *  Receipt of the printer reset command by the HPLJ II restores the user
  9. *  default environment, deletes temporary fonts and macros, and prints
  10. *  any partial pages of data which may have been received.
  11. *
  12. *  Hewlett-Packard strongly recommends the use of the printer reset
  13. *  command at the beginning and end of each job.
  14. *
  15. *  This program written by W. A. Jackson and dedicated to the public domain.
  16. *
  17. *****************************************************************************/
  18.  
  19.  
  20. #define INCL_BASE
  21. #include <OS2.H>
  22.  
  23. #include <stdio.h>
  24. #include <fcntl.h>
  25. #include <sys\types.h>
  26. #include <sys\stat.h>
  27. #include <io.h>
  28.  
  29. main()
  30.  
  31. {
  32.    int   print_handle;                           /* file handle for printer */
  33.    FILE *print_pointer;                               /* stream for printer */
  34.  
  35.    /*
  36.     *  Note: this is an awkward way to open a stream to the printer,
  37.     *  but necessary to work around a bug in Microsoft C Ver. 5.1 
  38.     *
  39.     *************************************************************************/
  40.  
  41.    print_handle = open ("PRN", O_WRONLY);               /* open file handle */
  42.    if (print_handle == -1)                           /* test for open error */
  43.       perror ("open failed on PRN");
  44.    print_pointer = fdopen (print_handle, "w");          /* associate stream */
  45.    if (print_pointer == NULL)                             /* test for error */
  46.       perror ("fopen failed on print_handle");
  47.    fprintf (print_pointer, "\x01BE");                 /* send Esc E (reset) */
  48.    if (fclose (print_pointer) == EOF)                       /* close stream */
  49.       perror ("fclose failed on print_pointer");          /* test for error */
  50.    printf ("Laserjet reset.");                           /* display message */
  51.  
  52. }
  53.  
  54.