home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / WWIV2.ZIP / STRIP.C < prev    next >
C/C++ Source or Header  |  1992-12-03  |  2KB  |  83 lines

  1. /*****************************************************************************
  2.  
  3.                 WWIV Version 4
  4.                     Copyright (C) 1988-1993 by Wayne Bell
  5.  
  6. Distribution of the source code for WWIV, in any form, modified or unmodified,
  7. without PRIOR, WRITTEN APPROVAL by the author, is expressly prohibited.
  8. Distribution of compiled versions of WWIV is limited to copies compiled BY
  9. THE AUTHOR.  Distribution of any copies of WWIV not compiled by the author
  10. is expressly prohibited.
  11.  
  12.  
  13. *****************************************************************************/
  14.  
  15.  
  16.  
  17. #include <stdio.h>
  18. #include <string.h>
  19.  
  20. void strip_file(char *fn, FILE *out)
  21. {
  22.   FILE *f;
  23.   char s[161],*ss;
  24.  
  25.   f=fopen(fn,"r");
  26.   if (!f)
  27.     return;
  28.  
  29.   fprintf(out,"\n\n/* File: %s */\n\n",fn);
  30.  
  31.   while (fgets(s,160,f)) {
  32.     ss=strchr(s,'\n');
  33.     if (ss)
  34.       *ss=0;
  35.     if ((s[0]) && (strchr("{}\t/# ",s[0])==NULL) && (s[strlen(s)-1]==')')) {
  36.       if (strncmp(s,"static",6))
  37.         fprintf(out,"%s;\n",s);
  38.     }
  39.   }
  40.   fclose(f);
  41. }
  42.  
  43.  
  44. /****************************************************************************/
  45.  
  46. void main(int argc, char *argv[])
  47. {
  48.   int i,i1;
  49.   FILE *out, *tmpin;
  50.   char *ss,s[161];
  51.  
  52.   if (argc!=3) {
  53.     printf("Run the STRIP program only from the makefile.\n\n");
  54.     exit(-1);
  55.   }
  56.  
  57.   out=fopen(argv[1],"w");
  58.   fprintf(out,"#ifndef _FCNS_H_\n#define _FCNS_H_\n\n");
  59.   fprintf(out,"#include \"vardec.h\"\n#include \"net.h\"\n");
  60.  
  61.   tmpin = fopen(argv[2],"r");
  62.   do {
  63.     i1=fscanf(tmpin,"%s",s);
  64.     if (i1>0) {
  65.       if ((ss=strstr(s,".obj"))!=NULL) {
  66.         *ss=0;
  67.         strcat(s,".c");
  68.         ss=strrchr(s,'\\');
  69.         if (!ss)
  70.           ss=s;
  71.         else
  72.           ++ss;
  73.       } else ss=s;
  74.       strip_file(ss,out);
  75.     }
  76.   } while (i1>0);
  77.   fclose(tmpin);
  78.  
  79.   fprintf(out,"\n#endif\n");
  80.   fclose(out);
  81.  
  82. }
  83.