home *** CD-ROM | disk | FTP | other *** search
- /*********************
- *
- * docxtrak.c - extract document paragraphs from a file
- *
- * Purpose: This program will search an input file for documentation
- * paragraphs for a function, and then output the paragraph to a
- * documentation file. The input file and the documentation file
- * are given on the command line. If the documentation file is not
- * specified, the default documentation file <input file name>.doc
- * is used - where <input file name> is the specified file name.
- *
- * USAGE:
- * docxtrak <input file> <documentation file>
- *
- * Blackstar C Function Library
- * (c) Copyright 1985 Sterling Castle Software
- *
- *******/
-
- #include <stdio.h>
- #include <string.h>
- #include <process.h>
- #include "blackstr.h"
- #include "pr_head.h"
-
-
- FILE *fpin,*fpo;
- char buff[200];
-
- void main(int argc, char *argv[])
- {
- int i,nc,nfun;
- char outfile[15];
-
- if(argc<2) {
- printf("Usage: docxtrak <input file> <documentation file>\n");
- exit(-1);
- }
-
- if((fpin=fopen(argv[1],"r")) == 0) {
- printf("\n\r File not found -- %12s",argv[1]);
- exit(-1);
- }
-
- if(argc<3) {
- i = 0;
- while (argv[1][i] != '.') {
- outfile[i] = argv[1][i];
- i++;
- }
- outfile[i++] = '.';
- outfile[i++] = 'd';
- outfile[i++] = 'o';
- outfile[i++] = 'c';
- outfile[i++] = NUL;
- } else
- strcpy(outfile, argv[2]);
-
- if((fpo = fopen(outfile, "w")) == 0) {
- printf("\n\r Error opening output file %12s file ",outfile);
- exit(-1);
- }
-
- nfun = 0;
- while((nc=fl_getln(buff,fpin))!=EOF) { /* get line of source */
- /* find lines that begin with '/' */
- /* and have >= 3 and <= 30 '*'s */
- if ((strncmp(buff,"/***",4) == 0) && (strncmp(&buff[4], "****************************",28) != 0)) {
-
- fprintf(fpo, "%c", FORMF);/* put each function on a separate page */
-
- fprintf(fpo, "\n\n\n");
-
- fprintf(fpo, "------------------------------");
- fprintf(fpo, " from: %s ", argv[1]);
- fprintf(fpo, "------------------------------");
-
- fprintf(fpo, "\n\n\n\n");
- fprintf(fpo, "%s\n", buff);
-
- nfun++;
- while((nc=fl_getln(buff,fpin))!=EOF) {
- /* get next line of source */
- if (buff[0] == '{') /* continue until '{' found */
- break;
- fprintf(fpo, "%s\n", buff);
- }
- fprintf(fpo, "\n\n\n");
- fprintf(fpo, " Include:");
- fprintf(fpo, "\n\n\n\n");
- fprintf(fpo, " Description:");
- fprintf(fpo, "\n\n\n\n");
- fprintf(fpo, " Returns:");
- fprintf(fpo, "\n\n\n\n");
- fprintf(fpo, " Example:");
- fprintf(fpo, "\n");
- }
- }
- printf("\n\r Found %d functions in source file ",nfun);
- printf("\n\r Program complete ");
- }
-