README
1-----
2Copyright (C) 1999 - 2006 Florian Schintke
3Copyright (C) 1999 Martin Kammerhofer for the CGI feature
4Copyright (C) 2000 Rob Ewan for the indexing feature
5
6This is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 2, or (at your option) any later
9version.
10
11This is distributed in the hope that it will be useful, but WITHOUT
12ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License with
17the c2html source package as the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA.
20-----
21
22c2html
23======
24
25Where to get c2html?
26--------------------
27The homepage of c2html is
28http://user.cs.tu-berlin.de/~schintke/x2html/index.html
29
30You can get c2html also from the metalab server:
31ftp://metalab.unc.edu/pub/Linux/apps/www/converters/
32
33What is c2html?
34---------------
35
36The c2html program is a syntax highlighter for C source code that
37produces a highlighted html file as output. The output can be read by
38any graphical WWW-Browser. If the browser understands the tags to
39change font colors (as Netscape does) the output will look like
40highlighted by emacs. Otherwise it will not look so nice, but
41readability is increased too.
42
43Who uses c2html?
44----------------
45
46Everyone who provides sources in the web.
47
48How do I use c2html?
49--------------------
50
51This is rather simple. If you start the program without any parameters
52it will read the source from stdin and prints the output to stdout.
53
54If you invoke c2html with filenames on the command line it will
55process every given file in sequence and will store the output in new
56files. The names of the new files are built by appending ".html" to
57the corresponding input filename.
58
59How do I convert my C sources on demand only?
60---------------------------------------------
61
62You need a webserver to do this. The webserver must be configured to
63INVOKE c2html as a CGI program to handle all *.c and *.h files. If
64your webserver is apache you can achieve this by adding lines
65
66 AddType text/x-c .c .h
67 Action text/x-c /cgi-bin/c2html
68
69to configuration file "http.conf". The c2html program expects the
70pathname of its input file in environment variable PATH_TRANSLATED.
71CGI mode works by checking for environment variables GATEWAY_INTERFACE
72and PATH_TRANSLATED. If both are set a HTTP header line
73
74 Content-Type: text/html
75
76and meta tags with the file's last modification date and the program
77that generated the html file are written to the html header.
78
79If you want to call the converter with default parameters like -n you
80have to write a wrapper script like the following (Notice that you
81have to 'chmod +x' the script file):
82
83file c2html_wrap in the cgi-bin directory of your webserver:
84--
85#! /bin/sh
86./c2html -n
87--
88
89Then you let apache call the wrapper script with the following entry:
90
91 Action text/x-c /cgi-bin/c2html_wrap
92
93Since your sources are converted on-the-fly to HTML you don't need any
94webspace for your html-ized files. Furthermore you don't have to
95bother about keeping your published html-ized sources up to date. :)
96
97If one wants to save the html-ized source for compiling it is best to
98use the "Text" format when saving from the browser.
99
100How can I save bandwidth using c2html as a CGI?
101-----------------------------------------------
102
103If c2html has been compiled with -DCOMPRESSION=1 it will compress it's
104HTML output with gzip if your browser supports it. This will save
105bandwidth but add additional load to your webserver machine. If you
106are connected to a server on 'localhost', c2html will not compress
107it's output by gzip. Larger values for COMPRESSION than 1 are not
108recommended because it adds more CPU load to the server without saving
109much bandwidth.
110
111How can I get an index at the top of the source?
112------------------------------------------------
113
114The -i switch lets you add a clickable index at the top of the HTML
115page. The index is a list of the labels that c2html generates for
116your source file. Each label is converted into an HTML list item
117(<li>-tag). To add the index, the program must make two passes through
118the source file, so you will need a wrapper script like this one:
119
120---
121#! /bin/sh
122echo "Content-type: text/html"
123echo ""
124echo "<html>"
125echo "<head><title>$PATH_TRANSLATED</title>"
126echo "<meta name=\"generator\" content=\"`c2html -V`\">"
127echo "</head>"
128echo "<body>"
129echo "<h1>Source of $PATH_TRANSLATED</h1>"
130echo "<ul>Structures and functions"
131cat $PATH_TRANSLATED | c2html -isc
132echo "</ul>"
133echo "<hr></hr>"
134cat $PATH_TRANSLATED | c2html -sc
135echo "</body></html>"
136exit
137---