diff --git a/en/cgi/man.cgi b/en/cgi/man.cgi index 1df2a938a1..88a0a182a1 100755 --- a/en/cgi/man.cgi +++ b/en/cgi/man.cgi @@ -1,1494 +1,1495 @@ #!/usr/bin/perl -T # # Copyright (c) 1996-2008 Wolfram Schneider # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # man.cgi - HTML hypertext FreeBSD man page interface # # based on bsdi-man.pl,v 2.17 1995/10/05 16:48:58 sanders Exp # bsdi-man -- HTML hypertext BSDI man page interface # based on bsdi-man.pl,v 2.10 1993/10/02 06:13:23 sanders Exp # by polk@BSDI.COM 1/10/95 # BSDI Id: bsdi-man,v 1.2 1995/01/11 02:30:01 polk Exp # Dual CGI/Plexus mode and new interface by sanders@bsdi.com 9/22/1995 # -# $Id: man.cgi,v 1.221 2008-09-21 19:07:43 wosch Exp $ -# $FreeBSD: www/en/cgi/man.cgi,v 1.220 2008/08/07 08:30:32 wosch Exp $ +# $Id: man.cgi,v 1.222 2008-09-22 19:13:42 wosch Exp $ +# $FreeBSD: www/en/cgi/man.cgi,v 1.221 2008/09/21 19:07:43 wosch Exp $ ############################################################################ # !!! man.cgi is stale perl4 code !!! ############################################################################ # run `perltidy -b man.cgi' to indent the code # Use standard FreeBSD CGI Style if available. # Otherwise print simple HTML design. package cgi_style; use constant HAS_FREEBSD_CGI_STYLE => eval { require "./cgi-style.pl"; }; package main; $debug = 2; $www{'title'} = 'FreeBSD Man Pages'; $www{'home'} = 'http://www.FreeBSD.org'; $www{'head'} = $www{'title'}; $command{'man'} = '/usr/bin/man'; # 8Bit clean man # Config Options # map sections to their man command argument(s) %sections = ( '', '', 'All', '', '0', '', '1', '-S1', '1c', '-S1', '1C', '-S1', '1g', '-S1', '1m', '-S1', '2', '-S2', '2j', '-S2', '3', '-S3', '3S', '-S3', '3f', '-S3', '3j', '-S3', '3m', '-S3', '3n', '-S3', '3p', '-S3', '3pm', '-S3', '3r', '-S3', '3s', '-S3', '3x', '-S3', '4', '-S4', '5', '-S5', '6', '-S6', '7', '-S7', '8', '-S8', '8c', '-S8', '9', '-S9', 'l', '-Sl', 'n', '-Sn', ); $sectionpath = { 'HP-UX 11.22' => { 'path' => '1:1m:2:3:4:5:7:9' }, 'HP-UX 11.20' => { 'path' => '1:1m:2:3:4:5:7:9' }, 'HP-UX 11.11' => { 'path' => '1:1m:2:3:4:5:7:9' }, 'HP-UX 11.00' => { 'path' => '1:1m:2:3:4:5:7:9' }, 'HP-UX 10.20' => { 'path' => '1:1m:2:3:4:5:7:9' }, 'HP-UX 10.10' => { 'path' => '1:1m:2:3:4:5:7:9' }, 'HP-UX 10.01' => { 'path' => '1:1m:2:3:4:5:7:9' }, 'SunOS 5.10' => { 'path' => '1:1m:1s:1as:2:3:3c:3malloc:3nsl:3socket:3ldap:3nisdb:3rac:3resolv:3rpc:3slp:3proc:3rt:3c_db:3elf:3kvm:3kstat:3m:3mp:3mvec:3pam:3aio:3bsm:3tsol:3contract:3cpc:3sec:3secdb:3smartcard:3cfgadm:3crypt:3devid:3devinfo:3door:3lib:3libucb:3head:3nvpair:3rsm:7:7d:7fs:7i:7ipp:7m:7p:9:9e:9f:9p:9s:4:5:4b:3gen:3exacct:3sysevent:3uuid:3wsreg:3dmi:3snmp:3tnf:3volmgt:3mail:3layout:3ext:3picl:3picltree:3pool:3project:3perl:3lgrp:3sasl:3scf:3dat:3hbaapi:3tecla:1b:1c:1f:3ucb:3xnet:3curses:3plot:3xcurses:3gss:6:3tiff:3fontconfig:3mlib:l:n', }, 'SunOS 5.9' => { 'path' => '1:1m:1s:2:3:3c:3malloc:3dl:3nsl:3socket:3ldap:3nisdb:3rac:3resolv:3rpc:3slp:3xfn:3proc:3rt:3thr:3elf:3kvm:3kstat:3m:3mp:3pam:3sched:3aio:3bsm:3cpc:3sec:3secdb:3cfgadm:3crypt:3devid:3devinfo:3door:3lib:3libucb:3head:3nvpair:3rsm:7:7d:7fs:7i:7m:7p:9:9e:9f:9p:9s:4:5:4b:3gen:3exacct:3sysevent:3wsreg:3dmi:3snmp:3tnf:3volmgt:3mail:3layout:3ext:3picl:3picltree:3pool:3project:1b:1c:1f:3ucb:3xnet:3curses:3plot:3xcurses:3gss:6:l:n', }, 'SunOS 5.8' => { 'path' => '1:1m:1s:2:3:3c:3malloc:3dl:3nsl:3socket:3ldap:3krb:3nisdb:3rac:3resolv:3rpc:3slp:3xfn:3proc:3rt:3thr:3elf:3kvm:3kstat:3m:3mp:3pam:3sched:3aio:3bsm:3cpc:3sec:3secdb:3cfgadm:3crypt:3devid:3devinfo:3door:3lib:3libucb:3head:7:7d:7fs:7i:7m:7p:9:9e:9f:9s:4:5:4b:3gen:3dmi:3snmp:3tnf:3volmgt:3mail:3layout:3ext:1b:1c:1f:3ucb:3xnet:3curses:3plot:3xcurses:6:l:n', }, 'SunOS 5.7' => { 'path' => '1:1m:1c:1f:1s:1b:2:3:3c:3s:3x:3xc:3n:3r:3t:3xn:3m:3k:3g:3e:3b:9f:9s:9e:9:4:5:7:7d:7i:7m:7p:7fs:4b:6:l:n', }, 'SunOS 5.6' => { 'path' => '1:1m:1c:1f:1s:1b:2:3:3c:3s:3x:3xc:3xn:3r:3t:3n:3m:3k:3g:3e:3b:9f:9s:9e:9:4:5:7:7d:7i:7m:7p:7fs:4b:6:l:n', }, 'SunOS 5.5.1' => { 'path' => '1:1m:1c:1f:1s:1b:2:3:3c:3s:3x:3xc:3xn:3r:3t:3n:3m:3k:3g:3e:3b:9f:9s:9e:9:4:5:7:7d:7i:7m:7p:7fs:4b:6:l:n', }, 'OpenBSD 3.0' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 3.1' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 3.2' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 3.3' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 3.4' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 3.5' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 3.6' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 3.7' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 3.8' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 3.9' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 4.0' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 4.1' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 4.2' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, 'OpenBSD 4.3' => { 'path' => '1:2:3:3p:4:5:6:7:8:9', }, }; foreach my $os ( keys %$sectionpath ) { foreach my $section ( split( /:/, $sectionpath->{$os}{'path'} ) ) { $section =~ /(.)(.*)/; $sectionpath->{$os}{$1} .= ( $sectionpath->{$os}{$1} ? ':' : '' ) . $section; } } %sectionName = ( '0', 'All Sections', '1', '1 - General Commands', '2', '2 - System Calls', '3', '3 - Subroutines', '4', '4 - Special Files', '5', '5 - File Formats', '6', '6 - Games', '7', '7 - Macros and Conventions', '8', '8 - Maintenance Commands', '9', '9 - Kernel Interface', 'n', 'n - New Commands', ); $manLocalDir = '/usr/local/www/bsddoc/man'; $manPathDefault = 'FreeBSD 7.0-RELEASE'; %manPath = ( 'FreeBSD 7.0-RELEASE and Ports', "$manLocalDir/FreeBSD-7.0-RELEASE/man:$manLocalDir/FreeBSD-7.0-RELEASE/openssl/man:$manLocalDir/FreeBSD-ports", 'FreeBSD 6.3-RELEASE and Ports', "$manLocalDir/FreeBSD-6.3-RELEASE/man:$manLocalDir/FreeBSD-6.3-RELEASE/openssl/man:$manLocalDir/FreeBSD-ports", 'FreeBSD 8-current', "$manLocalDir/FreeBSD-8-current", 'FreeBSD 7.0-stable', "$manLocalDir/FreeBSD-7.0-stable", 'FreeBSD 7.0-RELEASE', "$manLocalDir/FreeBSD-7.0-RELEASE/man:$manLocalDir/FreeBSD-7.0-RELEASE/openssl/man", 'FreeBSD Ports 7.0-RELEASE', "$manLocalDir/FreeBSD-ports-7.0-RELEASE", 'FreeBSD 6.3-stable', "$manLocalDir/FreeBSD-6.3-stable", 'FreeBSD 6.3-RELEASE', "$manLocalDir/FreeBSD-6.3-RELEASE/man:$manLocalDir/FreeBSD-6.3-RELEASE/openssl/man", 'FreeBSD 6.2-RELEASE', "$manLocalDir/FreeBSD-6.2-RELEASE/man:$manLocalDir/FreeBSD-6.2-RELEASE/openssl/man", 'FreeBSD Ports 6.2-RELEASE', "$manLocalDir/FreeBSD-ports-6.2-RELEASE", 'FreeBSD 6.1-RELEASE', "$manLocalDir/FreeBSD-6.1-RELEASE/man:$manLocalDir/FreeBSD-6.1-RELEASE/openssl/man", 'FreeBSD 6.0-RELEASE', "$manLocalDir/FreeBSD-6.0-RELEASE/man:$manLocalDir/FreeBSD-6.0-RELEASE/openssl/man", 'FreeBSD 5.5-RELEASE', "$manLocalDir/FreeBSD-5.5-RELEASE/man:$manLocalDir/FreeBSD-5.5-RELEASE/openssl/man", 'FreeBSD Ports 5.1-RELEASE', "$manLocalDir/FreeBSD-ports-5.1-RELEASE", 'FreeBSD 5.4-RELEASE', "$manLocalDir/FreeBSD-5.4-RELEASE/man:$manLocalDir/FreeBSD-5.4-RELEASE/openssl/man", 'FreeBSD 5.3-RELEASE', "$manLocalDir/FreeBSD-5.3-RELEASE/man:$manLocalDir/FreeBSD-5.3-RELEASE/openssl/man", 'FreeBSD 5.2.1-RELEASE', "$manLocalDir/FreeBSD-5.2-RELEASE/man:$manLocalDir/FreeBSD-5.2-RELEASE/openssl/man", 'FreeBSD 5.2-RELEASE', "$manLocalDir/FreeBSD-5.2-RELEASE/man:$manLocalDir/FreeBSD-5.2-RELEASE/openssl/man", 'FreeBSD 5.1-RELEASE', "$manLocalDir/FreeBSD-5.1-RELEASE/man:$manLocalDir/FreeBSD-5.1-RELEASE/openssl/man", 'FreeBSD 5.0-RELEASE', "$manLocalDir/FreeBSD-5.0-RELEASE", 'FreeBSD 4.11-RELEASE', "$manLocalDir/FreeBSD-4.11-RELEASE/man:$manLocalDir/FreeBSD-4.11-RELEASE/openssl/man:$manLocalDir/FreeBSD-4.11-RELEASE/perl/man", 'FreeBSD Ports 4.7-RELEASE', "$manLocalDir/FreeBSD-ports-4.7-RELEASE", 'FreeBSD 4.10-RELEASE', "$manLocalDir/FreeBSD-4.10-RELEASE/man:$manLocalDir/FreeBSD-4.10-RELEASE/openssl/man:$manLocalDir/FreeBSD-4.10-RELEASE/perl/man", 'FreeBSD 4.9-RELEASE', "$manLocalDir/FreeBSD-4.9-RELEASE", 'FreeBSD 4.8-RELEASE', "$manLocalDir/FreeBSD-4.8-RELEASE", 'FreeBSD 4.7-RELEASE', "$manLocalDir/FreeBSD-4.7-RELEASE", 'FreeBSD 4.6.2-RELEASE', "$manLocalDir/FreeBSD-4.6.2-RELEASE", 'FreeBSD 4.6-RELEASE', "$manLocalDir/FreeBSD-4.6-RELEASE", 'FreeBSD 4.5-RELEASE', "$manLocalDir/FreeBSD-4.5-RELEASE", 'FreeBSD 4.4-RELEASE', "$manLocalDir/FreeBSD-4.4-RELEASE", 'FreeBSD 4.3-RELEASE', "$manLocalDir/FreeBSD-4.3-RELEASE", 'FreeBSD 4.2-RELEASE', "$manLocalDir/FreeBSD-4.2-RELEASE", 'FreeBSD 4.1.1-RELEASE', "$manLocalDir/FreeBSD-4.1.1-RELEASE", 'FreeBSD 4.1-RELEASE', "$manLocalDir/FreeBSD-4.1-RELEASE", 'FreeBSD 4.0-RELEASE', "$manLocalDir/FreeBSD-4.0-RELEASE", 'FreeBSD 3.5.1-RELEASE', "$manLocalDir/FreeBSD-3.5.1-RELEASE", 'FreeBSD 3.4-RELEASE', "$manLocalDir/FreeBSD-3.4-RELEASE", 'FreeBSD 3.3-RELEASE', "$manLocalDir/FreeBSD-3.3-RELEASE", 'FreeBSD 3.2-RELEASE', "$manLocalDir/FreeBSD-3.2-RELEASE", 'FreeBSD 3.1-RELEASE', "$manLocalDir/FreeBSD-3.1-RELEASE", 'FreeBSD 3.0-RELEASE', "$manLocalDir/FreeBSD-3.0-RELEASE", 'FreeBSD 2.2.5-RELEASE', "$manLocalDir/FreeBSD-2.2.5-RELEASE", 'FreeBSD 2.2.6-RELEASE', "$manLocalDir/FreeBSD-2.2.6-RELEASE", 'FreeBSD 2.2.7-RELEASE', "$manLocalDir/FreeBSD-2.2.7-RELEASE", 'FreeBSD 2.2.8-RELEASE', "$manLocalDir/FreeBSD-2.2.8-RELEASE", 'FreeBSD 2.2.2-RELEASE', "$manLocalDir/FreeBSD-2.2.2-RELEASE", 'FreeBSD 2.2.1-RELEASE', "$manLocalDir/FreeBSD-2.2.1-RELEASE", 'FreeBSD 2.1.7.1-RELEASE', "$manLocalDir/FreeBSD-2.1.7.1-RELEASE", 'FreeBSD 2.1.6.1-RELEASE', "$manLocalDir/FreeBSD-2.1.6.1-RELEASE", 'FreeBSD 2.1.5-RELEASE', "$manLocalDir/FreeBSD-2.1.5-RELEASE", 'FreeBSD 2.1.0-RELEASE', "$manLocalDir/FreeBSD-2.1.0-RELEASE", 'FreeBSD 2.0.5-RELEASE', "$manLocalDir/FreeBSD-2.0.5-RELEASE", 'FreeBSD 2.0-RELEASE', "$manLocalDir/FreeBSD-2.0-RELEASE", 'FreeBSD 1.1.5.1-RELEASE', "$manLocalDir/FreeBSD-1.1.5.1-RELEASE", 'FreeBSD 1.1-RELEASE', "$manLocalDir/FreeBSD-1.1-RELEASE", 'FreeBSD 1.0-RELEASE', "$manLocalDir/FreeBSD-1.0-RELEASE", 'OpenBSD 2.0', "$manLocalDir/OpenBSD-2.0", 'OpenBSD 2.1', "$manLocalDir/OpenBSD-2.1", 'OpenBSD 2.2', "$manLocalDir/OpenBSD-2.2", 'OpenBSD 2.3', "$manLocalDir/OpenBSD-2.3", 'OpenBSD 2.4', "$manLocalDir/OpenBSD-2.4", 'OpenBSD 2.5', "$manLocalDir/OpenBSD-2.5", 'OpenBSD 2.6', "$manLocalDir/OpenBSD-2.6", 'OpenBSD 2.7', "$manLocalDir/OpenBSD-2.7", 'OpenBSD 2.8', "$manLocalDir/OpenBSD-2.8", 'OpenBSD 2.9', "$manLocalDir/OpenBSD-2.9", 'OpenBSD 3.0', "$manLocalDir/OpenBSD-3.0", 'OpenBSD 3.1', "$manLocalDir/OpenBSD-3.1", 'OpenBSD 3.2', "$manLocalDir/OpenBSD-3.2", 'OpenBSD 3.3', "$manLocalDir/OpenBSD-3.3", 'OpenBSD 3.4', "$manLocalDir/OpenBSD-3.4/share/man:$manLocalDir/OpenBSD-3.4/X11R6/man", 'OpenBSD 3.5', "$manLocalDir/OpenBSD-3.5/share/man:$manLocalDir/OpenBSD-3.5/X11R6/man", 'OpenBSD 3.6', "$manLocalDir/OpenBSD-3.6/share/man:$manLocalDir/OpenBSD-3.6/X11R6/man", 'OpenBSD 3.7', "$manLocalDir/OpenBSD-3.7", 'OpenBSD 3.8', "$manLocalDir/OpenBSD-3.8", 'OpenBSD 3.9', "$manLocalDir/OpenBSD-3.9", 'OpenBSD 4.0', "$manLocalDir/OpenBSD-4.0", 'OpenBSD 4.1', "$manLocalDir/OpenBSD-4.1", 'OpenBSD 4.2', "$manLocalDir/OpenBSD-4.2", 'OpenBSD 4.3', "$manLocalDir/OpenBSD-4.3", #'NetBSD 0.9', "$manLocalDir/NetBSD-0.9", 'NetBSD 1.0', "$manLocalDir/NetBSD-1.0", 'NetBSD 1.1', "$manLocalDir/NetBSD-1.1", 'NetBSD 1.2', "$manLocalDir/NetBSD-1.2", 'NetBSD 1.2.1', "$manLocalDir/NetBSD-1.2.1", 'NetBSD 1.3', "$manLocalDir/NetBSD-1.3", 'NetBSD 1.3.1', "$manLocalDir/NetBSD-1.3.1", 'NetBSD 1.3.2', "$manLocalDir/NetBSD-1.3.2", 'NetBSD 1.3.3', "$manLocalDir/NetBSD-1.3.3", 'NetBSD 1.4', "$manLocalDir/NetBSD-1.4", 'NetBSD 1.4.1', "$manLocalDir/NetBSD-1.4.1", 'NetBSD 1.4.2', "$manLocalDir/NetBSD-1.4.2", 'NetBSD 1.4.3', "$manLocalDir/NetBSD-1.4.3", 'NetBSD 1.5', "$manLocalDir/NetBSD-1.5", 'NetBSD 1.5.1', "$manLocalDir/NetBSD-1.5.1", 'NetBSD 1.5.2', "$manLocalDir/NetBSD-1.5.2", 'NetBSD 1.5.3', "$manLocalDir/NetBSD-1.5.3", 'NetBSD 1.6', "$manLocalDir/NetBSD-1.6", 'NetBSD 1.6.1', "$manLocalDir/NetBSD-1.6.1", 'NetBSD 1.6.2', "$manLocalDir/NetBSD-1.6.2", 'NetBSD 2.0', "$manLocalDir/NetBSD-2.0", 'NetBSD 2.0.2', "$manLocalDir/NetBSD-2.0.2", 'NetBSD 2.1', "$manLocalDir/NetBSD-2.1", 'NetBSD 3.0', "$manLocalDir/NetBSD-3.0", 'NetBSD 3.1', "$manLocalDir/NetBSD-3.1", 'NetBSD 4.0', "$manLocalDir/NetBSD-4.0", '2.8 BSD', "$manLocalDir/2.8BSD", '2.9.1 BSD', "$manLocalDir/2.9.1BSD", '2.10 BSD', "$manLocalDir/2.10BSD", '2.11 BSD', "$manLocalDir/2.11BSD", '386BSD 0.0', "$manLocalDir/386BSD-0.0", '386BSD 0.1', "$manLocalDir/386BSD-0.1", '4.3BSD Reno', "$manLocalDir/4.3BSD-Reno", '4.3BSD NET/2', "$manLocalDir/net2", '4.4BSD Lite2', "$manLocalDir/4.4BSD-Lite2", 'Linux Slackware 3.1', "$manLocalDir/Slackware-3.1", 'Red Hat Linux/i386 4.2', "$manLocalDir/RedHat-4.2", 'Red Hat Linux/i386 5.0', "$manLocalDir/RedHat-5.0", 'Red Hat Linux/i386 5.2', "$manLocalDir/RedHat-5.2-i386", 'Red Hat Linux/i386 6.1', "$manLocalDir/RedHat-6.1-i386", 'Red Hat Linux/i386 6.2', "$manLocalDir/RedHat-6.2-i386", 'Red Hat Linux/i386 7.0', "$manLocalDir/RedHat-7.0-i386", 'Red Hat Linux/i386 7.1', "$manLocalDir/RedHat-7.1-i386", 'Red Hat Linux/i386 7.2', "$manLocalDir/RedHat-7.2-i386", 'Red Hat Linux/i386 7.3', "$manLocalDir/RedHat-7.3-i386", 'Red Hat Linux/i386 8.0', "$manLocalDir/RedHat-8.0-i386", 'Red Hat Linux/i386 9', "$manLocalDir/RedHat-9-i386", 'SuSE Linux/i386 4.3', "$manLocalDir/SuSE-4.3-i386", 'SuSE Linux/i386 5.0', "$manLocalDir/SuSE-5.0-i386", 'SuSE Linux/i386 5.2', "$manLocalDir/SuSE-5.2-i386", 'SuSE Linux/i386 5.3', "$manLocalDir/SuSE-5.3-i386", 'SuSE Linux/i386 6.0', "$manLocalDir/SuSE-6.0-i386", 'SuSE Linux/i386 6.1', "$manLocalDir/SuSE-6.1-i386", 'SuSE Linux/i386 6.3', "$manLocalDir/SuSE-6.3-i386", 'SuSE Linux/i386 6.4', "$manLocalDir/SuSE-6.4-i386", 'SuSE Linux/i386 7.0', "$manLocalDir/SuSE-7.0-i386", 'SuSE Linux/i386 7.1', "$manLocalDir/SuSE-7.1-i386", 'SuSE Linux/i386 7.2', "$manLocalDir/SuSE-7.2-i386", 'SuSE Linux/i386 7.3', "$manLocalDir/SuSE-7.3-i386", 'SuSE Linux/i386 8.0', "$manLocalDir/SuSE-8.0-i386", 'SuSE Linux/i386 8.1', "$manLocalDir/SuSE-8.1-i386", 'SuSE Linux/i386 8.2', "$manLocalDir/SuSE-8.2-i386", 'SuSE Linux/i386 9.2', "$manLocalDir/SuSE-9.2-i386", 'SuSE Linux/i386 9.3', "$manLocalDir/SuSE-9.3-i386", 'SuSE Linux/i386 10.0', "$manLocalDir/SuSE-10.0", 'SuSE Linux/i386 10.1', "$manLocalDir/SuSE-10.1", 'SuSE Linux/i386 10.2', "$manLocalDir/SuSE-10.2", 'SuSE Linux/i386 10.3', "$manLocalDir/SuSE-10.3", 'SuSE Linux/i386 11.0', "$manLocalDir/SuSE-11.0", 'SuSE Linux/i386 ES 10 SP1', "$manLocalDir/SLES-10-SP1-i386", 'HP-UX 11.22', "$manLocalDir/HP-UX-11.22", 'HP-UX 11.20', "$manLocalDir/HP-UX-11.20", 'HP-UX 11.11', "$manLocalDir/HP-UX-11.11", 'HP-UX 11.00', "$manLocalDir/HP-UX-11.00", 'HP-UX 10.20', "$manLocalDir/HP-UX-10.20", 'HP-UX 10.10', "$manLocalDir/HP-UX-10.10", 'HP-UX 10.01', "$manLocalDir/HP-UX-10.01", 'SunOS 5.10', "$manLocalDir/SunOS-5.10", 'SunOS 5.9', "$manLocalDir/SunOS-5.9", 'SunOS 5.8', "$manLocalDir/SunOS-5.8", 'SunOS 5.7', "$manLocalDir/SunOS-5.7", 'SunOS 5.6', "$manLocalDir/SunOS-5.6", 'SunOS 5.5.1', "$manLocalDir/SunOS-5.5.1", 'SunOS 4.1.3', "$manLocalDir/SunOS-4.1.3", #'XFree86 3.2', "$manLocalDir/XFree86-3.2", 'XFree86 2.1', "$manLocalDir/XFree86-2.1", 'XFree86 3.3', "$manLocalDir/XFree86-3.3", 'XFree86 3.3.6', "$manLocalDir/XFree86-3.3.6", 'XFree86 4.0', "$manLocalDir/XFree86-4.0", 'XFree86 4.0.1', "$manLocalDir/XFree86-4.0.1", 'XFree86 4.0.2', "$manLocalDir/XFree86-4.0.2", 'XFree86 4.1.0', "$manLocalDir/XFree86-4.1.0", 'XFree86 4.2.0', "$manLocalDir/XFree86-4.2.0", 'XFree86 4.2.99.3', "$manLocalDir/XFree86-4.2.99.3", 'XFree86 4.3.0', "$manLocalDir/XFree86-4.3.0", 'XFree86 4.4.0', "$manLocalDir/XFree86-4.4.0", 'XFree86 4.5.0', "$manLocalDir/XFree86-4.5.0", 'XFree86 4.6.0', "$manLocalDir/XFree86-4.6.0", 'XFree86 4.7.0', "$manLocalDir/XFree86-4.7.0", 'X11R6.7.0', "$manLocalDir/X11R6.7.0", 'X11R6.8.2', "$manLocalDir/X11R6.8.2", 'X11R6.9.0', "$manLocalDir/X11R6.9.0", 'X11R7.2', "$manLocalDir/X11R7.2", 'X11R7.3.2', "$manLocalDir/X11R7.3.2", 'ULTRIX 4.2', "$manLocalDir/ULTRIX-4.2", 'OSF1 V4.0/alpha', "$manLocalDir/OSF1-V4.0-alpha", 'OSF1 V5.1/alpha', "$manLocalDir/OSF1-V5.1-alpha", 'Plan 9', "$manLocalDir/plan9", 'Minix 2.0', "$manLocalDir/Minix-2.0", 'Unix Seventh Edition', "$manLocalDir/v7man", "Darwin 1.3.1/x86", "$manLocalDir/Darwin-1.3.1-x86", "Darwin 1.4.1/x86", "$manLocalDir/Darwin-1.4.1-x86", "Darwin 6.0.2/x86", "$manLocalDir/Darwin-6.0.2-x86", "Darwin 7.0.1", "$manLocalDir/Darwin-7.0.1", "Darwin 8.0.1/ppc", "$manLocalDir/Darwin-8.0.1-ppc", "OpenDarwin 20030208pre4/ppc", "$manLocalDir/OpenDarwin-20030208pre4-ppc", "OpenDarwin 6.6.1/x86", "$manLocalDir/OpenDarwin-6.6.1-x86", "OpenDarwin 6.6.2/x86", "$manLocalDir/OpenDarwin-6.6.2-x86", "OpenDarwin 7.2.1", "$manLocalDir/OpenDarwin-7.2.1", ); # delete not existing releases while ( ( $key, $val ) = each %manPath ) { my $counter = 0; # if the manpath contains colons, at least one directory must exists foreach ( split( /:/, $val ) ) { $counter++ if -d; } # give up and delete release if ( !$counter && $key ne $manPathDefault ) { delete $manPath{"$key"}; warn qq{man.cgi Remove release "$key"\n} if $debug >= 2; } } # keywords must be in lower cases. %manPathAliases = ( 'freebsd', 'FreeBSD 7.0-RELEASE', 'freebsd-release', 'FreeBSD 7.0-RELEASE', 'freebsd-stable', 'FreeBSD 7.0-stable', 'freebsd-stable7', 'FreeBSD 7.0-stable', 'freebsd-stable6', 'FreeBSD 6.3-stable', 'freebsd-current', 'FreeBSD 8-current', 'freebsd-release-ports', 'FreeBSD 7.0-RELEASE and Ports', 'slackware', 'Linux Slackware 3.1', 'redhat', 'Red Hat Linux/i386 9', 'suse', 'SuSE Linux/i386 11.0', 'linux', 'Red Hat Linux/i386 9', 'darwin', 'Darwin 8.0.1/ppc', 'opendarwin', 'OpenDarwin 7.2.1', 'macosx', 'Darwin 8.0.1/ppc', 'netbsd', 'NetBSD 4.0', 'openbsd', 'OpenBSD 4.3', 'v7', 'Unix Seventh Edition', 'v7man', 'Unix Seventh Edition', 'x11', 'X11R7.3.2', 'xfree86', 'XFree86 4.7.0', 'ultrix', 'ULTRIX 4.2', 'hpux', 'HP-UX 11.22', 'solaris', 'SunOS 5.10', 'sunos5', 'SunOS 5.10', 'sunos4', 'SunOS 4.1.3', 'sunos', 'SunOS 4.1.3', 'freebsd ports', 'FreeBSD Ports 7.0-RELEASE', 'ports', 'FreeBSD Ports 7.0-RELEASE', 'plan9', 'Plan 9', 'osf1', 'OSF1 V5.1/alpha', 'true64', 'OSF1 V5.1/alpha', ); foreach ( sort keys %manPathAliases ) { # delete non-existing aliases if ( !defined( $manPath{ $manPathAliases{$_} } ) ) { undef $manPathAliases{$_}; next; } # add aliases, replases spaces with dashes if (/\s/) { local ($key) = $_; $key =~ s/\s+/-/g; $manPathAliases{$key} = $manPathAliases{$_}; } } @sections = keys %sections; shift @sections; # all but the "" entry $sections = join( "|", @sections ); # sections regexp # mailto - Author # webmaster - who run this service $mailto = 'wosch@FreeBSD.org'; $mailtoURL = 'http://wolfram.schneider.org'; $mailtoURL = "mailto:$mailto" if !$mailtoURL; $full_url = 'http://www.freebsd.org/cgi/man.cgi'; $want_to_link_to_this_page = 1; &secure_env; # CGI Interface -- runs at load time &do_man( &env('SCRIPT_NAME'), &env('PATH_INFO'), &env('QUERY_STRING') ) unless defined($main'plexus_configured); $enable_include_links = 0; $enable_mailto_links = 0; # # end of config ####################################################################################### sub html_footer { my %args = @_; print qq{home | help \n} if !$args{'no_home_link'}; if (cgi_style::HAS_FREEBSD_CGI_STYLE) { print q{
}; print &cgi_style::html_footer; } else { print "\n\n"; } } sub html_header { my ( $title, $base ) = @_; my $html_meta = q| + |; return &html_header2( $title, $html_meta ) if !cgi_style::HAS_FREEBSD_CGI_STYLE; ( my $header = &cgi_style::short_html_header( $title, 1 ) ) =~ s,,\n$html_meta,s; $header =~ s,^Content-type:\s+\S+\s+,,s; $header =~ s,,\n,s if $base; return $header; } # Plexus Native Interface sub do_man { local ( $BASE, $path, $form ) = @_; local ( $_, %form, $query, $name, $section, $apropos ); local ($u) = $BASE; return &faq_output($u) if ( $path =~ /\/(faq|help)\.html$/ ); return &get_the_sources if ( $path =~ /source$/ ); return &include_output($path) if ( $enable_include_links && $path =~ m%^/usr/include/% && -f $path ); return &indexpage if ( $form eq "" ); &decode_form( $form, *form, 0 ); $format = $form{'format'}; $format = 'html' if $format !~ /^(ps|pdf|ascii|latin1)$/; # remove trailing spaces for dumb users $form{'query'} =~ s/\s+$//; $form{'query'} =~ s/^\s+//; $name = $query = $form{'query'}; $section = $form{'sektion'}; $apropos = $form{'apropos'}; $alttitle = $form{'title'}; $manpath = $form{'manpath'}; if ( $manpath =~ /^([0-9A-Za-z \.\-\/]+)$/ ) { $manpath = $1; } else { $manpath = ''; } if ( !$manpath ) { $manpath = $manPathDefault; } elsif ( !$manPath{$manpath} ) { local ($m) = ( $manpath =~ y/A-Z/a-z/ ); if ( $manPath{ $manPathAliases{$manpath} } ) { $manpath = $manPathAliases{$manpath}; } else { $manpath = $manPathDefault; } } local ($fform) = &dec($form); if ( $fform =~ m%^([a-zA-Z_\-\.:]+)$% ) { return &man( $1, '' ); } elsif ( $fform =~ m%^([a-zA-Z_\-\.:]+)\(([0-9a-zA-Z]+)\)$% ) { return &man( $1, $2 ); } # download a man hierarchie as gzip'd tar file return &download if ( $apropos > 1 ); # empty query return &indexpage if ( $manpath && $form !~ /query=/ ); $section = "" if $section eq "ALL" || $section eq ''; if ( !$apropos && $query =~ m/^(.*)\(([^\)]*)\)/ ) { $name = $1; $section = $2; } if ( $name =~ /^([\w\-:\.]+)$/ ) { $name = $1; } else { $name = ''; } if ( $section =~ /^([\w\-\.]+)$/ ) { $section = $1; } else { $section = ''; } $apropos ? &apropos($query) : &man( $name, $section ); } # --------------------- support routines ------------------------ sub debug { &http_header("text/plain"); print @_, "\n----------\n\n\n"; } sub get_the_sources { local ($file) = $0; open( R, $file ) || &mydie("open $file: $!\n"); print "Content-type: text/plain\n\n"; while () { print } close R; exit; } # download a manual directory as gzip'd tar archive sub download { $| = 1; my $filename = $manpath; $filename =~ s/\s+/_/; $filename = &encode_url($filename); $filename .= '.tar.gz'; print qq{Content-type: application/x-tar\n} . qq{Content-encoding: x-gzip\n} . qq{Content-disposition: inline; filename="$filename"\n} . "\n"; local (@m); local ($m) = $manPath{"$manpath"}; foreach ( split( /:/, $m ) ) { push( @m, $_ . '/' ) if s%^$manLocalDir/?%%; } chdir($manLocalDir) || do { print "chdir: $!\n"; exit(0); }; $m = join( " ", @m ); #warn "find $m -print | cpio -o -H tar 2>/dev/null | gzip -cqf"; sleep 1; system("find $m -print | cpio -o -H tar 2>/dev/null | gzip -cqf"); exit(0); } sub http_header { local ( $content_type, $filename ) = @_; print qq{Content-disposition: inline; filename="$filename"\n} if $filename; if ( defined($main'plexus_configured) ) { &main'MIME_header( 'ok', $content_type ); } else { print "Content-type: $content_type\n\n"; } } sub env { defined( $main'ENV{ $_[0] } ) ? $main'ENV{ $_[0] } : undef; } sub apropos { local ($query) = @_; local ( $_, $title, $head, *APROPOS ); local ( $names, $section, $msg, $key ); local ($prefix); $prefix = "Apropos "; if ($alttitle) { $prefix = ""; $title = &encode_title($alttitle); $head = &encode_data($alttitle); } else { $title = &encode_title($query); $head = &encode_data($query); } &http_header("text/html"); print &html_header("Apropos $title"); print "

