#ifndef lint
static char *RCSid() { return RCSid("$Id: doc2html.c,v 1.9 2016/01/16 12:33:43 broeker Exp $"); }
#endif
/* GNUPLOT - doc2html.c */
/*[
* Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose with or without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
*
* Permission to modify the software is granted, but not the right to
* distribute the complete modified source code. Modifications are to
* be distributed as patches to the released version. Permission to
* distribute binaries produced by compiling modified sources is granted,
* provided you
* 1. distribute the corresponding source modifications from the
* released version in the form of a patch file along with the binaries,
* 2. add special version identification to distinguish your version
* in addition to the base release version number,
* 3. provide your name and address as the primary contact for the
* support of your modified version, and
* 4. retain our contact information in regard to use of the base
* software.
* Permission to distribute the released version of the source code along
* with corresponding source modifications in the form of a patch file is
* granted with same provisions 2 through 4 for binary distributions.
*
* This software is provided "as is" without express or implied warranty
* to the extent permitted by applicable law.
]*/
/*
* doc2html.c -- program to convert Gnuplot .DOC format to MS Windows
* HTML help (.html) format.
*
* Derived from doc2rtf and doc2html (version 3.7.3) by B. Maerkisch
*
* usage: doc2html file.doc outputdirectory [-d]
*
*/
/* note that tables must begin in at least the second column to */
/* be formatted correctly and tabs are forbidden */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef WXHELP
/* The Microsoft help compiler splits topics and creates the index automatically.
To create help files for wxWidgets we need to do this manually.
Note that this might overwrite the stub index file from CVS. */
#define SPLIT_FILES
#define CREATE_INDEX
#endif
#include "syscfg.h"
#include "stdfn.h"
#define MAX_LINE_LEN 10230
#include "doc2x.h"
#include "xref.h"
#include "version.h"
static TBOOLEAN debug = FALSE;
static char path[PATH_MAX];
static const char name[] = "wgnuplot";
void convert __PROTO((FILE *, FILE *, FILE *, FILE *));
void process_line __PROTO((char *, FILE *, FILE *, FILE *));
int
main (int argc, char **argv)
{
FILE *infile;
FILE *outfile;
FILE *contents;
FILE *index = NULL;
char filename[PATH_MAX];
char *last_char;
if (argc == 4 && argv[3][0] == '-' && argv[3][1] == 'd')
debug = TRUE;
if (argc != 3 && !debug) {
fprintf(stderr, "Usage: %s infile outpath\n", argv[0]);
exit(EXIT_FAILURE);
}
if ((infile = fopen(argv[1], "r")) == (FILE *) NULL) {
fprintf(stderr, "%s: Can't open %s for reading\n",
argv[0], argv[1]);
exit(EXIT_FAILURE);
}
strcpy(path, argv[2]);
/* make sure there's a path separator at the end */
last_char = path + strlen(path);
if ((*last_char != DIRSEP1) && (*last_char != DIRSEP2)) {
*last_char++ = DIRSEP1;
*last_char = 0;
}
strcpy(filename, path);
strcat(filename, name);
strcat(filename, ".html");
if ((outfile = fopen(filename, "w")) == (FILE *) NULL) {
fprintf(stderr, "%s: Can't open %s for writing\n",
argv[0], filename);
fclose(infile);
exit(EXIT_FAILURE);
}
strcpy(filename, path);
strcat(filename, name);
strcat(filename, ".hhc");
if ((contents = fopen(filename, "w")) == (FILE *) NULL) {
fprintf(stderr, "%s: Can't open %s for writing\n",
argv[0], filename);
fclose(infile);
fclose(outfile);
exit(EXIT_FAILURE);
}
#ifdef CREATE_INDEX
strcpy(filename, path);
strcat(filename, name);
strcat(filename, ".hhk");
if ((index = fopen(filename, "w")) == (FILE *) NULL) {
fprintf(stderr, "%s: Can't open %s for writing\n",
argv[0], filename);
fclose(infile);
fclose(outfile);
fclose(contents);
exit(EXIT_FAILURE);
}
#endif
parse(infile);
convert(infile, outfile, contents, index);
return EXIT_SUCCESS;
}
void
header(FILE *a, char * title)
{
/* generate html header */
fprintf(a, "\n");
fprintf(a, "\n");
fprintf(a, "