home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / UTILS / DOCXTRAK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-24  |  2.7 KB  |  102 lines

  1. /*********************
  2.  *
  3.  *  docxtrak.c - extract document paragraphs from a file
  4.  *
  5.  *  Purpose: This program will search an input file for documentation
  6.  *           paragraphs for a function, and then output the paragraph to a
  7.  *           documentation file. The input file and the documentation file
  8.  *           are given on the command line. If the documentation file is not
  9.  *           specified, the default documentation file <input file name>.doc
  10.  *           is used - where <input file name> is the specified file name.
  11.  *
  12.  *  USAGE:
  13.  *           docxtrak <input file> <documentation file>
  14.  *
  15.  *  Blackstar C Function Library
  16.  *  (c) Copyright 1985 Sterling Castle Software
  17.  *
  18.  *******/
  19.  
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include <process.h>
  23. #include "blackstr.h"
  24. #include "pr_head.h"
  25.  
  26.  
  27. FILE   *fpin,*fpo;
  28. char   buff[200];
  29.  
  30. void main(int argc, char *argv[])
  31. {
  32.     int    i,nc,nfun;
  33.     char   outfile[15];
  34.  
  35.     if(argc<2) {
  36.     printf("Usage: docxtrak <input file> <documentation file>\n");
  37.     exit(-1);
  38.     }
  39.  
  40.     if((fpin=fopen(argv[1],"r")) == 0) {
  41.     printf("\n\r File not found -- %12s",argv[1]);
  42.     exit(-1);
  43.     }
  44.  
  45.     if(argc<3) {
  46.     i = 0;
  47.     while (argv[1][i] != '.') {
  48.         outfile[i] = argv[1][i];
  49.         i++;
  50.     }
  51.     outfile[i++] = '.';
  52.     outfile[i++] = 'd';
  53.     outfile[i++] = 'o';
  54.     outfile[i++] = 'c';
  55.     outfile[i++] = NUL;
  56.     } else
  57.     strcpy(outfile, argv[2]);
  58.  
  59.     if((fpo = fopen(outfile, "w")) == 0) {
  60.     printf("\n\r Error opening output file %12s file ",outfile);
  61.     exit(-1);
  62.     }
  63.  
  64.     nfun = 0;
  65.     while((nc=fl_getln(buff,fpin))!=EOF) {  /* get line of source */
  66.                         /* find lines that begin with '/' */
  67.                         /*  and have >= 3 and <= 30 '*'s  */
  68.     if ((strncmp(buff,"/***",4) == 0) && (strncmp(&buff[4], "****************************",28) != 0)) {
  69.  
  70.         fprintf(fpo, "%c", FORMF);/* put each function on a separate page */
  71.  
  72.         fprintf(fpo, "\n\n\n");
  73.  
  74.         fprintf(fpo, "------------------------------");
  75.         fprintf(fpo, "  from: %s  ", argv[1]);
  76.         fprintf(fpo, "------------------------------");
  77.  
  78.         fprintf(fpo, "\n\n\n\n");
  79.         fprintf(fpo, "%s\n", buff);
  80.  
  81.         nfun++;
  82.         while((nc=fl_getln(buff,fpin))!=EOF) {
  83.                     /* get next line of source    */
  84.         if (buff[0] == '{')    /* continue until '{' found   */
  85.                     break;
  86.         fprintf(fpo, "%s\n", buff);
  87.         }
  88.         fprintf(fpo, "\n\n\n");
  89.         fprintf(fpo, " Include:");
  90.         fprintf(fpo, "\n\n\n\n");
  91.         fprintf(fpo, " Description:");
  92.         fprintf(fpo, "\n\n\n\n");
  93.         fprintf(fpo, " Returns:");
  94.         fprintf(fpo, "\n\n\n\n");
  95.         fprintf(fpo, " Example:");
  96.         fprintf(fpo, "\n");
  97.     }
  98.     }
  99.     printf("\n\r Found %d functions in source file ",nfun);
  100.     printf("\n\r Program complete ");
  101. }
  102.