", $www{'head'}, "

\n\n"; &formquery; local ($mpath) = $manPath{$manpath}; if ( $debug >= 2 ) { foreach my $dir ( split( /:/, $mpath ) ) { my $whatis = $dir . '/whatis'; warn "$manpath: no whatis file found: $whatis\n" if !-f $whatis; } } open( APROPOS, "env MANPATH=$mpath $command{'man'} -k . |" ) || do { warn "$0: Cannot open whatis database for `$mpath'\n"; print "Cannot open whatis database for `$mpath'\n"; print "\n\n\n"; return; }; local ($q) = $query; $q =~ s/(\W)/\\W/g; local ($acounter) = 0; print qq{
\n}; while () { next if !/$q/oi; $acounter++; # matches whatis.db lines: name[, name ...] (sect) - msg $names = $section = $msg = $key = undef; ( $key, $section ) = m/^([^()]+)\(([^)]*)\)/; $key =~ s/\s+$//; $key =~ s/.*\s+//; ( $names, $msg ) = m/^(.*\))\s+-\s+(.*)/; print "
", &encode_data("$names"), "\n
\n
", &encode_data($msg), "
\n"; } print qq{
\n}; close(APROPOS); if ( !$acounter ) { print "Sorry, no data found for `$query'.\n"; print qq{You may look for other } . qq{FreeBSD Search Services.\n}; } &html_footer; } sub to_filename { my %args = @_; my $name = exists $args{'name'} ? $args{'name'} : 'manpage'; my $section = exists $args{'section'} && $args{'section'} ne "" ? $args{'section'} : '0'; my $format = exists $args{'format'} ? $args{'format'} : 'unkown'; my $filename = qq{$name.$section.$format}; $filename =~ s/[^\w\-\.]/_/g; $filename =~ s/_+/_/g; return $filename; } sub man { local ( $name, $section ) = @_; local ( $_, $title, $head, *MAN ); local ( $html_name, $html_section, $prefix ); local (@manargs); local ($query) = $name; # $section =~ s/^([0-9ln]).*$/$1/; $section =~ tr/A-Z/a-z/; $prefix = "Man "; if ($alttitle) { $prefix = ""; $title = &encode_title($alttitle); $head = &encode_data($alttitle); } elsif ($section) { $title = &encode_title("${name}($section)"); $head = &encode_data("${name}($section)"); } else { $title = &encode_title("${name}"); $head = &encode_data("${name}"); } if ( $format eq "html" ) { &http_header("text/html"); print &html_header("$title"); print "

", $www{'head'}, "

\n\n"; &formquery; print "
\n";
     }
     else {
 
         #$format =~ /^(ps|ascii|latin1)$/')
         $ENV{'NROFF_FORMAT'} = $format;
 
         # Content-encoding: x-gzip
         if ( $format eq "ps" ) {
             &http_header(
                 "application/postscript",
                 &to_filename(
                     'name'    => $name,
                     'section' => $section,
                     'format'  => 'ps'
                 )
             );
         }
         elsif ( $format eq "pdf" ) {
             &http_header(
                 "application/pdf",
                 &to_filename(
                     'name'    => $name,
                     'section' => $section,
                     'format'  => 'pdf'
                 )
             );
         }
         else {
             &http_header("text/plain");
         }
     }
 
     $html_name    = &encode_data($name);
     $html_section = &encode_data($section);
 
     #print Dumper($sectionpath);
     #print "yy $section yy $manpath\n";
     if ( $name =~ /^\s*$/ ) {
         print "Empty input, no man page given.\n";
         return;
     }
 
     if ( index( $name, '*' ) != -1 ) {
         print "Invalid character input '*': $name\n";
         return;
     }
 
     if ( $section !~ /^[0-9ln]\w*$/ && $section ne '' ) {
         print "Sorry, section `$section' is not valid\n";
         return;
     }
 
     if ( !$section ) {
         if ( $sectionpath->{$manpath} ) {
             $section = "-S " . $sectionpath->{$manpath}{'path'};
         }
         else {
             $section = '';
         }
     }
     else {
         if ( $sectionpath->{$manpath}{$section} ) {
             $section = "-S " . $sectionpath->{$manpath}{$section};
         }
         else {
             my $s = substr( $section, 0, 1 );
 
             # create a colon separated list of sections
             $section = "-S $section" . ( $s ne $section ? ":$s" : '' );
         }
     }
 
     @manargs = split( / /, $section );
     if ($manpath) {
         if ( $manPath{$manpath} ) {
             unshift( @manargs, ( '-M', $manPath{$manpath} ) );
             &groff_path( $manPath{$manpath} );
         }
         elsif ( $manpath{ &dec($manpath) } ) {
             unshift( @manargs, ( '-M', $manPath{ &dec($manpath) } ) );
             &groff_path( $manPath{ &dec($manpath) } );
         }
         else {
 
             # unset invalid manpath
             print "x $manpath x\n";
             print "x " . &dec($manpath) . "x\n";
             undef $manpath;
         }
     }
 
     if ( $format =~ /^(ps|pdf)$/ ) {
         push( @manargs, '-t' );
     }
 
     warn "X $command{'man'} @manargs -- x $name x\n" if $debug >= 3;
 
     &proc( *MAN, $command{'man'}, @manargs, "--", $name )
       || &mydie("$0: open of $command{'man'} command failed: $!\n");
     if ( eof(MAN) ) {
 
         # print "X $command{'man'} @manargs -- x $name x\n";
         print qq{
\n}; print "Sorry, no data found for `$html_name" . ( $html_section ? "($html_section)" : '' ) . "'.\n"; print qq{Please try a keyword search.\n}; print qq{

You may look for other } . qq{FreeBSD Search Services.

\n}; &html_footer; return; } if ( $format ne "html" ) { if ( $format eq "latin1" || $format eq "ascii" ) { while () { s/.//g; print; } } elsif ( $format eq "pdf" ) { # # run a PostScript to PDF converter # local (@args) = ( 'mktemp', '/tmp/_man.cgi-ps2pdf-XXXXXXXXXXXX' ); open( TMP, "-|" ) or exec(@args) or die "open @args: $!\n"; local ($tempfile) = ; close TMP; # chomp, avoid security warnings using -T switch #chop($tempfile); if ( $tempfile =~ /(\S+)/ ) { $tempfile = $1; } if ( !$tempfile || !-f $tempfile ) { die "Cannot create tempfile: $tempfile\n"; } #warn $tempfile; #$tempfile = '/tmp/bla2'; open( TMP, "> $tempfile" ) or die "open $tempfile: $!\n"; while () { print TMP $_; } close TMP; local ( $ENV{'PATH'} ) = '/bin:/usr/bin:/usr/local/bin'; open( PDF, "-|" ) or exec( '/usr/local/bin/ps2pdf', $tempfile, '/dev/stdout' ) or die "open ps2pdf: $!\n"; # sleep and delete the temp file #select(undef, undef, undef, 0.8); #unlink($tempfile); while () { print; } close PDF; unlink($tempfile); } else { while () { print; } } close(MAN); exit(0); } local ($space) = 1; local (@sect); local ( $i, $j ); while () { # remove tailing white space if (/^\s+$/) { next if $space; $space = 1; } else { $space = 0; } $_ = &encode_data($_); if ( $enable_include_links && m,()?\#include()?\s+()?\<\;(.*\.h)\>\;()?, ) { $match = $4; ( $regexp = $match ) =~ s/\./\\\./; s,$regexp,\$match\,; } /^\s/ && # skip headers s,((<[IB]>)?[\w\_\.\-]+\s*()?\s*\(([1-9ln][a-zA-Z]*)\)),&mlnk($1),oige; # detect E-Mail Addreses in manpages if ( $enable_mailto_links && /\@/ ) { s/([a-z0-9_\-\.]+\@[a-z0-9\-\.]+\.[a-z]+)/$1<\/A>/gi; } # detect URLs in manpages if (m%tp://%) { s,((ftp|http)://[^\s<>\)]+),$1,gi; } if (s%^(.*?)+\n?$% ($str = $1) =~ s,(|),,g; $str%ge) { $i = $_; $j = &encode_url($i); $j =~ s/\+/_/g; $_ = qq{$i\n}; push( @sect, $i ); } print; } close(MAN); print qq{\n\n
\n}; for ( $i = 0 ; $i <= $#sect ; $i++ ) { $j = &encode_url( $sect[$i] ); $j =~ s/\+/_/g; print qq{
$sect[$i]} . ( $i < $#sect ? " |\n" : "\n" ); } if ($want_to_link_to_this_page) { my $url = qq{$full_url?query=$html_name}; $url .= qq{&sektion=$html_section} if $html_section != 0; $url .= qq{&manpath=} . &encode_url($manpath); print qq{

Want to link to this manual page? }; print qq{Use this URL:
<$url>

\n}; } &html_footer; # Sleep 0.35 seconds to avoid DoS attacs select undef, undef, undef, 0.35; } # # You may need to precreate some mdoc.local files for every system you # support (every collection of man pages), maybe like: # # $manLocalDir/NetBSD-1.4.2/tmac # # and then in your cgi script itself set the GROFF_TMAC_PATH as appropriate # like: # # GROFF_TMAC_PATH=$manLocalDir/NetBSD-1.4.2/tmac:/usr/share/tmac/ # sub groff_path { local $manpath = shift; local @groff_path; foreach ( split( /:/, $manpath ) ) { push( @groff_path, $_ . '/tmac' ); } $ENV{'GROFF_TMAC_PATH'} = join( ':', @groff_path, '/usr/share/tmac' ); } sub mlnk { local ($matched) = @_; local ( $link, $section ); ( $link = $matched ) =~ s/[\s]+//g; $link =~ s/<\/?[IB]>//ig; ( $link, $section ) = ( $link =~ m/^([^\(]*)\((.*)\)/ ); $link = &encode_url($link); $section = &encode_url($section); local ($manpath) = &encode_url($manpath); return qq{$matched}; } sub proc { local ( *FH, $prog, @args ) = @_; local ($pid) = open( FH, "-|" ); return undef unless defined($pid); if ( $pid == 0 ) { exec( $prog, @args ) or &mydie("exec $prog failed\n"); } 1; } # $indent is a bit of optional data processing I put in for # formatting the data nicely when you are emailing it. # This is derived from code by Denis Howe # and Thomas A Fine sub decode_form { local ( $form, *data, $indent, $key, $_ ) = @_; foreach $_ ( split( /&/, $form ) ) { ( $key, $_ ) = split( /=/, $_, 2 ); $_ =~ s/\+/ /g; # + -> space $key =~ s/\+/ /g; # + -> space $_ =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; # undo % escapes $key =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; # undo % escapes $_ =~ s/[\r\n]+/\n\t/g if defined($indent); # indent data after \n $data{$key} = &escape($_); } } # block cross-site scripting attacks (css) sub escape($) { $_ = $_[0]; s/&/&/g; s//>/g; $_; } sub dec { local ($_) = @_; s/\+/ /g; # '+' -> space s/%(..)/pack("c",hex($1))/ge; # '%ab' -> char ab return ($_); } # # Splits up a query request, returns an array of items. # usage: @items = &main'splitquery($query); # sub splitquery { local ($query) = @_; grep( ( s/%([\da-f]{1,2})/pack(C,hex($1))/eig, 1 ), split( /\+/, $query ) ); } # encode unknown data for use in a URL sub encode_url { local ($_) = @_; # rfc1738 says that ";"|"/"|"?"|":"|"@"|"&"|"=" may be reserved. # And % is the escape character so we escape it along with # single-quote('), double-quote("), grave accent(`), less than(<), # greater than(>), and non-US-ASCII characters (binary data), # and white space. Whew. s/([\000-\032\;\/\?\:\@\&\=\%\'\"\`\<\>\177-\377 ])/sprintf('%%%02x',ord($1))/eg; s/%20/+/g; $_; } # encode unknown data for use in ...</TITILE> sub encode_title { # like encode_url but less strict (I couldn't find docs on this) local ($_) = @_; s/([\000-\031\%\&\<\>\177-\377])/sprintf('%%%02x',ord($1))/eg; $_; } # encode unknown data for use inside markup attributes <MARKUP ATTR="..."> sub encode_attribute { # rfc1738 says to use entity references here local ($_) = @_; s/([\000-\031\"\'\`\%\&\<\>\177-\377])/sprintf('\&#%03d;',ord($1))/eg; $_; } # encode unknown text data for using as HTML, # treats ^H as overstrike ala nroff. sub encode_data { local ($_) = @_; local ($str); # Escape &, < and > s,\010[><&],,g; s/\&/\&\;/g; s/\</\<\;/g; s/\>/\>\;/g; s,((_\010[^_])+),($str = $1) =~ s/.\010//g; "<i>$str</i>";,ge; s,((.\010.)+),($str = $1) =~ s/.\010//g; "<b>$str</b>";,ge; #s,((_\010.)+),($str = $1) =~ s/.\010//g; "<i>$str</i>";,ge; #s,(.\010)+,$1,g; #if (!s,((.\010.)+\s+(.\010.)+),($str = $1) =~ s/.\010//g; "<b>$str</b>";,ge) { # s,(([^_]\010.)+),($str = $1) =~ s/[^_]\010//g; "<b>$str</b>";,ge; # s,(([_]\010.)+),($str = $1) =~ s/[_]\010//g; "<i>$str</i>";,ge; #} # Escape binary data except for ^H which we process below # \375 gets turned into the & for the entity reference #s/([^\010\012\015\032-\176])/sprintf('\375#%03d;',ord($1))/eg; # Process ^H sequences, we use \376 and \377 (already escaped # above) to stand in for < and > until those characters can # be properly escaped below. #s,\376[IB]\377_\376/[IB]\377,,g; #s/.[\b]//g; # just do an erase for anything else # Now convert our magic chars into our tag markers #s/\375/\&/g; s/\376/</g; s/\377/>/g; # cleanup all the rest s,.\010,,g; $_; } sub indexpage { &http_header("text/html"); print &html_header("$www{'title'}: Index Page") . "<h1>", $www{'head'}, "</h1>\n\n" . &intro; &formquery; local ($m) = ( $manpath ? $manpath : $manPathDefault ); $m = &encode_url($m); print "<b><i>Section Indexes</i></b>:\n"; foreach ( '1', '2', '3', '4', '5', '6', '7', '8', '9', 'n' ) { print qq{¤ } if $_ ne '1'; print qq{<a href="$BASE?query=($_)&sektion=&apropos=1&manpath=$m&title=Section%20$_Index">$_</a>\n}; } print "<br /><b><i>Explanations of Man Sections:</i></b>\n"; foreach ( '1', '2', '3', '4', '5', '6', '7', '8', '9' ) { print qq{¤ } if $_ ne '1'; print qq{<a href="$BASE?query=intro&sektion=$_&apropos=0&manpath=$m&title=Introduction%20Section%20$_">intro($_)</a>\n}; } if (0) { print "<br />\n<b><i>Quick Reference Categories:</i></b>\n"; foreach ( 'database', 'disk', 'driver', 'ethernet', 'mail', 'net', 'nfs', 'nis', 'protocol', 'ppp', 'roff', 'string', 'scsi', 'statistic', 'tcl', 'tcp', 'time' ) { print qq{¤ <a href="$BASE?query=$_&sektion=&apropos=1&manpath=$m&title=Quick%20Ref%20$_">$_</a>\n}; } } print <<ETX if 0 && $mailto; URL: <a href="$BASE" target="_parent">$www{'home'}$BASE</a><br /> ETX print "<br />\n"; &html_footer( 'no_home_link' => 1 ); } sub formquery { local ( $astring, $bstring ); if ( !$apropos ) { $astring = q{ checked="checked"}; } else { $bstring = q{ checked="checked"}; } print <<ETX; <form method="get" action="$BASE"> Man Page or Keyword Search: <input value="$query" name="query" /> <input type="submit" value="Submit" /> <input type="reset" value="Reset" /> <br /> <input name="apropos" value="0" type="radio"$astring /> <a href="$BASE?query=man&sektion=1&apropos=0">Man</a> <select name="sektion"> ETX foreach $key ( sort keys %sectionName ) { print "<option" . ( ( $key eq $section ) ? ' selected="selected" ' : ' ' ) . qq{value="$key">$sectionName{$key}</option>\n}; } print qq{</select>\n<select name="manpath">\n}; local ($l) = ( $manpath ? $manpath : $manPathDefault ); foreach ( sort keys %manPath ) { $key = $_; print "<option" . ( ( $key eq $l ) ? ' selected="selected" ' : ' ' ) . qq{value="$key">$key</option>\n}; } local ($m) = &encode_url($l); print <<ETX; </select> <br /> <input name="apropos" value="1" type="radio"$bstring /> <a href="$BASE?query=apropos&sektion=1&apropos=0">Apropos</a> Keyword Search (all sections) <select name="format"> ETX foreach ( 'html', 'ps', 'pdf', # you need a 8 bit clean man, e.g. jp-man 'ascii', 'latin1' ) { print qq{<option value="$_">$_</option>\n}; } print <<ETX; </select> Output format </form> <a href="$BASE?manpath=$m">home</a> | <a href="$BASE/help.html">help</a> <hr /> ETX 0; } sub faq { local ( @list, @list2 ); local ($url); foreach ( sort keys %manPath ) { $url = &encode_url($_); push( @list, qq{<li><a href="$BASE?apropos=2&manpath=$url">[download]} . qq{</a> "$_" -> $BASE?manpath=$url} . qq{</li>\n} ); } foreach ( sort keys %manPathAliases ) { push( @list2, qq[<li>"$_" -> "$manPathAliases{$_}" -> ] . qq{<a href="$BASE?manpath=} . &encode_url($_) . qq{">$BASE?manpath=} . &encode_url($_) . "</a></li>\n" ) if $manPathAliases{$_}; } local $id = - '$FreeBSD: www/en/cgi/man.cgi,v 1.220 2008/08/07 08:30:32 wosch Exp $'; + '$FreeBSD: www/en/cgi/man.cgi,v 1.221 2008/09/21 19:07:43 wosch Exp $'; return qq{\ <pre> Copyright (c) 1996-2008 <a href="$mailtoURL">Wolfram Schneider</a> Copyright (c) 1993-1995 Berkeley Software Design, Inc. This data is part of a licensed program from BERKELEY SOFTWARE DESIGN, INC. Portions are copyrighted by BSDI, The Regents of the University of California, Massachusetts Institute of Technology, Free Software Foundation, The FreeBSD Project, and others. </pre>\n This script has the revsion: $id <p /> Copyright (c) for man pages by OS vendors. <p/> <a href="ftp://ftp.2bsd.com">2.11 BSD</a>, <a href="http://www.hp.com">HP</a>, <a href="http://www.freebsd.org">FreeBSD</a>, <a href="http://www.cs.vu.nl/~ast/minix.html">Minix</a>, <a href="http://www.netbsd.org">NetBSD</a>, <a href="http://www.openbsd.org">OpenBSD</a>, <a href="http://plan9.bell-labs.com/plan9/">Plan 9</a>, <a href="http://www.redhat.com">Red Hat</a>, <a href="http://slackware.com">Slackware Linux</a>, <a href="http://www.sun.com">SunOS</a>, <a href="http://www.suse.com">SuSE</a>, <a href="http://www.digital.com">ULTRIX</a>, <a href="ftp://elib.zib.de/pub/netlib/att/cs/v7man">Unix Seventh Edition</a>, <a href="http://www.xfree86.org">XFree86</a>, <a href="http://www.x.org">X11R6</a> <h2>FAQ</h2> <ul> <li>Get the <a href="$BASE/source">source</a> of the man.cgi script</li> <li>Troff macros works only if defined in FreeBSD/groff. OS specific macros like `appeared in NetBSD version 1.2' are not supported.</li> <li>Some OSs provide only formated manual pages (catpages), e.g. NetBSD and OpenBSD. In this case it is not possible to create Postscript and troff output.</li> <li>The <a href="http://cvsweb.freebsd.org/src/share/misc/bsd-family-tree"> Unix family tree, BSD part</a>.</li> <li>The <a href="http://www.freebsd.org/cgi/ports.cgi"> FreeBSD Ports Changes</a> script.</li> <li>Copyright (c) and download for man pages by OS vendors</li> </ul> <h2>Shortcuts for FreeBSD manual pages</h2> <ul> <li>which manpage: <a href="http://man.freebsd.org/which">http://man.freebsd.org/which</a></li> <li>socket(2) manpage: <a href="http://man.freebsd.org/socket/2">http://man.freebsd.org/socket/2</a></li> </ul> <p /> <ul> <li>which manpage: <a href="$BASE?which">$full_url?which</a></li> <li>socket(2) manpage: <a href="$BASE?socket(2)">$full_url?socket(2)</a></li> </ul> <h2>Releases</h2> Releases and Releases Aliases are information how to make a link to this script to the right OS version. <p /> You may download the manpages as gzip'd tar archive for private use. A tarball is usually 5MB big. <p /> <ul> @list </ul> <h2>Releases Aliases</h2> Release aliases are for lazy people. Plus, they have a longer lifetime, eg. 'openbsd' points always to the latest OpenBSD release. <ul> @list2 </ul> }; } sub intro { return qq{\ <p /> <i>Man Page Lookup</i> searches for man pages name and section as given in the selection menu and the query dialog. <i>Apropos Keyword Search</i> searches the database for the string given in the query dialog. There are also several hypertext links provided as short-cuts to various queries: <i>Section Indexes</i> is apropos listings of all man pages by section. <i>Explanations of Man Sections</i> contains pointers to the intro pages for various man sections. <p /> }; } sub faq_output { my $base = $BASE; $base =~ s,[^/]*$,,; $base = 'http://www.freebsd.org/cgi/'; # XXX &http_header("text/html"); print &html_header( "FreeBSD manual page help", $base ) . "<h1>", $www{'head'}, "</h1>\n" . &faq . qq{<br />\n}; &html_footer; } sub html_header2 { my ( $title, $head ) = @_; return qq{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"> <head> <title>$title $head }; } sub secure_env { $main'ENV{'PATH'} = '/bin:/usr/bin'; $main'ENV{'MANPATH'} = $manPath{$manPathDefault}; $main'ENV{'IFS'} = " \t\n"; $main'ENV{'PAGER'} = 'cat'; $main'ENV{'SHELL'} = '/bin/sh'; $main'ENV{'LANG'} = 'C'; undef $main'ENV{'DISPLAY'}; } sub include_output { local ($inc) = @_; &http_header("text/plain"); open( I, "$inc" ) || do { print "open $inc: $!\n"; exit(1) }; while () { print } close(I); } # CGI script must die with error status 0 sub mydie { local ($message) = @_; &http_header("text/html"); print &html_header("Error"); print $message; print qq{

home }; &html_footer; exit(0); } 1; diff --git a/en/cgi/ports.cgi b/en/cgi/ports.cgi index 581478d597..c90550ac9e 100755 --- a/en/cgi/ports.cgi +++ b/en/cgi/ports.cgi @@ -1,671 +1,672 @@ #!/usr/bin/perl -T # -# Copyright (c) 1996-2007 Wolfram Schneider +# Copyright (c) 1996-2008 Wolfram Schneider # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: www/en/cgi/ports.cgi,v 1.95 2007/08/02 18:28:26 wosch Exp $ +# $FreeBSD: www/en/cgi/ports.cgi,v 1.96 2007/08/02 18:30:21 wosch Exp $ # # ports.cgi - search engine for FreeBSD ports # o search for a port by name or description use POSIX qw(strftime); use Time::Local; require "./cgi-style.pl"; $t_style = qq` + `; sub init_variables { $localPrefix = '/usr/ports'; # ports prefix # Directory of the up-to-date INDEX* $portsDatabaseHeadDir = "/usr/local/www/ports"; # Ports database file to use if ( -f "$portsDatabaseHeadDir/INDEX-6" ) { $ports_database = 'INDEX-6'; } elsif ( -f "$portsDatabaseHeadDir/INDEX-5" ) { $ports_database = 'INDEX-5'; } else { $ports_database = 'INDEX'; } # URL of ports tree for browsing $remotePrefixFtp = 'ports'; # 'ftp://ftp.FreeBSD.org/pub/FreeBSD/branches/-current/ports'; # URL of ports tree for download $remotePrefixFtpDownload = 'http://cvsweb.FreeBSD.org/ports'; $remoteSuffixFtpDownload = '%s.tar.gz?tarball=1'; # where to get -current packages local ($p) = 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386'; local ($palpha) = 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/alpha'; local ($pamd64) = 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/amd64'; local ($pia64) = 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/ia64'; local ($psparc64) = 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/sparc64'; $remotePrefixFtpPackagesDefault = '6-STABLE/i386'; # This is currently unused %remotePrefixFtpPackages = ( '7-CURRENT/i386', "$p/packages-7-current/All", '6-STABLE/i386', " $p/packages-6-stable/All", '5-STABLE/i386', " $p/packages-5-stable/All", '4-STABLE/i386', " $p/packages-4-stable/All", '6.0-RELEASE/i386', "$p/packages-6.0-release/All", '5.4-RELEASE/i386', "$p/packages-5.4-release/All", '4.11-RELEASE/i386', "$p/packages-4.11-release/All", '4-STABLE/alpha', "$palpha/packages-4-stable/All", '5.4-RELEASE/alpha', "$palpha/packages-5.4-release/All", '4.11-RELEASE/alpha', "$palpha/packages-4.11-release/All", '7-CURRENT/amd64', "$pamd64/packages-7-current/All", '6-STABLE/amd64', "$pamd64/packages-6-stable/All", '5-STABLE/amd64', "$pamd64/packages-5-stable/All", '6.0-RELEASE/amd64', "$pamd64/packages-6.0-release/All", '5.4-RELEASE/amd64', "$pamd64/packages-5.4-release/All", '7-CURRENT/ia64', "$pia64/packages-7-current/All", '6-STABLE/ia64', "$pia64/packages-6-stable/All", '6.0-RELEASE/ia64', "$pia64/packages-6.0-release/All", '5.4-RELEASE/ia64', "$pia64/packages-5.4-release/All", '7-CURRENT/sparc64', "$psparc64/packages-7-current/All", '6-STABLE/sparc64', "$psparc64/packages-6-stable/All", '5-STABLE/sparc64', "$psparc64/packages-5-stable/All", '6.0-RELEASE/sparc64', "$psparc64/packages-6.0-release/All", '5.4-RELEASE/sparc64', "$psparc64/packages-5.4-release/All", ); $remotePrefixHtml = "$hsty_base/ports"; # CVS Web interface $remotePrefixCvs = 'http://cvsweb.FreeBSD.org/ports'; # Ports documentation $portsDesc = "$hsty_base/ports/"; # location of the tiny BSD daemon $daemonGif = "Really small BSD Daemon"; # visible E-Mail address, plain text $mailto = 'www@FreeBSD.org'; # Mailinglist for FreeBSD Ports $mailtoList = 'ports@FreeBSD.org'; # use mailto:email?subject $mailtoAdvanced = 'yes'; # the URL if you click at the E-Mail address (see below) $mailtoURL = "mailto:$mailto" if !$mailtoURL; # security $ENV{'PATH'} = '/bin:/usr/bin'; # ports download sources script $pds = 'pds.cgi'; # make plain text URLs clickable cgi script $url = 'url.cgi'; # extension type for packages $packageExt = 'tbz'; local ($packageDB) = '../ports/packages.exists'; &packages_exist( $packageDB, *packages ) if -f $packageDB; } sub packages_exist { local ( $file, *p ) = @_; open( P, $file ) || do { warn "open $file: $!\n"; warn "Cannot create packages links\n"; return 1; }; while (

) { chop; $p{$_} = 1; } close P; return 0; } # return the date of the last ports database update sub last_update { local ($file) = "$portsDatabaseHeadDir/$ports_database"; local ( $modtime, $modtimestr ); $modtime = ( stat($file) )[9]; if ( defined($modtime) && $modtime > 0 ) { $modtimestr = strftime( "%G-%m-%d %H:%M:%S UTC", gmtime($modtime) ); } else { $modtimestr = "Unknown"; } return $modtimestr; } sub last_update_message { return "

