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

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