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

  1. /***
  2. *
  3. *
  4. *  hpplist.c
  5. *
  6. *  Sends the HP PCL command to select portrait line printer as primary font
  7. *  with 16.6 cpi and 10 lpi spacing and a 10 column left margin.
  8. *
  9. *  This mode permits printing of long listing files in a condensed type
  10. *  format with sufficient left margin for punching holes for a ring binder.
  11. *
  12. *  User default printer settings can be restored by running HPRESET.
  13. *
  14. *  This program written by W. A. Jackson and dedicated to the public domain.
  15. *
  16. *****************************************************************************/
  17.  
  18.  
  19.  
  20. #define INCL_BASE
  21. #include <OS2.H>
  22. #include <stdio.h>
  23. #include <fcntl.h>
  24. #include <sys\types.h>
  25. #include <sys\stat.h>
  26. #include <io.h>
  27.  
  28. main()
  29.  
  30. {
  31.    int   print_handle;                           /* file handle for printer */
  32.    FILE *print_pointer;                               /* stream for printer */
  33.  
  34.    /*
  35.     *  Note: this is an awkward way to open a stream to the printer,
  36.     *  but necessary to work around a bug in Microsoft C Ver. 5.1 
  37.     *
  38.     *************************************************************************/
  39.  
  40.    print_handle = open ("PRN", O_WRONLY);               /* open file handle */
  41.    if (print_handle == -1)                           /* test for open error */
  42.       perror ("open failed on PRN");
  43.    print_pointer = fdopen (print_handle, "w");          /* associate stream */
  44.    if (print_pointer == NULL)                             /* test for error */
  45.       perror ("fopen failed on print_handle");
  46.    fprintf (print_pointer, "\x01BE");                 /* send Esc E (reset) */
  47.    fprintf (print_pointer,                                   /* select font */
  48.     "\x01B&l0O"                                     /* portrait orientation */
  49.     "\x01B(10U"                                          /* PC-8 Symbol Set */
  50.     "\x01B(s0P"                                            /* fixed spacing */
  51.     "\x01B(s16.6H"                                        /* 16.6 cpi pitch */
  52.     "\x01B(s8.5V"                                       /* 8.5 point height */
  53.     "\x01B&l8D"                                       /* 8 lpi line spacing */
  54.     "\x01B(s0S"                                            /* upright style */
  55.     "\x01B(s0B"                                     /* medium stroke weight */
  56.     "\x01B(s0T");                                  /* Line Printer typeface */
  57.    fprintf (print_pointer, "\x01B&a10L");      /* set 10 column left margin */
  58.    if (fclose (print_pointer) == EOF)                       /* close stream */
  59.       perror ("fclose failed on print_pointer");          /* test for error */
  60.    printf ("Laserjet set to landscape line printer with top margin.");
  61.                                                          /* display message */
  62.  
  63. }
  64.  
  65.