home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1719 / offil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  1.0 KB  |  63 lines

  1. /*
  2.     offil, a printcap filter for printing the header page.
  3.  
  4.     Written by Brian Utterback
  5.     December 19878
  6.  
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <signal.h>
  11.  
  12. main(argc,argv)
  13. int argc;
  14. char *argv[];
  15. {
  16.     register char *cp;
  17.     register int ch;
  18.  
  19.     /* 'of' filters are only passed width and length arguments from lpd */
  20.     while (--argc) {
  21.         if (*(cp = *++argv) == '-' ) {
  22.             switch (cp[1]) {
  23.             case 'w':
  24.                 /* this filter does nothing with width */
  25.                 break;
  26.  
  27.             case 'l':
  28.                 /* this filter does nothing with length */
  29.                 break;
  30.  
  31.             }
  32.         }
  33.     }
  34.  
  35.     printf("\033E");
  36.     printf("\033&k3G");
  37.     while ((ch=getchar()) != EOF) {
  38.         switch(ch) {
  39.  
  40.         case '\31':
  41.                /*
  42.                 * LPD needs to use a different filter to
  43.                 * print data so stop what we are doing
  44.                 * and wait for lpd to restart us.
  45.                 */
  46.                 if ((ch = getchar()) == '\01') {
  47.                 (void) fflush(stdout);
  48.                 (void) kill(getpid(), SIGSTOP);
  49.                 printf("\033E");
  50.                 printf("\033&k3G");
  51.                 break;
  52.             } else {
  53.                 (void) ungetc(ch,stdin);
  54.                 ch='\31';
  55.             }
  56.         default:
  57.             putchar(ch);
  58.             break;
  59.         }
  60.     }
  61.         exit(0);
  62. }
  63.