View | Details | Raw Unified | Return to bug 10732
Collapse All | Expand All

(-)c2html/Makefile (-13 / +16 lines)
Lines 1-26 Link Here
1
# New ports collection makefile for:	c2html
1
# New ports collection makefile for:	c2html
2
# Version required:			0.1
2
# Version required:			0.3
3
# Date created:				28 October 1997
3
# Date created:				21 March 1999
4
# Whom:					Andrey Zakhvatov
4
# Whom:					Martin Kammerhofer
5
#
5
#
6
# $Id: Makefile,v 1.1.1.1 1997/11/22 00:30:17 jseger Exp $
6
# $Id$
7
#
7
#
8
8
9
DISTNAME=		c2html-0.1
9
DISTNAME=		c2html-0.3
10
CATEGORIES=		textproc www
10
CATEGORIES=		textproc www
11
MASTER_SITES=		${MASTER_SITE_SUNSITE}
11
MASTER_SITES=		${MASTER_SITE_SUNSITE}
12
MASTER_SITE_SUBDIR=	apps/www/converters
12
MASTER_SITE_SUBDIR=	apps/www/converters
13
13
14
MAINTAINER=		andy@icc.surw.chel.su
14
MAINTAINER=		mkamm@gmx.net
15
16
USE_AUTOCONF=		yes
15
17
16
MAN1=			c2html.1
18
MAN1=			c2html.1
17
19
18
do-install:
20
post-install:
19
	@ ${INSTALL_PROGRAM} ${WRKSRC}/c2html ${PREFIX}/bin
21
	strip ${PREFIX}/bin/c2html
20
	@ ${INSTALL_MAN} ${WRKSRC}/c2html.1 ${PREFIX}/man/man1
22
.if !defined(NOPORTDOCS)
21
	@ ${MKDIR} ${PREFIX}/share/doc/c2html
23
	${MKDIR} ${PREFIX}/share/doc/c2html
22
.for file in COPYING README
24
	${INSTALL_MAN} ${WRKSRC}/AUTHORS ${PREFIX}/share/doc/c2html
23
	@ ${INSTALL_DATA} ${WRKSRC}/${file} ${PREFIX}/share/doc/c2html
25
	${INSTALL_MAN} ${WRKSRC}/NEWS    ${PREFIX}/share/doc/c2html
24
.endfor
26
	${INSTALL_MAN} ${WRKSRC}/README  ${PREFIX}/share/doc/c2html
27
.endif
25
28
26
.include <bsd.port.mk>
29
.include <bsd.port.mk>
(-)c2html/files/md5 (-1 / +1 lines)
Line 1 Link Here
1
MD5 (c2html-0.1.tar.gz) = 66659aec84aad813e52042576abf6662
1
MD5 (c2html-0.3.tar.gz) = 81b404f443f63eb92c1f608673944408
(-)c2html/patches/patch-aa (-15 / +17 lines)
Lines 1-18 Link Here
1
--- Makefile.orig	Mon Sep  1 22:18:51 1997
1
--- Makefile.in~	Wed Mar 10 22:14:48 1999
2
+++ Makefile	Sun Nov 16 17:24:44 1997
2
+++ Makefile.in	Sun Mar 21 18:19:16 1999
3
@@ -2,13 +2,13 @@
3
@@ -12,7 +12,7 @@
4
 # for gzip because otherwise the load on the web server
5
 # grows without having big benefits.
6
 # COMPRESSION = -DCOMPRESSION=4
7
-COMPRESSION = -DCOMPRESSION=1
8
+COMPRESSION ?= -DCOMPRESSION=1
4
 
9
 
5
 CC = gcc
10
 # Dont change things beyond this line.
6
 FLEX = flex
11
 TARGET          = c2html
7
-CFLAGS = -O2 -Wall -pedantic -ansi
12
@@ -40,7 +40,7 @@
8
+CFLAGS+= -Wall -pedantic -ansi -DCOMPRESSION=1
13
 srcdir          = @srcdir@
14
 CPPFLAGS        = @CPPFLAGS@
9
 
15
 
10
 all: c2html
16
-CFLAGS  = -O2 -Wall -pedantic $(COMPRESSION) 
11
 
17
+CFLAGS  += -O2 -Wall -pedantic $(COMPRESSION) 
12
 c2html:	c2html.l
18
 ALL_CFLAGS = $(CFLAGS) -I$(srcdir)
13
 	$(FLEX) c2html.l
14
-	$(CC) $(CFLAGS) -o c2html lex.yy.c -static -lfl
15
+	$(CC) $(CFLAGS) -o c2html lex.yy.c -lfl
16
 clean:
17
 	rm -rf *.o *~ c2html
18
 
19
 
20
 all: $(TARGET)
