From 5280f9a0cd1f9ba200422ebba65d1e0133410995 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 13 Sep 2014 09:43:21 -0700 Subject: Initial. --- man2html/scripts/cgi-aux/man/man.aux | 75 +++++++ man2html/scripts/cgi-aux/man/mansearch.aux | 49 ++++ man2html/scripts/cgi-aux/man/mansearchhelp.aux | 295 +++++++++++++++++++++++++ man2html/scripts/cgi-bin/man/man2html | 109 +++++++++ man2html/scripts/cgi-bin/man/mansearch | 192 ++++++++++++++++ man2html/scripts/cgi-bin/man/mansearchhelp | 32 +++ man2html/scripts/cgi-bin/man/mansec | 183 +++++++++++++++ man2html/scripts/cgi-bin/man/manwhatis | 208 +++++++++++++++++ 8 files changed, 1143 insertions(+) create mode 100644 man2html/scripts/cgi-aux/man/man.aux create mode 100644 man2html/scripts/cgi-aux/man/mansearch.aux create mode 100644 man2html/scripts/cgi-aux/man/mansearchhelp.aux create mode 100755 man2html/scripts/cgi-bin/man/man2html create mode 100755 man2html/scripts/cgi-bin/man/mansearch create mode 100755 man2html/scripts/cgi-bin/man/mansearchhelp create mode 100755 man2html/scripts/cgi-bin/man/mansec create mode 100755 man2html/scripts/cgi-bin/man/manwhatis (limited to 'man2html/scripts') diff --git a/man2html/scripts/cgi-aux/man/man.aux b/man2html/scripts/cgi-aux/man/man.aux new file mode 100644 index 0000000..e381b01 --- /dev/null +++ b/man2html/scripts/cgi-aux/man/man.aux @@ -0,0 +1,75 @@ +Content-type: text/html + + + +Manual Pages - Main Contents + + + + +

Manual Pages - Main Contents

+
+ +

Name and Section lookup

+ + +%lynx Start a query by typing an s. +You can enter a program name, possibly preceded by the section, +the directories to search (with -M) or a full name. +For example: + + +
+ +

Index of pages by name and description

+Sections: + 1. User Commands; + 2. System Calls; + 3. Library Functions; + 4. Special Files; + 5. File Formats; + 6. Games; + 7. Miscellany; + 8. Administration and Privileged Commands; + l. Postgresql Commands; + n. Tcl Commands. +

+


+

Index of pages by name only

+ 1. User Commands; + 2. System Calls; + 3. Library Functions; + 4. Special Files; + 5. File Formats; + 6. Games; + 7. Miscellany; + 8. Administration and Privileged Commands; + l. Postgresql Commands; + n. Tcl Commands; + All Sections. +

+


+ +

Manual Pages full text search

+ + +Search the full text of the Manual Pages. + + +

+


+ +The original man2html program and scripts are due to + +Richard Verhoeven and + +Michael Hamilton. +This version is from man-1.6g maintained by +Federico Lucifredi. + + diff --git a/man2html/scripts/cgi-aux/man/mansearch.aux b/man2html/scripts/cgi-aux/man/mansearch.aux new file mode 100644 index 0000000..f1d19a2 --- /dev/null +++ b/man2html/scripts/cgi-aux/man/mansearch.aux @@ -0,0 +1,49 @@ +Content-type: text/html + + + +Manual Pages - Text Search + + + + +

Manual Pages - Text Search

+ +Return to Main Contents +

+ + +%lynx Start a query by typing an s. + +Examples: +

+ +
+

+The index uses the Glimpse +(glimpse(1)) +text indexing system. Many of the glimpse +options, regular expressions, and wildcards are valid: +see the help page for a summary. +

+


+ +

+Glimpse +was developed by Udi Manber and Burra Gopal of the University of +Arizona, and Sun Wu of the National Chung-Cheng University, Taiwan. +You may contact the authors at +glimpse@cs.arizona.edu +

+The Manual Page text search interface was created for Linux by + +Michael Hamilton. + + diff --git a/man2html/scripts/cgi-aux/man/mansearchhelp.aux b/man2html/scripts/cgi-aux/man/mansearchhelp.aux new file mode 100644 index 0000000..200b509 --- /dev/null +++ b/man2html/scripts/cgi-aux/man/mansearchhelp.aux @@ -0,0 +1,295 @@ +Content-type: text/html + + + +Manual Pages - Search Help + + + + +

Manual Pages - Search Help

