diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2001-11-21 09:42:23 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2001-11-21 09:42:23 +0000 |
commit | 16eaebf290222ac97b710d6baf88b2777a643372 (patch) | |
tree | 93b38700d7a6f37dc21aeef586cbd017b1ca1aa6 | |
parent | [w3m-dev 02470] (diff) | |
download | w3m-16eaebf290222ac97b710d6baf88b2777a643372.tar.gz w3m-16eaebf290222ac97b710d6baf88b2777a643372.zip |
[w3m-dev 02473] clean & install-scripts
From: Fumitoshi UKAI <ukai@debian.or.jp>
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | XMakefile | 15 | ||||
-rw-r--r-- | scripts/Makefile | 4 | ||||
-rw-r--r-- | scripts/dirlist.cgi | 532 | ||||
-rw-r--r-- | scripts/multipart/Makefile | 3 | ||||
-rw-r--r-- | scripts/w3mman/Makefile | 3 |
7 files changed, 36 insertions, 536 deletions
@@ -1,3 +1,15 @@ +2001-11-21 Fumitoshi UKAI <ukai@debian.or.jp> + + * [w3m-dev 02473] + * scripts/Makefile: chmod +x + * scripts/Makefile: add clean target + * scripts/multipart/Makefile: ditto + * scripts/w3mman/Makefile: ditto + * XMakefile: clean scripts + * scripts/dirlist.cgi: removed from CVS + * Makefile (install-scripts): added + * XMakefile: (install-scripts): depends all-scripts + 2001-11-21 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> * [w3m-dev 02470] @@ -6,6 +6,9 @@ all: XXMakefile install: XXMakefile make -f XXMakefile install +install-scripts: XXMakefile + make -f XXMakefile install-scripts + uninstall: XXMakefile make -f XXMakefile uninstall @@ -1,4 +1,4 @@ -# $Id: XMakefile,v 1.8 2001/11/21 09:21:59 ukai Exp $ +# $Id: XMakefile,v 1.9 2001/11/21 09:42:23 ukai Exp $ SRCS=main.c file.c buffer.c display.c etc.c search.c linein.c table.c local.c \ form.c map.c frame.c rc.c menu.c mailcap.c\ func.c cookie.c history.c backend.c $(KEYBIND_SRC) @@ -20,6 +20,9 @@ HELPER=w3mhelperpanel$(EXT) INFLATE=inflate$(EXT) TARGETS=$(TARGET) $(EXT_TARGETS) +SCRIPTSUBDIRS = scripts scripts/multipart scripts/w3mman +SUBDIRS = $(SCRIPTSUBDIRS) + INCLUDES=-I. DEFS=$(INCLUDES) # -DDEBUG @@ -94,13 +97,13 @@ install: $(TARGETS) all-scripts (cd scripts; for i in *.cgi; do $(INSTALL2) -m 755 $$i $(DESTDIR)$(LIB_DIR)/$$i; done) all-scripts: - for dir in scripts scripts/multipart scripts/w3mman; \ + for dir in $(SCRIPTSUBDIRS); \ do \ (cd $$dir; $(MAKE) PERL='$(PERL)' BIN_DIR='$(BIN_DIR)' LIB_DIR='$(LIB_DIR)'); \ done -install-scripts: - for dir in scripts scripts/multipart scripts/w3mman; \ +install-scripts: all-scripts + for dir in $(SCRIPTSUBDIRS); \ do \ (cd $$dir; $(MAKE) PERL='$(PERL)' BIN_DIR='$(BIN_DIR)' LIB_DIR='$(LIB_DIR)' DESTDIR='$(DESTDIR)' INSTALL='sh $(PWD)/install.sh' install); \ done @@ -119,6 +122,10 @@ uninstall: clean: sweep rm -f *.o *.a $(TARGETS) mktable$(EXT) rm -f funcname.c funcname1.h funcname2.h tagtable.c + for dir in $(SCRIPTSUBDIRS); \ + do \ + (cd $$dir; $(MAKE) clean); \ + done sweep: -rm -f core *~ *.bak *.orig *.rej diff --git a/scripts/Makefile b/scripts/Makefile index 00ee78c..b1d304a 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -17,9 +17,13 @@ all: $(LIB_TARGETS) .in: sed 's%@PERL@%$(PERL)%' $< > $@ + chmod +x $@ install: $(LIB_TARGETS) for file in $(LIB_TARGETS); \ do \ $(INSTALL_SCRIPT) $$file $(DISTDIR)$(LIB_DIR); \ done + +clean: + rm -f $(LIB_TARGETS) diff --git a/scripts/dirlist.cgi b/scripts/dirlist.cgi deleted file mode 100644 index 618d4e5..0000000 --- a/scripts/dirlist.cgi +++ /dev/null @@ -1,532 +0,0 @@ -#!/usr/local/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 = '<a href="%s"><nobr>%s</nobr></a>'; -$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 <<EOF; -Content-Type: text/html - -<html> -<head> -<title>Directory list of $qdir</title> -</head> -<body> -<b>$qdir</b>: $! ! -</body> -</html> -EOF - exit 1; -} - -# ($cgi > 0) && print <<EOF; -# w3m-control: DELETE_PREVBUF -# EOF -print <<EOF; -Content-Type: text/html - -<html> -<head> -<title>Directory list of $qdir</title> -</head> -<body> -<h1>Directory list of $qdir</h1> -EOF -&print_form($edir, @OPT); -print <<EOF; -<hr> -EOF -$dir =~ s@/$@@; -@sdirs = split('/', $dir); -$_ = $sdirs[0]; -if ($_ eq '') { - $_ = '/'; -} -if ($TYPE eq $TYPE_TREE) { - print <<EOF; -<table hborder width="640"> -<tr valign=top><td width="160"> -<pre> -EOF - $q = "$ROOT". &html_quote("$_"); - $e = "$ROOT" . &file_encode("$_"); - if ($dir =~ m@^$@) { - $n = "\" name=\"current"; - } else { - $n = ''; - } - printf("$AFMT\n", "$e$n", "<b>$q</b>"); - $N = 0; - $SKIPLINE = ""; - - &left_dir('', @sdirs); - - print <<EOF; -</pre> -</td><td width="400"> -<pre>$SKIPLINE -EOF -} else { - print <<EOF; -<pre> -EOF -} - -&right_dir($dir); - -if ($TYPE eq $TYPE_TREE) { - print <<EOF; -</pre> -</td></tr> -</table> -</body> -</html> -EOF -} else { - print <<EOF; -</pre> -</body> -</html> -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", "<b>$q</b>"); - &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 "<b>$qdir</b>\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 "<table>\n<tr valign=top>"; - foreach(@list) { - $f = "$ROOT$dir$_"; - $q = &html_quote($_); - $e = &file_encode($_); - if ($n % $nr == 0) { - print "<td>"; - } - if (-d $f) { - printf($AFMT, "$edir$e", "$q/"); - } else { - printf($AFMT, "$edir$e", $q); - } - $n++; - if ($n % $nr == 0) { - print "</td>\n"; - } else { - print "<br>\n"; - } - } - print "</tr></table>\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(<CONFIG>) { - 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; -type $TYPE -format $FORMAT -sort $SORT -EOF - close(CONFIG); -} - -sub print_form { - local($d, @OPT) = @_; - local(@disc) = ('Type', 'Format', 'Sort'); - local(@val) = ( - "('t', 'd')", - "('s', 'd', 'c')", - "('n', 's', 't')", - ); - local(@opt) = ( - "('Tree', 'Standard')", - "('Short', 'Standard', 'Column')", - "('By Name', 'By Size', 'By Time')" - ); - local($_, @vs, @os, $v, $o); - - print <<EOF; -<form action=\"$CGI\"> -<center> -<table> -<tr valign=top> -EOF - foreach(0 .. 2) { - print "<td align> $disc[$_]</td>\n"; - } - print "</tr><tr>\n"; - foreach(0 .. 2) { - print "<td><select name=opt$_>\n"; - eval "\@vs = $val[$_]"; - eval "\@os = $opt[$_]"; - foreach $v (@vs) { - $o = shift(@os); - if ($v eq $OPT[$_]) { - print "<option value=$v selected>$o\n"; - } else { - print "<option value=$v>$o\n"; - } - } - print "</select></td>\n"; - } - print <<EOF; -<td><input type=submit name=cmd value="Update"></td> -</tr> -</table> -</center> -<input type=hidden name=dir value="$d"> -</form> -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', $_); - $_ = <CYGPATH>; - close(CYGPATH); - s/\r?\n$//; - s!\\!/!g; - s!/$!!; - return $_; -} diff --git a/scripts/multipart/Makefile b/scripts/multipart/Makefile index d3510e9..07924a0 100644 --- a/scripts/multipart/Makefile +++ b/scripts/multipart/Makefile @@ -29,6 +29,9 @@ install: $(LIB_TARGETS) $(INSTALL_SCRIPT) $$file $(DISTDIR)$(LIB_DIR); \ done +clean: + rm -f $(LIB_TARGETS) + dist: all @-rm -fr $(distdir)/multipart mkdir -p $(distdir)/multipart diff --git a/scripts/w3mman/Makefile b/scripts/w3mman/Makefile index 0d7b582..613d561 100644 --- a/scripts/w3mman/Makefile +++ b/scripts/w3mman/Makefile @@ -37,6 +37,9 @@ install: $(TARGETS) $(LIB_TARGETS) $(INSTALL_SCRIPT) $$file $(DESTDIR)$(LIB_DIR); \ done +clean: + rm -f $(TARGETS) $(LIB_TARGETS) + dist: all @-rm -fr $(distdir)/w3mman mkdir -p $(distdir)/w3mman |