Date: Mon, 8 Feb 1999 07:38:18 +0300 (MSK) From: Andrey Zakhvatov <andy@icc.surw.chel.su> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: ports/9959: Update port: textproc/c2html Message-ID: <199902080438.HAA27475@icc.surw.chel.su>
next in thread | raw e-mail | index | archive | help
>Number: 9959 >Category: ports >Synopsis: Update port: textproc/c2html >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Feb 7 20:40:00 PST 1999 >Closed-Date: >Last-Modified: >Originator: Andrey Zakhvatov >Release: FreeBSD 2.2.8-RELEASE i386 >Organization: South Ural Railway ICC >Environment: >Description: This is a patch to update textproc/c2html port. It was submitted by Martin Kammerhofer (dada@sbox.tu-graz.ac.at). diff -Nru c2html/patches/patch-aa c2html-0.1/patches/patch-aa --- c2html/patches/patch-aa Sat Nov 22 00:30:17 1997 +++ c2html-0.1/patches/patch-aa Mon Feb 8 10:34:34 1999 @@ -5,7 +5,7 @@ CC = gcc FLEX = flex -CFLAGS = -O2 -Wall -pedantic -ansi -+CFLAGS+= -Wall -pedantic -ansi ++CFLAGS+= -Wall -pedantic -ansi -DCOMPRESSION=1 all: c2html diff -Nru c2html/patches/patch-ab c2html-0.1/patches/patch-ab --- c2html/patches/patch-ab Thu Jan 1 00:00:00 1970 +++ c2html-0.1/patches/patch-ab Mon Feb 8 10:37:43 1999 @@ -0,0 +1,62 @@ +--- README.orig Tue Sep 2 04:18:51 1997 ++++ README Sat Jan 16 16:28:33 1999 +@@ -1,8 +1,8 @@ +-c2html version 0.1 by Florian Schintke <schintke@cs.tu-berlin.de> +-distributed under the GNU Public license. For further information see +-the file COPYING. ++c2html version 0.2 by Florian Schintke <schintke@cs.tu-berlin.de> ++CGI features added by Martin Kammerhofer <mkamm@gmx.net> + +-%% Datei COPYING mitliefern!!! ++This program is distributed under the GNU Public license. For further ++information see the file COPYING. + + c2html + ====== +@@ -33,7 +33,43 @@ + files. The names of the new files are built by appending ".html" to + the corresponding input filename. + ++How do I convert my C sources on demand only? ++--------------------------------------------- + +- +- +- ++You need a webserver to do this. The webserver must be configured to ++INVOKE c2html as a CGI program to handle all *.c and *.h files. If ++your webserver is apache you can achieve this by adding lines ++ ++ AddType text/x-c .c .h ++ Action text/x-c /cgi-bin/c2html ++ ++to configuration file "srm.conf". c2html expects the pathname of it's ++input file in environment variable PATH_TRANSLATED. CGI mode works by ++checking for environment variables GATEWAY_INTERFACE and ++PATH_TRANSLATED. If both are set a HTTP header line ++ ++ Content-Type: text/html ++ ++is simply prepended to the output. ++ ++Since your sources are converted on-the-fly to HTML you don't need any ++webspace for your html-ized files. Furthermore you don't have to ++bother about keeping your published html-ized sources up to date. :) ++ ++A drawback might be that you cannot HTTP download the plain text ++source files any more. You can always enable the 'Action' directive ++mentioned above for specific directories or virtual hosts only. (You ++can even use symlinks in combination with '<Directory>' to let surfers ++choose themselves between html-ized and plain text representations). ++Another solution might be to set up anonymous ftp in such a way, that ++users simply have to change 'http:' to 'ftp:' in their URLs to get the ++plain text representations of C-sources. ++ ++How can I save bandwidth using c2html as a CGI? ++----------------------------------------------- ++ ++If c2html has been compiled with -DCOMPRESSION=1 it will compress it's ++HTML output with gzip if your browser supports it. This will save ++bandwidth but add additional load to your webserver machine. c2html ++will not have it's output compressed by gzip if you are connected to a ++server on 'localhost'. diff -Nru c2html/patches/patch-ac c2html-0.1/patches/patch-ac --- c2html/patches/patch-ac Thu Jan 1 00:00:00 1970 +++ c2html-0.1/patches/patch-ac Mon Feb 8 10:38:27 1999 @@ -0,0 +1,63 @@ +--- c2html.orig Tue Sep 2 04:18:51 1997 ++++ c2html.1 Sat Jan 16 16:28:33 1999 +@@ -3,7 +3,7 @@ + c2html \- generates highlighted html-files from C source + .SH SYNOPSIS + .B c2html +-[filenames] ++[filename...] + .br + .SH DESCRIPTION + This manual page +@@ -16,9 +16,50 @@ + + If invoked with filenames as arguments + .B c2html +-will write the output in new files. The names of the new ++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 + .BR c2html . ++.SS Installing as a CGI program ++.B 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 ++.RS ++ AddType text/x-c .c .h ++.P ++ Action text/x-c /cgi-bin/c2html ++.RE ++to the webserver configuration file. ++.B c2html ++depends on the webserver properly setting environment variable ++PATH_TRANSLATED to the pathname of the source file. ++If ++.B c2html ++has been compiled with option -DCOMPRESSION=1 then it will invoke ++.B gzip ++to compress the generated HTML before sending it to the requesting ++browser. Of course ++.B c2html ++takes care to check if the browser accepts gzip encoding. ++.SH OPTIONS ++.BI -t title ++If reading from stdin this sets the title instead of the default ++"stdin". If invoked with filenames as arguments this option is ++ignored. ++ ++.BI -w width ++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). ++ ++.BI -V ++reports the version number of ++.B c2html ++.SH EXIT STATUS ++.B c2html ++returns 0 on success, 1 if input files are not existing/readable, 2 if ++output files are not creatable/writable and 3 if invoked with illegal ++options. diff -Nru c2html/patches/patch-ad c2html-0.1/patches/patch-ad --- c2html/patches/patch-ad Thu Jan 1 00:00:00 1970 +++ c2html-0.1/patches/patch-ad Mon Feb 8 10:39:10 1999 @@ -0,0 +1,184 @@ +--- c2html.orig Tue Sep 2 04:18:51 1997 ++++ c2html.l Sat Jan 16 16:28:33 1999 +@@ -1,15 +1,21 @@ +-%{ ++%{ /* $Id: c2html.l,v 1.3 1999/01/16 15:28:33 dada Exp $ -*- mode: C -*- */ + /* + * We build a lexical analyzer that converts a C source file to + * a beautifully highlighted HTML file now. + */ + ++#define C2HTML_VERSION "0.2" ++ + #include <stdio.h> +-#include <malloc.h> ++#include <stdlib.h> + #include <string.h> + + #include "colors.h" + ++#ifndef COMPRESSION ++#define COMPRESSION 0 ++#endif ++ + FILE *actin; + FILE *actout; + +@@ -293,51 +299,113 @@ + * path this file) into the output file. + */ + ++static char *prog; ++static void usage() { ++ fprintf (stderr, "usage: %s [-t title] [-w width] [file_to_convert ...]\n", prog); ++ exit(3); ++} ++ ++ + int + main(int argc, char *argv[]) + { + char *outfilename; +- int i = 1; ++ int i, ch, width=80, rc=0; ++ char *title=(char *)0, *pt; ++ char gzipcmd[10]; ++ ++ prog = (pt=strrchr(argv[0], '/')) ? ++pt : argv[0]; /* basename */ ++ while ((ch = getopt(argc, argv, "h?t:w:V")) != -1) ++ switch(ch) { ++ case 't': ++ title = optarg; ++ break; ++ case 'w': ++ if (sscanf(optarg, "%d", &width) != 1) ++ usage(); ++ break; ++ case 'V': ++ fprintf(stderr, "c2html version %s%s\n", ++ C2HTML_VERSION, COMPRESSION ? "" : " (no compression)"); ++ exit(0); ++ default: ++ usage(); ++ } ++ argc -= optind; ++ argv += optind; + +- if (1 == argc) +- { ++ if (argc == 0) { + actin = stdin; + actout = stdout; +- fprintf (actout, "<HTML>\n<HEAD>\n"); +- fprintf (actout, "<TITLE>stdout" ); ++ ++ if ((pt=getenv("PATH_TRANSLATED")) && getenv("GATEWAY_INTERFACE")) { ++ /* CGI */ ++ if (!title) ++ title = pt; ++ actin = fopen (pt, "r"); ++ if (!actin) { ++ fprintf (actout, "Content-Type: text/html\n\n"); ++ fprintf (actout, "<HTML><HEAD><TITLE>error in CGI '%s'\ ++</TITLE></HEAD>\n\ ++<BODY><H1>error in CGI program '%s': cannot read file '%s'</H1></BODY>\n\ ++</HTML>\n", prog, prog, pt); ++ exit(1); ++ } ++ fprintf (actout, "Content-Type: text/html\n"); ++#if COMPRESSION ++ /* should we compress output with gzip? */ ++ do { ++ if (!(pt=getenv("HTTP_ACCEPT_ENCODING"))) ++ break; /* no header Accept-Encoding: */ ++ if (!strstr(pt, "gzip")) ++ break; /* browser doesn't understand gzip format */ ++ if ((pt=getenv("REMOTE_ADDR")) && !strncmp(pt, "127", 3)) ++ break; /* never compress to local client */ ++ /* OK, compress output with gzip */ ++ fprintf(actout, "Content-Encoding: x-gzip\n\n"); ++ fflush(actout); ++ snprintf(gzipcmd, sizeof(gzipcmd), "gzip -%d", COMPRESSION); ++ if (!(actout = popen(gzipcmd, "w"))) ++ exit(4); /* cannot fork, gzip not found, ... */ ++ } while (0); ++#endif /* COMPRESSION */ ++ } /* end of CGI section */ ++ fprintf (actout, "\n<HTML>\n<HEAD>\n"); ++ fprintf (actout, "<TITLE>%s", title ? title : "stdin"); + fprintf (actout, "</TITLE>\n</HEAD>\n\n"); + fprintf (actout, "<BODY BGCOLOR=\"%s\">\n", bgcolor); + (void) insert (actout, ownhead); +- fprintf (actout, "<PRE WIDTH=\"80\">"); +- +- yyin = stdin; +- yyout = stdout; +- ++ fprintf (actout, "<PRE WIDTH=\"%d\">", width); ++ ++ yyin = actin; ++ yyout = actout; + yylex(); +- +- fprintf (actout,"</PRE>\n</BODY>\n\n</HTML>\n"); +- } + +- while (i < argc) +- { ++ fprintf (actout,"</PRE>\n</BODY>\n\n</HTML>\n"); ++ } else for (i=0; i < argc; i++) { + actin = fopen (argv[i], "r"); +- if (!actin) +- { +- fprintf (stderr, "usage: %s [files_to_convert]\n", argv[0]); +- fprintf (stderr, "%s: cannot open file %s\n", argv[0], argv[i]); +- exit (1); ++ if (!actin) { ++ fprintf (stderr, "%s: cannot read file '%s'\n", prog, argv[i]); ++ rc = rc < 1 ? 1 : rc; ++ continue; + } + + outfilename = malloc (sizeof (char)*strlen (argv[i]) + 6); + strcat (strcpy (outfilename, argv[i]), ".html"); + actout = fopen (outfilename, "w"); ++ if (!actout) { ++ fprintf (stderr, "%s: cannot write file '%s'\n", prog, outfilename); ++ rc = rc < 2 ? 2 : rc; ++ continue; ++ } ++ outfilename[strlen(outfilename) - 5] = '\0'; /* chop '.html' suffix */ + fprintf (actout, "<HTML>\n<HEAD>\n"); + fprintf (actout, + "<TITLE>%s", outfilename ); + fprintf (actout, "</TITLE>\n</HEAD>\n\n"); + fprintf (actout, "<BODY BGCOLOR=\"%s\">\n", bgcolor); + (void) insert (actout, ownhead); +- fprintf (actout, "<PRE WIDTH=\"80\">"); ++ fprintf (actout, "<PRE WIDTH=\"%d\">", width); + + yyin = actin; + yyout = actout; +@@ -351,9 +419,8 @@ + free (outfilename); + fclose (actin); + fclose (actout); +- i++; +- } +- return 0; ++ } ++ return rc; + } + + int +@@ -372,8 +439,8 @@ + c = fgetc (infile); + } + fclose (infile); +- return (1); ++ return 1; + } + else +- return (0); ++ return 0; + } >How-To-Repeat: >Fix: Please, check and apply this patch. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902080438.HAA27475>