+ +Perform another search +
+Return to Main Contents +

+


+

+The full text index uses the Glimpse text indexing system. +The +glimpse(1) +manual page documents glimpse in full. This summary documents those +features of glimpse that are valid when searching through the manual pages. +

+


+ +

Search Options

+ +The following search options must be at the start of the search string. + +
+ +
- # +
+# is an integer between 1 and 8 +specifying the maximum number of errors +permitted in finding the approximate matches (the default is zero). +Generally, each insertion, deletion, or substitution counts as one error. +Since the index stores only lower case characters, errors of +substituting upper case with lower case may be missed. + +
-B +
+Best match mode. (Warning: -B sometimes misses matches. It is safer +to specify the number of errors explicitly.) +When -B is specified and no exact matches are found, glimpse +will continue to search until the closest matches (i.e., the ones +with minimum number of errors) +are found. +In general, -B may be slower than -#, but not by very much. +Since the index stores only lower case characters, errors of +substituting upper case with lower case may be missed. + +
-L x | x:y | x:y:z +
+A non-zero value of x limits the number of matches +that will be shown. +A non-zero value of y limits the number of man pages +that will be shown. +A non-zero valye of z will only show pages that have +less that z matches. +For example, -L 0:10 will output all matches for the first 10 files that +contain a match. + +
-F pattern +
+The -F option provides a pattern that restricts the search results to +those filenames that match the pattern. +or example, -F 8 effectively restricts matches to section 8. + +
-w +
+Search for the pattern as a word - i.e., surrounded by non-alphanumeric +characters. For example, +-w -1 car will match cars, but not characters and not +car10. +The non-alphanumeric must +surround the match; they cannot be counted as errors. +This option does not work with regular expressions. + +
-W +
+The default for Boolean AND queries is that they cover one record +(the default for a record is one line) at a time. +For example, glimpse 'good;bad' will output all lines containing +both 'good' and 'bad'. +The -W option changes the scope of Booleans to be the whole file. +Within a file glimpse will output all matches to any of the patterns. +So, glimpse -W 'good;bad' will output all lines containing 'good' +or 'bad', but only in files that contain both patterns. + +
-k +
+No symbol in the pattern is treated as a meta character. +For example, -k a(b|c)*d will find +the occurrences of a(b|c)*d whereas a(b|c)*d +will find substrings that match the regular expression 'a(b|c)*d'. +(The only exception is ^ at the beginning of the pattern and $ at the +end of the pattern, which are still interpreted in the usual way. +Use \^ or \$ if you need them verbatim.) + +
+ +

+


+ +

Patterns

