home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / thesrc15.zip / manext.c < prev    next >
C/C++ Source or Header  |  1993-09-01  |  4KB  |  150 lines

  1. /***********************************************************************/
  2. /* MANEXT - Extract manual pages from C source code.                   */
  3. /***********************************************************************/
  4. /*
  5.  * MANEXT - A program to extract manual pages from C source code.
  6.  * Copyright (C) 1991-1993 Mark Hessling
  7.  *
  8.  * This program is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU General Public License as
  10.  * published by the Free Software Foundation; either version 2 of
  11.  * the License, or any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16.  * General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to:
  20.  *
  21.  *    The Free Software Foundation, Inc.
  22.  *    675 Mass Ave,
  23.  *    Cambridge, MA 02139 USA.
  24.  *
  25.  *
  26.  * If you make modifications to this software that you feel increases
  27.  * it usefulness for the rest of the community, please email the
  28.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  29.  * This software is going to be maintained and enhanced as deemed
  30.  * necessary by the community.
  31.  *
  32.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  33.  * 36 David Road                     Phone: +61 7 849 7731
  34.  * Holland Park                      Fax:   +61 7 875 5314
  35.  * QLD 4121
  36.  * Australia
  37.  */
  38.  
  39. /*
  40. $Header: C:\THE\RCS\manext.c 1.4 1993/09/01 16:26:41 MH Interim MH $
  41. */
  42.  
  43. #include <stdio.h>
  44.  
  45. #ifdef PROTO
  46. void display_info(void);
  47. #else
  48. void display_info();
  49. #endif
  50.  
  51. #define MAX_LINE 255
  52.  
  53. /***********************************************************************/
  54. #ifdef PROTO
  55. int main(int argc,char *argv[])
  56. #else
  57. int main(argc,argv)
  58. int argc;
  59. char *argv[];
  60. #endif
  61. /***********************************************************************/
  62. {
  63.  char    s[MAX_LINE + 1];        /* input line */
  64.  register int     i = 0;
  65.  FILE *fp;
  66.  char c;
  67.  char append=0;
  68. #ifdef __EMX__
  69.  _wildcard(&argc,&argv);
  70. #endif
  71.  
  72.  if (strcmp(argv[1],"-h") == 0)
  73.    {
  74.     display_info();
  75.     exit(1);
  76.    }
  77.  for(i=1;i<argc;i++)
  78.     {
  79.      if ((fp = fopen(argv[i],"r")) == NULL)
  80.        {
  81.         fprintf(stderr,"\nCould not open %s\n",argv[i]);
  82.         continue;
  83.        }
  84.      while(1)
  85.        {
  86.         if (fgets(s, (int)sizeof(s), fp) == NULL)
  87.           {
  88.        if (ferror(fp) != 0)
  89.              {
  90.               fprintf(stderr, "*** Error reading %s.  Exiting.\n",argv[i]);
  91.               exit(1);
  92.              }
  93.        break;
  94.           }
  95.  
  96.         /* check for manual entry marker at beginning of line */
  97.         if (strncmp(s, "/*man-start*", 12) != 0)
  98.             continue;
  99.  
  100.         /* inner loop */
  101.         for (;;)
  102.            {
  103.             /* read next line of manual entry */
  104.         if (fgets(s, (int)sizeof(s), fp) == NULL)
  105.               {
  106.            if (ferror(fp) != 0)
  107.          {
  108.           fprintf(stderr, "*** Error reading %s.  Exiting.\n",argv[i]);
  109.           exit(1);
  110.          }
  111.         break;
  112.           }
  113.         /* check for end of entry marker */
  114.         if (strncmp(s, "**man-end", 9) == 0)
  115.            break;
  116.  
  117.         printf("     %s",s);
  118.             }
  119.     printf("\n\n\n     --------------------------------------------------------------------------\n");
  120.  
  121.         /* check if end of file */
  122.         if (feof(fp) != 0)
  123.             break;
  124.        }
  125.      fclose(fp);
  126.     }
  127.  printf("\n\n\n\n\n");
  128.  return(0);
  129. }
  130. /***********************************************************************/
  131. #ifdef PROTO
  132. void display_info(void)
  133. #else
  134. void display_info()
  135. #endif
  136. /***********************************************************************/
  137. {
  138. /*--------------------------- local data ------------------------------*/
  139. /*--------------------------- processing ------------------------------*/
  140.  
  141.  fprintf(stderr,"\nMANEXT 1.00 Copyright (C) 1991-1993 Mark Hessling\n");
  142.  fprintf(stderr,"All rights reserved.\n");
  143.  fprintf(stderr,"MANEXT is distributed under the terms of the GNU\n");
  144.  fprintf(stderr,"General Public License and comes with NO WARRANTY.\n");
  145.  fprintf(stderr,"See the file COPYING for details.\n");
  146.  fprintf(stderr,"\nUsage: MANEXT sourcefile [...]\n\n");
  147.  fflush(stderr);
  148.  return;
  149. }
  150.