Last database update: " . &last_update . "

\n"; } sub dec { local ($_) = @_; s/\+/ /g; # '+' -> space s/%(..)/pack("c",hex($1))/ge; # '%ab' -> char ab return ($_); } # $indent is a bit of optional data processing I put in for # formatting the data nicely when you are emailing it. # This is derived from code by Denis Howe # and Thomas A Fine sub decode_form { local ( $form, *data, $indent, $key, $_ ) = @_; foreach $_ ( split( /&/, $form ) ) { ( $key, $_ ) = split( /=/, $_, 2 ); $_ =~ s/\+/ /g; # + -> space $key =~ s/\+/ /g; # + -> space $_ =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; # undo % escapes $key =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; # undo % escapes $_ =~ s/[\r\n]+/\n\t/g if defined($indent); # indent data after \n $data{$key} = $_; } } sub escapeHTML { my $toencode = shift; return "" unless defined($toencode); $toencode =~ s{&}{&}gso; $toencode =~ s{<}{<}gso; $toencode =~ s{>}{>}gso; $toencode =~ s{"}{"}gso; return $toencode; } # encode unknown data for use in a URL sub encode_url { local ($_) = @_; s/([\000-\032\;\/\?\:\@\&\=\%\'\"\`\<\>\177-\377 ])/sprintf('%%%02x',ord($1))/eg; # s/%20/+/g; $_; } sub warn { print "$_[0]" } sub env { defined( $ENV{ $_[0] } ) ? $ENV{ $_[0] } : undef; } sub exit { exit 0 } sub readindex { local ( *var, *msec ) = @_; local ($localportsdb) = "$portsDatabaseHeadDir/$ports_database"; local ( @tmp, @s ); open( C, $localportsdb ) || do { warn "Cannot open ports database $localportsdb: $!\n"; &exit; }; while () { next if $query && !/$query/oi; chop; @tmp = split(/\|/); $var{"$tmp[4]"} = $_; @s = split( /\s+/, $tmp[6] ); foreach (@s) { $msec{"$tmp[4],$_"} = 1; } } close C; } # extract sub collections sub readcoll { local ( @a, @b, %key ); local ($file) = '../ports/categories'; local ($localportsdb) = "$portsDatabaseHeadDir/$ports_database"; if ( -r $file && open( C, $file ) ) { while () { chop; if (/^\s*([^,]+),\s*"([^"]+)",\s*([A-Z]+)/) { @b = split( /\s+/, $1 ); foreach (@b) { if ( !defined( $key{$_} ) ) { $key{$_} = 1; } } } } } else { if ( -r $localportsdb ) { open( C, $localportsdb ) || do { warn "Cannot open ports database $localportsdb: $!\n"; &exit; } } while () { chop; @a = split('\|'); @b = split( /\s+/, $a[6] ); foreach (@b) { if ( !defined( $key{$_} ) ) { $key{$_} = 1; } } } } close C; @a = (); foreach ( sort keys %key ) { push( @a, $_ ); } return @a; } # basic function for HTML output sub out { local ($line) = @_; local ( $version, $path, $local, $comment, $descfile, $email, $sections, $bdepends, $rdepends, @rest ) = split( /\|/, $line ); if ( $path =~ m%^$localPrefix/([^/]+)%o ) { if ( !$out_sec || $1 ne $out_sec ) { print "\n" if $counter > 0; print qq{\n

} . qq{Category $1} . "

