home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / DEVBBS.ZIP / STRIP.C < prev    next >
C/C++ Source or Header  |  1991-09-03  |  1KB  |  66 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void strip_file(char *fn, FILE *out)
  5. {
  6.   FILE *f;
  7.   char s[161],*ss;
  8.  
  9.   f=fopen(fn,"r");
  10.   if (!f)
  11.     return;
  12.  
  13.   fprintf(out,"\n\n/* File: %s */\n\n",fn);
  14.  
  15.   while (fgets(s,160,f)) {
  16.     ss=strchr(s,'\n');
  17.     if (ss)
  18.       *ss=0;
  19.     if ((s[0]) && (strchr("{}\t/# ",s[0])==NULL) && (s[strlen(s)-1]==')')) {
  20.         fprintf(out,"%s;\n",s);
  21.     }
  22.   }
  23.   fclose(f);
  24. }
  25.  
  26.  
  27. /****************************************************************************/
  28.  
  29. void main(int argc, char *argv[])
  30. {
  31.   int i,i1;
  32.   FILE *out, *tmpin;
  33.   char *ss,s[161];
  34.  
  35.   if (argc!=3) {
  36.     printf("Run the STRIP program only from the makefile.\n\n");
  37.     exit(-1);
  38.   }
  39.  
  40.   out=fopen(argv[1],"w");
  41.   fprintf(out,"#ifndef _FCNS_H_\n#define _FCNS_H_\n\n");
  42.   fprintf(out,"#include \"vardec.h\"\n#include \"net.h\"\n");
  43.  
  44.   tmpin = fopen(argv[2],"r");
  45.   do {
  46.     i1=fscanf(tmpin,"%s",s);
  47.     if (i1>0) {
  48.       if ((ss=strstr(s,".obj"))!=NULL) {
  49.         *ss=0;
  50.         strcat(s,".c");
  51.         ss=strrchr(s,'\\');
  52.         if (!ss)
  53.           ss=s;
  54.         else
  55.           ++ss;
  56.       } else ss=s;
  57.       strip_file(ss,out);
  58.     }
  59.   } while (i1>0);
  60.   fclose(tmpin);
  61.  
  62.   fprintf(out,"\n#endif\n");
  63.   fclose(out);
  64.  
  65. }
  66.