home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / duucp-1.17 / AU-117b4-src.lha / src / lib / makeproto.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-24  |  826 b   |  53 lines

  1. /*
  2.  *  MAKEPROTO.C
  3. */
  4. #include <string.h>
  5. #include <stdio.h>
  6.  
  7. void ScanFile (char *);
  8.  
  9. int
  10. main (int ac, char **av)
  11. {
  12.     short i;
  13.  
  14.     for (i = 1; i < ac; ++i) {
  15.     char *ptr = av[i];
  16.     if (*ptr != '-') {
  17.         ScanFile(ptr);
  18.         continue;
  19.     }
  20.     ptr += 2;
  21.     switch(ptr[-1]) {
  22.     case 'o':
  23.         freopen(ptr, "w", stdout);
  24.         printf("\n/* MACHINE GENERATED */\n\n");
  25.         break;
  26.     }
  27.     }
  28.     return(0);
  29. }
  30.  
  31. void
  32. ScanFile(file)
  33. char *file;
  34. {
  35.     FILE *fi = fopen(file, "r");
  36.     char buf[512];
  37.  
  38.     if (fi == NULL) {
  39.     fprintf(stderr, "makeproto: couldn't open %s\n", file);
  40.     return;
  41.     }
  42.     printf("\n/* %-20s */\n\n", file);
  43.     while (fgets(buf, sizeof(buf), fi)) {
  44.     if (strncmp(buf, "Prototype", 9) == 0)
  45.         fputs(buf, stdout);
  46.     else
  47.     if (strncmp(buf, ";Prototype", 10) == 0)
  48.         fputs(buf+1, stdout);
  49.     }
  50.     fclose(fi);
  51. }
  52.  
  53.