+ +Glimpse +supports a large variety of patterns, including simple +strings, strings with classes of characters, sets of strings, +wild cards, and regular expressions (see LIMITATIONS). + +
+
Strings
+Strings are any sequence of characters, including the special symbols +`^' for beginning of line and `$' for end of line. +The following special characters ( +`$', + +`^', + +`*', + +`[', + +`^', + +`|', + +`(', + +`)', + +`!', + +and +`\' + +) +as well as the following meta characters special to glimpse (and agrep): +`;', + +`,', + +`#', + +`<', + +`>', + +`-', + +and +`.', + +should be preceded by `\' if they are to be matched as regular +characters. For example, \^abc\\ corresponds to the string ^abc\, +whereas ^abc corresponds to the string abc at the beginning of a +line. +
Classes of characters
+a list of characters inside [] (in order) corresponds to any character +from the list. For example, [a-ho-z] is any character between a and h +or between o and z. The symbol `^' inside [] complements the list. +For example, [^i-n] denote any character in the character set except +character 'i' to 'n'. +The symbol `^' thus has two meanings, but this is consistent with +egrep. +The symbol `.' (don't care) stands for any symbol (except for the +newline symbol). +
Boolean operations
+Glimpse + +supports an `AND' operation denoted by the symbol `;' +an `OR' operation denoted by the symbol `,', +or any combination. +For example, +glimpse 'pizza;cheeseburger' will output all lines containing +both patterns. +glimpse -F 'gnu;\.c$' 'define;DEFAULT' +will output all lines containing both 'define' and 'DEFAULT' +(anywhere in the line, not necessarily in order) in +files whose name contains 'gnu' and ends with .c. +glimpse '{political,computer};science' will match 'political science' +or 'science of computers'. +
Wild cards
+The symbol '#' is used to denote a sequence +of any number (including 0) +of arbitrary characters (see LIMITATIONS). +The symbol # is equivalent to .* in egrep. +In fact, .* will work too, because it is a valid regular expression +(see below), but unless this is part of an actual regular expression, +# will work faster. +(Currently glimpse is experiencing some problems with #.) +
Combination of exact and approximate matching
+Any pattern inside angle brackets <> must match the text exactly even +if the match is with errors. For example, <mathemat>ics matches +mathematical with one error (replacing the last s with an a), but +mathe<matics> does not match mathematical no matter how many errors are +allowed. +(This option is buggy at the moment.) +
Regular expressions
+Since the index is word based, a regular expression must match +words that appear in the index for glimpse to find it. +Glimpse first strips the regular expression from all non-alphabetic +characters, and searches the index for all remaining words. +It then applies the regular expression matching algorithm to the +files found in the index. +For example, glimpse 'abc.*xyz' will search the index +for all files that contain both 'abc' and 'xyz', and then +search directly for 'abc.*xyz' in those files. +(If you use glimpse -w 'abc.*xyz', then 'abcxyz' will not be found, +because glimpse +will think that abc and xyz need to be matches to whole words.) +The syntax of regular expressions in glimpse is in general the same as +that for agrep. The union operation `|', Kleene closure `*', +and parentheses () are all supported. +Currently '+' is not supported. +Regular expressions are currently limited to approximately 30 +characters (generally excluding meta characters). Some options +(-d, -w, -t, -x, -D, -I, -S) do not +currently work with regular expressions. +The maximal number of errors for regular expressions that use '*' +or '|' is 4. (See LIMITATIONS.) + +
+ +
+ +

Limitations

+ +The index of glimpse is word based. A pattern that contains more than +one word cannot be found in the index. The way glimpse overcomes this +weakness is by splitting any multi-word pattern into its set of words +and looking for all of them in the index. +For example, glimpse 'linear programming' will first consult the index +to find all files containing both linear and programming, +and then apply agrep to find the combined pattern. +This is usually an effective solution, but it can be slow for +cases where both words are very common, but their combination is not. +

+ +As was mentioned in the section on PATTERNS above, some characters +serve as meta characters for glimpse and need to be +preceded by '\' to search for them. The most common +examples are the characters '.' (which stands for a wild card), +and '*' (the Kleene closure). +So, "glimpse ab.de" will match abcde, but "glimpse ab\.de" +will not, and "glimpse ab*de" will not match ab*de, but +"glimpse ab\*de" will. +The meta character - is translated automatically to a hyphen +unless it appears between [] (in which case it denotes a range of +characters). +

+ +The index of glimpse stores all patterns in lower case. +When glimpse searches the index it first converts +all patterns to lower case, finds the appropriate files, +and then searches the actual files using the original +patterns. +So, for example, glimpse ABCXYZ will first find all +files containing abcxyz in any combination of lower and upper +cases, and then searches these files directly, so only the +right cases will be found. +One problem with this approach is discovering misspellings +that are caused by wrong cases. +For example, glimpse -B abcXYZ will first search the +index for the best match to abcxyz (because the pattern is +converted to lower case); it will find that there are matches +with no errors, and will go to those files to search them +directly, this time with the original upper cases. +If the closest match is, say AbcXYZ, glimpse may miss it, +because it doesn't expect an error. +Another problem is speed. If you search for "ATT", it will look +at the index for "att". Unless you use -w to match the whole word, +glimpse may have to search all files containing, for example, "Seattle" +which has "att" in it. +

+ +There is no size limit for simple patterns and simple patterns +within Boolean expressions. +More complicated patterns, such as regular expressions, +are currently limited to approximately 30 characters. +Lines are limited to 1024 characters. +Records are limited to 48K, and may be truncated if they are larger +than that. +The limit of record length can be +changed by modifying the parameter Max_record in agrep.h. +

+ +Glimpseindex does not index words of size > 64. +  + +


+ + diff --git a/man2html/scripts/cgi-bin/man/man2html b/man2html/scripts/cgi-bin/man/man2html new file mode 100755 index 0000000..7c515d1 --- /dev/null +++ b/man2html/scripts/cgi-bin/man/man2html @@ -0,0 +1,109 @@ +#!/bin/sh +# man2html cgi script - uses /usr/bin/man2html to format man pages +# auxiliary text files in /home/httpd/cgi-aux/man +# aeb@cwi.nl - 980109 + +MAN2HTML="/usr/bin/man2html" +MANX="/home/httpd/cgi-aux/man/man.aux" + +# Do we need lynxcgi URLs? For the moment our criterion is +# 1) HTTP_USER_AGENT=Lynx* and 2) HTTP_HOST is unset. +AGENT="${HTTP_USER_AGENT-unknown}" + +case "$AGENT" in + Lynx*|lynx*) + HH="${HTTP_HOST-nohh}" + SED="s/%lynx //" + ;; + *) + HH=nolynx + SED="/%lynx/d" + ;; +esac + +SERVER="${SERVER_NAME-localhost}" +case "$HH" in + nohh) + LL="-l" + CG="lynxcgi:/home/httpd/cgi-bin/man" + ;; + *) + LL="-H$SERVER" + CG="http://$SERVER/cgi-bin/man" + ;; +esac + +# Find the required page - expect to be called with "man2html [sec] page". +# There may a prefixed "-M manpath" option. +if [ $# -ge 2 -a x"$1" = x-M ]; then + MANPATH="$2" + export MANPATH + shift; shift + MP=" using the given MANPATH" +else + MP="" +fi + +# If no arguments given, show a start page. +if [ $# = 0 ]; then + if [ -r $MANX ]; then + cat $MANX | sed "s#%cg#$CG#g; $SED" + else + "$MAN2HTML" -E "man2html: cannot open $MANX" + fi + exit 0 +fi + +if [ $# -gt 2 ]; then + "$MAN2HTML" -E "man2html: bad invocation: too many arguments" + exit 0 +fi + +# A single argument may be an explicitly give path name +# Otherwise, ask man where to find it +if [ $# = 1 ]; then + case "$1" in + /*) + PAGE="$1" + ;; + *) + PAGE=`man -w -c "$@" 2>/dev/null` + ;; + esac +else + PAGE=`man -w -c "$@" 2>/dev/null` +fi + +if [ x"$PAGE" = x ]; then + complaint="man2html: cannot find a page" + if [ $# = 1 ]; then + "$MAN2HTML" -E "$complaint for $1$MP" + else + "$MAN2HTML" -E "$complaint for $2 in section $1$MP" + fi + exit 0 +fi + +if [ -r "$PAGE" ] +then + case "$PAGE" in + *.gz) + zcat "$PAGE" | "$MAN2HTML" "$LL" -D "$PAGE" + ;; + *.bz2) + bzcat "$PAGE" | "$MAN2HTML" "$LL" -D "$PAGE" + ;; + *) + "$MAN2HTML" "$LL" "$PAGE" + ;; + esac +elif [ -r "$PAGE".gz ] +then + zcat "$PAGE".gz | "$MAN2HTML" "$LL" -D "$PAGE" +elif [ -r "$PAGE".bz2 ] +then + bzcat "$PAGE".bz2 | "$MAN2HTML" "$LL" -D "$PAGE" +else + "$MAN2HTML" -E "Strange... Cannot find (or read) $PAGE." +fi +exit 0 diff --git a/man2html/scripts/cgi-bin/man/mansearch b/man2html/scripts/cgi-bin/man/mansearch new file mode 100755 index 0000000..2644db6 --- /dev/null +++ b/man2html/scripts/cgi-bin/man/mansearch @@ -0,0 +1,192 @@ +#!/bin/sh +# +# Interface to a glimpse search of the man pages. +# Michael Hamilton +# Small changes - aeb, 980109 +# + +# Do we need lynxcgi URLs? For the moment our criterion is +# 1) HTTP_USER_AGENT=Lynx* and 2) HTTP_HOST is unset. +AGENT="${HTTP_USER_AGENT-unknown}" + +case "$AGENT" in + Lynx*|lynx*) + HH="${HTTP_HOST-nohh}" + SED="s/%lynx //" + ;; + *) + HH=nolynx + SED="/%lynx/d" + ;; +esac + +SERVER="${SERVER_NAME-localhost}" +case "$HH" in + nohh) + CG="lynxcgi:/home/httpd/cgi-bin/man" + ;; + *) + CG="http://$SERVER/cgi-bin/man" + ;; +esac +QUOTE="'" +export CG QUOTE SED + +exec awk ' +function removeopts(string) { + gsub(/^[ \t]/, "", string); # Remove leading spaces + gsub(/[ \t]$/, "", string); # Remove trailing spaces + gsub(/[ \t\\];/, ";", string); # Remove spaces before ; + gsub(/[ \t];/, ",", string); # Remove spaces before , + while (match(string, /^-[FLBwk1-8]/)) { + if (match(string, /^-[FL]( |.)[^ \t]+[ \t]+/)) { # Option with arg + options = options " " substr(string, RSTART, RLENGTH); + string = substr(string, RSTART + RLENGTH); + } + else if (match(string, /^-[Bwk1-8][ \t]+/)) { # Option without arg + options = options " " substr(string, RSTART, RLENGTH); + string = substr(string, RSTART + RLENGTH); + } + else if (match(string, /^-[^ \t]/)) { # Remove it + string = substr(string, RSTART + RLENGTH); + } + } + return string; +} + +BEGIN { + + searchdocument = "/home/httpd/cgi-aux/man/mansearch.aux"; + quote = ENVIRON["QUOTE"]; + cgipath = ENVIRON["CG"]; + sedcmd = ENVIRON["SED"]; + truncate_at = 11; # Single page display match limit. + + glimpse_cmd = "glimpse -z -H /var/man2html -y -W -i " + + for (i = 1; i < ARGC; i++) { + string = string " " ARGV[i]; + } + # Have to be careful to single quote this + # string later. + gsub(/[^a-zA-Z0-9-_+ \t\/@%:;,$*|]/, " ", string); + + string = removeopts(string); + + gsub(/[^a-zA-Z0-9-_+ \t\/@%:,]/, " ", options); + + if (!string) { + if (system("test -r " searchdocument ) != 0) { + print "Content-type: text/html\n\n"; + print ""; + print "mansearch - file not found"; + print "\n"; + print "Sorry - cannot read " searchdocument "."; + print ""; + exit; + } + system("sed " quote "s#%cg#" cgipath "#g;" sedcmd quote " " searchdocument ); + exit; + } + + print "Content-type: text/html"; + print ""; + print ""; + print ""; + print "Manual Pages - Search Results: " string ""; + print ""; + print ""; + + print "

Manual Pages - Search Results

"; + print "

Target text: " options " " string "

"; + + print ""; + print "Perform another search"; + print "
"; + print ""; + print "Return to Main Contents"; + print ""; + + print "
"; + + print "
"; + # Unless you like being hacked, the single + # forward quotes are most important. + cmd = glimpse_cmd " " options " " quote string quote " 2>/dev/null" ; + + while ((cmd | getline matchline) > 0) { + if (split(matchline, part, ": ") == 1) { + continue; + } + else { + fullname = part[1]; + } + + if (fullname == "glimpse") { + print "
"fullname":"; + } + else if (fullname != last_fullname) { + mcount++; + tcount = 0; + last_fullname = fullname ; + last_text = ""; + + if (match(fullname, ".*/")) { + dirname = substr(fullname, 1, RLENGTH); + filename = substr(fullname, RLENGTH + 1); + if (dirname != last_dirname) { + last_dirname = dirname; + print "
"; + print "

Location: " dirname "

"; + print "
"; + } + } + else { + filename = fullname; + } + + if (match(filename, /\.[^.]+$/)) { + ref = substr(filename, 1, RSTART - 1) "+" substr(filename, RSTART + 1); + } + else { + ref = filename; + } + print "
"; + textname = filename; + sub(/\.(gz)|Z|z$/, "", textname); + sub(/\./, "(", textname); + textname = textname ")"; + print textname; + print ""; + } + + text = substr(matchline, length(fullname) + 2); + tcount++; + if (tcount < truncate_at) { + sub(/^ *.[^ ]+ /, "", text); + sub(/ +$/, "", text); + gsub(/\\f./, "", text); + gsub(/\\&/, "", text); + gsub(/\\/, "", text); + print "
" text; + } + else if (tcount == truncate_at) { + print "
...additional matches not shown."; + } + } + + print "
"; + if (mcount == 0) { + print "No matches found."; + } + else if (mcount == 1) { + print "
\n

1 match found." + } + else { + print "


\n

" mcount " matches found." + } + print ""; + print ""; + exit; +}' "$@" + diff --git a/man2html/scripts/cgi-bin/man/mansearchhelp b/man2html/scripts/cgi-bin/man/mansearchhelp new file mode 100755 index 0000000..a96e796 --- /dev/null +++ b/man2html/scripts/cgi-bin/man/mansearchhelp @@ -0,0 +1,32 @@ +#!/bin/sh +MAN2HTML=/usr/bin/man2html +MANSH=/home/httpd/cgi-aux/man/mansearchhelp.aux + +# Do we need lynxcgi URLs? For the moment our criterion is +# 1) HTTP_USER_AGENT=Lynx* and 2) HTTP_HOST is unset. +AGENT="${HTTP_USER_AGENT-unknown}" +case "$AGENT" in + Lynx*|lynx*) + HH="${HTTP_HOST-nohh}" + ;; + *) + HH=nolynx + ;; +esac + +SERVER="${SERVER_NAME-localhost}" +case "$HH" in + nohh) + CG="lynxcgi:/home/httpd/cgi-bin/man" + ;; + *) + CG="http://$SERVER/cgi-bin/man" + ;; +esac + +if [ -r $MANSH ]; then + sed s#%cg#$CG#g $MANSH +else + $MAN2HTML -E "man2html: cannot open $MANSH" +fi +exit 0 diff --git a/man2html/scripts/cgi-bin/man/mansec b/man2html/scripts/cgi-bin/man/mansec new file mode 100755 index 0000000..24c189e --- /dev/null +++ b/man2html/scripts/cgi-bin/man/mansec @@ -0,0 +1,183 @@ +#!/usr/bin/awk -f +# +# Generate an index into a manual section by using find. +# Michael Hamilton +# Small changes - aeb, 980109 +# +BEGIN { + + OFS=""; + + if (ARGC != 3) { + print "Content-type: text/html\n\n"; + print ""; + print "manwhatis - bad call"; + print "\n"; + print "manwhatis: wrong number of arguments"; + print ""; + exit; + } + cgipath = ARGV[1]; + section = ARGV[2]; + + if (section !~ /^[1-8ln]$/ && section != "all") { + print "Content-type: text/html\n\n"; + print ""; + print "Manual - Illegal section"; + print ""; + print "Illegal section number '" section "'." ; + print "Must be one of 1,2,3,4,5,6,7,8,l,n or all"; + print ""; + exit; + } + + "echo $PPID" | getline pid; + + if (cgipath ~ /lynxcgi/) { + cache_suffix = "l"; + } + else { + cache_suffix = "h"; + } + + cache_dir = "/var/man2html"; + cache_file = "manindex" cache_suffix "-" section ".html"; + cache = cache_dir "/" cache_file; + cache_tmp = cache "_" pid; + buffer_tmp = cache "_items_" pid; + + # Find out the man path + "man -w" | getline man_path + man_path = man_path ":"; + gsub(":", " ", man_path); + # See if anything is out of date. + # Check all man[1-8] dir dates vs cache date + if (section == "all") { + if (system("test -f " cache) == 0) { + cmd = "find " man_path " -maxdepth 1 -name 'man[1-8]' -newer " cache; + cmd | getline need_update; + } + else { + need_update = 1; + } + } + else { + if (system("test -f " cache) == 0) { + cmd = "find " man_path " -maxdepth 1 -name man" section " -newer " cache; + cmd | getline need_update; + } + else { + need_update = 1; + } + } + + if (need_update != "") { + if (system("test -w " cache_dir "/.") != 0) { + print "Content-type: text/html\n\n"; + print ""; + print "mansec - no cache"; + print "\n"; + print "Sorry - cannot create index."; + print "No writable cache directory " cache_dir " exists."; + print ""; + exit; + } + + sec_name[1] = "User Commands"; + sec_name[2] = "System Calls"; + sec_name[3] = "Library Functions"; + sec_name[4] = "Special Files"; + sec_name[5] = "File Formats"; + sec_name[6] = "Games"; + sec_name[7] = "Miscellany"; + sec_name[8] = "Administration and Privileged Commands"; + sec_name["all"] = "All available manual pages"; + num_sections = 8; + + # Print heading + print "Content-type: text/html\n\n" > cache_tmp; + print "\n" > cache_tmp; + print "Manual Pages - Names: " section ". " sec_name[section] ""> cache_tmp; + print "\n" > cache_tmp; + print "

Manual Pages - Page Names

" > cache_tmp; + print "

Section " section ": " sec_name[section] "

" > cache_tmp; + + "hostname" | getline hostname; + "date" | getline date; + print hostname " (" date ")" > cache_tmp; + + if (section != "all") { + sec_sub_dir = "/man" section; + } + else { + sec_sub_dir = "/man*"; + } + gsub(" ", sec_sub_dir " ", man_path); + + print "

Manual pages found under " man_path "." > cache_tmp; + + # Find any man[1-8]/filenames + while ((("find " man_path " -follow -type f -printf '%f\n' | sort -f ") | getline manpage) > 0) { + # Check for new letter of alphabet + letter = tolower(substr(manpage,1,1)); + if (letter != last_letter) { + last_letter = letter; + letter_index[++num_letters] = letter; + # Start a new alphabetic heading + print "

", toupper(letter), "

" > buffer_tmp; + # Print out alphabetic quick index and other links + } + # Split page.n into "page" and "n" and generate an entry + sub(/[.]([zZ]|(gz))$/, "", manpage); + match(manpage, /[.][^.]+$/); + title = substr(manpage, 1, RSTART - 1); + if (section != "all") { + print "", title, "(", substr(manpage, RSTART + 1), ")" > buffer_tmp; + } + else { + sec = substr(manpage, RSTART + 1) + print "", title, "(", sec, ")" > buffer_tmp; + } + } + + close(buffer_tmp); + + print "

" > cache_tmp; + + # Print out alphabetic quick index and other links + for (i = 1; i <= num_letters; i++) { + print "" toupper(letter_index[i]) "" > cache_tmp; + } + + print "


" > cache_tmp; + print "Return to Main Contents" > cache_tmp; + + print "

Other sections:" > cache_tmp; + for (i=1; i<=num_sections; i++) { + if (i != section) { # Dont print an entry for the section we are in + print "" i ". " sec_name[i] " " > cache_tmp; + } + } + print "


" > cache_tmp; + # Print out the accumulated index entries + while ((getline < buffer_tmp) > 0) print > cache_tmp; + print "


" > cache_tmp; + # Print out alphabetic quick index and other links + for (i = 1; i <= num_letters; i++) { + print "" toupper(letter_index[i]) "" > cache_tmp; + } + print "


" > cache_tmp; + print "

Return to Main Contents" > cache_tmp; + print "

Other sections:" > cache_tmp; + for (i=1; i<=num_sections; i++) { + if (i != section) { # Dont print an entry for the section we are in + print "" i ". " sec_name[i] " " > cache_tmp; + } + } + print "\n" > cache_tmp; + system("/bin/mv " cache_tmp " " cache); + system("/bin/rm -f " buffer_tmp); + } + system("/bin/cat " cache); + exit; +} diff --git a/man2html/scripts/cgi-bin/man/manwhatis b/man2html/scripts/cgi-bin/man/manwhatis new file mode 100755 index 0000000..d14a516 --- /dev/null +++ b/man2html/scripts/cgi-bin/man/manwhatis @@ -0,0 +1,208 @@ +#!/usr/bin/awk -f +# +# Generate a whatis index into the manual pages by using find to +# locate all the whatis files. +# Michael Hamilton +# Small changes - aeb, 980109 +# +BEGIN { + + OFS=""; + + if (ARGC != 3) { + print "Content-type: text/html\n\n"; + print ""; + print "manwhatis - bad call"; + print "\n"; + print "manwhatis: wrong number of arguments"; + print ""; + exit; + } + cgipath = ARGV[1]; + section = ARGV[2]; + + if (section !~ /^[1-8ln]$/) { + print "Content-type: text/html\n\n"; + print ""; + print "Manual - Illegal section"; + print "\n"; + print "Illegal section number '" section "'." ; + print "Must be one of 1,2,3,4,5,6,7,8,l,n"; + print ""; + exit; + } + + if (cgipath ~ /lynxcgi/) { + cache_suffix = "l"; + } + else { + cache_suffix = "h"; + } + + cache_dir = "/var/man2html"; + cache_file = "whatis" cache_suffix "-" section ".html"; + cache = cache_dir "/" cache_file; + + + # Find out the man path + "man -w" | getline man_path + gsub(":", " ", man_path); + # See if anything is out of date. + if (system("test -f " cache) == 0) { + cmd = "find " man_path " -maxdepth 1 -name whatis -newer " cache; + cmd | getline need_update; + } + else { + need_update = 1; + } + + if (need_update != "") { + + if (system("test -w " cache_dir "/.") != 0) { + print "Content-type: text/html\n\n"; + print ""; + print "manwhatis - no cache"; + print "\n"; + print "Sorry - cannot create index."; + print "No writable cache directory " cache_dir " exists."; + print ""; + exit; + } + + "echo $PPID" | getline pid; + + cache_tmp = cache "_" pid; + sort_tmp = cache_dir "/manwhatis_tmp_" pid ; + buffer_tmp = cache_dir "/manwhatis_tmp2_" pid; + + sec_name[1] = "User Commands"; + sec_name[2] = "System Calls"; + sec_name[3] = "Library Functions"; + sec_name[4] = "Special Files"; + sec_name[5] = "File Formats"; + sec_name[6] = "Games"; + sec_name[7] = "Miscellany"; + sec_name[8] = "Administration and Privileged Commands"; + num_sections = 8; + # Print heading + print "Content-type: text/html\n\n" > cache_tmp; + print "\n" > cache_tmp; + print "Manual Pages - Names and Descriptions: " section ". " sec_name[section] "" > cache_tmp; + + print "\n" > cache_tmp; + print "

Manual Pages - Names and Descriptions

" > cache_tmp; + print "

Section " section ": " sec_name[section] "

" > cache_tmp; + "hostname" | getline hostname; + "date" | getline date; + print hostname " (" date ")" > cache_tmp; + # Find out the man path + "man -w" | getline; + $1 = $1 ":"; + gsub(":", " ", $1); + + find_cmd = "find " man_path " -maxdepth 1 -name whatis -printf '%p '"; + find_cmd | getline whatis_files; + close(find_cmd); + + if (whatis_files == "") { + print "Content-type: text/html\n\n"; + print ""; + print "Manwhatis - Error updating index"; + print "\n"; + print "Unable to find whatis files - Sorry." + print ""; + exit; + } + # Try to parse valid entries - those that contain ([0-9]) + # Note that egrep is sometimes in /bin, sometimes in /usr/bin + extract_cmd = "egrep -h '\\(" section "[A-Za-z]*\\)' " whatis_files ; + + print "
Manual pages referenced in " whatis_files "

" > cache_tmp; + + # Note that sort sometimes lives in /bin and sometimes in /usr/bin + sort_cmd = "sort -f >> " sort_tmp; + + while ( (extract_cmd | getline) > 0 ) { + if (bracket_pos = index($0, "(")) { + sec_full_num = substr($0, bracket_pos + 1, index($0, ")") - bracket_pos - 1); + names = substr($0, 1, bracket_pos - 2); + # Get rid of blanks and commas. + n = split(names, name_list, " *, *"); + description = substr($0, bracket_pos + length(sec_full_num) + 2); + # Get rid of AT&T + gsub("&", "\&", description); + # Generate a entry for each name + for (i = 1; i <= n; i++) { + print name_list[i] " " sec_full_num " " name_list[1] " / " description | sort_cmd; + } + } + } + close(extract_cmd); + close(sort_cmd); + + while ((getline < sort_tmp) > 0) { + + letter = tolower(substr($1,1,1)); + if (letter != last_letter) { + if (last_letter) { + print "

" > buffer_tmp; + } + last_letter = letter; + letter_index[++num_letters] = letter; + # Terminate list, start a new one + + print "

", toupper(letter), "

\n
" > buffer_tmp ; + } + # Generate a
for the name + if ($3 != last_file || $1 != last_name) { # Don't repeat the same entry link. + print "
", $1, "(", $2, ")", "" > buffer_tmp; + last_file = $3; + last_name = $1; + } + print "
", substr($0, match($0, "/") + 1) > buffer_tmp; + } + # Finish off last list + + print "\n

" > buffer_tmp; + close(buffer_tmp); + + system("/bin/rm " sort_tmp); + + # Print out alphabetic quick index and other links + for (i = 1; i <= num_letters; i++) { + print "" toupper(letter_index[i]) "" > cache_tmp; + } + print "


" > cache_tmp; + print "Return to Main Contents" > cache_tmp; + + print "

Other sections:" > cache_tmp; + for (i=1; i<=num_sections; i++) { + if (i != section) { # Dont print an entry for the section we are in + print "" i ". " sec_name[i] " " > cache_tmp; + } + } + print "


" > cache_tmp; + # Print out the accumulated contents entries + while ((getline < buffer_tmp) > 0) print > cache_tmp; + print "


" > cache_tmp; + + for (i = 1; i <= num_letters; i++) { + print "" toupper(letter_index[i]) "" > cache_tmp; + } + print "


" > cache_tmp; + print "

Return to Main Contents" > cache_tmp; + + print "

Other sections:" > cache_tmp; + for (i=1; i<=num_sections; i++) { + if (i != section) { # Dont print an entry for the section we are in + print "" i ". " sec_name[i] " " > cache_tmp; + } + } + print "" > cache_tmp; + print "" > cache_tmp; + system("/bin/mv " cache_tmp " " cache); + system("/bin/rm " buffer_tmp); + } + system("/bin/cat " cache); + exit; +} -- cgit v1.2.3