home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 334_01 / doc2hlp.c < prev    next >
Text File  |  1991-02-05  |  1KB  |  71 lines

  1. /*
  2.  * doc2hlp.c  -- program to convert Gnuplot .DOC format to 
  3.  * VMS help (.HLP) format.
  4.  *
  5.  * This involves stripping all lines with a leading ?,
  6.  * @, #, or %.
  7.  * Modified by Russell Lang from hlp2ms.c by Thomas Williams 
  8.  *
  9.  * usage:  doc2hlp < file.doc > file.hlp
  10.  *
  11.  * Original version by David Kotz used the following one line script!
  12.  * sed '/^[?@#%]/d' file.doc > file.hlp
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include <ctype.h>
  17.  
  18. #define MAX_LINE_LEN    256
  19. #define TRUE 1
  20. #define FALSE 0
  21.  
  22. main()
  23. {
  24.     convert(stdin,stdout);
  25.     exit(0);
  26. }
  27.  
  28.  
  29. convert(a,b)
  30.     FILE *a,*b;
  31. {
  32.     static char line[MAX_LINE_LEN];
  33.  
  34.     while (fgets(line,MAX_LINE_LEN,a)) {
  35.        process_line(line, b);
  36.     }
  37. }
  38.  
  39. process_line(line, b)
  40.     char *line;
  41.     FILE *b;
  42. {
  43.     switch(line[0]) {        /* control character */
  44.        case '?': {            /* interactive help entry */
  45.           break;            /* ignore */
  46.        }
  47.        case '@': {            /* start/end table */
  48.           break;            /* ignore */
  49.        }
  50.        case '#': {            /* latex table entry */
  51.           break;            /* ignore */
  52.        }
  53.        case '%': {            /* troff table entry */
  54.           break;            /* ignore */
  55.        }
  56.        case '\n':            /* empty text line */
  57.        case ' ': {            /* normal text line */
  58.           (void) fputs(line,b); 
  59.           break;
  60.        }
  61.        default: {
  62.           if (isdigit(line[0])) { /* start of section */
  63.             (void) fputs(line,b); 
  64.           } else
  65.             fprintf(stderr, "unknown control code '%c' in column 1\n", 
  66.                   line[0]);
  67.           break;
  68.        }
  69.     }
  70. }
  71.