home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume12 / psf2 / part01 / psdetect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-19  |  762 b   |  31 lines

  1. /* ta=4 */
  2. /************************************************************************
  3. *        p s d e t e c t . c        v1.1                                    *
  4. *                                                                        *
  5. *    determine if a a text file contains postscript code.                *
  6. ************************************************************************/
  7.  
  8. /*    this routine is intended for use within shell scripts.  It exits
  9.     with a return code of 0 if it detects a postscript file or
  10.     a value of 1 if it is not a postscript file
  11. */
  12.  
  13. #include <stdio.h>
  14. #include "patchlevel.h"
  15.  
  16. main ()
  17. {    char    stuff[20];
  18.     int        i;
  19.     
  20.     stuff[0] = getchar();
  21.     if (stuff[0] != '%')
  22.         exit (1);
  23.     for (i = 1;  i < 5;  i++)
  24.     {    if (stuff[i-1] == '%'  &&  (stuff[i] = getchar()) == '!')
  25.             exit (0);
  26.         if (feof (stdin)  ||  ferror (stdin))
  27.             break;
  28.     }
  29.     exit (1);
  30. }
  31.