home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / utility / gsview13 / src / gvdoc.c < prev    next >
C/C++ Source or Header  |  1995-12-09  |  2KB  |  89 lines

  1. /* Copyright (C) 1993, 1994, Russell Lang.  All rights reserved.
  2.   
  3.   This file is part of GSview.
  4.   
  5.   This program is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the GSview Free Public Licence 
  9.   (the "Licence") for full details.
  10.   
  11.   Every copy of GSview must include a copy of the Licence, normally in a 
  12.   plain ASCII text file named LICENCE.  The Licence grants you the right 
  13.   to copy, modify and redistribute GSview, but only under certain conditions 
  14.   described in the Licence.  Among other things, the Licence requires that 
  15.   the copyright notice and this notice be preserved on all copies.
  16. */
  17.  
  18. /* gvdoc.c */
  19. /* Preprocess doc file
  20.  *
  21.  * usage:  gvdoc W infile.doc outfile.doc
  22.  *
  23.  *   where infile.doc is a GSview superset of a Gnuplot .DOC file 
  24.  *   supporting conditionals and outfile.doc is a gnuplot style .DOC file.
  25.  *
  26.  * typical usage for GSview:
  27.  *
  28.  *   for Windows:
  29.  *     gvdoc W gvc.doc gsview.doc
  30.  *     doc2rtf gsview.doc gsview.rtf
  31.  *     hc31 gsview.hpj
  32.  *
  33.  *   for OS/2:
  34.  *     gvdoc P gvc.doc gsview.doc
  35.  *     doc2ipf gsview.doc gvpm.ipf
  36.  *     ipfc gvpm.ipf
  37.  *     ipfc /INF gvpm.ipf
  38.  *     
  39.  */
  40.  
  41. #include <stdio.h>
  42. #include <ctype.h>
  43.  
  44. #define MAX_NAME_LEN    256
  45. #define MAX_LINE_LEN    256
  46. #define TRUE 1
  47. #define FALSE 0
  48.  
  49. typedef int boolean;
  50.  
  51. char start;
  52. char end = 'E';
  53. boolean ignore = FALSE;
  54. char line[MAX_LINE_LEN];
  55.  
  56. int
  57. main(int argc, char *argv[])
  58. {
  59. FILE * infile;
  60. FILE * outfile;
  61.     infile = stdin;
  62.     outfile = stdout;
  63.     if (argc != 4) {
  64.         fprintf(stderr,"Usage: %s W|P infile outfile\n", argv[0]);
  65.         return 1;
  66.     }
  67.     start = argv[1][0];
  68.     if ( (infile = fopen(argv[2],"r")) == (FILE *)NULL) {
  69.         fprintf(stderr,"%s: Can't open %s for reading\n",
  70.             argv[0], argv[2]);
  71.         return 1;
  72.     }
  73.     if ( (outfile = fopen(argv[3],"w")) == (FILE *)NULL) {
  74.         fprintf(stderr,"%s: Can't open %s for writing\n",
  75.             argv[0], argv[3]);
  76.     }
  77.     
  78.     while (fgets(line, MAX_LINE_LEN, infile)) {
  79.         if ( (line[0] == start) || (line[0] == end) )
  80.         ignore = FALSE;
  81.         else if (isalpha(line[0]))
  82.         ignore = TRUE;
  83.         else if (!ignore)
  84.         fputs(line, outfile);
  85.     }
  86.     fclose(outfile);
  87.     return 0;
  88. }
  89.