home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
txict100.zip
/
texicvt1.00
/
source
/
mainhtml.cc
< prev
next >
Wrap
C/C++ Source or Header
|
1997-03-31
|
6KB
|
231 lines
/*
================================================================================
Texinfo converting Tools
Release 1.00 28.03.97
(c) 1996 by Andreas Kaiser
(c) 1997 by Karl Heinz Marbaise
================================================================================
Discription:
main Programm for converting Texinfo to HTML
Authors:
Andreas Kaiser
Karl Heinz Marbaise
e-mail:
Internet: KHMarbaise@p69.ks.fido.de
Fido-net: 2:2452/117.69
Bugs, question:
to above e-mail adress.
Register:
Please send a e-mail to above adress to register.
(include the release you want to register)
This registration should be done to let me
know how many people using these tools and
if it is worth to invest more time in continuing
development these tools or let the first release
of them be the last.
That is the only reason to make a registration.
I think a e-mail is not to much, isn't it?
License:
The "Texinfo converting tools" are free software;
you can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option)
any later version.
The "Texinfo converting tools" are distributed in the hope that
they will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the "Texinfo converting tools" ; see the file COPYING.
If not, write to the:
Free Software Foundation,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
See \texicvt1.00\COPYING for details.
================================================================================
*/
/*
------------------------------------------------------------------------------
(R)evision (C)ontrol (S)ystem
------------------------------------------------------------------------------
*/
#ifdef __RCS__
static const char *mainhtml_cc = "$Id: MAINHTML.CC 1.7 1997/03/30 15:08:19 KHM Exp $";
#endif
/*--------------------------------------------------------------------------*/
/* Include Files */
/*--------------------------------------------------------------------------*/
#define EXTERN
#define INIT(x) = x
#include "info.h"
#include <fstream.h>
#include <stdio.h>
#include <ctype.h>
#if defined (__EMX__)
#include <getopt.h>
#else
#include <GetOpt.h>
#endif
#include "version.h"
void
usage()
{
cout <<"txi2html [options {in [out]]" << endl
<<" -Dflag set Texinfo flag" << endl
<<" -Uflag clear Texinfo flag" << endl
<<" -i create IPF index" << endl
<<" -n use @node to split into panels, not @chapter" << endl
<<" -d debugging aid" << endl
<<" -f flex scanner trace" << endl
<<" -v print out version, copyright and" << endl
<<" copying conditions." << endl
<<" in texinfo file, default=stdin" << endl
<<" out inf file (*.inf) or ipf source (else)" << endl;
}
main(int argc, char **argv)
{
int c;
int compile = 0;
int direct = 0;
char *fn = (char *)NULL;
#if defined (__EMX__)
char s[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char file[_MAX_FNAME];
char ext[_MAX_EXT];
#endif
ofstream *outf = 0;
extern int yy_flex_debug;
yy_flex_debug = 0;
f_node = 0; /* use chapter */
f_index = 0; /* don't create index */
IncludeFile = 0;
#if defined (__EMX__)
GetOpt getopt(argc, argv, "?hdD:finU:ov");
#else
GetOpt getopt(argc, argv, "?hdD:finU:v");
#endif
for (c = 0; (c = getopt()) != EOF; )
switch (c) {
case 'o':
direct = 1;
break;
case 'd':
++debug;
break;
case 'D':
flags[(String &)getopt.optarg] = 1;
break;
case 'f':
++yy_flex_debug;
break;
case 'i':
++f_index;
break;
case 'n':
++f_node;
break;
case 'U':
flags[(String &)getopt.optarg] = (const char *)0;
break;
case 'v':
PrintCopyright ();
case '?':
case 'h':
default:
usage();
exit(2);
}
if (getopt.optind < argc) {
fn = argv[getopt.optind];
if (freopen(fn, "r", stdin) == NULL) {
perror(fn);
exit(1);
}
}
String ipfname, basename;
#if defined (__EMX__)
if (direct)
{
sprintf (s, fn);
_splitpath(s,drive,dir,file,ext);
_makepath (s,drive,dir,file,".html");
fprintf (stderr, "converting %s to %s\n", fn, s);
out = outf = new ofstream(s);
if (!outf->good()) {
perror(s);
exit(1);
}
}
#endif
if (++getopt.optind < argc) {
ipfname = argv[getopt.optind];
int ext = ipfname.index('.', -1);
if (ext >= 0) {
basename = ipfname.before(ext);
if (fcompare(ipfname.from(ext), ".inf") == 0) {
compile = 1;
ipfname.from(ext) = ".ipf";
}
}
out = outf = new ofstream(ipfname);
if (!outf->good()) {
perror(ipfname);
exit(1);
}
}
*out << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 3.0//EN\">" << endl;
*out << "<HTML>" << endl;
*out << "<!-- " << RELEASENAME << " -->" << endl;
*out << "<!-- " << COPYRIGHT << " -->" << endl;
*out << "<HEAD>" << endl;
while ((c = yylex()) > 0)
{
if (c == '\n')
/* *out << endl; */ /* << "<BR>";*/ /* this looks well but is
* not allowed in all
* circumstances
*/
newline (); /**out << endl;*/
else
PUTS ((char)c); /* *out << (char)c; */
}
*out << "</BODY>" << endl;
*out << "</HTML>" << endl;
if (outf)
outf->close();
if (IncludeFile)
cerr << endl;
return c ? 1 : 0;
}