From 2a57d730276ed5565ca2252376bc47ddaccf5b0a Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Wed, 21 Nov 2001 03:58:32 +0000 Subject: remove autogenerated files rename scripts/dirlist.in to scripts/dirlist.cgi.in --- ChangeLog | 8 + configure | 7 +- scripts/dirlist.cgi | 532 ---------------------------------------- scripts/dirlist.cgi.in | 532 ++++++++++++++++++++++++++++++++++++++++ scripts/dirlist.in | 532 ---------------------------------------- scripts/multipart/multipart.cgi | 272 -------------------- scripts/w3mman/w3mman | 41 ---- scripts/w3mman/w3mman2html.cgi | 252 ------------------- 8 files changed, 544 insertions(+), 1632 deletions(-) delete mode 100644 scripts/dirlist.cgi create mode 100755 scripts/dirlist.cgi.in delete mode 100755 scripts/dirlist.in delete mode 100644 scripts/multipart/multipart.cgi delete mode 100644 scripts/w3mman/w3mman delete mode 100644 scripts/w3mman/w3mman2html.cgi diff --git a/ChangeLog b/ChangeLog index 5d59cc8..6bf327b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-11-21 Fumitoshi UKAI + + * XMakefile: update scripts/dirlist.cgi generation + * scripts/multipart/multipart.cgi: removed + * scripts/w3mman/w3mman scripts/w3mman/w3mman2html.cgi: removed + * scripts/dirlist.in scripts/dirlist.cgi: removed + * scripts/dirlist.cgi.in: added + 2001-11-21 Fumitoshi UKAI * add rcsids diff --git a/configure b/configure index 08fb9f8..93633e8 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: configure,v 1.7 2001/11/20 17:49:23 ukai Exp $ +# $Id: configure,v 1.8 2001/11/21 03:58:32 ukai Exp $ # Configuration. # @@ -1927,13 +1927,14 @@ END_OF_CONFIG_H echo '' echo 'config.h is created. See config.h for further configuration.' echo '' -echo 'Generating dirlist.cgi' +echo 'Generating scripts/dirlist.cgi' perl=`./which perl` if [ `expr "$perl" : 'not found'` != 0 ]; then perl=/usr/local/bin/perl fi sed -e "s;@PERL@;$perl;" \ - scripts/dirlist.in > scripts/dirlist.cgi + scripts/dirlist.cgi.in > scripts/dirlist.cgi +chmod +x scripts/dirlist.cgi echo 'Configuration done. Just type "make".' diff --git a/scripts/dirlist.cgi b/scripts/dirlist.cgi deleted file mode 100644 index 2e723b4..0000000 --- a/scripts/dirlist.cgi +++ /dev/null @@ -1,532 +0,0 @@ -#!/usr/bin/perl -# -# Directory list CGI by Hironori Sakamoto (hsaka@mth.biglobe.ne.jp) -# - -if ( $^O =~ /^(ms)?(dos|win(32|nt)?)/i ) { - $WIN32 = 1; - $CYGPATH = 1; -} -elsif ( $^O =~ /cygwin|os2/i ) { - $WIN32 = 1; - $CYGPATH = 0; -} -else { - $WIN32 = 0; - $CYGPATH = 0; -} -$RC_DIR = '~/.w3m/'; - -$RC_DIR =~ s@^~/@$ENV{'HOME'}/@; -if ($CYGPATH) { - $RC_DIR = &cygwin_pathconv("$RC_DIR"); -} -$CONFIG = "$RC_DIR/dirlist"; -$CGI = $ENV{'SCRIPT_NAME'} || $0; -$CGI = "file://" . &file_encode("$CGI"); - -$AFMT = '%s'; -$NOW = time(); - -@OPT = &init_option($CONFIG); - -$query = $ENV{'QUERY_STRING'}; -$cmd = ''; -$cgi = 0; -if ($query eq '') { - $_ = `pwd`; - chop; - s/\r$//; - $dir = $_; - $cgi = 0; -} elsif ($query =~ /^(opt\d+|dir|cmd)=/) { - foreach(split(/\&/, $query)) { - if (s/^dir=//) { - $dir = &form_decode($_); - } elsif (s/^opt(\d+)=//) { - $OPT[$1] = $_; - } elsif (s/^cmd=//) { - $cmd = $_; - } - } - $cgi = 1; -} else { - $dir = $query; - if (($dir !~ m@^/@) && - ($WIN32 && $dir !~ /^[a-z]:/i)) { - $_ = `pwd`; - chop; - s/\r$//; - $dir = "$_/$dir"; - } - $cgi = -1; -} -if ($dir !~ m@/$@) { - $dir .= '/'; -} -if ($dir =~ m@^/@ && $CYGPATH) { - $dir = &cygwin_pathconv("$dir"); -} -$ROOT = ''; -if ($WIN32) { - if (($dir =~ s@^//[^/]+@@) || ($dir =~ s@^[a-z]:@@i)) { - $ROOT = $&; - } - if ($CYGPATH) { - $ROOT = &cygwin_pathconv("$ROOT"); - } -} -if ($cgi) { - $dir = &cleanup($dir); -} - -$TYPE = $OPT[$OPT_TYPE]; -$FORMAT = $OPT[$OPT_FORMAT]; -$SORT = $OPT[$OPT_SORT]; -if ($cmd) { - &update_option($CONFIG); -} - -$qdir = "$ROOT" . &html_quote("$dir"); -$edir = "$ROOT" . &file_encode("$dir"); -if (! opendir(DIR, "$ROOT$dir")) { - print < - -Directory list of $qdir - - -$qdir: $! ! - - -EOF - exit 1; -} - -# ($cgi > 0) && print < - -Directory list of $qdir - - -

Directory list of $qdir