(-)c2html/patches/patch-ab (-62 lines)
Lines 1-62 Link Here
1
--- README.orig	Tue Sep  2 04:18:51 1997
2
+++ README	Sat Jan 16 16:28:33 1999
3
@@ -1,8 +1,8 @@
4
-c2html version 0.1 by Florian Schintke <schintke@cs.tu-berlin.de>
5
-distributed under the GNU Public license. For further information see
6
-the file COPYING.
7
+c2html version 0.2 by Florian Schintke <schintke@cs.tu-berlin.de>
8
+CGI features added by Martin Kammerhofer <mkamm@gmx.net>
9
 
10
-%% Datei COPYING mitliefern!!!
11
+This program is distributed under  the GNU Public license. For further
12
+information see the file COPYING.
13
 
14
 c2html
15
 ======
16
@@ -33,7 +33,43 @@
17
 files.  The names of the  new files are  built by appending ".html" to
18
 the corresponding input filename. 
19
 
20
+How do I convert my C sources on demand only?
21
+---------------------------------------------
22
 
23
-
24
-
25
-
26
+You need a  webserver to do this. The webserver  must be configured to
27
+INVOKE c2html  as a CGI program to  handle all *.c and  *.h files.  If
28
+your webserver is apache you can achieve this by adding lines
29
+
30
+  AddType text/x-c .c .h
31
+  Action text/x-c /cgi-bin/c2html
32
+
33
+to configuration file "srm.conf".  c2html expects the pathname of it's
34
+input file in environment variable PATH_TRANSLATED.  CGI mode works by
35
+checking    for    environment    variables   GATEWAY_INTERFACE    and
36
+PATH_TRANSLATED. If both are set a HTTP header line
37
+
38
+  Content-Type: text/html
39
+
40
+is simply prepended to the output.
41
+
42
+Since your sources are converted on-the-fly to HTML you don't need any
43
+webspace  for your  html-ized  files. Furthermore  you  don't have  to
44
+bother about keeping your published html-ized sources up to date. :)
45
+
46
+A  drawback might  be that  you cannot  HTTP download  the  plain text
47
+source files  any more. You  can always enable the  'Action' directive
48
+mentioned above  for specific directories or virtual  hosts only. (You
49
+can even use symlinks in combination with '<Directory>' to let surfers
50
+choose themselves  between html-ized and  plain text representations).
51
+Another solution might be to set  up anonymous ftp in such a way, that
52
+users simply have to change 'http:' to 'ftp:' in their URLs to get the
53
+plain text representations of C-sources.
54
+
55
+How can I save bandwidth using c2html as a CGI?
56
+-----------------------------------------------
57
+
58
+If c2html has been compiled with -DCOMPRESSION=1 it will compress it's
59
+HTML  output with gzip  if your  browser supports  it. This  will save
60
+bandwidth but  add additional load  to your webserver  machine. c2html
61
+will not have it's output compressed by gzip if you are connected to a
62
+server on 'localhost'.
(-)c2html/patches/patch-ac (-63 lines)
Lines 1-63 Link Here
1
--- c2html.orig	Tue Sep  2 04:18:51 1997
2
+++ c2html.1	Sat Jan 16 16:28:33 1999
3
@@ -3,7 +3,7 @@
4
 c2html \- generates highlighted html-files from C source
5
 .SH SYNOPSIS
6
 .B c2html
7
-[filenames]
8
+[filename...]
9
 .br
10
 .SH DESCRIPTION
11
 This manual page
12
@@ -16,9 +16,50 @@
13
 
14
 If invoked with filenames as arguments
15
 .B c2html
16
-will write the output in new files. The  names  of the  new 
17
+will write it's output into new files. Names of output
18
 files  are  generated by appending ".html" to the 
19
 corresponding input filename. 
20
 
21
 You can convert both .c and .h files with  
22
 .BR c2html .
