home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / 14 / protol.c < prev   
Encoding:
C/C++ Source or Header  |  1988-08-11  |  1.1 KB  |  34 lines

  1. /*
  2.         PROTOL.C: a template for a line-oriented filter.
  3.  
  4.         Ray Duncan, June 1987.
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9. static char input[256];                 /* buffer for input line */
  10. static char output[256];                /* buffer for output line */
  11.  
  12. main(argc,argv)
  13. int argc;
  14. char *argv[];
  15. {       while( gets(input) != NULL )    /* get a line from input stream */
  16.                                         /* perform any necessary translation
  17.                                            and possibly write result */
  18.         {       if (translate()) puts(output);
  19.         }
  20.         exit(0);                        /* terminate at end of file */
  21. }
  22.  
  23. /*
  24.         Perform any necessary translation on input line, leaving
  25.         the resulting text in output buffer.  Value of function
  26.         is 'true' if output buffer should be written to standard output
  27.         by main routine, 'false' if nothing should be written.
  28. */
  29.  
  30. translate()
  31. {       strcpy(output,input);           /* template action is copy input */
  32.         return(1);                      /* line and return true flag */
  33. }
  34.