c2html - generates highlighted html-files from C source
c2html [options] [filename...]
This manual page documents how to use c2html. If no arguments are
given on the command line of c2html, it reads from stdin and writes to
If invoked with filenames as arguments c2html will write it’s output
into new files. Names of output files are generated by appending
".html" to the corresponding input filename.
You can convert both .c and .h files with c2html.
Installing as a CGI program
c2html can be installed as a CGI program and convert source files on
the fly. In order to set this up for apache the webmaster has to add
the two lines
AddType text/x-c .c .h
Action text/x-c /cgi-bin/c2html
to the webserver configuration file. c2html depends on the webserver
properly setting environment variable PATH_TRANSLATED to the pathname
of the source file. If c2html has been compiled with option
-DCOMPRESSION=1 then it will invoke gzip to compress the generated HTML
before sending it to the requesting browser. Of course c2html takes
care to check if the browser accepts gzip encoding.
-- Interpret all following arguments on the command line as
filenames. This is useful, if you want to convert files
beginning with a ’-’.
Insert the file ’filename’ after converted data and before HTML
footer. See also the -s option.
-c Turns off CGI-script detection and HTTP header generation. This
is needed to use c2html as a subcommand in another CGI script.
Insert the file ’filename’ after the HTML headers and before the
converted data. See also the -s option.
-i Generate an index only. This will generate a list of references
(HREF’s) to the labels that c2html creates for your source file.
The references are created as list items (<li>) in an HTML list.
Each line has the form
so they can be used directly as an index list, or further parsed
by another script.
If you want the index at the top of the source file, you will
need a wrapper script like this one:
echo "Content-type: text/html"
echo "<meta name=\"generator\""
echo "content=\"`c2html -V`\">"
echo "<h1>Source of $PATH_TRANSLATED</h1>"
echo "<ul>Structures and functions"
cat $PATH_TRANSLATED | c2html -isc
cat $PATH_TRANSLATED | c2html -sc
-n Number lines and label them with ’line’ followed by the line
number. Empty lines get no label, but the linecounter will count
them nevertheless. With this feature you can refer to special
lines of code from other parts of the generated file or from
external files with a line like this:
<A HREF="foo.c.html#line301">Go to line 301</A>
-N Similar to -n , but also blank lines get a label.
-s With this option you can suppress the generation of HTML
headers. This is especially useful together with options -b
file and -h file.
Set the title to ’title’. The default is the filename you
converted or "stdin" if reading from stdin. This option is only
used if -s is not set.
-u Print usage information.
sets the WIDTH attribute for HTML tag <PRE>. If this option is
not used a default of 80 is assumed. (Currently most browsers
are ignoring this attribute).
use size for tab size (default 8, max 80).
-V reports the version number of c2html.
c2html returns 0 on success, 1 if input files are not
existing/readable, 2 if output files are not creatable/writable, 3 if
invoked with illegal options and 4 if gzip cannot be invoked.
Florian Schintke <firstname.lastname@example.org>
Martin Kammerhofer <email@example.com> wrote the CGI feature.
Rob Ewan <firstname.lastname@example.org> wrote the indexing feature.
java2html(1), pas2html(1), perl2html(1).