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

  1. /*
  2.   H P 5 L P R I N T
  3.  
  4.   Print a host file or files on an HP LaserJet 5L printer through a
  5.   VT terminal or emulator using transparent print sequences.  Latin-1
  6.   characters are translated to CP437.
  7.  
  8.   Authors: F. da Cruz & C. Gianone, Columbia University, 1996.
  9. */
  10.  
  11. #include <stdio.h>
  12.  
  13. unsigned char
  14. yl143[] = {  /* 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. 186, 205, 201, 187, 200, 188, 204, 185, 203, 202, 206, 223, 220, 219, 254, 242,
  24. 179, 196, 218, 191, 192, 217, 195, 180, 194, 193, 197, 176, 177, 178, 213, 159,
  25. 255, 173, 155, 156, 207, 157, 221, 245, 249, 184, 166, 174, 170, 240, 169, 238,
  26. 248, 241, 253, 252, 239, 230, 244, 250, 247, 251, 167, 175, 172, 171, 243, 168,
  27. 183, 181, 182, 199, 142, 143, 146, 128, 212, 144, 210, 211, 222, 214, 215, 216,
  28. 209, 165, 227, 224, 226, 229, 153, 158, 190, 235, 233, 234, 154, 237, 232, 225,
  29. 133, 160, 131, 198, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139,
  30. 208, 164, 149, 162, 147, 228, 148, 246, 189, 151, 163, 150, 129, 236, 231, 152
  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(yl143[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(yl143[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.