home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / printers / hp4lpr.c next >
C/C++ Source or Header  |  2020-01-01  |  2KB  |  57 lines

  1. /*
  2.   H P 4 L P R I N T
  3.  
  4.   Print a host file or files on an HP LaserJet 4L printer through a
  5.   VT terminal or emulator using transparent print sequences.  Latin-1
  6.   characters are translated to HP Roman 8.
  7.  
  8.   Authors: F. da Cruz & C. Gianone, Columbia University, 1996.
  9. */
  10.  
  11. #include <stdio.h>
  12.  
  13. unsigned char
  14. yl1r8[] = {  /* Latin-1 to IBM Code Page 437 */
  15.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  16.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  17.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  18.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  19.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  20.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  21.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  22. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  23. 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
  24. 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
  25. 160, 184, 191, 187, 186, 188, 124, 189, 171,  99, 249, 251, 126,  45,  82, 176,
  26. 179, 254,  50,  51, 168, 243, 244, 242,  44,  49, 250, 253, 247, 248, 245, 185,
  27. 161, 224, 162, 225, 216, 208, 211, 180, 163, 220, 164, 165, 230, 229, 166, 167,
  28. 227, 182, 232, 231, 223, 233, 218, 120, 210, 173, 237, 174, 219, 177, 240, 222,
  29. 200, 196, 192, 226, 204, 212, 215, 181, 201, 197, 193, 205, 217, 213, 209, 221,
  30. 228, 183, 202, 198, 194, 234, 206,  47, 214, 203, 199, 195, 207, 178, 241, 239
  31. };
  32.  
  33. #define ESC 27
  34. #define FF  12
  35.  
  36. main(argc,argv) int argc; char *argv[]; {
  37.     int c, i;
  38.     FILE * fp;
  39.     if (argc == 1) {            /* Standard input */
  40.     printf("%c[5i",ESC);        /* Send start-print sequence */
  41.     while ((c = getchar()) != EOF)    /* Send characters */
  42.       putchar(yl1r8[c]);        /* translated */
  43.     printf("%c%c[4i",FF,ESC);    /* Send formfeed and stop-print */
  44.     exit(0);            /* Done */
  45.     }
  46.     for (i = 1; i < argc; i++) {    /* File list */
  47.     if (!(fp = fopen(argv[i],"r"))) /* Open file i */
  48.       continue;
  49.     printf("%c[5i",ESC);        /* Send start-print sequence */
  50.     while ((c = fgetc(fp)) != EOF)    /* Send characters */
  51.       putchar(yl1r8[c]);        /* translated */
  52.     fclose(fp);            /* Close file i */
  53.     printf("%c%c[4i",FF,ESC);    /* Send FF and stop-print */
  54.     }
  55.     exit(0);                /* Done */
  56. }
  57.