\n
\n"; $out_sec = $1; } } $counter++; $pathDownload = $path; $pathB = $path; $pathB =~ s/^$localPrefix/ports/o; $path =~ s/^$localPrefix/$remotePrefixFtp/o; $pathDownload =~ s/^$localPrefix/$remotePrefixFtpDownload/o; if ($remoteSuffixFtpDownload) { if ( substr( $remoteSuffixFtpDownload, 0, 2 ) eq '%s' ) { $pathDownload =~ m,([^/]+)$,; $pathDownload .= "/$1" . substr( $remoteSuffixFtpDownload, 2 ); } else { $pathDownload .= $remoteSuffixFtpDownload; } } $descfile =~ s/^$localPrefix/$remotePrefixFtp/o; $version = &encode_url($version); #$version =~ s/[\+,]/X/g; local ($l) = $path; $l =~ s%^$remotePrefixFtp%$remotePrefixCvs%o; print qq{
$version
\n}; print qq{
}, &escapeHTML($comment), qq{
\n}; print qq[Long description :\n]; print qq[Sources :\n]; # Link package in "default" arch/release. Verify it's existence on ftp-master. if ( $packages{"$version.$packageExt"} ) { print qq[Package :\n]; } print qq[Changes :\n]; print qq[Download
\n]; print qq{Maintained by: $email
\n}; local (@s) = split( /\s+/, $sections ); if ( $#s > 0 ) { print qq{Also listed in: }; foreach (@s) { print qq{$_ } if $_ ne $out_sec; } print "
\n"; } if ( $bdepends || $rdepends ) { local ($flag) = 0; local ($last) = ''; print qq{Requires: }; foreach ( sort split( /\s+/, "$bdepends $rdepends" ) ) { # delete double entries next if $_ eq $last; $last = $_; print ", " if $flag; $flag++; print qq{$_}; } print "
\n"; } print qq[
]; # XXX: should be done in a CSS print qq[
 
]; print qq[\n\n]; } # search and output sub search_ports { local (@a) = (); local ( $key, $name, $text ); foreach $key ( sort keys %today ) { next if $today{$key} !~ /$query/oi; @a = split( /\|/, $today{$key} ); $name = $a[0]; #$name =~ s/(\W)/\\$1/g; $text = $a[3]; #$text =~ s/(\W)/\\$1/g; if ( $section ne "all" ) { next if $a[6] !~ /^$section(\s|$)/; } #warn "$stype:$query: $name $text\n"; if ( $stype eq "name" && $name =~ /$query/o ) { &out( $today{$key} ); } elsif ( $stype eq "text" && $text =~ /$query/oi ) { &out( $today{$key} ); } elsif ( $stype eq "all" && ( $text =~ /$query/oi || $name =~ /$query/io ) ) { &out( $today{$key} ); } elsif ( $stype eq 'maintainer' && $a[5] =~ /$query/io ) { &out( $today{$key} ); } elsif ( $stype eq 'requires' && ( $a[7] =~ /$query/io || $a[8] =~ /$query/io ) ) { &out( $today{$key} ); } } } sub forms { print qq{

