File: 011-man2html-doctype-status.patch

package info (click to toggle)
man2html 1.6f%2Brepack-1%2Bsqueeze1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,416 kB
  • ctags: 2,894
  • sloc: ansic: 9,558; sh: 2,301; makefile: 343; perl: 335; awk: 305; lisp: 171; cs: 170
file content (145 lines) | stat: -rw-r--r-- 4,301 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Add DOCTYPE and `Status:' header to man2html

diff -ruN -x config.guess -x config.sub man-1.6e-old/man2html/man2html.c man-1.6e/man2html/man2html.c
--- man-1.6e-old/man2html/man2html.c	2007-01-31 01:29:30.000000000 +0100
+++ man-1.6e/man2html/man2html.c	2007-01-31 01:29:30.000000000 +0100
@@ -27,6 +27,8 @@
 #define BD_INDENT   2
 
 #define SIZE(a)	(sizeof(a)/sizeof(*a))
+#define DOCTYPE "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
+#define CONTENTTYPE "Content-type: text/html\n\n"
 
 static char NEWLINE[2]="\n";
 static char idxlabel[6] = "ixAAA";
@@ -1848,6 +1850,7 @@
 		    if (!t) t=fname;
 		    fprintf(stderr, "ln -s %s.html %s.html\n", h, t);
 		    s=strrchr(t, '.');if (!s) s=t;
+		    printf(CONTENTTYPE DOCTYPE);
 		    printf("<HTML><HEAD><TITLE> Man page of %s</TITLE>\n"
 			   "</HEAD><BODY>\n"
 			   "See the man page for <A HREF=\"%s.html\">%s</A>.\n"
@@ -2102,6 +2105,7 @@
 		*sl = 0;
 		if (words > 1) {
 		    output_possible=1;
+		    printf(CONTENTTYPE DOCTYPE);
 		    out_html("<HTML><HEAD><TITLE>Man page of ");
 		    out_html(wordlist[0]);
 		    out_html("</TITLE>\n</HEAD><BODY>\n<H1>");
@@ -3001,9 +3005,25 @@
 STRDEF *foundpages=NULL;
 
 static void
-error_page(char *s, char *t, ...) {
+error_page(int status, char *s, char *t, ...) {
      va_list p;
 
+     switch(status) {
+	case 403:
+		printf("Status: 403 Forbidden\n");
+		break;
+	case 404:
+		printf("Status: 404 Not Found\n");
+		break;
+	case 500:
+		printf("Status: 500 Internal Server Error\n");
+		break;
+	case 0:
+	default:
+		break;
+     }
+	     
+     printf(CONTENTTYPE DOCTYPE);
      printf("<HTML><HEAD><TITLE>%s</TITLE></HEAD>\n"
 	    "<BODY>\n<H1>%s</H1>\n", s, s);
      va_start(p, t);
@@ -3017,7 +3037,7 @@
 xstrdup(const char *s) {
      char *p = strdup(s);
      if (p == NULL)
-	  error_page("Out of memory",
+	  error_page(500, "Out of memory",
 			 "Sorry, out of memory, aborting...\n");
      return p;
 }
@@ -3026,7 +3046,7 @@
 xmalloc(size_t size) {
      void *p = malloc(size);
      if (p == NULL)
-	  error_page("Out of memory",
+	  error_page(500, "Out of memory",
 			 "Sorry, out of memory, aborting...\n");
      return p;
 }
@@ -3035,14 +3055,14 @@
 xrealloc(void *ptr, size_t size) {
      void *p = realloc(ptr,size);
      if (p == NULL)
-	  error_page("Out of memory",
+	  error_page(500, "Out of memory",
 			 "Sorry, out of memory, aborting...\n");
      return p;
 }
 
 static void
 usage(void) {
-     error_page("man2html: bad invocation",
+     error_page(500, "man2html: bad invocation",
 	"Call: man2html [-l|-h host.domain:port] [-p|-q] [filename]\n"
 	"or:   man2html -r [filename]\n");
 }
@@ -3095,7 +3115,7 @@
     extern char *optarg;
 #endif
 
-    printf("Content-type: text/html\n\n");
+/*    printf("Content-type: text/html\n\n"); */
 
     opterr = 0;			/* no stderr error messages */
     while ((c = getopt (argc, argv, "D:E:hH:lL:M:pqr?vVf")) != -1) {
@@ -3103,7 +3123,7 @@
 	 case 'D':
 	      goto_dir(optarg, 0, 0); break;
 	 case 'E':
-	      error_page("Error", "%s", optarg); break;
+	      error_page(0, "Error", "%s", optarg); break;
 	 case 'h':
 	      set_cgibase("localhost"); break;
 	 case 'H':
@@ -3122,7 +3142,7 @@
 	      set_relative_html_links(); break;
 	 case 'v':
 	 case 'V':
-	      error_page("Version", "%s from man-%s", argv[0], version);
+	      error_page(0, "Version", "%s from man-%s", argv[0], version);
 	      exit(0);
 	 case '?':
 	 default:
@@ -3154,7 +3174,7 @@
 
 	 f = fopen(fnam, "r");
 	 if (f == NULL)
-	      error_page("File not found", "Could not open %s\n", filename);
+	      error_page(404, "File not found", "Could not open %s\n", filename);
 	 fname = fnam;
     }
 
@@ -3222,14 +3242,14 @@
 	if (!filename)
 	     filename = fname;
 	if (*filename == '/')
-	     error_page("Invalid Man Page",
+	     error_page(403, "Invalid Man Page",
 		   "The requested file %s is not a valid (unformatted) "
 		   "man page.\nIf the file is a formatted man page, "
 		   "you could try to load the\n"
 		   "<A HREF=\"file://localhost%s\">plain file</A>.\n",
 		   filename, filename);
 	else
-	     error_page("Invalid Man Page",
+	     error_page(403, "Invalid Man Page",
 		   "The requested file %s is not a valid (unformatted) "
 		   "man page.", filename);
     }