-EOF -&print_form($edir, @OPT); -print < -EOF -$dir =~ s@/$@@; -@sdirs = split('/', $dir); -$_ = $sdirs[0]; -if ($_ eq '') { - $_ = '/'; -} -if ($TYPE eq $TYPE_TREE) { - print < - -
-EOF
-  $q = "$ROOT". &html_quote("$_");
-  $e = "$ROOT" . &file_encode("$_");
-  if ($dir =~ m@^$@) {
-    $n = "\" name=\"current";
-  } else {
-    $n = '';
-  }
-  printf("$AFMT\n", "$e$n", "$q");
-  $N = 0;
-  $SKIPLINE = "";
-
-  &left_dir('', @sdirs);
-
-  print <
-
-
$SKIPLINE
-EOF
-} else {
-  print <
-EOF
-}
-
-&right_dir($dir);
-
-if ($TYPE eq $TYPE_TREE) {
-  print <
-
-
-
-
-EOF
-} else {
-  print <
-
-
-EOF
-}
-
-sub left_dir {
-  local($pre, $dir, @sdirs) = @_;
-  local($ok) = (@sdirs == 0);
-  local(@cdirs) = ();
-  local($_, $dir0, $d, $qdir, $q, $edir, $e);
-
-  $dir0 = "$dir/";
-  $dir = "$dir0";
-  opendir(DIR, "$ROOT$dir") || return;
-
-  foreach(sort readdir(DIR)) {
-    -d "$ROOT$dir$_" || next;
-    /^\.$/ && next;
-    /^\.\.$/ && next;
-    push(@cdirs, $_);
-  }
-  closedir(DIR);
-
-  $qdir = "$ROOT" . &html_quote($dir);
-  $edir = "$ROOT" . &file_encode($dir);
-  while(@cdirs) {
-    $_ = shift @cdirs;
-    $q = &html_quote($_);
-    $e = &file_encode($_);
-    $N++;
-    if (!$ok && $_ eq $sdirs[0]) {
-      $d = $dir0 . shift @sdirs;
-      if (!@sdirs) {
-        $n = "\" name=\"current";
-        $SKIPLINE = "\n" x $N;
-      } else {
-        $n = '';
-      }
-      printf("${pre}o-$AFMT\n", "$edir$e$n", "$q");
-      &left_dir(@cdirs ? "$pre| " : "$pre  ", $d, @sdirs);
-      $ok = 1;
-    } else {
-      printf("${pre}+-$AFMT\n", "$edir$e", $q);
-    }
-  }
-}
-
-sub right_dir {
-  local($dir) = @_;
-  local(@list);
-  local($_, $qdir, $q, $edir, $e, $f, $max, @d, $type, $u, $g);
-  local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-        $atime,$mtime,$ctime,$blksize,$blocks);
-  local(%sizes, %ctimes, %prints);
-
-  $dir = "$dir/";
-  opendir(DIR, "$ROOT$dir") || return;
-
-  $qdir = "$ROOT" . &html_quote($dir);
-  $edir = "$ROOT" . &file_encode($dir);
-  if ($TYPE eq $TYPE_TREE) {
-    print "$qdir\n";
-  }
-  @list = ();
-  $max = 0;
-  foreach(readdir(DIR)) {
-    /^\.$/ && next;
-#    if ($TYPE eq $TYPE_TREE) {
-#      /^\.\.$/ && next;
-#    }
-    $f = "$ROOT$dir$_";
-    (($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-      $atime,$mtime,$ctime,$blksize,$blocks) = lstat($f)) || next;
-    push(@list, $_);
-    $sizes{$_} = $size;
-    $ctimes{$_} = $ctime;
-
-    if ($FORMAT eq $FORMAT_COLUMN)  {
-      if (length($_) > $max) {
-        $max = length($_);
-      }
-      next;
-    }
-    $type = &utype($mode);
-    if ($FORMAT eq $FORMAT_SHORT)  {
-      $prints{$_} = sprintf("%-6s ", "[$type]");
-      next;
-    }
-    if ($type =~ /^[CB]/) {
-      $size = sprintf("%3u, %3u", ($rdev >> 8) & 0xff, $rdev & 0xffff00ff);
-    }
-    if ($FORMAT eq $FORMAT_LONG) {
-      $u = $USER{$uid} || ($USER{$uid} = getpwuid($uid) || $uid);
-      $g = $GROUP{$gid} || ($GROUP{$gid} = getgrgid($gid) || $gid);
-      $prints{$_} = sprintf( "%s %-8s %-8s %8s %s ",
-		&umode($mode), $u, $g, $size, &utime($ctime));
-#   } elsif ($FORMAT eq $FORMAT_STANDARD) {
-    } else {
-      $prints{$_} = sprintf("%-6s %8s %s ", "[$type]", $size, &utime($ctime));
-    }
-  }
-  closedir(DIR);
-  if ($SORT eq $SORT_SIZE) { 
-    @list = sort { $sizes{$b} <=> $sizes{$a} || $a <=> $b } @list;
-  } elsif ($SORT eq $SORT_TIME) { 
-    @list = sort { $ctimes{$b} <=> $ctimes{$a} || $a <=> $b } @list;
-  } else {
-    @list = sort @list;
-  }
-  if ($FORMAT eq $FORMAT_COLUMN) {
-    local($COLS, $l, $nr, $n);
-    if ($TYPE eq $TYPE_TREE) {
-      $COLS = 60;
-    } else {
-      $COLS = 80;
-    }
-    $l = int($COLS / ($max + 2)) || 1;
-    $nr = int($#list / $l + 1);
-    $n = 0;
-    print "\n";
-    foreach(@list) {
-      $f = "$ROOT$dir$_";
-      $q = &html_quote($_);
-      $e = &file_encode($_);
-      if ($n % $nr == 0) {
-        print "\n";
-      } else {
-        print "
\n"; - } - } - print "
"; - } - if (-d $f) { - printf($AFMT, "$edir$e", "$q/"); - } else { - printf($AFMT, "$edir$e", $q); - } - $n++; - if ($n % $nr == 0) { - print "
\n"; - return; - } - foreach(@list) { - $f = "$ROOT$dir$_"; - $q = &html_quote($_); - $e = &file_encode($_); - print $prints{$_}; - if (-d $f) { - printf($AFMT, "$edir$e", "$q/"); - } else { - printf($AFMT, "$edir$e", $q); - } - if (-l $f) { - print " -> ", &html_quote(readlink($f)); - } - print "\n"; - } -} - -sub init_option { - local($config) = @_; - $OPT_TYPE = 0; - $OPT_FORMAT = 1; - $OPT_SORT = 2; - $TYPE_TREE = 't'; - $TYPE_STANDARD = 'd'; - $FORMAT_SHORT = 's'; - $FORMAT_STANDARD = 'd'; - $FORMAT_LONG = 'l'; - $FORMAT_COLUMN = 'c'; - $SORT_NAME = 'n'; - $SORT_SIZE = 's'; - $SORT_TIME = 't'; - local(@opt) = ($TYPE_TREE, $FORMAT_STANDARD, $SORT_NAME); - local($_); - - open(CONFIG, "< $config") || return @opt; - while() { - chop; - s/^\s+//; - tr/A-Z/a-z/; - if (/^type\s+(\S)/i) { - $opt[$OPT_TYPE] = $1; - } elsif (/^format\s+(\S)/i) { - $opt[$OPT_FORMAT] = $1 - } elsif (/^sort\s+(\S)/i) { - $opt[$OPT_SORT] = $1; - } - } - close(CONFIG); - return @opt; -} - -sub update_option { - local($config) = @_; - - open(CONFIG, "> $config") || return; - print CONFIG < -
- - -EOF - foreach(0 .. 2) { - print "\n"; - } - print "\n"; - foreach(0 .. 2) { - print "\n"; - } - print < - -
 $disc[$_]
-
- - -EOF -} - -sub html_quote { - local($_) = @_; - local(%QUOTE) = ( - '<', '<', - '>', '>', - '&', '&', - '"', '"', - ); - s/[<>&"]/$QUOTE{$&}/g; - return $_; -} -sub file_encode { - local($_) = @_; - s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg; - return $_; -} - -sub form_decode { - local($_) = @_; - s/\+/ /g; - s/%([\da-f][\da-f])/pack('C', hex($1))/egi; - return $_; -} - -sub cleanup { - local($_) = @_; - - s@//+@/@g; - s@/\./@/@g; - while(m@/\.\./@) { - s@^/(\.\./)+@/@; - s@/[^/]+/\.\./@/@; - } - return $_; -} - -sub utype { - local($_) = @_; - local(%T) = ( - 0010000, 'PIPE', - 0020000, 'CHR', - 0040000, 'DIR', - 0060000, 'BLK', - 0100000, 'FILE', - 0120000, 'LINK', - 0140000, 'SOCK', - ); - return $T{($_ & 0170000)} || 'FILE'; -} - -sub umode { - local($_) = @_; - local(%T) = ( - 0010000, 'p', - 0020000, 'c', - 0040000, 'd', - 0060000, 'b', - 0100000, '-', - 0120000, 'l', - 0140000, 's', - ); - - return ($T{($_ & 0170000)} || '-') - . (($_ & 00400) ? 'r' : '-') - . (($_ & 00200) ? 'w' : '-') - . (($_ & 04000) ? 's' : - (($_ & 00100) ? 'x' : '-')) - . (($_ & 00040) ? 'r' : '-') - . (($_ & 00020) ? 'w' : '-') - . (($_ & 02000) ? 's' : - (($_ & 00010) ? 'x' : '-')) - . (($_ & 00004) ? 'r' : '-') - . (($_ & 00002) ? 'w' : '-') - . (($_ & 01000) ? 't' : - (($_ & 00001) ? 'x' : '-')); -} - -sub utime { - local($_) = @_; - local(@MON) = ( - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' - ); - local($sec,$min,$hour,$mday,$mon, - $year,$wday,$yday,$isdst) = localtime($_); - - if ($_ > $NOW - 182*24*60*60 && $_ < $NOW + 183*24*60*60) { - return sprintf("%3s %2d %.2d:%.2d", $MON[$mon], $mday, $hour, $min); - } else { - return sprintf("%3s %2d %5d", $MON[$mon], $mday, 1900+$year); - } -} - -sub cygwin_pathconv { - local($_) = @_; - local(*CYGPATH); - - open(CYGPATH, '-|') or exec('cygpath', '-w', $_); - $_ = ; - close(CYGPATH); - s/\r?\n$//; - s!\\!/!g; - s!/$!!; - return $_; -} diff --git a/scripts/dirlist.cgi.in b/scripts/dirlist.cgi.in new file mode 100755 index 0000000..c756273 --- /dev/null +++ b/scripts/dirlist.cgi.in @@ -0,0 +1,532 @@ +#!@PERL@ +# +# Directory list CGI by Hironori Sakamoto (hsaka@mth.biglobe.ne.jp) +# + +if ( $^O =~ /^(ms)?(dos|win(32|nt)?)/i ) { + $WIN32 = 1; + $CYGPATH = 1; +} +elsif ( $^O =~ /cygwin|os2/i ) { + $WIN32 = 1; + $CYGPATH = 0; +} +else { + $WIN32 = 0; + $CYGPATH = 0; +} +$RC_DIR = '~/.w3m/'; + +$RC_DIR =~ s@^~/@$ENV{'HOME'}/@; +if ($CYGPATH) { + $RC_DIR = &cygwin_pathconv("$RC_DIR"); +} +$CONFIG = "$RC_DIR/dirlist"; +$CGI = $ENV{'SCRIPT_NAME'} || $0; +$CGI = "file://" . &file_encode("$CGI"); + +$AFMT = '%s'; +$NOW = time(); + +@OPT = &init_option($CONFIG); + +$query = $ENV{'QUERY_STRING'}; +$cmd = ''; +$cgi = 0; +if ($query eq '') { + $_ = `pwd`; + chop; + s/\r$//; + $dir = $_; + $cgi = 0; +} elsif ($query =~ /^(opt\d+|dir|cmd)=/) { + foreach(split(/\&/, $query)) { + if (s/^dir=//) { + $dir = &form_decode($_); + } elsif (s/^opt(\d+)=//) { + $OPT[$1] = $_; + } elsif (s/^cmd=//) { + $cmd = $_; + } + } + $cgi = 1; +} else { + $dir = $query; + if (($dir !~ m@^/@) && + ($WIN32 && $dir !~ /^[a-z]:/i)) { + $_ = `pwd`; + chop; + s/\r$//; + $dir = "$_/$dir"; + } + $cgi = -1; +} +if ($dir !~ m@/$@) { + $dir .= '/'; +} +if ($dir =~ m@^/@ && $CYGPATH) { + $dir = &cygwin_pathconv("$dir"); +} +$ROOT = ''; +if ($WIN32) { + if (($dir =~ s@^//[^/]+@@) || ($dir =~ s@^[a-z]:@@i)) { + $ROOT = $&; + } + if ($CYGPATH) { + $ROOT = &cygwin_pathconv("$ROOT"); + } +} +if ($cgi) { + $dir = &cleanup($dir); +} + +$TYPE = $OPT[$OPT_TYPE]; +$FORMAT = $OPT[$OPT_FORMAT]; +$SORT = $OPT[$OPT_SORT]; +if ($cmd) { + &update_option($CONFIG); +} + +$qdir = "$ROOT" . &html_quote("$dir"); +$edir = "$ROOT" . &file_encode("$dir"); +if (! opendir(DIR, "$ROOT$dir")) { + print < + +Directory list of $qdir + + +$qdir: $! ! + + +EOF + exit 1; +} + +# ($cgi > 0) && print < + +Directory list of $qdir + + +

Directory list of $qdir

+EOF +&print_form($edir, @OPT); +print < +EOF +$dir =~ s@/$@@; +@sdirs = split('/', $dir); +$_ = $sdirs[0]; +if ($_ eq '') { + $_ = '/'; +} +if ($TYPE eq $TYPE_TREE) { + print < + +
+EOF
+  $q = "$ROOT". &html_quote("$_");
+  $e = "$ROOT" . &file_encode("$_");
+  if ($dir =~ m@^$@) {
+    $n = "\" name=\"current";
+  } else {
+    $n = '';
+  }
+  printf("$AFMT\n", "$e$n", "$q");
+  $N = 0;
+  $SKIPLINE = "";
+
+  &left_dir('', @sdirs);
+
+  print <
+
+
$SKIPLINE
+EOF
+} else {
+  print <
+EOF
+}
+
+&right_dir($dir);
+
+if ($TYPE eq $TYPE_TREE) {
+  print <
+
+
+
+
+EOF
+} else {
+  print <
+
+
+EOF
+}
+
+sub left_dir {
+  local($pre, $dir, @sdirs) = @_;
+  local($ok) = (@sdirs == 0);
+  local(@cdirs) = ();
+  local($_, $dir0, $d, $qdir, $q, $edir, $e);
+
+  $dir0 = "$dir/";
+  $dir = "$dir0";
+  opendir(DIR, "$ROOT$dir") || return;
+
+  foreach(sort readdir(DIR)) {
+    -d "$ROOT$dir$_" || next;
+    /^\.$/ && next;
+    /^\.\.$/ && next;
+    push(@cdirs, $_);
+  }
+  closedir(DIR);
+
+  $qdir = "$ROOT" . &html_quote($dir);
+  $edir = "$ROOT" . &file_encode($dir);
+  while(@cdirs) {
+    $_ = shift @cdirs;
+    $q = &html_quote($_);
+    $e = &file_encode($_);
+    $N++;
+    if (!$ok && $_ eq $sdirs[0]) {
+      $d = $dir0 . shift @sdirs;
+      if (!@sdirs) {
+        $n = "\" name=\"current";
+        $SKIPLINE = "\n" x $N;
+      } else {
+        $n = '';
+      }
+      printf("${pre}o-$AFMT\n", "$edir$e$n", "$q");
+      &left_dir(@cdirs ? "$pre| " : "$pre  ", $d, @sdirs);
+      $ok = 1;
+    } else {
+      printf("${pre}+-$AFMT\n", "$edir$e", $q);
+    }
+  }
+}
+
+sub right_dir {
+  local($dir) = @_;
+  local(@list);
+  local($_, $qdir, $q, $edir, $e, $f, $max, @d, $type, $u, $g);
+  local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+        $atime,$mtime,$ctime,$blksize,$blocks);
+  local(%sizes, %ctimes, %prints);
+
+  $dir = "$dir/";
+  opendir(DIR, "$ROOT$dir") || return;
+
+  $qdir = "$ROOT" . &html_quote($dir);
+  $edir = "$ROOT" . &file_encode($dir);
+  if ($TYPE eq $TYPE_TREE) {
+    print "$qdir\n";
+  }
+  @list = ();
+  $max = 0;
+  foreach(readdir(DIR)) {
+    /^\.$/ && next;
+#    if ($TYPE eq $TYPE_TREE) {
+#      /^\.\.$/ && next;
+#    }
+    $f = "$ROOT$dir$_";
+    (($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+      $atime,$mtime,$ctime,$blksize,$blocks) = lstat($f)) || next;
+    push(@list, $_);
+    $sizes{$_} = $size;
+    $ctimes{$_} = $ctime;
+
+    if ($FORMAT eq $FORMAT_COLUMN)  {
+      if (length($_) > $max) {
+        $max = length($_);
+      }
+      next;
+    }
+    $type = &utype($mode);
+    if ($FORMAT eq $FORMAT_SHORT)  {
+      $prints{$_} = sprintf("%-6s ", "[$type]");
+      next;
+    }
+    if ($type =~ /^[CB]/) {
+      $size = sprintf("%3u, %3u", ($rdev >> 8) & 0xff, $rdev & 0xffff00ff);
+    }
+    if ($FORMAT eq $FORMAT_LONG) {
+      $u = $USER{$uid} || ($USER{$uid} = getpwuid($uid) || $uid);
+      $g = $GROUP{$gid} || ($GROUP{$gid} = getgrgid($gid) || $gid);
+      $prints{$_} = sprintf( "%s %-8s %-8s %8s %s ",
+		&umode($mode), $u, $g, $size, &utime($ctime));
+#   } elsif ($FORMAT eq $FORMAT_STANDARD) {
+    } else {
+      $prints{$_} = sprintf("%-6s %8s %s ", "[$type]", $size, &utime($ctime));
+    }
+  }
+  closedir(DIR);
+  if ($SORT eq $SORT_SIZE) { 
+    @list = sort { $sizes{$b} <=> $sizes{$a} || $a <=> $b } @list;
+  } elsif ($SORT eq $SORT_TIME) { 
+    @list = sort { $ctimes{$b} <=> $ctimes{$a} || $a <=> $b } @list;
+  } else {
+    @list = sort @list;
+  }
+  if ($FORMAT eq $FORMAT_COLUMN) {
+    local($COLS, $l, $nr, $n);
+    if ($TYPE eq $TYPE_TREE) {
+      $COLS = 60;
+    } else {
+      $COLS = 80;
+    }
+    $l = int($COLS / ($max + 2)) || 1;
+    $nr = int($#list / $l + 1);
+    $n = 0;
+    print "\n";
+    foreach(@list) {
+      $f = "$ROOT$dir$_";
+      $q = &html_quote($_);
+      $e = &file_encode($_);
+      if ($n % $nr == 0) {
+        print "\n";
+      } else {
+        print "
\n"; + } + } + print "
"; + } + if (-d $f) { + printf($AFMT, "$edir$e", "$q/"); + } else { + printf($AFMT, "$edir$e", $q); + } + $n++; + if ($n % $nr == 0) { + print "
\n"; + return; + } + foreach(@list) { + $f = "$ROOT$dir$_"; + $q = &html_quote($_); + $e = &file_encode($_); + print $prints{$_}; + if (-d $f) { + printf($AFMT, "$edir$e", "$q/"); + } else { + printf($AFMT, "$edir$e", $q); + } + if (-l $f) { + print " -> ", &html_quote(readlink($f)); + } + print "\n"; + } +} + +sub init_option { + local($config) = @_; + $OPT_TYPE = 0; + $OPT_FORMAT = 1; + $OPT_SORT = 2; + $TYPE_TREE = 't'; + $TYPE_STANDARD = 'd'; + $FORMAT_SHORT = 's'; + $FORMAT_STANDARD = 'd'; + $FORMAT_LONG = 'l'; + $FORMAT_COLUMN = 'c'; + $SORT_NAME = 'n'; + $SORT_SIZE = 's'; + $SORT_TIME = 't'; + local(@opt) = ($TYPE_TREE, $FORMAT_STANDARD, $SORT_NAME); + local($_); + + open(CONFIG, "< $config") || return @opt; + while() { + chop; + s/^\s+//; + tr/A-Z/a-z/; + if (/^type\s+(\S)/i) { + $opt[$OPT_TYPE] = $1; + } elsif (/^format\s+(\S)/i) { + $opt[$OPT_FORMAT] = $1 + } elsif (/^sort\s+(\S)/i) { + $opt[$OPT_SORT] = $1; + } + } + close(CONFIG); + return @opt; +} + +sub update_option { + local($config) = @_; + + open(CONFIG, "> $config") || return; + print CONFIG < +
+ + +EOF + foreach(0 .. 2) { + print "\n"; + } + print "\n"; + foreach(0 .. 2) { + print "\n"; + } + print < + +
 $disc[$_]
+
+ + +EOF +} + +sub html_quote { + local($_) = @_; + local(%QUOTE) = ( + '<', '<', + '>', '>', + '&', '&', + '"', '"', + ); + s/[<>&"]/$QUOTE{$&}/g; + return $_; +} +sub file_encode { + local($_) = @_; + s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg; + return $_; +} + +sub form_decode { + local($_) = @_; + s/\+/ /g; + s/%([\da-f][\da-f])/pack('C', hex($1))/egi; + return $_; +} + +sub cleanup { + local($_) = @_; + + s@//+@/@g; + s@/\./@/@g; + while(m@/\.\./@) { + s@^/(\.\./)+@/@; + s@/[^/]+/\.\./@/@; + } + return $_; +} + +sub utype { + local($_) = @_; + local(%T) = ( + 0010000, 'PIPE', + 0020000, 'CHR', + 0040000, 'DIR', + 0060000, 'BLK', + 0100000, 'FILE', + 0120000, 'LINK', + 0140000, 'SOCK', + ); + return $T{($_ & 0170000)} || 'FILE'; +} + +sub umode { + local($_) = @_; + local(%T) = ( + 0010000, 'p', + 0020000, 'c', + 0040000, 'd', + 0060000, 'b', + 0100000, '-', + 0120000, 'l', + 0140000, 's', + ); + + return ($T{($_ & 0170000)} || '-') + . (($_ & 00400) ? 'r' : '-') + . (($_ & 00200) ? 'w' : '-') + . (($_ & 04000) ? 's' : + (($_ & 00100) ? 'x' : '-')) + . (($_ & 00040) ? 'r' : '-') + . (($_ & 00020) ? 'w' : '-') + . (($_ & 02000) ? 's' : + (($_ & 00010) ? 'x' : '-')) + . (($_ & 00004) ? 'r' : '-') + . (($_ & 00002) ? 'w' : '-') + . (($_ & 01000) ? 't' : + (($_ & 00001) ? 'x' : '-')); +} + +sub utime { + local($_) = @_; + local(@MON) = ( + 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' + ); + local($sec,$min,$hour,$mday,$mon, + $year,$wday,$yday,$isdst) = localtime($_); + + if ($_ > $NOW - 182*24*60*60 && $_ < $NOW + 183*24*60*60) { + return sprintf("%3s %2d %.2d:%.2d", $MON[$mon], $mday, $hour, $min); + } else { + return sprintf("%3s %2d %5d", $MON[$mon], $mday, 1900+$year); + } +} + +sub cygwin_pathconv { + local($_) = @_; + local(*CYGPATH); + + open(CYGPATH, '-|') or exec('cygpath', '-w', $_); + $_ = ; + close(CYGPATH); + s/\r?\n$//; + s!\\!/!g; + s!/$!!; + return $_; +} diff --git a/scripts/dirlist.in b/scripts/dirlist.in deleted file mode 100755 index c756273..0000000 --- a/scripts/dirlist.in +++ /dev/null @@ -1,532 +0,0 @@ -#!@PERL@ -# -# Directory list CGI by Hironori Sakamoto (hsaka@mth.biglobe.ne.jp) -# - -if ( $^O =~ /^(ms)?(dos|win(32|nt)?)/i ) { - $WIN32 = 1; - $CYGPATH = 1; -} -elsif ( $^O =~ /cygwin|os2/i ) { - $WIN32 = 1; - $CYGPATH = 0; -} -else { - $WIN32 = 0; - $CYGPATH = 0; -} -$RC_DIR = '~/.w3m/'; - -$RC_DIR =~ s@^~/@$ENV{'HOME'}/@; -if ($CYGPATH) { - $RC_DIR = &cygwin_pathconv("$RC_DIR"); -} -$CONFIG = "$RC_DIR/dirlist"; -$CGI = $ENV{'SCRIPT_NAME'} || $0; -$CGI = "file://" . &file_encode("$CGI"); - -$AFMT = '%s'; -$NOW = time(); - -@OPT = &init_option($CONFIG); - -$query = $ENV{'QUERY_STRING'}; -$cmd = ''; -$cgi = 0; -if ($query eq '') { - $_ = `pwd`; - chop; - s/\r$//; - $dir = $_; - $cgi = 0; -} elsif ($query =~ /^(opt\d+|dir|cmd)=/) { - foreach(split(/\&/, $query)) { - if (s/^dir=//) { - $dir = &form_decode($_); - } elsif (s/^opt(\d+)=//) { - $OPT[$1] = $_; - } elsif (s/^cmd=//) { - $cmd = $_; - } - } - $cgi = 1; -} else { - $dir = $query; - if (($dir !~ m@^/@) && - ($WIN32 && $dir !~ /^[a-z]:/i)) { - $_ = `pwd`; - chop; - s/\r$//; - $dir = "$_/$dir"; - } - $cgi = -1; -} -if ($dir !~ m@/$@) { - $dir .= '/'; -} -if ($dir =~ m@^/@ && $CYGPATH) { - $dir = &cygwin_pathconv("$dir"); -} -$ROOT = ''; -if ($WIN32) { - if (($dir =~ s@^//[^/]+@@) || ($dir =~ s@^[a-z]:@@i)) { - $ROOT = $&; - } - if ($CYGPATH) { - $ROOT = &cygwin_pathconv("$ROOT"); - } -} -if ($cgi) { - $dir = &cleanup($dir); -} - -$TYPE = $OPT[$OPT_TYPE]; -$FORMAT = $OPT[$OPT_FORMAT]; -$SORT = $OPT[$OPT_SORT]; -if ($cmd) { - &update_option($CONFIG); -} - -$qdir = "$ROOT" . &html_quote("$dir"); -$edir = "$ROOT" . &file_encode("$dir"); -if (! opendir(DIR, "$ROOT$dir")) { - print < - -Directory list of $qdir - - -$qdir: $! ! - - -EOF - exit 1; -} - -# ($cgi > 0) && print < - -Directory list of $qdir - - -

Directory list of $qdir

-EOF -&print_form($edir, @OPT); -print < -EOF -$dir =~ s@/$@@; -@sdirs = split('/', $dir); -$_ = $sdirs[0]; -if ($_ eq '') { - $_ = '/'; -} -if ($TYPE eq $TYPE_TREE) { - print < - -
-EOF
-  $q = "$ROOT". &html_quote("$_");
-  $e = "$ROOT" . &file_encode("$_");
-  if ($dir =~ m@^$@) {
-    $n = "\" name=\"current";
-  } else {
-    $n = '';
-  }
-  printf("$AFMT\n", "$e$n", "$q");
-  $N = 0;
-  $SKIPLINE = "";
-
-  &left_dir('', @sdirs);
-
-  print <
-
-
$SKIPLINE
-EOF
-} else {
-  print <
-EOF
-}
-
-&right_dir($dir);
-
-if ($TYPE eq $TYPE_TREE) {
-  print <
-
-
-
-
-EOF
-} else {
-  print <
-
-
-EOF
-}
-
-sub left_dir {
-  local($pre, $dir, @sdirs) = @_;
-  local($ok) = (@sdirs == 0);
-  local(@cdirs) = ();
-  local($_, $dir0, $d, $qdir, $q, $edir, $e);
-
-  $dir0 = "$dir/";
-  $dir = "$dir0";
-  opendir(DIR, "$ROOT$dir") || return;
-
-  foreach(sort readdir(DIR)) {
-    -d "$ROOT$dir$_" || next;
-    /^\.$/ && next;
-    /^\.\.$/ && next;
-    push(@cdirs, $_);
-  }
-  closedir(DIR);
-
-  $qdir = "$ROOT" . &html_quote($dir);
-  $edir = "$ROOT" . &file_encode($dir);
-  while(@cdirs) {
-    $_ = shift @cdirs;
-    $q = &html_quote($_);
-    $e = &file_encode($_);
-    $N++;
-    if (!$ok && $_ eq $sdirs[0]) {
-      $d = $dir0 . shift @sdirs;
-      if (!@sdirs) {
-        $n = "\" name=\"current";
-        $SKIPLINE = "\n" x $N;
-      } else {
-        $n = '';
-      }
-      printf("${pre}o-$AFMT\n", "$edir$e$n", "$q");
-      &left_dir(@cdirs ? "$pre| " : "$pre  ", $d, @sdirs);
-      $ok = 1;
-    } else {
-      printf("${pre}+-$AFMT\n", "$edir$e", $q);
-    }
-  }
-}
-
-sub right_dir {
-  local($dir) = @_;
-  local(@list);
-  local($_, $qdir, $q, $edir, $e, $f, $max, @d, $type, $u, $g);
-  local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-        $atime,$mtime,$ctime,$blksize,$blocks);
-  local(%sizes, %ctimes, %prints);
-
-  $dir = "$dir/";
-  opendir(DIR, "$ROOT$dir") || return;
-
-  $qdir = "$ROOT" . &html_quote($dir);
-  $edir = "$ROOT" . &file_encode($dir);
-  if ($TYPE eq $TYPE_TREE) {
-    print "$qdir\n";
-  }
-  @list = ();
-  $max = 0;
-  foreach(readdir(DIR)) {
-    /^\.$/ && next;
-#    if ($TYPE eq $TYPE_TREE) {
-#      /^\.\.$/ && next;
-#    }
-    $f = "$ROOT$dir$_";
-    (($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-      $atime,$mtime,$ctime,$blksize,$blocks) = lstat($f)) || next;
-    push(@list, $_);
-    $sizes{$_} = $size;
-    $ctimes{$_} = $ctime;
-
-    if ($FORMAT eq $FORMAT_COLUMN)  {
-      if (length($_) > $max) {
-        $max = length($_);
-      }
-      next;
-    }
-    $type = &utype($mode);
-    if ($FORMAT eq $FORMAT_SHORT)  {
-      $prints{$_} = sprintf("%-6s ", "[$type]");
-      next;
-    }
-    if ($type =~ /^[CB]/) {
-      $size = sprintf("%3u, %3u", ($rdev >> 8) & 0xff, $rdev & 0xffff00ff);
-    }
-    if ($FORMAT eq $FORMAT_LONG) {
-      $u = $USER{$uid} || ($USER{$uid} = getpwuid($uid) || $uid);
-      $g = $GROUP{$gid} || ($GROUP{$gid} = getgrgid($gid) || $gid);
-      $prints{$_} = sprintf( "%s %-8s %-8s %8s %s ",
-		&umode($mode), $u, $g, $size, &utime($ctime));
-#   } elsif ($FORMAT eq $FORMAT_STANDARD) {
-    } else {
-      $prints{$_} = sprintf("%-6s %8s %s ", "[$type]", $size, &utime($ctime));
-    }
-  }
-  closedir(DIR);
-  if ($SORT eq $SORT_SIZE) { 
-    @list = sort { $sizes{$b} <=> $sizes{$a} || $a <=> $b } @list;
-  } elsif ($SORT eq $SORT_TIME) { 
-    @list = sort { $ctimes{$b} <=> $ctimes{$a} || $a <=> $b } @list;
-  } else {
-    @list = sort @list;
-  }
-  if ($FORMAT eq $FORMAT_COLUMN) {
-    local($COLS, $l, $nr, $n);
-    if ($TYPE eq $TYPE_TREE) {
-      $COLS = 60;
-    } else {
-      $COLS = 80;
-    }
-    $l = int($COLS / ($max + 2)) || 1;
-    $nr = int($#list / $l + 1);
-    $n = 0;
-    print "\n";
-    foreach(@list) {
-      $f = "$ROOT$dir$_";
-      $q = &html_quote($_);
-      $e = &file_encode($_);
-      if ($n % $nr == 0) {
-        print "\n";
-      } else {
-        print "
\n"; - } - } - print "
"; - } - if (-d $f) { - printf($AFMT, "$edir$e", "$q/"); - } else { - printf($AFMT, "$edir$e", $q); - } - $n++; - if ($n % $nr == 0) { - print "
\n"; - return; - } - foreach(@list) { - $f = "$ROOT$dir$_"; - $q = &html_quote($_); - $e = &file_encode($_); - print $prints{$_}; - if (-d $f) { - printf($AFMT, "$edir$e", "$q/"); - } else { - printf($AFMT, "$edir$e", $q); - } - if (-l $f) { - print " -> ", &html_quote(readlink($f)); - } - print "\n"; - } -} - -sub init_option { - local($config) = @_; - $OPT_TYPE = 0; - $OPT_FORMAT = 1; - $OPT_SORT = 2; - $TYPE_TREE = 't'; - $TYPE_STANDARD = 'd'; - $FORMAT_SHORT = 's'; - $FORMAT_STANDARD = 'd'; - $FORMAT_LONG = 'l'; - $FORMAT_COLUMN = 'c'; - $SORT_NAME = 'n'; - $SORT_SIZE = 's'; - $SORT_TIME = 't'; - local(@opt) = ($TYPE_TREE, $FORMAT_STANDARD, $SORT_NAME); - local($_); - - open(CONFIG, "< $config") || return @opt; - while() { - chop; - s/^\s+//; - tr/A-Z/a-z/; - if (/^type\s+(\S)/i) { - $opt[$OPT_TYPE] = $1; - } elsif (/^format\s+(\S)/i) { - $opt[$OPT_FORMAT] = $1 - } elsif (/^sort\s+(\S)/i) { - $opt[$OPT_SORT] = $1; - } - } - close(CONFIG); - return @opt; -} - -sub update_option { - local($config) = @_; - - open(CONFIG, "> $config") || return; - print CONFIG < -
- - -EOF - foreach(0 .. 2) { - print "\n"; - } - print "\n"; - foreach(0 .. 2) { - print "\n"; - } - print < - -
 $disc[$_]
-
- - -EOF -} - -sub html_quote { - local($_) = @_; - local(%QUOTE) = ( - '<', '<', - '>', '>', - '&', '&', - '"', '"', - ); - s/[<>&"]/$QUOTE{$&}/g; - return $_; -} -sub file_encode { - local($_) = @_; - s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg; - return $_; -} - -sub form_decode { - local($_) = @_; - s/\+/ /g; - s/%([\da-f][\da-f])/pack('C', hex($1))/egi; - return $_; -} - -sub cleanup { - local($_) = @_; - - s@//+@/@g; - s@/\./@/@g; - while(m@/\.\./@) { - s@^/(\.\./)+@/@; - s@/[^/]+/\.\./@/@; - } - return $_; -} - -sub utype { - local($_) = @_; - local(%T) = ( - 0010000, 'PIPE', - 0020000, 'CHR', - 0040000, 'DIR', - 0060000, 'BLK', - 0100000, 'FILE', - 0120000, 'LINK', - 0140000, 'SOCK', - ); - return $T{($_ & 0170000)} || 'FILE'; -} - -sub umode { - local($_) = @_; - local(%T) = ( - 0010000, 'p', - 0020000, 'c', - 0040000, 'd', - 0060000, 'b', - 0100000, '-', - 0120000, 'l', - 0140000, 's', - ); - - return ($T{($_ & 0170000)} || '-') - . (($_ & 00400) ? 'r' : '-') - . (($_ & 00200) ? 'w' : '-') - . (($_ & 04000) ? 's' : - (($_ & 00100) ? 'x' : '-')) - . (($_ & 00040) ? 'r' : '-') - . (($_ & 00020) ? 'w' : '-') - . (($_ & 02000) ? 's' : - (($_ & 00010) ? 'x' : '-')) - . (($_ & 00004) ? 'r' : '-') - . (($_ & 00002) ? 'w' : '-') - . (($_ & 01000) ? 't' : - (($_ & 00001) ? 'x' : '-')); -} - -sub utime { - local($_) = @_; - local(@MON) = ( - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' - ); - local($sec,$min,$hour,$mday,$mon, - $year,$wday,$yday,$isdst) = localtime($_); - - if ($_ > $NOW - 182*24*60*60 && $_ < $NOW + 183*24*60*60) { - return sprintf("%3s %2d %.2d:%.2d", $MON[$mon], $mday, $hour, $min); - } else { - return sprintf("%3s %2d %5d", $MON[$mon], $mday, 1900+$year); - } -} - -sub cygwin_pathconv { - local($_) = @_; - local(*CYGPATH); - - open(CYGPATH, '-|') or exec('cygpath', '-w', $_); - $_ = ; - close(CYGPATH); - s/\r?\n$//; - s!\\!/!g; - s!/$!!; - return $_; -} diff --git a/scripts/multipart/multipart.cgi b/scripts/multipart/multipart.cgi deleted file mode 100644 index e7c71e5..0000000 --- a/scripts/multipart/multipart.cgi +++ /dev/null @@ -1,272 +0,0 @@ -#!/usr/local/bin/perl - -if ($use_NKF = eval "use NKF;") { - $CONV = "-e"; - $MIME_DECODE = "-m -e"; -} else { -# $CONV = "w3m -dump -e"; - $CONV = "/usr/local/bin/nkf -e"; - $MIME_DECODE = "/usr/local/bin/nkf -m -e"; -} -$MIME_TYPE = "$ENV{'HOME'}/.mime.types"; - -if (defined($ENV{'QUERY_STRING'})) { - for (split('&', $ENV{'QUERY_STRING'})) { - s/^([^=]*)=//; - $v{$1} = $_; - } - $file = &form_decode($v{'file'}); - $boundary = &form_decode($v{'boundary'}); -} else { - $file = $ARGV[0]; - if (@ARGV >= 2) { - $boundary = $ARGV[1]; - } - $CGI = "file:///\$LIB/multipart.cgi?file=" . &html_quote($file); -} - -open(F, $file); -$end = 0; -$mbody = ''; -if (defined($boundary)) { - while() { - s/\r?\n$//; - ($_ eq "--$boundary") && last; - ($_ eq "--$boundary--") && ($end = 1, last); - $mbody .= "$_\n"; - } -} else { - while() { - s/\r?\n$//; - if (s/^\-\-//) { - $boundary = $_; - last; - } - $mbody .= "$_\n"; - } -} -$CGI .= "&boundary=" . &html_quote($boundary); - -if (defined($v{'count'})) { - $count = 0; - while($count < $v{'count'}) { - while() { - s/\r?\n$//; - ($_ eq "--$boundary") && last; - } - eof(F) && exit; - $count++; - } - - %header = (); - $hbody = ''; - while() { - /^\s*$/ && last; - $x = $_; - s/\r?\n$//; - if (/=\?/) { - $_ = &decode($_, $MIME_DECODE); - } - if (s/^(\S+)\s*:\s*//) { - $hbody .= "$&$_\n"; - $p = $1; - $p =~ tr/A-Z/a-z/; - $header{$p} = $_; - } elsif (s/^\s+//) { - chop $hbody; - $hbody .= "$_\n"; - $header{$p} .= $_; - } - } - $type = $header{"content-type"}; - $dispos = $header{"content-disposition"}; - if ($type =~ /application\/octet-stream/) { - if ($type =~ /type\=gzip/) { - print "Content-Encoding: x-gzip\n"; - } - if ($type =~ /name=\"?([^\"]+)\"?/ || - $dispos =~ /filename=\"?([^\"]+)\"?/) { - $type = &guess_type($1); - if ($type) { - print "Content-Type: $type; name=\"$1\"\n"; - } else { - print "Content-Type: text/plain; name=\"$1\"\n"; - } - } - } - print $hbody; - print "\n"; - while() { - $x = $_; - s/\r?\n$//; - ($_ eq "--$boundary") && last; - if ($_ eq "--$boundary--") { - last; - } - print $x; - } - close(F); - exit; -} - -if ($mbody =~ /\S/) { - $_ = $mbody; - s/\&/\&/g; - s/\/\>/g; - print "
\n";
-	print $_;
-	print "
\n"; -} - -$count = 0; -while(! $end) { - %header = (); - $hbody = ''; - while() { - /^\s*$/ && last; - s/\r?\n$//; - if (/=\?/) { - $_ = &decode($_, $MIME_DECODE); - } - if (s/^(\S+)\s*:\s*//) { - $hbody .= "$&$_\n"; - $p = $1; - $p =~ tr/A-Z/a-z/; - $header{$p} = $_; - } elsif (s/^\s+//) { - chop $hbody; - $hbody .= "$_\n"; - $header{$p} .= $_; - } - } - $type = $header{"content-type"}; - $dispos = $header{"content-disposition"}; - if ((! $type || $type =~ /^text\/plain/i) && - (! $dispos || $dispos =~ /^inline/i)) { - $plain = 1; - } else { - $plain = 0; - } - $body = ''; - while() { - s/\r?\n$//; - ($_ eq "--$boundary") && last; - if ($_ eq "--$boundary--") { - $end = 1; - last; - } - if ($plain) { - $body .= "$_\n"; - } - } - $| = 1; - print "
\n"; - { - $_ = $hbody; - s/\&/\&/g; - s/\/\>/g; - print "
\n";
-		print $_;
-		if ($type =~ /name=\"?([^\"]+)\"?/ ||
-			$dispos =~ /filename=\"?([^\"]+)\"?/) {
-			$name = $1;
-		} else {
-			$name = "[Content]";
-		}
-		print "\n", &html_quote($name), "";
-		print "\n\n
\n"; - } - if ($plain) { - $body = &decode($body, $CONV); - $_ = $body; - s/\&/\&/g; - s/\/\>/g; - print "
\n";
-		print $_;
-		print "
\n"; - } - eof(F) && last; - $count++; -} -close(F); - -sub decode { -if ($use_NKF) { - local($body, $opt) = @_; - return nkf($opt, $body); -} - local($body, @cmd) = @_; - local($_); - - $| = 1; - pipe(R, W2); - pipe(R2, W); - if (! fork()) { - close(F); - close(R); - close(W); - open(STDIN, "<&R2"); - open(STDOUT, ">&W2"); - exec @cmd; - die; - } - close(R2); - close(W2); - print W $body; - close(W); - $body = ''; - while() { - $body .= $_; - } - close(R); - return $body; -} - -sub html_quote { - local($_) = @_; - local(%QUOTE) = ( - '<', '<', - '>', '>', - '&', '&', - '"', '"', - ); - s/[<>&"]/$QUOTE{$&}/g; - return $_; -} - -sub form_decode { - local($_) = @_; - s/\+/ /g; - s/%([\da-f][\da-f])/pack('c', hex($1))/egi; - return $_; -} - -sub guess_type { - local($_) = @_; - - /\.(\w+)$/ || next; - $_ = $1; - tr/A-Z/a-z/; - %mime_type = &load_mime_type($MIME_TYPE); - $mime_type{$_}; -} - -sub load_mime_type { - local($file) = @_; - local(%m, $a, @b, $_); - - open(M, $file) || return (); - while() { - /^#/ && next; - chop; - (($a, @b) = split(" ")) >= 2 || next; - for(@b) { - $m{$_} = $a; - } - } - close(M); - return %m; -} diff --git a/scripts/w3mman/w3mman b/scripts/w3mman/w3mman deleted file mode 100644 index 44aba2f..0000000 --- a/scripts/w3mman/w3mman +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/local/bin/perl - -@W3M = split(' ', 'w3m'); -$ENV{'MAN'} = 'man'; -$SCRIPT = 'file:///$LIB/w3mman2html.cgi'; - -sub usage { - ($_ = $0) =~ s@.*/@@; - print STDERR "$_ [-M ] [[
] ]\n"; - print STDERR "$_ [-M ] [-k ]\n"; - exit 1; -} - -$query = ""; -while (@ARGV) { - $_ = shift @ARGV; - if (/^-M$/) { - @ARGV || &usage(); - $ENV{'MANPATH'} = shift @ARGV; - } elsif (/^-k$/) { - @ARGV || &usage(); - $query = "?keyword=" . &form_encode(shift @ARGV); - } elsif (/^-/) { - &usage(); - } elsif (/^\d/ || $_ eq 'n') { - @ARGV || &usage(); - $query = "?quit=ok&man=" . &form_encode(shift @ARGV); - $query .= "§ion=" . &form_encode($_); - } else { - $query = "?quit=ok&man=" . &form_encode($_); - } -} - -exec @W3M, "$SCRIPT$query"; - -sub form_encode { - local($_) = @_; - s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg; - return $_; -} - diff --git a/scripts/w3mman/w3mman2html.cgi b/scripts/w3mman/w3mman2html.cgi deleted file mode 100644 index 0f75502..0000000 --- a/scripts/w3mman/w3mman2html.cgi +++ /dev/null @@ -1,252 +0,0 @@ -#!/usr/local/bin/perl - -$MAN = $ENV{'MAN'} || 'man'; -$QUERY = $ENV{'QUERY_STRING'} || $ARGV[0]; -$SCRIPT_NAME = $ENV{'SCRIPT_NAME'} || $0; -$CGI = "file://$SCRIPT_NAME"; -$CGI2 = "file:"; -# $CGI2 = "file:///\$LIB/hlink.cgi?"; -$SQUEEZE = 1; - -if ($QUERY =~ /\=/) { - for (split('&', $QUERY)) { - ($v, $q) = split('=', $_, 2); - $query{$v} = &form_decode($q); - } -} else { - $QUERY =~ s/^man=//; - $query{"man"} = &form_decode($QUERY); -} - -if (! $query{"man"}) { - if ($query{"keyword"}) { - $keyword = $query{"keyword"}; - $k = &html_quote($keyword); - print < -man -k $k - -

man -k $k

-
    -EOF - $keyword =~ s:([^\w./]):\\$1:g; - open(F, "$MAN -k $keyword 2> /dev/null |"); - @line = (); - while() { - chop; - $_ = &html_quote($_); - s/(\s+-.*)$//; - $title = $1; - s@(\w[\w.\-]*(\s*\,\s*\w[\w.\-]*)*)\s*(\([\dn]\w*\))@&keyword_ref($1, $3)@ge; - print "
  • $_$title\n"; - } - close(F); - print < - - -EOF - exit; - } - print < -man - -
    - -
    Manual: -
    Section: -
    Keyword: -
    -
    -
    - - -EOF - exit; -} - -$man = $query{"man"}; -if ($man =~ s/\((\w+)\)$//) { - $section = $1; - $man_section = "$man($1)"; -} elsif ($query{"section"}) { - $section = $query{"section"}; - $man_section = "$man($section)"; -} else { - $section = ""; - $man_section = "$man"; -} - -$section =~ s:([^\w./]):\\$1:g; -$man =~ s:([^\w./]):\\$1:g; -open(F, "$MAN $section $man 2> /dev/null |"); -$ok = 0; -undef $header; -$blank = -1; -while() { - if (! defined($header)) { - /^\s*$/ && next; - $header = $_; - $space = $header; - chop $space; - $space =~ s/\S.*//; - } elsif ($_ eq $header) { # delete header - $blank = -1; - next; - } elsif (!/\010/ && /^$space[\w\200-\377].*\s\S/o) { # delete footer - $blank = -1; - next; - } - if ($SQUEEZE) { - if (/^\s*$/) { - $blank || $blank++; - next; - } elsif ($blank) { - $blank > 0 && print "\n"; - $blank = 0; - } - } - - s/\&/\&/g; - s/\/\>/g; - - s@([\200-\377].)(\010{1,2}\1)+@$1@g; - s@(\&\w+;|.)(\010\1)+@$1@g; - s@__\010{1,2}((\)?[\200-\377].(\)?)@$1@g; - s@_\010((\)?(\&\w+\;|.)(\)?)@$1@g; - s@((\)?[\200-\377].(\)?)\010{1,2}__@$1@g; - s@((\)?(\&\w+\;|.)(\)?)\010_@$1@g; - s@.\010(.)@$1@g; - - s@\\\_\\\@_@g; - s@\\_\\@_@g; - s@\\@@g; - s@\\@@g; - - if (! $ok) { - /^No/ && last; - print < -man $man_section - -
    -EOF
    -    print;
    -    $ok = 1;
    -    next;
    -  }
    -
    -  s@(http|ftp)://[\w.\-/~]+[\w/]@$&@g;
    -  s@(\W)(mailto:)?(\w[\w.\-]*\@\w[\w.\-]*\.[\w.\-]*\w)@$1$2$3@g;
    -  s@(\W)(\~?/[\w.][/\w.\-]*)@$1 . &file_ref($2)@ge;
    -  s@(include(<\/?[bu]\>|\s)*\<)([/\w.\-]+)@$1 . &include_ref($3)@ge;
    -  s@(\w[\w.\-]*)((\)*)(\([\dm]\w*\))@$1$2$4@g;
    -  print;
    -}
    -close(F);
    -if (! $ok) {
    -  if ($query{'quit'}) {
    -    print STDERR "No manual entry for $man_section.\n";
    -    print <
    -man $man_section
    -
    -
    -EOF
    -  print "No manual entry for $man_section.\n";
    -}
    -print <
    -
    -
    -EOF
    -
    -sub is_command {
    -  local($_) = @_;
    -  local($p);
    -
    -  (! -d && -x) || return 0;
    -  if (! defined(%PATH)) {
    -    for $p (split(":", $ENV{'PATH'})) {
    -      $p =~ s@/+$@@;
    -      $PATH{$p} = 1;
    -    }
    -  }
    -  s@/[^/]*$@@;
    -  return defined($PATH{$_});
    -}
    -
    -sub file_ref {
    -  local($_) = @_;
    -
    -  if (&is_command($_)) {
    -    ($man = $_) =~ s@.*/@@;
    -    return "$_";
    -  }
    -  if (/^\~/ || -f || -d) {
    -    return "$_";
    -  }
    -  return $_;
    -}
    -
    -sub include_ref {
    -  local($_) = @_;
    -  local($d);
    -
    -  for $d (
    -	"/usr/include",
    -	"/usr/local/include",
    -	"/usr/X11R6/include",
    -	"/usr/X11/include",
    -	"/usr/X/include",
    -	"/usr/include/X11"
    -  ) {
    -    -f "$d/$_" && return "$_";
    -  }
    -  return $_;
    -}
    -
    -sub keyword_ref {
    -  local($_, $s) = @_;
    -  local(@a) = ();
    -
    -  for (split(/\s*,\s*/)) {
    -    push(@a, "$_");
    -  }
    -  return join(", ", @a) . $s;
    -}
    -
    -sub html_quote {
    -  local($_) = @_;
    -  local(%QUOTE) = (
    -    '<', '<',
    -    '>', '>',
    -    '&', '&',
    -    '"', '"',
    -  );
    -  s/[<>&"]/$QUOTE{$&}/g;
    -  return $_;
    -}
    -
    -sub form_decode {
    -  local($_) = @_;
    -  s/\+/ /g;
    -  s/%([\da-f][\da-f])/pack('c', hex($1))/egi;
    -  return $_;
    -}
    -
    -- 
    cgit v1.2.3