FreeBSD Ports [short description followed ...] FAQ

}; print qq{

"Package Name" searches for the name of a port or distribution. "Description" searches case-insensitive in a short comment about the port. "All" searches case-insensitive for the package name and in the description about the port.

Search for:

}; } sub footer { print qq{ Powered by FreeBSD -© 1996-2007 by Wolfram Schneider. All rights reserved.
+© 1996-2008 by Wolfram Schneider. All rights reserved.
}; -#print q{$FreeBSD: www/en/cgi/ports.cgi,v 1.95 2007/08/02 18:28:26 wosch Exp $} . "
\n"; +#print q{$FreeBSD: www/en/cgi/ports.cgi,v 1.96 2007/08/02 18:30:21 wosch Exp $} . "
\n"; print qq{Please direct questions about this service to $mailto
\n}; print qq{General questions about FreeBSD ports should be sent to } . qq{} . qq{$mailtoList
\n}; print &last_update_message; print qq{
\n

\n}; } sub check_input { if ($query) { $stype = "all" if !$stype; if ( !( $stype eq "name" || $stype eq "text" || $stype eq "maintainer" || $stype eq "requires" || $stype eq "all" ) ) { &warn( "unknown search type ``$type'', use `all', `text', `name', 'requires', or `maintainer'\n" ); &exit(0); } else { return; } } } sub faq { print qq{

FreeBSD Ports Search FAQ

Keywords

Description
A more detailed description.
Download
Download the ports directory.
Package
Download the pre-compiled software package.
Changes
Read the latest changes.
Sources
Links to all source files.

Misc

Package download links point to the FreeBSD 6-STABLE version and not to the latest releases.

The script ports.cgi use the file $ports_database as database for it's operations. $ports_database is updated automatically every two hours.

You may also search the ports manual pages.

Back to the search engine


}; } # # Main # &init_variables; $query_string = &env('QUERY_STRING'); $path_info = &env('PATH_INFO'); &decode_form( $query_string, *form ); $section = $form{'sektion'}; $section = 'all' if ( !$section ); $query = $form{'query'}; $stype = $form{'stype'}; $script_name = &env('SCRIPT_NAME'); if ( $path_info eq "/source" ) { # XXX print "Content-type: text/plain\n\n"; open( R, $0 ) || do { print "ick!\n"; &exit; }; while () { print } close R; &exit; } # Full text search in ports//port>/pkg-descr if ( $stype eq 'pkgdescr' ) { local ($url) = 'http://www.FreeBSD.org/cgi/search.cgi?source=pkgdescr&max=25'; $query =~ s/\s+/+/g; print "Location: $url&words=$query\n\n"; &exit; } if ( $stype eq "faq" ) { print &short_html_header( "FreeBSD Ports Search FAQ", 1 ); &faq; &footer; print &html_footer; &exit(0); } print &html_header( "FreeBSD Ports Search", 1 ); # allow `/ports.cgi?netscape' where 'netscape' is the query port to search # this make links to this script shorter if ( !$query && $query_string =~ /^([^=&]+)$/ ) { $query = $1; } # automatically read collections, need only 0.2 sec on a pentium @sec = &readcoll; &forms; $query =~ s/^\s+//; $query =~ s/\s+$//; if ( $query_string eq "" || !$query ) { &footer; print &html_footer; &exit(0); } &check_input; $counter = 0; # search if ($query) { &readindex( *today, *msec ); $query =~ s/([^\w\^])/\\$1/g; &search_ports; } if ( !$counter ) { print "Sorry, nothing found.\n"; print qq{You may look for other } . qq{FreeBSD Search Services.\n}; } else { print "
\n"; } print qq{
\n}; &footer; print &html_footer; diff --git a/en/cgi/query-pr.cgi b/en/cgi/query-pr.cgi index 0a9ffa7059..2d56816be4 100755 --- a/en/cgi/query-pr.cgi +++ b/en/cgi/query-pr.cgi @@ -1,1184 +1,1185 @@ #!/usr/bin/perl -Tw # # A "More Useful" GNATS query-pr Interface # # Copyright (C) 2006, Shaun Amott # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: www/en/cgi/query-pr.cgi,v 1.63 2007/12/17 17:46:05 shaun Exp $ +# $FreeBSD: www/en/cgi/query-pr.cgi,v 1.64 2008/01/26 15:53:55 shaun Exp $ # # # Note: this is a script to run on a webserver. If you want to do tests # on the command-line, use the QUERY_STRING environment variable to # pass parameters to the script: # $ QUERY_STRING=pr=bin/106049 ./query-pr.cgi # use strict; use MIME::Base64; # ports/converters/p5-MIME-Base64 use MIME::QuotedPrint; # use Convert::UU qw(uudecode uuencode); # ports/converters/p5-Convert-UU require './cgi-style.pl'; require './query-pr-lib.pl'; use constant HTTP_HEADER => "Content-type: text/html; charset=UTF-8\r\n\r\n"; use constant HTTP_HEADER_PATCH => "Content-type: text/plain; charset=UTF-8\r\nContent-Disposition: inline; filename=\"%s\"\r\n\r\n"; use constant SECT_HEADER => 1; use constant SECT_SFIELDS => 2; use constant SECT_MFIELDS => 3; use constant ENCODING_BASE64 => 1; use constant ENCODING_QP => 2; use constant PATCH_ANY => 0x0001; use constant PATCH_DIFF => 0x0002; use constant PATCH_UUENC => 0x0004; use constant PATCH_UUENC_BIN => 0x0008; use constant PATCH_SHAR => 0x0010; use constant PATCH_BASE64 => 0x0020; my @fields_single = ( "Number", "Category", "Synopsis", "Confidential", "Severity", "Priority", "Responsible", "State", "Quarter", "Keywords", "Date-Required", "Class", "Submitter-Id", "Arrival-Date", "Closed-Date", "Last-Modified", "Originator", "Release", ); my @fields_multiple = ( "Organization", "Environment", "Description", "How-To-Repeat", "Fix", "Release-Note", "Audit-Trail", "Unformatted", ); my $fields_skip = "Confidential|Quarter|Keywords|Date-Required|Submitter-Id"; my $valid_category = '[a-z0-9][A-Za-z0-9-_]{1,25}'; my $valid_pr = '\d{1,8}'; my $binary_filetypes = '(?:\.gz|\.bz2|\.zip|\.tar)$'; my %fmt; my $f = ""; my $PR = -1; my $getpatch = -1; my $mimepatch = ""; my $inpatch = 0; my $patchendhint = 0; my $category; my @query; my (%header, %sfields, %mfields); my $iscgi = defined $ENV{'SCRIPT_NAME'}; my $fromwebform = 0; $ENV{'PATH'} = "/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin"; $ENV{'QUERY_STRING'} ||= ""; $ENV{'SCRIPT_NAME'} ||= $0; # Junk from cgi-style.pl $main::hsty_base ||= ""; $main::t_style ||= ""; my $scriptname = htmlclean($ENV{'SCRIPT_NAME'}); my $querystring = htmlclean($ENV{'QUERY_STRING'}); # Do not change $self_url_base, unless you understand what it is for! # In particular: it is used as a delimiter between comments in the # Audit-Trail. my $self_url_base = "http://www.FreeBSD.org/cgi/query-pr.cgi?pr="; my $cvsweb_url = "http://www.FreeBSD.org/cgi/cvsweb.cgi/"; my $stylesheet = "$main::hsty_base/layout/css/query-pr.css"; #----------------------------------------------------------------------- # Format strings #----------------------------------------------------------------------- $fmt{'header_thead'} = < EOF $fmt{'header_tfoot'} = <
EOF $fmt{'header_trow'} = <%%(1):%%(2) EOF $fmt{'sfields_thead'} = < EOF $fmt{'sfields_trow'} = <%%(1):%%(2) EOF $fmt{'sfields_tfoot'} = <
EOF $fmt{'mfields_header'} = <%%(1):
EOF $fmt{'mfields_header'} =~ s/\n+$//; $fmt{'mfields_footer'} = < EOF $fmt{'patchblock_thead'} = < Download %%(2)
 EOF
 $fmt{'patchblock_thead'} =~ s/\n+$//;
 
 $fmt{'patchblock_tfoot'} = <
 