23
+.SS Installing as a CGI program
24
+.B c2html
25
+can be installed as a CGI program and convert source files on the
26
+fly. In order to set this up for apache the webmaster has to add the
27
+two lines
28
+.RS
29
+ AddType text/x-c .c .h
30
+.P
31
+ Action text/x-c /cgi-bin/c2html
32
+.RE
33
+to the webserver configuration file.
34
+.B c2html
35
+depends on the webserver properly setting environment variable
36
+PATH_TRANSLATED to the pathname of the source file.
37
+If 
38
+.B c2html
39
+has been compiled with option -DCOMPRESSION=1 then it will invoke
40
+.B gzip
41
+to compress the generated HTML before sending it to the requesting
42
+browser. Of course
43
+.B c2html
44
+takes care to check if the browser accepts gzip encoding.
45
+.SH OPTIONS
46
+.BI -t title
47
+If reading from stdin this sets the title instead of the default
48
+"stdin".  If invoked with filenames as arguments this option is
49
+ignored.
50
+
51
+.BI -w width
52
+sets the WIDTH attribute for HTML tag <PRE>. If this option is not
53
+used a default of 80 is assumed.  (Currently most browsers are
54
+ignoring this attribute).
55
+
56
+.BI -V
57
+reports the version number of
58
+.B c2html
59
+.SH EXIT STATUS
60
+.B c2html
61
+returns 0 on success, 1 if input files are not existing/readable, 2 if
62
+output files are not creatable/writable and 3 if invoked with illegal
63
+options.
(-)c2html/patches/patch-ad (-185 lines)
Lines 1-185 Link Here
1
--- c2html.l.orig	Mon Sep  1 21:18:51 1997
2
+++ c2html.l	Sun Feb 21 20:03:48 1999
3
@@ -1,15 +1,22 @@
4
-%{
5
+%{ /* $Id: patch-ad,v 1.1 1999/02/22 04:22:23 steve Exp $    -*- mode: C -*- */
6
 /* 
7
  * We build a lexical analyzer that converts a C source file to 
8
  * a beautifully highlighted HTML file now.
9
  */
10
 
11
+#define C2HTML_VERSION "0.2"
12
+
13
 #include <stdio.h>
14
-#include <malloc.h>
15
+#include <stdlib.h>
16
 #include <string.h>
17
+#include <unistd.h>
18
 
19
 #include "colors.h"
20
 
21
+#ifndef COMPRESSION
22
+#define COMPRESSION 0
23
+#endif
24
+
25
 FILE *actin;
26
 FILE *actout;
27
 
28
@@ -293,51 +300,113 @@
29
  * path this file) into the output file.
30
  */
31
 
32
+static char *prog;
33
+static void usage() {
34
+    fprintf (stderr, "usage: %s [-t title] [-w width] [file_to_convert ...]\n", prog);
35
+    exit(3);
36
+}
37
+
38
+
39
 int
40
 main(int argc, char *argv[])
41
 {
42
   char *outfilename;
43
-  int i = 1;
44
+  int i, ch, width=80, rc=0;
45
+  char *title=(char *)0, *pt;
46
+  char gzipcmd[10];
47
+
48
+  prog = (pt=strrchr(argv[0], '/')) ? ++pt : argv[0]; /* basename */
49
+  while ((ch = getopt(argc, argv, "h?t:w:V")) != -1)
50
+      switch(ch) {
51
+      case 't':
52
+          title = optarg;
53
+          break;
54
+      case 'w':
55
+          if (sscanf(optarg, "%d", &width) != 1)
56
+              usage();
57
+          break;
58
+      case 'V':
59
+          fprintf(stderr, "c2html version %s%s\n",
60
+		  C2HTML_VERSION, COMPRESSION ? "" : " (no compression)");
61
+          exit(0);
62
+      default:
63
+          usage();
64
+      }
65
+  argc -= optind;
66
+  argv += optind;
67
 
68
-  if (1 == argc) 
69
-    {
70
+  if (argc == 0) {
71
       actin = stdin;
72
       actout = stdout;
73
-      fprintf (actout, "<HTML>\n<HEAD>\n");
74
-      fprintf (actout, "<TITLE>stdout" );
75
+      
76
+      if ((pt=getenv("PATH_TRANSLATED")) && getenv("GATEWAY_INTERFACE")) {
77
+          /* CGI */
78
+          if (!title)
79
+              title = pt;
80
+          actin = fopen (pt, "r");
81
+          if (!actin) {
82
+              fprintf (actout, "Content-Type: text/html\n\n");
83
+              fprintf (actout, "<HTML><HEAD><TITLE>error in CGI '%s'\
84
+</TITLE></HEAD>\n\
85
+<BODY><H1>error in CGI program '%s': cannot read file '%s'</H1></BODY>\n\
86
+</HTML>\n", prog, prog, pt);
87
+              exit(1);
88
+          }
89
+          fprintf (actout, "Content-Type: text/html\n");
90
+#if COMPRESSION
91
+          /* should we compress output with gzip? */
92
+          do {
93
+              if (!(pt=getenv("HTTP_ACCEPT_ENCODING")))
94
+                  break; /* no header Accept-Encoding: */
95
+              if (!strstr(pt, "gzip"))
96
+                  break; /* browser doesn't understand gzip format */
97
+              if ((pt=getenv("REMOTE_ADDR")) && !strncmp(pt, "127", 3))
98
+                  break; /* never compress to local client */
99
+              /* OK, compress output with gzip */
100
+              fprintf(actout, "Content-Encoding: x-gzip\n\n");
101
+              fflush(actout);
102
+              snprintf(gzipcmd, sizeof(gzipcmd), "gzip -%d", COMPRESSION);
103
+              if (!(actout = popen(gzipcmd, "w")))
104
+                  exit(4); /* cannot fork, gzip not found, ... */
105
+          } while (0);
106
+#endif /* COMPRESSION */
107
+      } /* end of CGI section */
108
+      fprintf (actout, "\n<HTML>\n<HEAD>\n");
109
+      fprintf (actout, "<TITLE>%s", title ? title : "stdin");
110
       fprintf (actout, "</TITLE>\n</HEAD>\n\n");
111
       fprintf (actout, "<BODY BGCOLOR=\"%s\">\n", bgcolor);
112
       (void) insert (actout, ownhead);
113
-      fprintf (actout, "<PRE WIDTH=\"80\">");
114
-
115
-      yyin = stdin;
116
-      yyout = stdout;
117
-      
118
+      fprintf (actout, "<PRE WIDTH=\"%d\">", width);
119
+  
120
+      yyin = actin;
121
+      yyout = actout;
122
       yylex();
123
-      
124
-      fprintf (actout,"</PRE>\n</BODY>\n\n</HTML>\n");
125
-    }
126
 
127
-  while (i < argc)
128
-    {
129
+      fprintf (actout,"</PRE>\n</BODY>\n\n</HTML>\n");
130
+  } else for (i=0; i < argc; i++) {
131
       actin = fopen (argv[i], "r");
132
-      if (!actin) 
133
-        {
134
-          fprintf (stderr, "usage: %s [files_to_convert]\n", argv[0]);
135
-          fprintf (stderr, "%s: cannot open file %s\n", argv[0], argv[i]);
136
-          exit (1);
137
+      if (!actin) {
138
+          fprintf (stderr, "%s: cannot read file '%s'\n", prog, argv[i]);
139
+          rc = rc < 1 ? 1 : rc;
140
+          continue;
141
         }
142
       
143
       outfilename = malloc (sizeof (char)*strlen (argv[i]) + 6);
144
       strcat (strcpy (outfilename, argv[i]), ".html");
145
       actout = fopen (outfilename, "w");
146
+      if (!actout) {
147
+          fprintf (stderr, "%s: cannot write file '%s'\n", prog, outfilename);
148
+          rc = rc < 2 ? 2 : rc;
149
+          continue;
150
+      }
151
+      outfilename[strlen(outfilename) - 5] = '\0'; /* chop '.html' suffix */
152
       fprintf (actout, "<HTML>\n<HEAD>\n");
153
       fprintf (actout, 
154
                "<TITLE>%s", outfilename );
155
       fprintf (actout, "</TITLE>\n</HEAD>\n\n");
156
       fprintf (actout, "<BODY BGCOLOR=\"%s\">\n", bgcolor);
157
       (void) insert (actout, ownhead);
158
-      fprintf (actout, "<PRE WIDTH=\"80\">");
159
+      fprintf (actout, "<PRE WIDTH=\"%d\">", width);
160
 
161
       yyin = actin;
162
       yyout = actout;
163
@@ -351,9 +420,8 @@
164
       free (outfilename);
165
       fclose (actin);
166
       fclose (actout);
167
-      i++;
168
-    }
169
-  return 0;
170
+  }
171
+  return rc;
172
 }
173
 
174
 int
175
@@ -372,8 +440,8 @@
176
           c = fgetc (infile);
177
         }
178
       fclose (infile);
179
-      return (1);
180
+      return 1;
181
     }
182
   else
183
-    return (0);   
184
+    return 0;
185
 }
(-)c2html/pkg/DESCR (+5 lines)
Lines 4-6 Link Here
4
font colors  (as Netscape does) the  output will look like highlighted
4
font colors  (as Netscape does) the  output will look like highlighted
5
by emacs.  Otherwise it will  not look  so   nice, but readability  is
5
by emacs.  Otherwise it will  not look  so   nice, but readability  is
6
increased too.
6
increased too.
7
8
c2html can also work as a  CGI program and convert your sources on the
9
fly.   To use  in this  way  copy it  to your  /cgi-bin directory  and
10
configure  your webserver to  call c2html  for *.c  and *.h  files. An
11
example that works with Apache is described in the manpage.
(-)c2html/pkg/PLIST (-1 / +2 lines)
Lines 1-4 Link Here
1
bin/c2html
1
bin/c2html
2
share/doc/c2html/COPYING
2
share/doc/c2html/AUTHORS
3
share/doc/c2html/NEWS
3
share/doc/c2html/README
4
share/doc/c2html/README
4
@dirrm share/doc/c2html
5
@dirrm share/doc/c2html

Return to bug 10732