EOF $fmt{'patchblock_tfoot'} =~ s/\n+$//; $fmt{'patchblock_tfoot'} =~ s/^\n+//; $fmt{'auditblock_thead'} = < %%(1) Changed EOF $fmt{'auditblock_tfoot'} = <
EOF $fmt{'auditblock_trow'} = <%%(1):%%(2) EOF $fmt{'responseblock_thead'} = < Reply via E-mail EOF $fmt{'responseblock_tfoot'} = <
EOF $fmt{'responseblock_textfoot'} = < EOF $fmt{'responseblock_texthead'} = < EOF $fmt{'responseblock_trow'} = <%%(1):%%(2) EOF $fmt{'unexpectedtext_thead'} = < EOF $fmt{'html_footerlinks'} = < Submit Followup | Raw PR | Find another PR
EOF $fmt{'trylatermsg'} = < Please try again later.

EOF $fmt{'mime_boundary'} = < EOF $fmt{'quote_level_0'} = '> '; $fmt{'quote_level_1'} = '> '; $fmt{'quote_end'} = ''; $fmt{'empty'} = ' '; $fmt{'break'} = "
\n"; # From cgi-style.pl $main::t_style = ""; +$main::t_style .= qq{\n\n}; #----------------------------------------------------------------------- # Begin Code #----------------------------------------------------------------------- if ($ENV{'QUERY_STRING'}) { foreach (split(/&/, $ENV{'QUERY_STRING'})) { my ($key, $val) = map { s/%([0-9a-f]{2})/chr hex $1/egi; $_ } split /=/; $f = lc $val if ($key eq "f"); $PR = lc $val if ($key eq "pr" or $key eq "q"); $PR = lc $key if ($key =~ /^(?:$valid_category\/)?$valid_pr$/i); $category = lc $val if ($key eq "cat"); $getpatch = lc $val if ($key eq "getpatch"); if ($key eq "prp") { if ( lc ($val) =~ /^(\d+)-(\d+)-(\w+)$/ ) { $PR = $1; $getpatch = $2; $mimepatch = $3; } } } } unless (!$iscgi) { if ($getpatch > 0 or $f eq "raw") { if ($mimepatch eq "diff") { printf HTTP_HEADER_PATCH, "patch-$getpatch.diff"; } elsif ($mimepatch eq "shar") { printf HTTP_HEADER_PATCH, "shar-$getpatch.sh"; } elsif ($mimepatch eq "uu") { printf HTTP_HEADER_PATCH, "patch-$getpatch.uu"; } elsif ($mimepatch eq "txt") { printf HTTP_HEADER_PATCH, "txt-$getpatch.txt"; } else { printf HTTP_HEADER_PATCH, "unknown-$getpatch.txt"; } } } ($category, $PR) = ($1, $2) if ($PR =~ /^($valid_category)\/($valid_pr)$/); $category = undef if ($category && $category !~ /^$valid_category$/); if ($PR !~ /^$valid_pr$/ || $PR < 0) { print html_header("Query PR Database"); displayform(); print html_footer(); exit; } # Just in case $PR = int $PR; $PR = quotemeta $PR; if ($category) { $category = quotemeta $category; @query = split /\n/, qx(query-pr.web --full --category=${category} ${PR} 2>&1); } else { @query = split /\n/, qx(query-pr.web --full ${PR} 2>&1); } if (!@query or ($query[0] and $query[0] =~ /^query-pr(:?\.(:?real|web))?: /)) { print html_header("No PRs Matched Query"); displayform(); print html_footer(); exit; } elsif ($query[0] =~ /^lockf: /) { print html_header("PR Database Busy"); sprint('trylatermsg'); print html_footer(); exit; } if ($f eq "raw") { print "$_\n" foreach (@query); exit; } #----------------------------------------------------------------------- # Process Results from query-pr #----------------------------------------------------------------------- my $section = SECT_HEADER; my $mfield = $fields_multiple[0]; foreach my $line (@query) { my ($k, $v); if ($section == SECT_HEADER) { $section++ if ($line =~ /^\s*$/); next if ($line !~ /^([A-Z][A-Za-z0-9-_.]+): (.*)$/); ($k, $v) = ($1, $2); $k = lc $k; $header{$k} = $v; next; } if ($section == SECT_SFIELDS) { my $i = -1; my $f = 0; next if ($line !~ /^>([A-Z][A-Za-z-]+):\s*(.*)$/); ($k, $v) = ($1, $2); foreach (@fields_single) { if ($k eq $_) { $f = 1; last; } $i++; } if (!$f or $i == $#fields_single) { $section++; next; } $sfields{$k} = $v; next; } if ($section == SECT_MFIELDS) { my $f = 0; if ($line =~ /^>([A-Z][A-Za-z-]+):\s*(.*)$/) { foreach (@fields_multiple) { $f = 1 if $1 eq $_; next; } if ($f) { $mfield = $1; } else { push @{$mfields{$mfield}}, $2; } next; } push @{$mfields{$mfield}}, $line; next; } } $getpatch = 0 if ($getpatch < 0); $fromwebform = $header{'x-send-pr-version'} =~ /^www-/; if ($getpatch > 0) { extractpatch(); exit; } # Construct footer now we have enough information buildfooter(); print html_header(htmlclean("$sfields{'Category'}/$sfields{'Number'}: " . $sfields{'Synopsis'})); sprint('header_thead'); sprint('header_trow', 'From', htmlclean($header{'from'})); sprint('header_trow', 'Date', htmlclean($header{'date'})); sprint('header_trow', 'Subject', htmlclean($header{'subject'})); sprint('header_trow', 'Send-pr version', htmlclean($header{'x-send-pr-version'})); sprint('header_tfoot'); # Single-Line fields sprint('sfields_thead'); foreach (@fields_single) { my ($k, $v); $k = htmlclean($_); $v = htmlclean($sfields{$_}) || ""; $v =~ s/^(\S*).*$/$1\@FreeBSD.org<\/a>/ if ($_ eq "Responsible"); $v = "never" if ($_ eq "Last-Modified" and $v =~ /^\s*$/); next if ($_ =~ /$fields_skip/i); sprint('sfields_trow', $k, $v); } sprint('sfields_tfoot'); # Multiple-Line fields foreach my $field (@fields_multiple) { my $cfound = 0; sprint('mfields_header', $field); if ($field eq "Audit-Trail") { my %block; my $cliphack; my $blockwhy; my ($inblock, $inresponse, $mbreak) = (0, 0, 0); my $url = "${self_url_base}${PR}"; my $outp = ""; my %mime_headers; my $mime_boundary; my $mime_endheader; my $encoding = 0; # Hack for older PRs with no usable delimiter push @{$mfields{'Audit-Trail'}}, $url; $url = quotemeta $url; foreach (@{$mfields{$field}}) { # If we're sure we have a genuine Reply via E-mail block, # allow for a border case, where there is a space rather # than an empty line between the header and body. $_ = "" if ($cliphack && /^ {1,2}$/); $cliphack = 0; if ($inblock == 1 && (/^${url}\s*$/i || /^([A-Za-z_]+-Changed-From-To: .*)$/ || /^(From: )/)) { my $onnextline = ($1 ? 1 : 0); if ($blockwhy) { $blockwhy =~ s/
$//; $blockwhy = htmlparse($blockwhy); } sprint('auditblock_trow', "Why", $blockwhy || ""); undef %block; undef $blockwhy; $inblock = 0; $mbreak = 0; if ($inresponse) { if ($inpatch) { $inpatch = 0; sprint('patchblock_tfoot'); sprint('break'); } sprint('responseblock_textfoot') if ($inresponse > 1); sprint('responseblock_tfoot'); $inresponse = 0; } sprint('auditblock_tfoot'); next unless ($onnextline); } if (/^([A-Za-z_]+)-Changed-([A-Za-z_-]+?): (.*)$/) { my $w = $1; my $k = $2; if ($inresponse) { if ($inpatch) { $inpatch = 0; sprint('patchblock_tfoot'); sprint('break'); } sprint('responseblock_textfoot') if ($inresponse > 1); sprint('responseblock_tfoot'); $inresponse = 0; } if ($inblock == 0) { $block{'changed'} = $w; sprint('auditblock_thead', htmlclean($w)); $inblock = 1; } $block{$k} = $3; if ($k ne "Why") { sprint('auditblock_trow', htmlclean($k), htmlclean($block{$k})); next; } next; } elsif (/^(From|To|Cc|Subject|Date): (.*)$/) { my ($k, $v); $k = htmlclean($1); $v = htmlclean($2); if ($inresponse > 1) { if ($inpatch) { $inpatch = 0; sprint('patchblock_tfoot'); sprint('break'); } $mime_boundary = undef; $mime_endheader = 0; $encoding = 0; sprint('responseblock_textfoot'); sprint('responseblock_tfoot'); } if (!$inresponse || $inresponse > 1) { sprint('responseblock_thead'); } if ($k eq "From" or $k eq "Date") { sprint('responseblock_trow', $k, $v); } $inresponse = 1; $cliphack = 1; next; } elsif (/^\s/ and $inresponse == 1 and !$mbreak) { $cliphack = 1; next; } elsif (/^ (.*)$/) { next if ($inresponse and !$mbreak); if ($inresponse == 1) { sprint('responseblock_texthead'); $inresponse++; } # XXX - use trailing cfound if ($inresponse) { my $txt = $1; if ($txt !~ /^-+$/ && $txt !~ /(?:cut|snip)/i && $txt =~ /^--(\S+)$/) { $mime_boundary = $1 if (!defined $mime_boundary && !$inpatch); if ($1 =~ /^${mime_boundary}(--)?$/) { $mime_boundary = undef if (defined $1); if ($encoding == ENCODING_BASE64 and $outp ne "") { my $patchname; my $dp = $mime_headers{'disposition'}; if ($dp and $dp =~ /.*\bfilename=["']?([A-Za-z0-9\-\.:_]{6,36})["']?.*/) { $patchname = $1; } else { $patchname = "attachment.dat"; } if ($patchname =~ /$binary_filetypes/) { $outp = "(Binary attachment not viewable.)\n"; } else { $outp = decode_base64($outp); } $outp = "--- $patchname begins here ---\n" . $outp . "\n--- $patchname ends here ---\n"; parsepatches($_) foreach (split /\n/, $outp); $outp = ""; } sprint('mime_boundary'); $mime_endheader = 0; $encoding = 0; next; } } if (defined $mime_boundary && !$mime_endheader && !$inpatch) { if ($txt =~ /^Content-([A-Za-z-]{2,}):\s*(.*)\s*$/i) { $mime_headers{lc $1} = $2; next; } elsif ($txt =~ /^\s*(?:file)?name=["']?.*?["']?\s*$/i) { $mime_headers{'disposition'} ||= ""; if ($mime_headers{'disposition'} !~ /(?:file)?name=/) { $mime_headers{'disposition'} .= "; $txt"; } next; } else { $mime_endheader = 1; if ($mime_headers{'transfer-encoding'}) { my $enc = $mime_headers{'transfer-encoding'}; if ($enc =~ /^\s*["']?base64["']?\s*$/i) { $encoding = ENCODING_BASE64; } elsif ($enc =~ /^\s*["']?quoted-printable["']?\s*$/i) { $encoding = ENCODING_QP; } else { $encoding = 0; } } else { $encoding = 0; } } } if ($encoding == ENCODING_BASE64) { $outp .= $txt; next; } elsif ($encoding == ENCODING_QP) { # XXX: lines ending in = should be joined $txt =~ s/=$//; $txt = decode_qp($txt); } if ($txt =~ /^\s*((?:>\s*)+)/) { my $level = $1; $txt =~ s/^((?:>\s*)*={47})(=+\s*)$/$1 $2/; if ($level =~ s/.*?>.*?/./g) { my $i = 0; my @levels = split(/\s*>\s*/, $txt, length $level); my $last = pop @levels; foreach (@levels) { sprint('quote_level_'.(++$i % 2)); $_ = htmlclean($_); $_ = htmlparse($_); print; } print htmlclean($last); sprint('quote_end') while ($i--); sprint('break'); } } else { $patchendhint = 1 if ($txt eq '-- '); if ($inpatch or $txt) { parsepatches($txt) || ($inpatch || sprint('break')); } else { sprint('break'); } } } } elsif (/^$/ and $inresponse and !$mbreak) { # XXX: >line 1 ignored (but not needed) $mbreak = 1; next; } elsif (/^$/) { $mbreak = 0; next; } elsif (!$inblock and $_ !~ /^${url}\s*$/i) { if ($inresponse > 1) { if ($inpatch) { $inpatch = 0; sprint('patchblock_tfoot'); sprint('break'); } sprint('responseblock_textfoot'); sprint('responseblock_tfoot'); } sprint('unexpectedtext_thead'); print htmlclean($_); sprint('unexpectedtext_tfoot'); $inresponse = 0; next; } $cfound = ($_ ? 1 : 0) if (!$cfound); next if (!$cfound); if (!$_) { $cfound++; next; } else { print "\n" while (--$cfound); $cfound = 1; } $_ =~ s/^((?:>\s*)*={47})(=+\s*)$/$1 $2/; $_ = htmlclean($_); $blockwhy .= "$_
\n" if defined($block{'Why'}); } if ($inresponse) { if ($inpatch) { $inpatch = 0; sprint('patchblock_tfoot'); sprint('break'); } sprint('responseblock_textfoot') if ($inresponse > 1); sprint('responseblock_tfoot'); $inresponse = 0; } } elsif ($field eq "Fix") { foreach (@{$mfields{$field}}) { s/\s+$//; $cfound = ($_ ? 1 : 0) if (!$cfound); next if (!$cfound); if (!$_) { $cfound++; next; } else { sprint('break') while (--$cfound > 1); $cfound = 1; } parsepatches($_) || ($inpatch || sprint('break')); } if ($inpatch) { $inpatch = 0; sprint('patchblock_tfoot'); sprint('break'); } } else { foreach (@{$mfields{$field}}) { s/\s+$//; $cfound = ($_ ? 1 : 0) if (!$cfound); next if (!$cfound); if (!$_) { $cfound++; next; } else { sprint('break') while (--$cfound); $cfound = 1; } $_ = htmlclean($_); $_ = htmlparse($_); print; sprint('break'); } sprint('empty') if ($cfound <= 1); } sprint('mfields_footer'); } sprint('html_footerlinks'); print html_footer(); # DoS protection -- apparently. select undef, undef, undef, 0.35 unless (!$iscgi); exit; #----------------------------------------------------------------------- # Func: extractpatch() # Desc: Isolate the requested patch, and print unformatted to STDOUT. #----------------------------------------------------------------------- sub extractpatch { foreach (@{$mfields{'Fix'}}) { return if (parsepatches($_) == -1); } foreach (@{$mfields{'Audit-Trail'}}) { if (s/^ //) { return if (parsepatches($_) == -1); } else { $inpatch = 0; } } } #----------------------------------------------------------------------- # Func: sprint() # Desc: Merge provided list of strings into the desired message and # print the result to STDOUT. #----------------------------------------------------------------------- sub sprint { my $k = shift; my $msg = $fmt{$k}; if (!$msg) { warn "Message format \"$k\" not found"; return; } my $i = 1; foreach (@_) { $msg =~ s/%%()\(${i}\)/$_/g; $i++; } $msg =~ s/%%\([0-9]+\)//g; print $msg; } #----------------------------------------------------------------------- # Func: htmlclean() # Desc: Remove HTML entities from message and return the result. #----------------------------------------------------------------------- sub htmlclean { my $v = shift; return "" if (!$v); $v =~ s/&/&/g; $v =~ s//>/g; return $v; } #----------------------------------------------------------------------- # Func: htmlparse() # Desc: Perform any fancy formatting on the message (e.g. HTML-ify # URLs) and return the result. #----------------------------------------------------------------------- sub htmlparse { my $v = shift; return "" if (!$v); my $iv = 'A-Za-z0-9\-_\/#@\$=\\\\'; $v =~ s/(?$1\/$2<\/a>/g; $v =~ s/((?:https?|ftps?):\/\/[^\s\/]+\/[][\w=.,\'\(\)\~\?\!\&\/\%\$\{\}:;@#+-]*)/
$1<\/a>/g; $v =~ s/^RCS file: (\/home\/[A-Za-z0-9]+\/(.*?)),v$/RCS file: $1<\/a>,v/; return $v; } #----------------------------------------------------------------------- # Func: buildfooter() # Desc: Build the page footer links section. #----------------------------------------------------------------------- sub buildfooter { my ($newstr, $synopsis, $mail, $replyto, $pr, $cat); $pr = htmlclean($sfields{'Number'}); $cat = htmlclean($sfields{'Category'}); $synopsis = htmlclean($sfields{'Synopsis'}); $mail = $header{'from'}; if ($mail) { $mail =~ s/^\s*(.*)\s*$/$1/; $mail =~ s/.*<(.*)>.*/$1/; $mail =~ s/\s*\(.*\)\s*//; } $replyto = $header{'reply-to'}; if ($replyto) { $replyto =~ s/^\s*(.*)\s*$/$1/; $replyto =~ s/.*<(.*)>.*/$1/; $replyto =~ s/\s*\(.*\)\s*//; } $mail = $replyto if ($replyto); $mail .= '@FreeBSD.org' unless ($mail =~ /@/); $synopsis =~ s/[^a-zA-Z+.@-]/"%" . sprintf("%02X", unpack("C", $&))/eg; $mail =~ s/[^a-zA-Z+.@-]/"%" . sprintf("%02X", unpack("C", $&))/eg; $newstr = "mailto:bug-followup\@FreeBSD.org,${mail}?subject=Re:%20${cat}/${pr}:%20${synopsis}"; $fmt{'html_footerlinks'} =~ s/%%\(maillink\)/${newstr}/g; # Do some other replacements while here $fmt{$_} =~ s/%%\(pr\)/${pr}/g foreach (keys %fmt); } #----------------------------------------------------------------------- # Func: parsepatches() # Desc: Parse lines which might contain patches, adding HTML formatting # if requested. #----------------------------------------------------------------------- { # Local static variables my ($outp, $patchnum, $cfound, $lastcol, $lastrev, $context, $mime_boundary); sub parsepatches { $_ = shift; $outp ||= ""; $patchnum ||= 0; $cfound ||= 0; $context ||= 0; my $plus_s = ''; my $minus_s = ''; my $context_s = ''; my $revinfo_s = ''; my $at_s = ''; my $all_e = ''; my $maxcontext = 3; # XXX: This ought to be dynamic if (!$getpatch) { $cfound = ($_ ? 1 : 0) if (!$cfound); return 0 if (!$cfound); if (!$_) { $cfound++; return 0; } else { sprint('break') while (--$cfound > 1); $cfound = 1; } } if (/^--(\S+)$/ && $getpatch && !$inpatch) { if ($getpatch == $patchnum+1) { $mime_boundary = $1; return 0; } } if (/^Content-([A-Za-z-]{2,}):\s*(.*)\s*$/i && $getpatch) { if (!$inpatch) { my $k = lc $1; my $v = lc $2; if ($getpatch == $patchnum+1 and defined $mime_boundary) { if ($k eq "transfer-encoding" && $v =~ /\bbase64\b/) { $patchnum++; $inpatch |= PATCH_BASE64; } return 0; } } return 0; } if (defined $mime_boundary && /^--${mime_boundary}(?:--)?$/ && $getpatch && ($inpatch & PATCH_BASE64)) { $inpatch = 0; $mime_boundary = undef; if ($outp ne "") { print decode_base64($outp); $outp = ""; } return -1; } if (($inpatch & PATCH_BASE64) && $getpatch) { $outp .= $_; return 1; } if (/^Patch attached with submission follows:$/ && $fromwebform && !$inpatch) { $patchnum++; $inpatch |= PATCH_ANY; return 1 if ($getpatch and $patchnum != $getpatch); $lastcol = undef; $lastrev = undef; sprint('patchblock_thead', $patchnum, 'patch.txt', "txt") unless ($getpatch); return 1; } if (/^---{1,8}\s?([A-Za-z0-9-_.,:%]+) (begins|starts) here/i && !$inpatch) { $patchnum++; $inpatch |= PATCH_ANY; return 1 if ($getpatch and $patchnum != $getpatch); $lastcol = undef; $lastrev = undef; sprint('patchblock_thead', $patchnum, htmlclean($1), "txt") unless ($getpatch); return 1; } if (/^((?:(?:---|\*\*\*) (?:\S+)\s*(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) .*)|(diff -.*? .*? .*)|(Index: \S+)|(\*{3} \d+,\d+ \*{4}))$/ && !$inpatch) { $patchnum++; $inpatch |= PATCH_DIFF; return 1 if ($getpatch and $patchnum != $getpatch); $lastcol = undef; $lastrev = undef; sprint('patchblock_thead', $patchnum, "patch-$patchnum.diff", "diff") unless ($getpatch); } if (/^# This is a shell archive\. Save it in a file, remove anything before/ && !$inpatch) { $patchnum++; $inpatch |= PATCH_SHAR; return 1 if ($getpatch and $patchnum != $getpatch); $lastcol = undef; $lastrev = undef; sprint('patchblock_thead', $patchnum, "shar-$patchnum.sh", "shar") unless ($getpatch); } if (/^---{1,8}\s?[A-Za-z0-9-_.,:%]+ ends here/i && ($inpatch & PATCH_ANY)) { #$inpatch ^= PATCH_ANY; $inpatch = 0; $context = 0; sprint('patchblock_tfoot') unless ($getpatch); return (($patchnum == $getpatch) ? -1 : $inpatch) if ($getpatch); return $inpatch; } if (/^exit$/ && ($inpatch & PATCH_SHAR)) { $inpatch ^= PATCH_SHAR; print; sprint('patchblock_tfoot') unless ($getpatch); return 1; } if (/^begin \d\d\d (.*)/ && !($inpatch & PATCH_UUENC)) { if (!$inpatch) { $patchnum++; return 1 if ($getpatch and $patchnum != $getpatch); } sprint('patchblock_thead', $patchnum, "patch-$patchnum.uu", "uu") unless ($getpatch or $inpatch); $inpatch |= PATCH_UUENC; $inpatch |= PATCH_UUENC_BIN if ($1 =~ /$binary_filetypes/); } if ($inpatch) { if ($inpatch & PATCH_UUENC) { if (!$getpatch or $patchnum == $getpatch) { $outp .= "$_\n"; if (/^end$/) { $outp = uudecode($outp) unless (!$getpatch and $inpatch & PATCH_UUENC_BIN); $outp = htmlclean($outp) unless ($getpatch); print $outp; $inpatch ^= PATCH_UUENC; $outp = ""; $inpatch ^= PATCH_UUENC_BIN; # No outer container? sprint('patchblock_tfoot') if (!$inpatch and !$getpatch); return -1; } } } else { if (!$getpatch) { if (!($inpatch & PATCH_ANY)) { if (/^ / or $_ eq "") { $context++; } else { if ($context == $maxcontext and $patchendhint) { $context++; } else { $context = 0; } } if ($context > $maxcontext and $patchendhint) { $context = 0; # Disabled for now, since it doesn't # work quite right. # $inpatch = 0; # sprint('patchblock_tfoot'); # print; # return 0; } } $_=~ s/ $//; $_ = htmlclean($_); $_ = htmlparse($_); while (s/\t/" " x (8 - ((length($`)-1) % 8))/e) {}; # Obfustication coutesy of cdiff s/^(\+.*)$/${plus_s}$1${all_e}/o; s/^(-.*)$/${minus_s}$1${all_e}/o if !s/^(--- \d+,\d+ ----.*)$/${revinfo_s}$1${all_e}/o; s/^(\*\*\* \d+,\d+ *\*\*\*.*)$/${revinfo_s}$1${all_e}/o; s/^(\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*)$/${revinfo_s}$1${all_e}/o; s/^(!.*)$/${context_s}$1${all_e}/o; s/^(@@.*$)/${at_s}$1${all_e}/o; # if (/^1.(\d+)(\s+\(\w+\s+\d{2}-\w{3}-\d{2}\):\s)(.*)/) { # $lastcol = $lastcol || 0; # $lastcol++ if defined($lastrev) && $lastrev != $1; # $lastrev = $1; # $lastcol %= 6; # $_ = "\033[3" . ($lastcol + 1) . "m1.$1$2\033[0m$3\n"; # } } if (!$getpatch or $patchnum == $getpatch) { print; print "\n"; } } } else { if (!$getpatch) { $_ = htmlclean($_); $_ = htmlparse($_); print; } } return $inpatch; } } # ex: ts=4 sw=4