Compare commits
3 Commits
master
...
combined_g
Author | SHA1 | Date |
---|---|---|
paiging | 1474016ff5 | |
hjp | 4d8289dad6 | |
cvs2git | cd3d78bbb1 |
|
@ -1,26 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
BINDIR=/usr/local/bin
|
||||
|
||||
all: agestat
|
||||
|
||||
clean:
|
||||
rm agestat customize
|
||||
|
||||
install: $(BINDIR) $(BINDIR)/agestat
|
||||
|
||||
%: %.pl customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
%: %.sh customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
customize: configure
|
||||
sh ./configure
|
||||
|
||||
$(BINDIR):
|
||||
mkdir -p $@
|
||||
|
||||
include GNUmakerules
|
|
@ -1,86 +0,0 @@
|
|||
#!@@@perl@@@ -w
|
||||
#
|
||||
# $Id: agestat.pl,v 1.4 2001-01-19 19:06:01 hjp Exp $
|
||||
#
|
||||
|
||||
use strict;
|
||||
use File::stat;
|
||||
use File::Find;
|
||||
use Getopt::Long;
|
||||
|
||||
my $now = time();
|
||||
my $log_2 = log(2);
|
||||
|
||||
my %opts = ();
|
||||
GetOptions(\%opts, "atime", "mtime", "scale=s");
|
||||
my $scale;
|
||||
if (!defined($opts{scale})) {
|
||||
$scale = 1;
|
||||
} elsif ($opts{scale} eq 'k') {
|
||||
$scale = 1024;
|
||||
} elsif ($opts{scale} eq 'M') {
|
||||
$scale = 1024*1024;
|
||||
} else {
|
||||
print STDERR "Usage: $0 [-atime|-mtime] [-scale=(k|M)]\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my @hist;
|
||||
|
||||
sub wanted {
|
||||
|
||||
my $st = lstat($_);
|
||||
my $age = $now - (
|
||||
$opts{atime} ? $st->atime :
|
||||
$opts{mtime} ? $st->mtime :
|
||||
($st->atime > $st->mtime ? $st->atime
|
||||
: $st->mtime ));
|
||||
#print $File::Find::name, ": $age sec, ", $st->size, " bytes, ", $st->nlink, " links\n";
|
||||
my $log2age = log($age >= 1 ? $age : 1) / $log_2;
|
||||
$hist[$log2age] += $st->size / $st->nlink;
|
||||
}
|
||||
|
||||
sub logtime2str {
|
||||
my ($lt) = (@_);
|
||||
|
||||
my $t = 1 << $lt;
|
||||
|
||||
if ($t < 60) {
|
||||
return sprintf ("%5.1f s", $t);
|
||||
} elsif ($t < 3600) {
|
||||
return sprintf ("%5.1f m", $t/60);
|
||||
} elsif ($t < 3600 * 24) {
|
||||
return sprintf ("%5.1f h", $t/3600);
|
||||
} elsif ($t < 3600 * 24 * 365.2422) {
|
||||
return sprintf ("%5.1f d", $t/(3600*24));
|
||||
} else {
|
||||
return sprintf ("%5.1f y", $t/(3600*24*365.2422));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (@ARGV == 0) { push (@ARGV, "."); }
|
||||
find(\&wanted, @ARGV);
|
||||
|
||||
print "\n\n";
|
||||
|
||||
my $sum = 0;
|
||||
|
||||
for (my $i = 0; $i <= $#hist; $i++) {
|
||||
$sum += ($hist[$i] || 0);
|
||||
}
|
||||
|
||||
|
||||
my $c = 0;
|
||||
for (my $i = 0; $i <= $#hist; $i++) {
|
||||
my $h = ($hist[$i] || 0);
|
||||
$c += $h;
|
||||
printf("%2d\t%s\t%12.0f\t%5.1f\t%12.0f\t%5.1f\n", $i,
|
||||
logtime2str($i), $h/$scale, $h * 100 / $sum, $c/$scale, $c * 100 / $sum);
|
||||
}
|
||||
|
||||
# $Log: agestat.pl,v $
|
||||
# Revision 1.4 2001-01-19 19:06:01 hjp
|
||||
# Removed superfluous "total" line.
|
||||
# Fixed usage message.
|
||||
#
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
echo "#!/bin/sh" > customize.$$
|
||||
echo "sed \\" >> customize.$$
|
||||
chmod +x customize.$$
|
||||
|
||||
################################################################
|
||||
# find a working perl:
|
||||
#
|
||||
for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5
|
||||
do
|
||||
if $i -e 'exit ($] < 5.000)'
|
||||
then
|
||||
echo $i works
|
||||
perl="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$perl" ]
|
||||
then
|
||||
could not find a working perl command, sorry.
|
||||
exit 1
|
||||
fi
|
||||
echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize.$$
|
||||
|
||||
|
||||
echo >> customize.$$
|
||||
|
||||
mv customize.$$ customize
|
||||
|
106
cgigw/cgigw.cgi
106
cgigw/cgigw.cgi
|
@ -1,106 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# $Id: cgigw.cgi,v 1.1 1998-04-28 22:01:23 hjp Exp $
|
||||
#
|
||||
# This is a simpe CGI gateway script.
|
||||
#
|
||||
# It can be used to access CGI scripts on a different server and/or
|
||||
# port.
|
||||
# Possible scenarios where this is useful:
|
||||
# * Your real CGI scripts have to run on a machine behind a firewall.
|
||||
# In this case you may also want to modify this script to check
|
||||
# parameters.
|
||||
# * Your real CGI scripts have to run on a different server (e.g., one
|
||||
# with some special database installed), but you don't want to expose
|
||||
# that server's address in your URLs.
|
||||
# * Your real CGI scripts have to run on a Web server which doesn't
|
||||
# speak SSL.
|
||||
#
|
||||
# Usage: Change the customization section to point to the script which
|
||||
# you really want to call. Install this script in some convenient
|
||||
# place. Make sure the target script generates only links to your
|
||||
# "official" server (If this is not possible, you might want to
|
||||
# tweak its output just before "print @rest;" at the very bottom
|
||||
# of this script.
|
||||
#
|
||||
# $Log: cgigw.cgi,v $
|
||||
# Revision 1.1 1998-04-28 22:01:23 hjp
|
||||
# Initial release.
|
||||
# Only tested with a few CGIs and the Roxen web server.
|
||||
#
|
||||
#
|
||||
|
||||
use IO::Socket;
|
||||
|
||||
# BEGIN customization section
|
||||
$serv_addr = "internal.host.com";
|
||||
$serv_port = 80;
|
||||
$serv_script = "/some/script.cgi";
|
||||
# END customization section
|
||||
|
||||
$sock = IO::Socket::INET->new(PeerAddr => $serv_addr,
|
||||
PeerPort => $serv_port);
|
||||
if (!$sock) {
|
||||
print "Status: 500\r\n";
|
||||
print "Content-type: text/html\r\n";
|
||||
print "\r\n";
|
||||
print "<html><body>\n";
|
||||
print "<h1>Internal error</h1>\n";
|
||||
print "Connection to $serv_addr:$serv_port failed: $!\n";
|
||||
print "</body></html>\n";
|
||||
}
|
||||
|
||||
$method = $ENV{REQUEST_METHOD};
|
||||
$query_string = $ENV{QUERY_STRING};
|
||||
print STDERR "$0: method = $method\n";
|
||||
|
||||
$sock->print("$method $serv_script");
|
||||
if ($query_string ne "") {
|
||||
$sock->print("?$query_string");
|
||||
}
|
||||
$sock->print(" HTTP/1.0\r\n");
|
||||
for $i (keys(%ENV)) {
|
||||
if ($i =~ m/^HTTP_(.*)/) {
|
||||
$key = $1;
|
||||
$key =~ s/_/-/g;
|
||||
$val = $ENV{$i};
|
||||
$sock->print("$key: $val\r\n");
|
||||
print STDERR "$0: Header: $key: $val\n";
|
||||
} else {
|
||||
$val = $ENV{$i};
|
||||
print STDERR "$0: Env: $i: $val\n";
|
||||
}
|
||||
}
|
||||
$content_length = $ENV{CONTENT_LENGTH};
|
||||
if ($content_length) {
|
||||
$sock->print("Content-Length: ", $content_length, "\r\n\r\n");
|
||||
for ($i = 0; $i < $content_length; $i++) {
|
||||
read(STDIN, $c, 1);
|
||||
print STDERR "$0: Body: $i of $content_length: $c\n";
|
||||
$sock->print($c);
|
||||
}
|
||||
# padding:
|
||||
$sock->print("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n");
|
||||
} else {
|
||||
$sock->print("\r\n");
|
||||
}
|
||||
$sock->flush();
|
||||
print STDERR "$0: Flushing\n";
|
||||
|
||||
$status = $sock->getline();
|
||||
print STDERR "$0: Status: $status\n";
|
||||
if ($status =~ m|^HTTP/\d+\.\d+ (\d+) |) {
|
||||
print "Status: $1\r\n";
|
||||
} elsif ($status =~ m|:|) {
|
||||
# error: Assume this is a header and just pass it on
|
||||
print $status;
|
||||
} else {
|
||||
# error: not a header. Assume this is HTML
|
||||
print "Content-Type: text/html\r\n";
|
||||
print "\r\n";
|
||||
print $status;
|
||||
}
|
||||
@rest = $sock->getlines;
|
||||
print @rest;
|
||||
|
||||
print STDERR "$0: Finished\n";
|
|
@ -1,10 +0,0 @@
|
|||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
all: charhist
|
||||
|
||||
chartab:
|
||||
clean:
|
||||
rm -f charhist core foo bar baz
|
||||
|
||||
install: $(BINDIR)/charhist
|
|
@ -1,21 +0,0 @@
|
|||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
long hist[UCHAR_MAX+1];
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
int c;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
while ((c = getchar()) != EOF) {
|
||||
hist[c]++;
|
||||
}
|
||||
for (c = 0; c <= UCHAR_MAX; c++) {
|
||||
if (hist[c]) {
|
||||
printf ("%x %d %o %c\t%ld\n", c, c, c, isprint(c) ? c : '.', hist[c]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
all: chartab ctype-test
|
||||
|
||||
chartab:
|
||||
ctype-test:
|
||||
clean:
|
||||
rm chartab
|
||||
install: $(BINDIR)/chartab $(BINDIR)/ctype-test
|
||||
|
||||
include GNUmakerules
|
|
@ -1,10 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
int i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
printf ("%x %d %o %c\t", i, i, i, i);
|
||||
if (i % 4 == 3) printf ("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
for (i = 0; i <= UCHAR_MAX; i++) {
|
||||
printf ("%2x: ", i);
|
||||
printf("%c ", isprint(i) ? i : '.');
|
||||
printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
version 5.0
|
||||
map! >I<yypa/O
|
||||
set autoindent
|
||||
set exrc
|
||||
set number
|
||||
set shiftwidth=4
|
|
@ -1,39 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
TARGETS = cleandir
|
||||
CONFDIR=../../configure
|
||||
CONFDIR_exists=$(shell [ -d $(CONFDIR) ] && echo ok)
|
||||
|
||||
all: configure $(TARGETS)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGETS) *.bak core foo bar baz *.ps
|
||||
|
||||
distclean: clean
|
||||
rm -f customize
|
||||
|
||||
install: $(BINDIR) $(BINDIR)/cleandir
|
||||
|
||||
%: %.pl customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
%: %.sh customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
customize: configure
|
||||
sh ./configure
|
||||
|
||||
$(SBINDIR):
|
||||
mkdir -p $@
|
||||
|
||||
ifeq ($(CONFDIR_exists),ok)
|
||||
|
||||
configure: $(CONFDIR)/start $(CONFDIR)/perl $(CONFDIR)/finish
|
||||
cat $^ > $@
|
||||
|
||||
endif
|
||||
|
||||
|
||||
include GNUmakerules
|
|
@ -1,131 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
use File::stat;
|
||||
use POSIX;
|
||||
|
||||
my $verbose = 0;
|
||||
my $nop = 0;
|
||||
|
||||
sub usage {
|
||||
print STDERR "Usage: $0 [-d days] dir ...\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sub cleandir {
|
||||
my ($dir, $since, $level) = (@_);
|
||||
my $notremoved = 0;
|
||||
|
||||
if ($verbose > 1) {
|
||||
print STDERR "$0:", " " x $level, " cleandir $dir $since {\n";
|
||||
}
|
||||
if (!opendir(DIR, ".")) {
|
||||
printf STDERR "$0:", " " x $level, " cannot opendir $dir: $!";
|
||||
return;
|
||||
}
|
||||
my $std = lstat(".");
|
||||
for my $i (readdir(DIR)) {
|
||||
if ($i eq "." || $i eq "..") {next}
|
||||
if ($verbose > 2) {
|
||||
print STDERR "$0:", " " x $level, " checking $dir/$i\n";
|
||||
}
|
||||
my $st = lstat("$i");
|
||||
if ($verbose > 3) {
|
||||
print STDERR "$0:", " " x $level, " mtime=", $st->mtime, " atime=", $st->atime, "\n";
|
||||
}
|
||||
if (-d _) {
|
||||
my $cwd = getcwd();
|
||||
if (chdir($i)) {
|
||||
my $remaining = -1;
|
||||
my $st1 = lstat(".");
|
||||
if ($st->dev == $st1->dev && $st->ino == $st1->ino) {
|
||||
$remaining = cleandir("$dir/$i", $since, $level+1);
|
||||
} else {
|
||||
print STDERR "$0:", " " x $level,
|
||||
" $dir/$i changed dev/inode from ",
|
||||
$st->dev, "/", $st->ino,
|
||||
" to ",
|
||||
$st1->dev, "/", $st1->ino,
|
||||
"\n";
|
||||
}
|
||||
chdir($cwd);
|
||||
my $std1 = lstat(".");
|
||||
if (!($std->dev == $std1->dev && $std->ino == $std1->ino)) {
|
||||
print STDERR "$0:", " " x $level,
|
||||
" $cwd changed dev/inode from ",
|
||||
$std->dev, "/", $std->ino,
|
||||
" to ",
|
||||
$std1->dev, "/", $std1->ino,
|
||||
"\n";
|
||||
}
|
||||
if ($remaining == 0 && $st->mtime < $since) {
|
||||
if ($verbose > 0) {
|
||||
print STDERR "$0:", " " x $level, "rmdir $i\n";
|
||||
}
|
||||
if (rmdir("$i")) {next}
|
||||
print STDERR "$0:", " " x $level, "rmdir $i failed: $!\n";
|
||||
}
|
||||
} else {
|
||||
print STDERR "$0:", " " x $level, " chdir $dir/$i failed: $!\n";
|
||||
}
|
||||
|
||||
} elsif ($st->mtime < $since && $st->atime < $since) {
|
||||
if ($nop) {
|
||||
print "would remove $dir/$i\n";
|
||||
} else {
|
||||
if ($verbose > 0) {
|
||||
print STDERR "$0:", " " x $level, " removing $dir/$i\n";
|
||||
}
|
||||
if (unlink("$i")) {next}
|
||||
print STDERR "$0:", " " x $level, " removing $dir/$i failed: $!\n";
|
||||
}
|
||||
|
||||
}
|
||||
$notremoved++;
|
||||
}
|
||||
if ($verbose > 1) {
|
||||
print STDERR "$0:", " " x $level, " cleandir: $notremoved }\n";
|
||||
}
|
||||
return $notremoved;
|
||||
}
|
||||
|
||||
sub main {
|
||||
my $since = time() - 14 * 86400;;
|
||||
my $i;
|
||||
while ($i = shift(@ARGV)) {
|
||||
if ($i eq "-d") {
|
||||
my $days = shift(@ARGV);
|
||||
$since = time() - $days * 86400;
|
||||
} elsif ($i eq "-v") {
|
||||
$verbose++;
|
||||
} elsif ($i eq "-n") {
|
||||
$nop++;
|
||||
} else {
|
||||
my $cwd = getcwd();
|
||||
if (chdir($i)) {
|
||||
cleandir($i, $since, 0);
|
||||
chdir($cwd);
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
# $Log: cleandir,v $
|
||||
# Revision 1.4 2000-11-20 21:10:08 hjp
|
||||
# Checks introduced in last version prevented deletion of unused subdirs.
|
||||
# Fixed.
|
||||
#
|
||||
# revision 1.3
|
||||
# date: 2000/09/10 16:16:41; author: hjp; state: Exp; lines: +37 -6
|
||||
# Added checks to detect directory/symlink switching attacks.
|
||||
# ----------------------------
|
||||
# revision 1.2
|
||||
# date: 1999/08/21 12:37:53; author: hjp; state: Exp; lines: +25 -13
|
||||
# More levels of verbosity.
|
||||
# ----------------------------
|
||||
# revision 1.1
|
||||
# date: 1999/07/09 21:05:26; author: hjp; state: Exp;
|
||||
# Added cleandir
|
||||
#
|
|
@ -1,134 +0,0 @@
|
|||
#!@@@perl@@@ -w
|
||||
use strict;
|
||||
use File::stat;
|
||||
use POSIX;
|
||||
|
||||
my $verbose = 0;
|
||||
my $nop = 0;
|
||||
|
||||
sub usage {
|
||||
print STDERR "Usage: $0 [-d days] dir ...\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sub cleandir {
|
||||
my ($dir, $since, $level) = (@_);
|
||||
my $notremoved = 0;
|
||||
|
||||
if ($verbose > 1) {
|
||||
print STDERR "$0:", " " x $level, " cleandir $dir $since {\n";
|
||||
}
|
||||
if (!opendir(DIR, ".")) {
|
||||
printf STDERR "$0:", " " x $level, " cannot opendir $dir: $!";
|
||||
return;
|
||||
}
|
||||
my $std = lstat(".");
|
||||
for my $i (readdir(DIR)) {
|
||||
if ($i eq "." || $i eq "..") {next}
|
||||
if ($verbose > 2) {
|
||||
print STDERR "$0:", " " x $level, " checking $dir/$i\n";
|
||||
}
|
||||
my $st = lstat("$i");
|
||||
if ($verbose > 3) {
|
||||
print STDERR "$0:", " " x $level, " mtime=", $st->mtime, " atime=", $st->atime, "\n";
|
||||
}
|
||||
if (-d _) {
|
||||
my $cwd = getcwd();
|
||||
if (chdir($i)) {
|
||||
my $remaining = -1;
|
||||
my $st1 = lstat(".");
|
||||
if ($st->dev == $st1->dev && $st->ino == $st1->ino) {
|
||||
$remaining = cleandir("$dir/$i", $since, $level+1);
|
||||
} else {
|
||||
print STDERR "$0:", " " x $level,
|
||||
" $dir/$i changed dev/inode from ",
|
||||
$st->dev, "/", $st->ino,
|
||||
" to ",
|
||||
$st1->dev, "/", $st1->ino,
|
||||
"\n";
|
||||
}
|
||||
chdir($cwd);
|
||||
my $std1 = lstat(".");
|
||||
if (!($std->dev == $std1->dev && $std->ino == $std1->ino)) {
|
||||
print STDERR "$0:", " " x $level,
|
||||
" $cwd changed dev/inode from ",
|
||||
$std->dev, "/", $std->ino,
|
||||
" to ",
|
||||
$std1->dev, "/", $std1->ino,
|
||||
"\n";
|
||||
}
|
||||
if ($remaining == 0 && $st->mtime < $since) {
|
||||
if ($verbose > 0) {
|
||||
print STDERR "$0:", " " x $level, "rmdir $i\n";
|
||||
}
|
||||
if (rmdir("$i")) {next}
|
||||
print STDERR "$0:", " " x $level, "rmdir $i failed: $!\n";
|
||||
}
|
||||
} else {
|
||||
print STDERR "$0:", " " x $level, " chdir $dir/$i failed: $!\n";
|
||||
}
|
||||
|
||||
} elsif ($st->mtime < $since && $st->atime < $since) {
|
||||
if ($nop) {
|
||||
print "would remove $dir/$i\n";
|
||||
} else {
|
||||
if ($verbose > 0) {
|
||||
print STDERR "$0:", " " x $level, " removing $dir/$i\n";
|
||||
}
|
||||
if (unlink("$i")) {next}
|
||||
print STDERR "$0:", " " x $level, " removing $dir/$i failed: $!\n";
|
||||
}
|
||||
|
||||
}
|
||||
$notremoved++;
|
||||
}
|
||||
if ($verbose > 1) {
|
||||
print STDERR "$0:", " " x $level, " cleandir: $notremoved }\n";
|
||||
}
|
||||
return $notremoved;
|
||||
}
|
||||
|
||||
sub main {
|
||||
my $since = time() - 14 * 86400;;
|
||||
my $i;
|
||||
while ($i = shift(@ARGV)) {
|
||||
if ($i eq "-d") {
|
||||
my $days = shift(@ARGV);
|
||||
$since = time() - $days * 86400;
|
||||
} elsif ($i eq "-v") {
|
||||
$verbose++;
|
||||
} elsif ($i eq "-n") {
|
||||
$nop++;
|
||||
} else {
|
||||
my $cwd = getcwd();
|
||||
if (chdir($i)) {
|
||||
cleandir($i, $since, 0);
|
||||
chdir($cwd);
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
# $Log: cleandir.pl,v $
|
||||
# Revision 1.1 2001-06-25 17:55:03 hjp
|
||||
# Added configure script to figure out perl location.
|
||||
#
|
||||
# Revision 1.4 2000/11/20 21:10:08 hjp
|
||||
# Checks introduced in last version prevented deletion of unused subdirs.
|
||||
# Fixed.
|
||||
#
|
||||
# revision 1.3
|
||||
# date: 2000/09/10 16:16:41; author: hjp; state: Exp; lines: +37 -6
|
||||
# Added checks to detect directory/symlink switching attacks.
|
||||
# ----------------------------
|
||||
# revision 1.2
|
||||
# date: 1999/08/21 12:37:53; author: hjp; state: Exp; lines: +25 -13
|
||||
# More levels of verbosity.
|
||||
# ----------------------------
|
||||
# revision 1.1
|
||||
# date: 1999/07/09 21:05:26; author: hjp; state: Exp;
|
||||
# Added cleandir
|
||||
#
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
echo "#!/bin/sh" > customize.$$
|
||||
echo "sed \\" > customize.$$
|
||||
chmod +x customize.$$
|
||||
|
||||
################################################################
|
||||
# find a working perl:
|
||||
#
|
||||
for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5
|
||||
do
|
||||
if $i -e 'exit ($] < 5.000)'
|
||||
then
|
||||
echo $i works
|
||||
perl="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$perl" ]
|
||||
then
|
||||
could not find a working perl command, sorry.
|
||||
exit 1
|
||||
fi
|
||||
echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize.$$
|
||||
|
||||
|
||||
################################################################
|
||||
# finish
|
||||
# Add trailing newline and rename temp file to final name
|
||||
#
|
||||
echo >> customize.$$
|
||||
|
||||
mv customize.$$ customize
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
include GNUmakerules
|
||||
include GNUmakevars
|
||||
|
||||
count:
|
||||
|
||||
install: $(ROOT)/usr/local/bin/count
|
||||
|
||||
install_all:
|
||||
$(MAKE) install ROOT=/nfs/wsrdb
|
||||
$(MAKE) install ROOT=/nfs/wsrcom
|
||||
$(MAKE) install ROOT=/nfs/wifosv
|
||||
$(MAKE) install ROOT=/nfs/ihssv
|
||||
$(MAKE) install ROOT=/nfs/wsrtest
|
||||
|
||||
$(ROOT)/usr/local/bin/%: %
|
||||
$(INSTALL) $< $@
|
||||
|
||||
$(ROOT)/usr/local/man/man8/%.8: %.man
|
||||
$(INSTALL) $< $@
|
||||
|
||||
clean:
|
||||
rm count
|
|
@ -1,30 +0,0 @@
|
|||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
unsigned long start = 0;
|
||||
unsigned long stop = ULONG_MAX;
|
||||
unsigned long i;
|
||||
|
||||
switch (argc) {
|
||||
case 0:
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
stop = strtoul(argv[1], NULL, 0);
|
||||
break;
|
||||
case 3:
|
||||
start = strtoul(argv[1], NULL, 0);
|
||||
stop = strtoul(argv[2], NULL, 0);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Usage: %s [[start] stop]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = start; i < stop; i++) {
|
||||
printf("%ld\n", i);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
version 5.0
|
||||
map! >I<yypa/O
|
||||
set autoindent
|
||||
set exrc
|
||||
set ruler
|
||||
set shiftwidth=4
|
|
@ -1,24 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
all: cvsdiffmin
|
||||
|
||||
clean:
|
||||
rm cvsdiffmin customize
|
||||
|
||||
install: $(BINDIR) $(BINDIR)/cvsdiffmin
|
||||
|
||||
%: %.pl customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
%: %.sh customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
customize: configure
|
||||
sh ./configure
|
||||
|
||||
$(BINDIR):
|
||||
mkdir -p $@
|
||||
|
||||
include GNUmakerules
|
|
@ -1,68 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
echo "#!/bin/sh" > customize.$$
|
||||
echo "sed \\" > customize.$$
|
||||
chmod +x customize.$$
|
||||
|
||||
################################################################
|
||||
# find a working perl:
|
||||
#
|
||||
for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5
|
||||
do
|
||||
if $i -e 'exit ($] < 5.000)'
|
||||
then
|
||||
echo $i works
|
||||
perl="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$perl" ]
|
||||
then
|
||||
could not find a working perl command, sorry.
|
||||
exit 1
|
||||
fi
|
||||
echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize.$$
|
||||
|
||||
|
||||
################################################################
|
||||
# find a diff which understands --changed-group-format
|
||||
# and related options (like gnu diff)
|
||||
#
|
||||
echo 'a
|
||||
b
|
||||
c' > diff_format-test.$$.1
|
||||
echo 'a
|
||||
B
|
||||
c' > diff_format-test.$$.2
|
||||
|
||||
wanted="<b
|
||||
=B
|
||||
>"
|
||||
for i in /usr/bin/diff /usr/local/bin/diff
|
||||
do
|
||||
a="`$i --unchanged-group-format='' --changed-group-format='<%<=%>>' diff_format-test.$$.1 diff_format-test.$$.2`"
|
||||
echo "$a"
|
||||
|
||||
if [ "x$a" = "x$wanted" ]
|
||||
then
|
||||
echo $i works
|
||||
diff_format="$i"
|
||||
fi
|
||||
done
|
||||
if [ -z "$diff_format" ]
|
||||
then
|
||||
echo could not find a working diff_format command, sorry.
|
||||
exit 1
|
||||
fi
|
||||
echo " -e 's,@@@diff_format@@@,$diff_format,g' \\" >> customize.$$
|
||||
rm diff_format-test.$$.?
|
||||
|
||||
|
||||
################################################################
|
||||
# finish
|
||||
# Add trailing newline and rename temp file to final name
|
||||
#
|
||||
echo >> customize.$$
|
||||
|
||||
mv customize.$$ customize
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
#!@@@perl@@@ -w
|
||||
#
|
||||
# $Id: cvsdiffmin.pl,v 1.3 2000-02-08 17:21:38 hjp Exp $
|
||||
#
|
||||
# cvsdiffmin - minimize output of cvs diff
|
||||
#
|
||||
|
||||
use strict;
|
||||
|
||||
use File::Slurp;
|
||||
|
||||
my $diff = "@@@diff_format@@@";
|
||||
|
||||
my $state = 'EQ';
|
||||
my %text = ();
|
||||
my %cap = ();
|
||||
my $count = 0;
|
||||
|
||||
local $| = 1;
|
||||
|
||||
while (<>) {
|
||||
|
||||
if ($state eq 'EQ' && /^\<{7} /) {
|
||||
$state = 'V1';
|
||||
$text{$state} = "";
|
||||
s/'/_/g;
|
||||
$cap{$state} = $_;
|
||||
next;
|
||||
}
|
||||
if ($state eq 'V1' && /^\={7}$/) {
|
||||
$state = 'V2';
|
||||
$text{$state} = "";
|
||||
next;
|
||||
}
|
||||
if ($state eq 'V2' && /^\>{7} /) {
|
||||
s/'/_/g;
|
||||
$cap{$state} = $_;
|
||||
write_file("cvsdiffmin.$$.$count.1", $text{V1});
|
||||
write_file("cvsdiffmin.$$.$count.2", $text{V2});
|
||||
open (DIFF,
|
||||
"$diff " .
|
||||
" --unchanged-group-format='\%='" .
|
||||
" --changed-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
|
||||
" --old-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
|
||||
" --new-group-format='${cap{V1}}\%<=======\n\%>${cap{V2}}'" .
|
||||
" cvsdiffmin.$$.$count.1" .
|
||||
" cvsdiffmin.$$.$count.2" .
|
||||
"|") or die "cannot invoke diff: $!";
|
||||
while (<DIFF>) {
|
||||
print;
|
||||
}
|
||||
close(DIFF);
|
||||
unlink ("cvsdiffmin.$$.$count.1", "cvsdiffmin.$$.$count.2")
|
||||
or die "cannot unlink temporary files cvsdiffmin.$$.$count.1, cvsdiffmin.$$.$count.2: $!";
|
||||
|
||||
|
||||
$state = 'EQ';
|
||||
$count++;
|
||||
next;
|
||||
}
|
||||
if ($state eq 'EQ') {
|
||||
print;
|
||||
} else {
|
||||
$text{$state} .= $_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# vim:sw=4
|
|
@ -1,34 +0,0 @@
|
|||
# $Id: GNUmakefile,v 1.3 2000-06-04 16:33:20 hjp Exp $
|
||||
|
||||
include GNUmakevars
|
||||
|
||||
ddm: ddm.o
|
||||
$(CC) $^ $(ANTLIB) -o $@
|
||||
|
||||
ddm.o: ddm.c
|
||||
|
||||
clean:
|
||||
rm ddm ddm.o
|
||||
|
||||
install: $(SBINDIR)/ddm
|
||||
|
||||
cfg/%.h: cfg/%.sh
|
||||
sh $< > $@
|
||||
|
||||
include GNUmakerules
|
||||
|
||||
-include ddm.d
|
||||
|
||||
# $Log: GNUmakefile,v $
|
||||
# Revision 1.3 2000-06-04 16:33:20 hjp
|
||||
# Removed MNTTAB autodetection again as it seems to be already defined.
|
||||
# Don't skip rest of mountpoints if one is not accessible.
|
||||
# chdir to / while sleeping to avoid blocking automounters
|
||||
# increased default sleep interval to 1 hour max.
|
||||
#
|
||||
# Revision 1.2 2000/06/04 16:11:12 hjp
|
||||
# Added autodetection of /etc/m(nt)?tab.
|
||||
#
|
||||
# Revision 1.1 2000/06/04 15:53:18 hjp
|
||||
# Pre-Version. Options are still missing.
|
||||
#
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
for i in /etc/mnttab /etc/mtab
|
||||
do
|
||||
if [ -f $i ]
|
||||
then
|
||||
echo '#define PATH_MNTTAB "'$i'"'
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
exit 1
|
231
ddm/ddm.c
231
ddm/ddm.c
|
@ -1,231 +0,0 @@
|
|||
char ddm_c_rcs_id[] =
|
||||
"$Id: ddm.c,v 1.6 2001-02-21 16:02:46 hjp Exp $";
|
||||
/*
|
||||
* ddm - disk delay monitor
|
||||
*
|
||||
* chdirs to a list of filesystems (mount points by default) and does
|
||||
* the equivalent of an ls -l.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ant/da.h>
|
||||
#include <ant/io.h>
|
||||
#include <ant/globals.h>
|
||||
|
||||
#include "cfg/mnttab.h"
|
||||
|
||||
|
||||
typedef enum { MODE_NONE, MODE_ARGS, MODE_MNTTAB, MODE_DIRFILE } modeT;
|
||||
|
||||
|
||||
static double gettimestamp(void) {
|
||||
struct timeval tm;
|
||||
|
||||
gettimeofday(&tm, NULL);
|
||||
return tm.tv_sec + tm.tv_usec/1E6;
|
||||
}
|
||||
|
||||
static void usage(void) {
|
||||
fprintf(stderr, "Usage: %s [-d dirfile | -m mnttab | directory ... ] [-s max_sleep_time]\n",
|
||||
cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void printtimestamp (const char *fmt, ...) {
|
||||
static double lts = 0;
|
||||
double ts = gettimestamp();
|
||||
va_list ap;
|
||||
|
||||
fprintf(stderr, "%s: %.6f: %.6f: ", cmnd, ts, ts - lts);
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
lts = ts;
|
||||
}
|
||||
|
||||
int main(int argc, char**argv) {
|
||||
char **dirs = NULL;
|
||||
modeT mode = MODE_NONE;
|
||||
int nr_dirs;
|
||||
int c;
|
||||
char *filename = NULL;
|
||||
double maxsleeptime = 3600;
|
||||
|
||||
cmnd = argv[0];
|
||||
|
||||
while ((c = getopt(argc, argv, "d:m:s:")) != EOF) {
|
||||
switch (c) {
|
||||
char *p;
|
||||
|
||||
case 'd':
|
||||
mode = MODE_DIRFILE;
|
||||
filename = optarg;
|
||||
break;
|
||||
case 'm':
|
||||
mode = MODE_MNTTAB;
|
||||
filename = optarg;
|
||||
break;
|
||||
case 's':
|
||||
maxsleeptime = strtod(optarg, &p);
|
||||
if (p == optarg || *p) usage();
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == MODE_NONE) {
|
||||
if (optind == argc) {
|
||||
mode = MODE_MNTTAB;
|
||||
filename = PATH_MNTTAB;
|
||||
} else {
|
||||
mode = MODE_ARGS;
|
||||
dirs = argv + optind;
|
||||
nr_dirs = argc - optind;
|
||||
}
|
||||
} else {
|
||||
if (optind != argc) usage();
|
||||
}
|
||||
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
for (;;) {
|
||||
int i;
|
||||
int sleeptime;
|
||||
|
||||
/* Get list of directories
|
||||
*/
|
||||
switch (mode) {
|
||||
case MODE_MNTTAB: {
|
||||
FILE *mtp;
|
||||
struct mntent *me;
|
||||
|
||||
printtimestamp("open %s\n", filename);
|
||||
if ((mtp = setmntent(filename, "r")) == NULL) {
|
||||
fprintf(stderr, "%s: cannot open %s: %s\n",
|
||||
argv[0], filename, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
for (i = 0;(me = getmntent(mtp)); i++) {
|
||||
DA_MKIND_INI(dirs, i, NULL);
|
||||
if (dirs[i]) free(dirs[i]);
|
||||
dirs[i] = strdup(me->mnt_dir);
|
||||
printtimestamp("mountpoint %s\n", dirs[i]);
|
||||
}
|
||||
endmntent(mtp);
|
||||
|
||||
nr_dirs = i;
|
||||
break;
|
||||
}
|
||||
case MODE_DIRFILE: {
|
||||
FILE *fp;
|
||||
char *p;
|
||||
|
||||
printtimestamp("open %s\n", filename);
|
||||
fp = efopen(filename, "r");
|
||||
for (i = 0;(p = getline(fp)); i++) {
|
||||
DA_MKIND_INI(dirs, i, NULL);
|
||||
if (dirs[i]) free(dirs[i]);
|
||||
dirs[i] = strdup(p);
|
||||
printtimestamp("directory %s\n", dirs[i]);
|
||||
}
|
||||
efclose(fp);
|
||||
|
||||
nr_dirs = i;
|
||||
break;
|
||||
}
|
||||
case MODE_ARGS:
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
/* Now read them
|
||||
*/
|
||||
for (i = 0; i < nr_dirs; i++) {
|
||||
int j;
|
||||
char **entries = NULL;
|
||||
int nr_entries;
|
||||
DIR *dp;
|
||||
struct dirent *de;
|
||||
|
||||
printtimestamp("start %s\n", dirs[i]);
|
||||
if (chdir(dirs[i]) == -1) {
|
||||
printtimestamp("chdir %s failed: %s\n", dirs[i], strerror(errno));
|
||||
continue;
|
||||
}
|
||||
printtimestamp("chdir %s ok\n", dirs[i]);
|
||||
|
||||
if ((dp = opendir(".")) == NULL) {
|
||||
printtimestamp("opendir %s failed: %s\n", dirs[i], strerror(errno));
|
||||
continue;
|
||||
}
|
||||
for (j = 0;(de = readdir(dp)); j++) {
|
||||
DA_MKIND_INI(entries, j, NULL);
|
||||
if (entries[j]) free(entries[j]);
|
||||
entries[j] = strdup(de->d_name);
|
||||
printtimestamp("entry %s\n", entries[j]);
|
||||
}
|
||||
closedir(dp);
|
||||
nr_entries = j;
|
||||
|
||||
for (j = 0; j < nr_entries; j++) {
|
||||
struct stat st;
|
||||
stat (entries[j], &st);
|
||||
printtimestamp("stat entry %s\n", entries[j]);
|
||||
}
|
||||
}
|
||||
|
||||
chdir("/");
|
||||
|
||||
sleeptime = rand() * maxsleeptime / RAND_MAX;
|
||||
printtimestamp("sleeping %d seconds\n", sleeptime);
|
||||
sleep(sleeptime);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: ddm.c,v $
|
||||
* Revision 1.6 2001-02-21 16:02:46 hjp
|
||||
* Added config test for mnttab again.
|
||||
* Added option -s (max sleep time)
|
||||
* Added script stats.sh to generate stats.
|
||||
*
|
||||
* Revision 1.5 2000/09/07 10:12:35 hjp
|
||||
* Added alternate ways to specify directories to be monitored.
|
||||
*
|
||||
* Revision 1.4 2000/06/04 16:33:21 hjp
|
||||
* Removed MNTTAB autodetection again as it seems to be already defined.
|
||||
* Don't skip rest of mountpoints if one is not accessible.
|
||||
* chdir to / while sleeping to avoid blocking automounters
|
||||
* increased default sleep interval to 1 hour max.
|
||||
*
|
||||
* Revision 1.3 2000/06/04 16:19:00 hjp
|
||||
* Fixed order of args in fprintf (segfault).
|
||||
*
|
||||
* Revision 1.2 2000/06/04 16:11:12 hjp
|
||||
* Added autodetection of /etc/m(nt)?tab.
|
||||
*
|
||||
* Revision 1.1 2000/06/04 15:53:19 hjp
|
||||
* Pre-Version. Options are still missing.
|
||||
*
|
||||
*/
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# simple statistics (min, avg, max) for ddm output
|
||||
|
||||
awk -F : '{ n[$4] ++; s[$4] += $3; if ($3 < min[$4]) min[$4] = $3; if ($3 > max[$4]) max[$4] = $3; }
|
||||
END { for (i in n) { printf "%10.6f %10.6f %10.6f %s\n", min[i], s[i]/n[i], max[i], i } }' "$@" | sort -n +2
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
all: gethostbyname
|
||||
install: $(BINDIR)/gethostbyname
|
||||
|
||||
clean:
|
||||
rm -f *.bak *.o core gethostbyname
|
||||
|
||||
distclean: clean
|
||||
rm -f *.d
|
||||
|
||||
cfg/%:
|
||||
$(MAKE) -C cfg all
|
||||
|
||||
gethostbyname: gethostbyname.o hstrerror.o
|
||||
|
||||
hstrerror.o: cfg/have_hstrerror.h
|
||||
|
||||
-include *.d
|
|
@ -1,4 +0,0 @@
|
|||
all: have_hstrerror.h
|
||||
|
||||
%.h: %.sh
|
||||
CC='$(CC)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' sh $^ > $@
|
|
@ -1,11 +0,0 @@
|
|||
cat > has_hstrerror_$$.c <<EOF
|
||||
#include <netdb.h>
|
||||
int main(void) { hstrerror(0); }
|
||||
EOF
|
||||
if $CC $CFLAGS has_hstrerror_$$.c $LDFLAGS -o has_hstrerror_$$
|
||||
then
|
||||
echo '#define HAVE_HSTRERROR 1'
|
||||
else
|
||||
echo '#define HAVE_HSTRERROR 0'
|
||||
fi
|
||||
rm has_hstrerror_$$.c has_hstrerror_$$
|
|
@ -1,51 +0,0 @@
|
|||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "hstrerror.h"
|
||||
|
||||
char *cmnd;
|
||||
|
||||
void usage(void) {
|
||||
fprintf(stderr, "Usage: %s [hostname ...]\n", cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
int rc = 0;
|
||||
|
||||
cmnd = argv[0];
|
||||
|
||||
if (argc < 2) {
|
||||
usage();
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
struct hostent *he = gethostbyname(argv[i]);
|
||||
char **a;
|
||||
|
||||
if (!he) {
|
||||
fprintf(stderr, "%s: cannot resolve %s: %s\n",
|
||||
argv[0], argv[i], hstrerror(h_errno));
|
||||
rc++;
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%s\n", argv[i]);
|
||||
printf("\tCanonical: %s\n", he->h_name);
|
||||
for (a = he->h_aliases; *a; a++) {
|
||||
printf("\tAlias: %s\n", *a);
|
||||
}
|
||||
for (a = he->h_addr_list; *a; a++) {
|
||||
int j;
|
||||
printf("\tAddress: ");
|
||||
for (j = 0; j < he->h_length; j++) {
|
||||
printf("%s%d", j ? "." : "", (unsigned char)(*a)[j]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
return rc;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
#include "cfg/have_hstrerror.h"
|
||||
#include "hstrerror.h"
|
||||
|
||||
#if (!HAVE_HSTRERROR)
|
||||
const char *hstrerror(int err) {
|
||||
static char errstr[80];
|
||||
|
||||
snprintf(errstr, sizeof(errstr), "resolver error %d", err);
|
||||
return errstr;
|
||||
}
|
||||
#endif
|
|
@ -1 +0,0 @@
|
|||
const char * hstrerror(int err);
|
|
@ -1,9 +0,0 @@
|
|||
install: $(ROOT)/usr/local/bin/duwatch
|
||||
install_all:
|
||||
make install ROOT=/nfs/wsrdb
|
||||
make install ROOT=/nfs/wifosv
|
||||
make install ROOT=/nfs/ihssv
|
||||
make install ROOT=/nfs/wsrcom
|
||||
|
||||
$(ROOT)/usr/local/bin/%: %
|
||||
install $< $@
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
$avgfile = "/usr/local/lib/duwatch.avg";
|
||||
$root = "/";
|
||||
$thresh = 20000;
|
||||
$period = 30;
|
||||
|
||||
open AVG, $avgfile || die;
|
||||
while (<AVG>) {
|
||||
($size, $name) = split;
|
||||
$avgdu{$name} = $size;
|
||||
$all{$name} = 1;
|
||||
}
|
||||
close AVG;
|
||||
|
||||
open NEW, "/bin/du -t hfs $root |" || die;
|
||||
while (<NEW>) {
|
||||
($size, $name) = split;
|
||||
$size /= 2; # du reports 512 byte blocks :-(
|
||||
if ($size < $thresh) {next};
|
||||
$newdu{$name} = $size;
|
||||
$all{$name} = 1;
|
||||
}
|
||||
close NEW;
|
||||
|
||||
for $i (keys %all) {
|
||||
if ($newdu{"$i"} > 2 * ($avgdu{"$i"})) {
|
||||
printf "%s: %d -> %d\n", $i, $avgdu{$i}, $newdu{$i};
|
||||
}
|
||||
$avgdu{$i} = ($avgdu{$i} * ($period - 1) + $newdu{$i}) / $period;
|
||||
}
|
||||
|
||||
open AVG, ">" . $avgfile || die;
|
||||
for $i (keys %avgdu) {
|
||||
printf AVG "%d %s\n", $avgdu{$i}, $i;
|
||||
}
|
||||
close AVG;
|
|
@ -1,15 +0,0 @@
|
|||
# $Id: GNUmakefile,v 1.2 1998-05-31 01:20:06 hjp Exp $
|
||||
# $Log: GNUmakefile,v $
|
||||
# Revision 1.2 1998-05-31 01:20:06 hjp
|
||||
# GNUmakerules split into GNUmakerules and GNUmakevars.
|
||||
#
|
||||
|
||||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
all: errno
|
||||
|
||||
errno:
|
||||
clean:
|
||||
rm errno
|
||||
install: $(BINDIR)/errno
|
|
@ -1,34 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *cmnd;
|
||||
|
||||
static void usage(void) {
|
||||
fprintf(stderr, "Usage: %s errno ...\n", cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
|
||||
cmnd = argv[0];
|
||||
|
||||
if (argc <= 1) {
|
||||
int e;
|
||||
for (e = 0;; e++) {
|
||||
printf("%d\t%s\n", e, strerror(e));
|
||||
}
|
||||
} else {
|
||||
for (i = 1; i < argc; i++) {
|
||||
int e = strtoul(argv[i], NULL, 0);
|
||||
|
||||
printf("%d\t%s\n", e, strerror(e));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* vim:sw=4
|
||||
*/
|
|
@ -1,35 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
CONFDIR=../../configure
|
||||
CONFDIR_exists=$(shell [ -d $(CONFDIR) ] && echo ok)
|
||||
|
||||
all: configure fact
|
||||
|
||||
clean:
|
||||
rm fact customize
|
||||
|
||||
install: $(BINDIR) $(BINDIR)/fact
|
||||
|
||||
%: %.pl customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
%: %.sh customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
customize: configure
|
||||
sh ./configure
|
||||
|
||||
ifeq ($(CONFDIR_exists),ok)
|
||||
|
||||
configure: $(CONFDIR)/start $(CONFDIR)/perl $(CONFDIR)/finish
|
||||
cat $^ > $@
|
||||
|
||||
endif
|
||||
|
||||
$(BINDIR):
|
||||
mkdir -p $@
|
||||
|
||||
include GNUmakerules
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
echo "#!/bin/sh" > customize.$$
|
||||
echo "sed \\" > customize.$$
|
||||
chmod +x customize.$$
|
||||
|
||||
################################################################
|
||||
# find a working perl:
|
||||
#
|
||||
for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5
|
||||
do
|
||||
if $i -e 'exit ($] < 5.000)'
|
||||
then
|
||||
echo $i works
|
||||
perl="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$perl" ]
|
||||
then
|
||||
could not find a working perl command, sorry.
|
||||
exit 1
|
||||
fi
|
||||
echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize.$$
|
||||
|
||||
|
||||
################################################################
|
||||
# finish
|
||||
# Add trailing newline and rename temp file to final name
|
||||
#
|
||||
echo >> customize.$$
|
||||
|
||||
mv customize.$$ customize
|
||||
|
31
fact/fact.pl
31
fact/fact.pl
|
@ -1,31 +0,0 @@
|
|||
#!@@@perl@@@ -w
|
||||
use strict;
|
||||
|
||||
sub usage {
|
||||
print STDERR "Usage: $0 number\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sub fact {
|
||||
my ($n) = @_;
|
||||
|
||||
my $d = 2;
|
||||
|
||||
my @f = ();
|
||||
|
||||
while ($d <= $n) {
|
||||
if ($n % $d == 0) {
|
||||
push (@f, $d);
|
||||
$n /= $d;
|
||||
} else {
|
||||
$d++;
|
||||
}
|
||||
}
|
||||
return @f;
|
||||
}
|
||||
|
||||
if (@ARGV != 1) { usage(); }
|
||||
my @f = fact($ARGV[0]);
|
||||
print "@f\n";
|
||||
|
||||
#vim:sw=4
|
|
@ -1,9 +0,0 @@
|
|||
BINDIR=/usr/local/bin
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -ansi -pedantic -O2 -g
|
||||
fix2var: fix2var.o
|
||||
$(CC) $^ -lant -o $@
|
||||
|
||||
install: $(BINDIR)/fix2var
|
||||
$(BINDIR)/%: %
|
||||
install $< $@
|
|
@ -1,94 +0,0 @@
|
|||
char fix2var_c_rcs_id[] =
|
||||
"$Id: fix2var.c,v 1.1 1996-08-30 12:25:22 hjp Exp $";
|
||||
/*
|
||||
* fix2var - convert fixed length record data to line oriented format
|
||||
*
|
||||
* This program simply copies fixed length chunks from a file to
|
||||
* stdout. Each chunk is terminated with a '\n' character.
|
||||
* Optionally trailing white space can be stripped.
|
||||
*
|
||||
* $Log: fix2var.c,v $
|
||||
* Revision 1.1 1996-08-30 12:25:22 hjp
|
||||
* Initial release.
|
||||
*
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <ant/io.h>
|
||||
#include <ant/alloc.h>
|
||||
|
||||
char *cmnd;
|
||||
|
||||
unsigned long width = 80;
|
||||
int strip = 1;
|
||||
|
||||
void usage(void) {
|
||||
fprintf(stderr, "Usage: %s [-l width] [file ...]\n", cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
void fix2var(const char *filename) {
|
||||
FILE *fp;
|
||||
char *buf = emalloc(width+1);
|
||||
size_t rc;
|
||||
int i;
|
||||
|
||||
if (strcmp(filename, "-") == 0) {
|
||||
fp = stdin;
|
||||
} else {
|
||||
fp = efopen(filename, "r");
|
||||
}
|
||||
while ((rc = fread (buf, 1, width, fp)) != 0 && (rc != (size_t)-1)) {
|
||||
if (rc < width) {
|
||||
fprintf(stderr, "%s: warning: short record (%lu bytes)"
|
||||
" encountered\n", cmnd, (unsigned long)rc);
|
||||
}
|
||||
assert (rc <= INT_MAX);
|
||||
if (strip) {
|
||||
for (i = rc - 1; i >= 0 && isspace(buf[i]); i--);
|
||||
buf[i+1] = '\0';
|
||||
} else {
|
||||
buf[rc] = '\0';
|
||||
}
|
||||
puts(buf);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int c;
|
||||
int i;
|
||||
char *p;
|
||||
|
||||
cmnd = argv[0];
|
||||
|
||||
while ((c = getopt(argc, argv, "sw:")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
strip= 1;
|
||||
break;
|
||||
case 'w':
|
||||
width= strtoul(optarg, &p, 0);
|
||||
if (width == 0 || *p) usage();
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
if (optind == argc) {
|
||||
fix2var("-");
|
||||
} else {
|
||||
for (i = optind; i < argc; i++) {
|
||||
fix2var(argv[i]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
CC = gcc
|
||||
CFLAGS = -O2
|
||||
|
||||
BINDIR = /usr/local/bin
|
||||
|
||||
fortune: fortune.c
|
||||
$(CC) $(CFLAGS) -o fortune fortune.c -lant
|
||||
|
||||
clean:
|
||||
rm fortune core
|
||||
|
||||
install: $(BINDIR)/fortune
|
||||
|
||||
$(BINDIR)/fortune: fortune
|
||||
cp fortune $(BINDIR)/fortune
|
||||
|
|
@ -1,213 +0,0 @@
|
|||
/*
|
||||
* Fortune -- Print one fortune out of an indexed fortune file
|
||||
*/
|
||||
|
||||
static char fortune_c_rcsid[] = "$Id: fortune.c,v 3.4 1994-01-08 18:05:00 hjp Exp $";
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ant/io.h>
|
||||
#include <ant/string.h>
|
||||
#include <ant/globals.h>
|
||||
|
||||
/* The following parameters will have to be adapted to your system */
|
||||
#define DELIMITER "%%\n"
|
||||
#define MAXLINE (80 + 1 + 1)
|
||||
char * fortunefile = "/usr/lib/fortune.dat";
|
||||
char indexfile [PATH_MAX] = "/usr/lib/fortune.idx";
|
||||
#define RECLEN 4 /* length of a record in the index
|
||||
* file. This would normally be the
|
||||
* size of a long, but could be more
|
||||
* or less if you want the program
|
||||
* run on systems with different lengths
|
||||
* of a long and share the same index
|
||||
* file.
|
||||
*/
|
||||
/* The rest should be generic */
|
||||
|
||||
|
||||
|
||||
void fwritelong (FILE *fp, long offset, long value) {
|
||||
unsigned char c [RECLEN];
|
||||
|
||||
assert (value < (1UL << (8 * RECLEN - 1)));
|
||||
|
||||
if (fseek (fp, offset, SEEK_SET) != 0) {
|
||||
eprintf ("%s: cannot seek to %ld in %s: %s\n",
|
||||
cmnd, offset, indexfile, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
c [0] = value & 0xFF;
|
||||
c [1] = (value >> 8) & 0xFF;
|
||||
c [2] = (value >> 16) & 0xFF;
|
||||
c [3] = (value >> 24) & 0xFF;
|
||||
|
||||
if (fwrite (c, RECLEN, 1, fp) != 1) {
|
||||
eprintf ("%s: cannot write to %s: %s\n",
|
||||
cmnd, indexfile, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
long freadlong (FILE *fp, long offset) {
|
||||
unsigned char c [RECLEN];
|
||||
unsigned long value;
|
||||
|
||||
if (fseek (fp, offset, SEEK_SET) != 0) {
|
||||
eprintf ("%s: cannot seek to %ld in %s: %s\n",
|
||||
cmnd, offset, indexfile, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (fread (c, RECLEN, 1, fp) != 1) {
|
||||
eprintf ("%s: cannot write to %s: %s\n",
|
||||
cmnd, indexfile, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
value = c [0] + (c [1] << 8) + (c [2] << 16) + (c [3] << 24);
|
||||
return value > LONG_MAX ? - (long) (- value) : value;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(
|
||||
int argc,
|
||||
char **argv
|
||||
){
|
||||
FILE * ffp, * ifp;
|
||||
char * p;
|
||||
long pos, ipos, /* position in fortune and
|
||||
* index file
|
||||
*/
|
||||
cnt, /* Number of fortunes in the file
|
||||
*/
|
||||
nr, /* number of fortune to read */
|
||||
fortune_time; /* time the fortune file was last
|
||||
* updated.
|
||||
*/
|
||||
struct stat statbuf;
|
||||
char line [MAXLINE];
|
||||
|
||||
cmnd = argv [0];
|
||||
|
||||
if (argc >= 2){
|
||||
fortunefile = argv [1];
|
||||
strncpy (indexfile, argv [1], PATH_MAX);
|
||||
if ((p = strrchr (indexfile, '.'))) {
|
||||
strcpy (p, ".idx");
|
||||
} else {
|
||||
strcat (indexfile, ".idx");
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf ("fortunefile = \"%s\"\n", fortunefile);
|
||||
printf ("indexfile = \"%s\"\n", indexfile);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* First check if index file is younger than fortune file
|
||||
* and rebuild it if necessary.
|
||||
*/
|
||||
|
||||
if (stat (fortunefile, &statbuf) < 0) {
|
||||
eprintf ("%s: Cannot stat \"%s\": %s",
|
||||
argv [0], fortunefile, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
fortune_time = statbuf.st_mtime;
|
||||
if (stat (indexfile, &statbuf) < 0) {
|
||||
/* Index file does not exit -- force its creation
|
||||
* and pretend it is older than fortune file
|
||||
*/
|
||||
|
||||
if ((ifp = fopen (indexfile, "wb")) == NULL) {
|
||||
eprintf ("%s: Cannot fopen \"%s\": %s",
|
||||
argv [0], indexfile, strerror (errno));
|
||||
exit (3);
|
||||
}
|
||||
fclose (ifp);
|
||||
statbuf.st_mtime = 0;
|
||||
}
|
||||
if (statbuf.st_mtime < fortune_time) {
|
||||
/* Index file does either not exist or is older
|
||||
* than fortune file.
|
||||
*/
|
||||
|
||||
if ((ffp = fopen (fortunefile, "r")) == NULL) {
|
||||
eprintf ("%s: Cannot fopen \"%s\": %s",
|
||||
argv [0], fortunefile, strerror (errno));
|
||||
exit (2);
|
||||
}
|
||||
if ((ifp = fopen (indexfile, "r+b")) == NULL) {
|
||||
eprintf ("%s: Cannot fopen \"%s\": %s",
|
||||
argv [0], indexfile, strerror (errno));
|
||||
exit (3);
|
||||
}
|
||||
cnt = 0;
|
||||
fwritelong (ifp, 0, cnt);
|
||||
ipos = RECLEN * 2;
|
||||
while (fgets (line, sizeof (line), ffp)) {
|
||||
if (STREQ (line, DELIMITER)) {
|
||||
pos = ftell (ffp);
|
||||
fwritelong (ifp, ipos, pos);
|
||||
++ cnt;
|
||||
ipos += RECLEN;
|
||||
}
|
||||
}
|
||||
fwritelong (ifp, 0, cnt);
|
||||
fclose (ifp);
|
||||
fclose (ffp);
|
||||
}
|
||||
|
||||
/* Now that we have a valid index file, open it and choose a fortune
|
||||
*/
|
||||
|
||||
if ((ifp = fopen (indexfile, "r+b")) == NULL) {
|
||||
eprintf ("%s: Cannot fopen \"%s\": %s",
|
||||
argv [0], indexfile, strerror (errno));
|
||||
exit (4);
|
||||
}
|
||||
|
||||
if ((ffp = fopen (fortunefile, "r")) == NULL) {
|
||||
eprintf ("%s: Cannot fopen \"%s\": %s",
|
||||
argv [0], fortunefile, strerror (errno));
|
||||
exit (5);
|
||||
}
|
||||
|
||||
/* Get number of entries */
|
||||
cnt = freadlong (ifp, 0);
|
||||
|
||||
if (cnt == 0) {
|
||||
eprintf ("%s: empty fortune file\n", argv [0]);
|
||||
exit (6);
|
||||
}
|
||||
|
||||
nr = freadlong (ifp, RECLEN);
|
||||
nr ++;
|
||||
if (nr >= cnt) nr = 0;
|
||||
fwritelong (ifp, RECLEN, nr);
|
||||
|
||||
/* Now look for the start of the fortune in the index file */
|
||||
pos = freadlong (ifp, (nr + 2) * RECLEN);
|
||||
|
||||
/* And seek to it in the fortune file */
|
||||
fseek (ffp, pos, SEEK_SET);
|
||||
|
||||
/* write one fortune */
|
||||
while (fgets (line, sizeof (line), ffp) && ! STREQ (line, DELIMITER)) {
|
||||
fputs (line, stdout);
|
||||
}
|
||||
fclose (ifp);
|
||||
fclose (ffp);
|
||||
return 0;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
fotoindex:
|
||||
|
||||
install: /usr/local/bin/fotoindex
|
||||
|
||||
|
||||
/usr/local/man/man8/%.8: %.man
|
||||
$(INSTALL) $< $@
|
||||
|
||||
clean:
|
||||
rm -f *.gif *.jpg core foo bar baz
|
|
@ -1,57 +0,0 @@
|
|||
#!/usr/local/bin/perl
|
||||
#
|
||||
# Combine several images into an index image (e.g., for use as an imagemap).
|
||||
#
|
||||
# Usage: fotoindex [-o outputfile] [templatefile]
|
||||
#
|
||||
# The first three lines give the width and height of the thumbnails and
|
||||
# the number of thumbnails per row. The remaining lines are file names
|
||||
# of the images to be combined.
|
||||
|
||||
open(STDERR, ">/tmp/fotoindex.$$.debug");
|
||||
|
||||
$giftopnm = "/usr/local/bin/giftopnm";
|
||||
$pnmscale = "/usr/local/bin/pnmscale";
|
||||
$pbmmake = "/usr/local/bin/pbmmake";
|
||||
$pnmpaste = "/usr/local/bin/pnmpaste";
|
||||
$cjpeg = "/usr/local/bin/cjpeg";
|
||||
|
||||
if ($ARGV[0] eq "-o") {
|
||||
shift;
|
||||
$outputredirect = ">" . shift;
|
||||
}
|
||||
|
||||
@file = (<>);
|
||||
chomp(@file);
|
||||
|
||||
# Remove empty and comment lines
|
||||
for ($i = 0; $i <= $#file;) {
|
||||
if ($file[$i] =~ m/^(\#|\s*$)/ ) {
|
||||
splice(@file, $i, 1);
|
||||
} else {
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$tnw = shift(@file);
|
||||
$tnh = shift(@file);
|
||||
$fw = shift(@file);
|
||||
$fh = int(($#file + 1 + ($fw - 1)) / $fw);
|
||||
|
||||
system ("$pbmmake " . $fw * $tnw . " " . $fh * $tnh . "> /tmp/fotoindex.$$.1.pnm");
|
||||
|
||||
|
||||
for ($i = 0; $i < $fh; $i ++) {
|
||||
for ($j = 0; $j < $fw; $j++) {
|
||||
$pic = $file[$i * $fw + $j];
|
||||
if (-f $pic) {
|
||||
$cmnd = "$giftopnm $pic | $pnmscale -xysize $tnw $tnh > $pic.$$.pnm";
|
||||
system ($cmnd);
|
||||
system ("$pnmpaste $pic.$$.pnm " . $j * $tnw . " " . $i * $tnh . " /tmp/fotoindex.$$.1.pnm > /tmp/fotoindex.$$.2.pnm");
|
||||
rename ("/tmp/fotoindex.$$.2.pnm", "/tmp/fotoindex.$$.1.pnm");
|
||||
unlink ("$pic.$$.pnm");
|
||||
}
|
||||
}
|
||||
}
|
||||
system("$cjpeg -progressive /tmp/fotoindex.$$.1.pnm $outputredirect");
|
||||
unlink ("/tmp/fotoindex.$$.1.pnm");
|
|
@ -1,22 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
int main(void) {
|
||||
size_t s = 0x100000;
|
||||
size_t sum = 0;
|
||||
|
||||
while (s) {
|
||||
void *p;
|
||||
if (p = malloc(s)) {
|
||||
sum += s;
|
||||
printf("%lu - %lu\n",
|
||||
(unsigned long)s,
|
||||
(unsigned long)sum);
|
||||
sleep (1);
|
||||
memset(p, 'a', s);
|
||||
s *= 2;
|
||||
} else {
|
||||
s /= 2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
all: ieeefloat
|
||||
install: $(BINDIR)/ieeefloat
|
||||
|
||||
clean:
|
||||
rm -f *.bak *.o core ieeefloat
|
||||
|
||||
distclean: clean
|
||||
rm -f *.d
|
||||
|
||||
-include *.d
|
|
@ -1,186 +0,0 @@
|
|||
char ieeefloat_c_rcs_id[] =
|
||||
"$Id: ieeefloat.c,v 1.2 2000-02-08 17:04:37 hjp Exp $";
|
||||
/* ieeefloat: print binary representations of IEEE 754 FP numbers.
|
||||
*
|
||||
* $Log: ieeefloat.c,v $
|
||||
* Revision 1.2 2000-02-08 17:04:37 hjp
|
||||
* Added -f and -d options to force input to be float or double format.
|
||||
*
|
||||
* Revision 1.1 1998/03/20 20:09:53 hjp
|
||||
* Initial release:
|
||||
* prints arguments as strings, floats, and doubles decimal and binary.
|
||||
*
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#define BITS_FLT 32
|
||||
#define EXC_FLT 127
|
||||
#define MANT_FLT 23
|
||||
#define SIGN_FLT ((floatint)1<<(BITS_FLT-1))
|
||||
|
||||
#define BITS_DBL 64
|
||||
#define EXC_DBL 1023
|
||||
#define MANT_DBL 52
|
||||
#define SIGN_DBL ((doubleint)1<<(BITS_DBL-1))
|
||||
|
||||
#if ULONG_MAX/2+1 == (1UL << (BITS_FLT-1))
|
||||
typedef unsigned long int floatint;
|
||||
#elif UINT_MAX/2+1 == (1U << (BITS_FLT-1))
|
||||
typedef unsigned int floatint;
|
||||
#else
|
||||
#error "no integral type with BITS_FLT bits"
|
||||
#endif
|
||||
|
||||
#if ULONG_MAX/2+1 == (1UL << (BITS_DBL-1))
|
||||
typedef unsigned long int doubleint;
|
||||
#else
|
||||
/* We cannot portably test for the existance of long long.
|
||||
* If it doesn't exist, either the compiler or sanitychecks
|
||||
* will complain
|
||||
*/
|
||||
typedef unsigned long long int doubleint;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
char *cmnd;
|
||||
|
||||
|
||||
static void usage(void) {
|
||||
fprintf(stderr, "Usage: %s [-f|-d] fp-number ...\n", cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
static void printbinary (doubleint b, int d) {
|
||||
while (--d >= 0) {
|
||||
putchar('0' + ((b >> d) & 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void printfloat(float f) {
|
||||
union {
|
||||
floatint i;
|
||||
float f;
|
||||
} u;
|
||||
floatint e;
|
||||
floatint m;
|
||||
|
||||
u.f = f;
|
||||
|
||||
printf("%24.7g: ", f);
|
||||
printf("%c ", (u.i & SIGN_FLT) ? '-' : '+');
|
||||
u.i &= ~SIGN_FLT;
|
||||
e = u.i >> MANT_FLT;
|
||||
printf(" ");
|
||||
printbinary(e, BITS_FLT-1-MANT_FLT);
|
||||
|
||||
m = (u.i & (((floatint)1 << MANT_FLT) - 1));
|
||||
if (e == 0) { /* denormalized */
|
||||
printf(" [0.]");
|
||||
} else {
|
||||
printf(" [1.]");
|
||||
}
|
||||
printbinary(m, MANT_FLT);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
static void printdouble(double f) {
|
||||
union {
|
||||
doubleint i;
|
||||
double f;
|
||||
} u;
|
||||
doubleint e;
|
||||
doubleint m;
|
||||
|
||||
u.f = f;
|
||||
|
||||
printf("%24.17g: ", f);
|
||||
printf("%c ", (u.i & SIGN_DBL) ? '-' : '+');
|
||||
u.i &= ~SIGN_DBL;
|
||||
e = u.i >> MANT_DBL;
|
||||
printbinary(e, BITS_DBL-1-MANT_DBL);
|
||||
|
||||
m = (u.i & (((doubleint)1 << MANT_DBL) - 1));
|
||||
if (e == 0) {
|
||||
printf(" [0.]");
|
||||
} else {
|
||||
printf(" [1.]");
|
||||
}
|
||||
printbinary(m, MANT_DBL);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
static void sanitychecks(void) {
|
||||
union {
|
||||
floatint i;
|
||||
float f;
|
||||
} fu;
|
||||
union {
|
||||
doubleint i;
|
||||
double f;
|
||||
} du;
|
||||
|
||||
/* size */
|
||||
assert (sizeof(floatint) == sizeof(float));
|
||||
assert (sizeof(doubleint) == sizeof(double));
|
||||
|
||||
/* some numbers */
|
||||
fu.f = 0;
|
||||
assert (fu.i == 0);
|
||||
du.f = 0;
|
||||
assert (du.i == 0);
|
||||
|
||||
fu.f = 1.0;
|
||||
assert (fu.i == (floatint)(0 + EXC_FLT) << MANT_FLT);
|
||||
du.f = 1.0;
|
||||
assert (du.i == (doubleint)(0 + EXC_DBL) << MANT_DBL);
|
||||
|
||||
fu.f = 1.5;
|
||||
assert (fu.i ==
|
||||
(((floatint)(0 + EXC_FLT) << MANT_FLT) | (1 << (MANT_FLT-1))));
|
||||
du.f = 1.5;
|
||||
assert (du.i ==
|
||||
(((doubleint)(0 + EXC_DBL) << MANT_DBL) | ((doubleint)1 << (MANT_DBL-1))));
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char**argv) {
|
||||
int i;
|
||||
int convfloat = 0;
|
||||
char *p;
|
||||
|
||||
cmnd = argv[0];
|
||||
sanitychecks();
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
double d;
|
||||
if (strcmp(argv[i], "-f") == 0) {
|
||||
convfloat = 1;
|
||||
continue;
|
||||
} else if (strcmp(argv[i], "-d") == 0) {
|
||||
convfloat = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
d = strtod(argv[i], &p);
|
||||
if (p && *p) usage();
|
||||
|
||||
if (convfloat) {
|
||||
d = (float) d;
|
||||
}
|
||||
printf("%s\n", argv[i]);
|
||||
printdouble(d);
|
||||
printfloat(d);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
all: lspath
|
||||
|
||||
clean:
|
||||
rm lspath customize
|
||||
|
||||
install: $(BINDIR) $(BINDIR)/lspath
|
||||
|
||||
%: %.pl customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
%: %.sh customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
customize: configure
|
||||
sh ./configure
|
||||
|
||||
$(BINDIR):
|
||||
mkdir -p $@
|
||||
|
||||
include GNUmakerules
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
echo "#!/bin/sh" > customize.$$
|
||||
echo "sed \\" > customize.$$
|
||||
chmod +x customize.$$
|
||||
|
||||
################################################################
|
||||
# find a working perl:
|
||||
#
|
||||
for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5
|
||||
do
|
||||
if $i -e 'exit ($] < 5.000)'
|
||||
then
|
||||
echo $i works
|
||||
perl="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$perl" ]
|
||||
then
|
||||
could not find a working perl command, sorry.
|
||||
exit 1
|
||||
fi
|
||||
echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize.$$
|
||||
|
||||
|
||||
################################################################
|
||||
# finish
|
||||
# Add trailing newline and rename temp file to final name
|
||||
#
|
||||
echo >> customize.$$
|
||||
|
||||
mv customize.$$ customize
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#!@@@perl@@@ -w
|
||||
use strict;
|
||||
|
||||
|
||||
for my $p (@ARGV) {
|
||||
|
||||
my @p = split (/\//, $p);
|
||||
for (my $i = 0; $i < scalar(@p); $i++) {
|
||||
my $pp = join("/", @p[0..$i]);
|
||||
$pp = "/" if $pp eq "";
|
||||
|
||||
system("/bin/ls", "-ldi", $pp);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
all: mailsummary
|
||||
|
||||
clean:
|
||||
rm -f mailsummary *.bak
|
||||
|
||||
distclean: clean
|
||||
rm -f customize
|
||||
|
||||
install: $(BINDIR) $(BINDIR)/mailsummary
|
||||
|
||||
%: %.pl customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
%: %.sh customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
customize: configure
|
||||
sh ./configure
|
||||
|
||||
$(BINDIR):
|
||||
mkdir -p $@
|
||||
|
||||
include GNUmakerules
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
echo "#!/bin/sh" > customize
|
||||
echo "sed \\" > customize
|
||||
chmod +x customize
|
||||
|
||||
################################################################
|
||||
# find a working perl:
|
||||
#
|
||||
for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5
|
||||
do
|
||||
if $i -e 'exit ($] < 5.000)'
|
||||
then
|
||||
echo $i works
|
||||
perl="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$perl" ]
|
||||
then
|
||||
could not find a working perl command, sorry.
|
||||
exit 1
|
||||
fi
|
||||
echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize
|
||||
|
||||
|
||||
################################################################
|
||||
# finish:
|
||||
# add a blank line to customize
|
||||
echo >> customize
|
|
@ -1,85 +0,0 @@
|
|||
#!@@@perl@@@
|
||||
|
||||
%mon2num = (
|
||||
Jan => 1,
|
||||
Feb => 2,
|
||||
Mar => 3,
|
||||
Apr => 4,
|
||||
May => 5,
|
||||
Jun => 6,
|
||||
Jul => 7,
|
||||
Aug => 8,
|
||||
Sep => 9,
|
||||
Oct => 10,
|
||||
Nov => 11,
|
||||
Dec => 12
|
||||
);
|
||||
$header = 0;
|
||||
|
||||
foreach $f (@ARGV) {
|
||||
if (!open(F, $f)) {next};
|
||||
$header = 1;
|
||||
$from = "";
|
||||
$date = "";
|
||||
$subject = "";
|
||||
$to = "";
|
||||
|
||||
while (<F>) {
|
||||
if (/^From ([^ ]*) /) {
|
||||
$from = $1;
|
||||
$header = 1;
|
||||
if (/
|
||||
(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s)?
|
||||
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s
|
||||
([0-9]?[0-9])\s
|
||||
([0-9]?[0-9]:[0-9][0-9]:[0-9][0-9])\s
|
||||
(19[0-9][0-9])
|
||||
/x) {
|
||||
$date = sprintf("%04d-%02d-%02d %8s", $4, $mon2num{$1}, $2, $3);
|
||||
} else {
|
||||
$date = "XXXX-XX-XX XX:XX:XX";
|
||||
}
|
||||
} elsif ($header && /^Date:/) {
|
||||
# Thu, 22 May 1997 16:49:23 +0200
|
||||
if (/^Date:\s+
|
||||
(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s+)?
|
||||
([0-9]?[0-9])\s
|
||||
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s
|
||||
(19[0-9][0-9])\s+
|
||||
([0-9]?[0-9]:[0-9][0-9]:[0-9][0-9])/x) {
|
||||
$date = sprintf("%04d-%02d-%02d %8s", $3, $mon2num{$2}, $1, $4);
|
||||
} elsif (/^Date:\s+
|
||||
(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s+)?
|
||||
([0-9]?[0-9])\s
|
||||
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s
|
||||
([7-9][0-9])\s+
|
||||
([0-9]?[0-9]:[0-9][0-9]:[0-9][0-9])/x) {
|
||||
$date = sprintf("%04d-%02d-%02d %8s", 1900 + $3, $mon2num{$2}, $1, $4);
|
||||
} else {
|
||||
print "bad date: $_\n";
|
||||
}
|
||||
} elsif ($header && /^To:/) {
|
||||
if (/^To:\s+(.*)/) {
|
||||
$to = $1;
|
||||
} else {
|
||||
print "bad to: $_\n";
|
||||
}
|
||||
} elsif ($header && /^Subject:/) {
|
||||
if (/^Subject:\s+(.*)/) {
|
||||
$subject = $1;
|
||||
} else {
|
||||
print "bad subject: $_\n";
|
||||
}
|
||||
} elsif ($header && /^From:/) {
|
||||
if (/^From:\s+(.*)/) {
|
||||
$from = $1;
|
||||
} else {
|
||||
print "bad from: $_\n";
|
||||
}
|
||||
} elsif ($header && /^$/) {
|
||||
print "$date\t$f\t$from\t$to\t$subject\n";
|
||||
$header=0;
|
||||
}
|
||||
}
|
||||
close(F);
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
BINDIR=/usr/local/sbin
|
||||
|
||||
include GNUmakerules
|
||||
|
||||
memlog:
|
||||
|
||||
install: $(BINDIR)/memlog
|
||||
|
||||
clean:
|
||||
:
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/sh
|
||||
now=`/bin/date '+%Y-%m-%dT%H:%M:%S'`
|
||||
egrep -i '^[a-z]+: +[0-9]+ kB$' /proc/meminfo |\
|
||||
while read a
|
||||
do
|
||||
echo "$now $a"
|
||||
done >> /var/log/memlog
|
|
@ -1,75 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
use MIME::Parser;
|
||||
|
||||
#------------------------------
|
||||
#
|
||||
# dump_entity ENTITY, NAME
|
||||
#
|
||||
# Recursive routine for dumping an entity.
|
||||
#
|
||||
sub dump_entity {
|
||||
my ($entity, $level) = @_;
|
||||
my $IO;
|
||||
|
||||
$entity->head->unfold;
|
||||
|
||||
# Output the head:
|
||||
$subject = $entity->head->get('subject') || "";
|
||||
if ($subject) {
|
||||
chomp($subject);
|
||||
print ' ' x $level, "Subject: ", $subject, "\n";
|
||||
}
|
||||
$from = $entity->head->get('from') || "";
|
||||
if ($from) {
|
||||
chomp($from);
|
||||
print ' ' x $level, "From: ", $from, "\n";
|
||||
}
|
||||
|
||||
# Output the body:
|
||||
my @parts = $entity->parts;
|
||||
if (@parts) { # multipart...
|
||||
my $i;
|
||||
foreach $i (0 .. $#parts) { # dump each part...
|
||||
dump_entity($parts[$i], $level + 1);
|
||||
}
|
||||
}
|
||||
else { # single part...
|
||||
|
||||
# Get MIME type, and display accordingly...
|
||||
my ($type, $subtype) = split('/', $entity->head->mime_type);
|
||||
my $body = $entity->bodyhandle;
|
||||
my $size = length($body->as_string);
|
||||
print ' ' x $level, "Content-type: $type/$subtype ($size bytes)\n";
|
||||
}
|
||||
1;
|
||||
}
|
||||
|
||||
#------------------------------
|
||||
#
|
||||
# main
|
||||
#
|
||||
sub main {
|
||||
|
||||
# Create a new MIME parser:
|
||||
my $parser = new MIME::Parser;
|
||||
|
||||
# Create and set the output directory:
|
||||
(-d ".mimedump-tmp") or mkdir ".mimedump-tmp",0700 or die "mkdir: $!";
|
||||
(-w ".mimedump-tmp") or die "can't write to directory";
|
||||
$parser->output_dir(".mimedump-tmp");
|
||||
$parser->output_to_core(ALL);
|
||||
|
||||
# Read the MIME message:
|
||||
$entity = $parser->read(\*STDIN) or die "couldn't parse MIME stream";
|
||||
|
||||
# Dump it out:
|
||||
dump_entity($entity, 0);
|
||||
}
|
||||
exit(&main ? 0 : -1);
|
||||
|
||||
#------------------------------
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
$spooldir = "/usr/adm/motd";
|
||||
$motdfile = "/etc/motd";
|
||||
|
||||
chdir $spooldir || die "cannot chdir to $spooldir";
|
||||
|
||||
# build a list of files in the spool directory
|
||||
opendir DIR, "." || die "cannot open `.'";
|
||||
@files = readdir (DIR);
|
||||
closedir (DIR);
|
||||
|
||||
open MOTD, ">$motdfile" || die "cannot open $motdfile";
|
||||
|
||||
foreach $thisfile (@files) {
|
||||
if (-f $thisfile) {
|
||||
$nonempty=1;
|
||||
print MOTD "\n------------------------------------------------------------\n";
|
||||
open THISFILE, $thisfile || die "cannot open $thisfile";
|
||||
while ($line = <THISFILE>) {
|
||||
print MOTD $line;
|
||||
}
|
||||
close THISFILE;
|
||||
}
|
||||
}
|
||||
if ($nonempty) {
|
||||
print MOTD "\n------------------------------------------------------------\n";
|
||||
}
|
||||
system "/usr/local/bin/ci -l -q $motdfile" || die;
|
||||
exit (0);
|
|
@ -1,9 +0,0 @@
|
|||
map [18~ :cp
|
||||
map [19~ :cn
|
||||
set autoindent
|
||||
set errorformat=%f:%l:%m
|
||||
set exrc
|
||||
set number
|
||||
set ruler
|
||||
set shiftwidth=4
|
||||
set textwidth=72
|
|
@ -1,8 +0,0 @@
|
|||
include GNUmakerules
|
||||
|
||||
all: obwrap
|
||||
|
||||
errno:
|
||||
clean:
|
||||
rm obwrap
|
||||
install: $(BINDIR)/obwrap
|
|
@ -1,94 +0,0 @@
|
|||
char obwrap_c_rcsid[] =
|
||||
"$Id: ";
|
||||
/* obwrap - wrapper for omniback scripts
|
||||
*
|
||||
* Omniback leaves a lot of file descriptors open when executing its
|
||||
* pre- and post-backup scripts. This means that any program started
|
||||
* from such a script (e.g., oracle) will have open file descriptors
|
||||
* on /var/opt/omni, which is a bad thing.
|
||||
* This program closes all file descriptors except stdin and stdout,
|
||||
* changes uid (if -u is given) and executes the specified program.
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define nonstderr stdout /* Omniback bogosity */
|
||||
|
||||
char *cmnd;
|
||||
|
||||
void usage(void) {
|
||||
fprintf(stderr, "Usage: %s [-u user] path arg0 ...\n", cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
int c;
|
||||
int open_max = sysconf(_SC_OPEN_MAX);
|
||||
|
||||
cmnd = argv[0];
|
||||
|
||||
while ((c = getopt(argc, argv, "u:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'u': {
|
||||
char *p;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
|
||||
uid = strtol(optarg, &p, 0);
|
||||
if (*p != '\0') {
|
||||
struct passwd *pwd = getpwnam(optarg);
|
||||
if (!pwd) {
|
||||
fprintf(nonstderr, "%s: no user %s\n", cmnd, optarg);
|
||||
exit(1);
|
||||
}
|
||||
initgroups(optarg, pwd->pw_gid);
|
||||
setresgid(pwd->pw_gid, pwd->pw_gid, pwd->pw_gid);
|
||||
if (getgid() != pwd->pw_gid) {
|
||||
fprintf(nonstderr, "%s: could not set gid %d (still %d)\n", cmnd, pwd->pw_gid, getgid());
|
||||
exit(1);
|
||||
}
|
||||
if (getegid() != pwd->pw_gid) {
|
||||
fprintf(nonstderr, "%s: could not set egid %d (still %d)\n", cmnd, pwd->pw_gid, getgid());
|
||||
exit(1);
|
||||
}
|
||||
uid = pwd->pw_uid;
|
||||
|
||||
}
|
||||
setresuid(uid, uid, uid);
|
||||
if (getuid() != uid) {
|
||||
fprintf(nonstderr, "%s: could not set uid %d (still %d)\n", cmnd, uid, getuid());
|
||||
exit(1);
|
||||
}
|
||||
if (geteuid() != uid) {
|
||||
fprintf(nonstderr, "%s: could not set euid %d (still %d)\n", cmnd, uid, geteuid());
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
usage();
|
||||
|
||||
}
|
||||
}
|
||||
if (optind == argc) usage();
|
||||
|
||||
for (i = 2; i < open_max; i++) {
|
||||
close(i);
|
||||
}
|
||||
|
||||
dup2(1, 2);
|
||||
|
||||
execv(argv[optind], argv + optind + 1);
|
||||
fprintf(nonstderr, "%s: could not exec %s: %s\n",
|
||||
cmnd, argv[optind], strerror(errno));
|
||||
exit(1);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
CONFDIR=../../configure
|
||||
|
||||
all: configure oragetsrc
|
||||
|
||||
clean:
|
||||
rm oragetsrc customize
|
||||
|
||||
install: $(BINDIR) $(BINDIR)/oragetsrc
|
||||
|
||||
%: %.pl customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
%: %.sh customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
customize: configure
|
||||
sh ./configure
|
||||
|
||||
configure: $(CONFDIR)/start $(CONFDIR)/perl $(CONFDIR)/finish
|
||||
cat $^ > $@
|
||||
|
||||
$(BINDIR):
|
||||
mkdir -p $@
|
||||
|
||||
include GNUmakerules
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
echo "#!/bin/sh" > customize.$$
|
||||
echo "sed \\" > customize.$$
|
||||
chmod +x customize.$$
|
||||
|
||||
################################################################
|
||||
# find a working perl:
|
||||
#
|
||||
for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5
|
||||
do
|
||||
if $i -e 'exit ($] < 5.000)'
|
||||
then
|
||||
echo $i works
|
||||
perl="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$perl" ]
|
||||
then
|
||||
could not find a working perl command, sorry.
|
||||
exit 1
|
||||
fi
|
||||
echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize.$$
|
||||
|
||||
|
||||
################################################################
|
||||
# finish
|
||||
# Add trailing newline and rename temp file to final name
|
||||
#
|
||||
echo >> customize.$$
|
||||
|
||||
mv customize.$$ customize
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#!@@@perl@@@ -w
|
||||
|
||||
# $Id: oragetsrc.pl,v 1.1 2001-02-12 14:32:43 hjp Exp $
|
||||
#
|
||||
# print a named source (e.g, a function or procedure) from an oracle schema
|
||||
#
|
||||
use strict;
|
||||
use DBI;
|
||||
|
||||
sub read_cred {
|
||||
my ($fn) = @_;
|
||||
|
||||
open(FN, "<$fn") or die "cannot open $fn: $!";
|
||||
my $line = <FN>;
|
||||
close(FN);
|
||||
my @cred = split(/[\s\n]/, $line);
|
||||
return @cred;
|
||||
}
|
||||
|
||||
if (@ARGV != 2) {
|
||||
print STDERR "Usage: $0 credential_file source_name\n";
|
||||
print STDERR "\tcredential_file is a filename relative to \$HOME/.dbi/\n";
|
||||
print STDERR "\tThe file must contain a single line with three whitespace-separated fields:\n";
|
||||
print STDERR "\tDBI data source, username, password.\n";
|
||||
print STDERR "\te.g:\n";
|
||||
print STDERR "\tdbi:Oracle:ORCL scott tiger\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
|
||||
my $db_name = $ARGV[0];
|
||||
my $src_name = $ARGV[1];
|
||||
|
||||
my @cred = read_cred("$ENV{HOME}/.dbi/$ARGV[0]");
|
||||
my $dbh = DBI->connect($cred[0], $cred[1], $cred[2],
|
||||
{ RaiseError => 1, AutoCommit => 0 });
|
||||
|
||||
my $lines =
|
||||
$dbh->selectcol_arrayref(
|
||||
"select text from user_source where name=? order by line",
|
||||
{},
|
||||
$src_name
|
||||
);
|
||||
|
||||
for my $i (@$lines) {
|
||||
print "$i";
|
||||
}
|
||||
$dbh->disconnect();
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
prwtmp:
|
||||
|
||||
install: $(ROOT)/usr/local/bin/prwtmp $(ROOT)/usr/local/man/man8/prwtmp.8
|
||||
|
||||
install_all:
|
||||
$(MAKE) install ROOT=/nfs/wsrdb
|
||||
$(MAKE) install ROOT=/nfs/wsrcom
|
||||
$(MAKE) install ROOT=/nfs/wifosv
|
||||
$(MAKE) install ROOT=/nfs/ihssv
|
||||
$(MAKE) install ROOT=/nfs/wsrtest
|
||||
|
||||
$(ROOT)/usr/local/bin/%: %
|
||||
$(INSTALL) $< $@
|
||||
|
||||
$(ROOT)/usr/local/man/man8/%.8: %.man
|
||||
$(INSTALL) $< $@
|
||||
|
||||
clean:
|
||||
rm prwtmp
|
110
prwtmp/prwtmp.c
110
prwtmp/prwtmp.c
|
@ -1,110 +0,0 @@
|
|||
char prwtmp_c_rcs_id[] =
|
||||
"$Id: prwtmp.c,v 1.2 1998-05-28 16:18:21 hjp Exp $";
|
||||
/*
|
||||
* prwtmp - print wtmp to stdout
|
||||
*
|
||||
* $Log: prwtmp.c,v $
|
||||
* Revision 1.2 1998-05-28 16:18:21 hjp
|
||||
* use GNUmakerules/GNUmakevars for CC and INSTALL.
|
||||
* Bug fix: initial offset wasn't initialized
|
||||
* Bug fix: #include <unistd.h> and a cast (both needed for glibc2)
|
||||
*
|
||||
* Revision 1.1 1997/01/13 14:59:40 hjp
|
||||
* Checked into CVS.
|
||||
* Added -o and -s options.
|
||||
*
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <utmp.h>
|
||||
|
||||
char *cmnd;
|
||||
|
||||
void usage(void) {
|
||||
fprintf(stderr, "Usage: %s [-o] [-s start] [file]\n", cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
FILE *fp;
|
||||
struct utmp u;
|
||||
char *filename = WTMP_FILE;
|
||||
long off = 0;
|
||||
int print_offset = 0;
|
||||
int c;
|
||||
char *p;
|
||||
|
||||
cmnd = argv[0];
|
||||
while ((c = getopt(argc, argv, "s:o")) != EOF) {
|
||||
switch(c) {
|
||||
case 's':
|
||||
off = strtoul(optarg, &p, 0);
|
||||
if (p == optarg || *p != '\0') usage();
|
||||
break;
|
||||
case 'o':
|
||||
print_offset = 1;
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > optind) filename = argv[optind];
|
||||
|
||||
fp = fopen(filename, "rb");
|
||||
if (!fp) {
|
||||
fprintf(stderr, "%s: cannot open %s: %s\n",
|
||||
cmnd, filename, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if (fseek(fp, off, SEEK_SET) == -1) {
|
||||
fprintf(stderr, "%s: cannot seek to %ld on %s: %s\n",
|
||||
cmnd, off, filename, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (fread(&u, (int)sizeof(u), 1, fp) == 1) {
|
||||
char tbuf[20];
|
||||
|
||||
if (print_offset) printf ("%8ld: ", off);
|
||||
off += sizeof(u);
|
||||
|
||||
strftime(tbuf, (int)sizeof(tbuf), "%Y-%m-%d %H:%M:%S",
|
||||
localtime(&u.ut_time));
|
||||
printf("%s ", tbuf);
|
||||
printf("%-*.*s ",
|
||||
(int)sizeof(u.ut_user),
|
||||
(int)sizeof(u.ut_user),
|
||||
u.ut_user);
|
||||
printf("%-*.*s ",
|
||||
(int)sizeof(u.ut_id),
|
||||
(int)sizeof(u.ut_id),
|
||||
u.ut_id);
|
||||
printf("%-*.*s ",
|
||||
(int)sizeof(u.ut_line),
|
||||
(int)sizeof(u.ut_line),
|
||||
u.ut_line);
|
||||
printf("%5d ", (int)u.ut_pid); /* PID is typically < 30000 */
|
||||
printf("%5d ", (int)u.ut_type); /* short on HP-UX */
|
||||
printf("%5d ", (int)u.ut_exit.e_termination); /* short on HP-UX */
|
||||
printf("%5d ", (int)u.ut_exit.e_exit); /* short on HP-UX */
|
||||
printf("%-*.*s ",
|
||||
(int)sizeof(u.ut_host),
|
||||
(int)sizeof(u.ut_host),
|
||||
u.ut_host);
|
||||
printf("%08lx", (unsigned long)u.ut_addr);
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
.\" $Header: /usr/local/src/master/simple/prwtmp/prwtmp.man,v 1.1 1997-01-13 14:59:41 hjp Exp $
|
||||
.TH prwtmp 8
|
||||
.SH NAME
|
||||
prwtmp \- print contents of wtmp file
|
||||
.SH SYNOPSIS
|
||||
.C prwtmp
|
||||
.RC [ \-o ]
|
||||
.RC [ \-s start ]
|
||||
.RC [ file ]
|
||||
.SH DESCRIPTION
|
||||
.C prwtmp
|
||||
interpretes
|
||||
.I file
|
||||
(default is the system wtmp file, normally /etc/wtmp, /var/log/wtmp, or
|
||||
/var/adm/wtmp) as a
|
||||
wtmp file and prints one line to stdout for each record.
|
||||
If the
|
||||
.B \-o
|
||||
Option is given, each record is preceded by a decimal byte offset.
|
||||
If the
|
||||
.B -s
|
||||
Option is given, processing starts at the given byte offset instead of
|
||||
the beginning of the file.
|
||||
.SH RETURN VALUE
|
||||
Exit values are:
|
||||
.RS 3
|
||||
.TP 8
|
||||
.B \00
|
||||
Successful completion.
|
||||
.PD 0
|
||||
.TP
|
||||
.B >0
|
||||
Error condition occurred.
|
||||
.RE
|
||||
.PD
|
||||
.SH FILES
|
||||
.TP
|
||||
.B /etc/wtmp
|
||||
.B /var/adm/wtmp
|
||||
.B /var/log/wtmp
|
||||
Default wtmp file (depends on OS).
|
||||
.SH BUGS
|
||||
None known. There are a few improvements planned, though:
|
||||
An option to print the file in reverse (like last(1M), but without
|
||||
coalescing matching records). Some way to select records or columns.
|
||||
NLS support would be nice, too.
|
||||
.SH SEE ALSO
|
||||
last(1M)
|
|
@ -1,16 +1,22 @@
|
|||
#!@@@perl@@@
|
||||
#!@@@perl@@@ -w
|
||||
|
||||
use strict;
|
||||
|
||||
use Getopt::Std;
|
||||
my $time=time;
|
||||
my @time=localtime($time);
|
||||
my $hostname;
|
||||
|
||||
sub warnmsg {
|
||||
my ($mount, $usage, $soft, $hard, $grace, $unit) = @_;
|
||||
%dosdrv = (
|
||||
my ($mount, $usage, $soft, $hard, $grace, $unit, $user) = @_;
|
||||
my %dosdrv = (
|
||||
'/wifosv/dosprogs' => 'H:',
|
||||
'/wsrdb/users' => 'J:',
|
||||
'/wifosv/users' => 'K:',
|
||||
'/usr/local/www' => 'W:',
|
||||
);
|
||||
|
||||
my $wo;
|
||||
if ($dosdrv{$mount}) {
|
||||
$wo = 'Netzplatte ' . $dosdrv{$mount};
|
||||
} else {
|
||||
|
@ -19,7 +25,7 @@ sub warnmsg {
|
|||
|
||||
|
||||
my $msg = "Sie haben auf $wo Ihr in Disk Quotas gesetztes Limit\n" .
|
||||
"überschritten. ";
|
||||
"überschritten. \n";
|
||||
|
||||
if ($grace eq "EXPIRED" or $usage >= $hard-2) {
|
||||
$msg .= "Sie können dort KEINE Files mehr anlegen.\n" ;
|
||||
|
@ -29,10 +35,19 @@ sub warnmsg {
|
|||
$msg .= "Sie können noch " .
|
||||
(int (($hard - $usage) * 10 + 0.5) / 10) . " $unit anlegen.\n" ;
|
||||
}
|
||||
my $mount_t = $mount;
|
||||
$mount_t =~ s|/|_|g;
|
||||
|
||||
$msg .= "\nBei dringendem Bedarf können Sie sofort zusätzlichen Platz schaffen,\n" .
|
||||
"indem Sie auf $wo Files löschen, komprimieren oder auf eine\n" .
|
||||
"andere Netzplatte verschieben.\n" .
|
||||
"\n" .
|
||||
"Sie können sich Ihre Verbrauchsgraphen unter\n" .
|
||||
"http://sww.wsr.ac.at/intranet/quotas/$user$mount_t.gif ansehen. \n" .
|
||||
"Die Quotas die Sie verwendet haben werden rot angezeigt. Außerdem zeigen\n" .
|
||||
"die Softquotas, die Grenze an, die Sie überschritten haben und die Hardquotas\n" .
|
||||
"die Obergrenze, die Sie nicht überschreiten können. \n" .
|
||||
"\n" .
|
||||
"Lassen Sie sich bei Gelegenheit auch von einem der zuständigen\n" .
|
||||
"Systemadministratoren unterstützen:\n" .
|
||||
"Peter Holzer, hjp\@wsr.ac.at, Kl. 786\n" .
|
||||
|
@ -40,61 +55,23 @@ sub warnmsg {
|
|||
return $msg;
|
||||
}
|
||||
|
||||
getopts('ad', \%opts);
|
||||
my %opts;
|
||||
|
||||
$hostname=`hostname`;
|
||||
chomp($hostname);
|
||||
open (DF, "@@@df@@@ |") or die "cannot call @@@df@@@: $!";
|
||||
sub sendmail
|
||||
{
|
||||
my ($user, $msg, $mount) = @_;
|
||||
|
||||
$fs = $/;
|
||||
undef ($/);
|
||||
$df = <DF>;
|
||||
close(DF);
|
||||
$/ = $fs;
|
||||
|
||||
$df =~ s/\n[ \t]+/ /mg;
|
||||
@df = split(/\n/, $df);
|
||||
for $ln (@df) {
|
||||
($fs, $total, $used, $free, $pct, $mount) = split(/\s+/, $ln);
|
||||
if ($fs =~ m|^/dev/|) {
|
||||
open REPQUOTA, "@@@repquota@@@ $mount 2>/dev/null |" or die "cannot call @@@repquota@@@: $!";
|
||||
while (<REPQUOTA>) {
|
||||
$msg = "";
|
||||
if (/(\w+) \s+ -- \s*
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+
|
||||
(\d+)\s+(\d+)\s+(\d+)
|
||||
/x) {
|
||||
#print "ok: $1\n";
|
||||
} elsif (/(\w+) \s+ \+- \s*
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))\s+
|
||||
(\d+)\s+(\d+)\s+(\d+)
|
||||
/x) {
|
||||
print "block limit: $1: $2 > ($3 $4) $5\n";
|
||||
$user = $1;
|
||||
$msg = warnmsg($mount, $2/1024, $3/1024, $4/1024, $5/1024, "MB");
|
||||
|
||||
} elsif (/(\w+) \s+ -\+ \s*
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))
|
||||
/x) {
|
||||
print "file limit: $1: $5 > ($6 $7) $8\n";
|
||||
$user = $1;
|
||||
$msg = warnmsg($mount, $5, $6, $7, $8, "Files");
|
||||
} elsif (/(\w+) \s+ \+\+ \s*
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))\s+
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))
|
||||
/x) {
|
||||
print "block limit: $1: $2 > ($3 $4) $5\n";
|
||||
$user = $1;
|
||||
$msg = warnmsg($mount, $2/1024, $3/1024, $4/1024, $5/1024, "MB");
|
||||
print "file limit: $1: $6 > ($7 $8) $9\n";
|
||||
$msg .= "\n\n" . warnmsg($mount, $6, $7, $8, $9, "Files");
|
||||
} else {
|
||||
if ($. > 2) { # ignore header lines
|
||||
print "$mount: $.: unparseable: $_";
|
||||
my @startgraph=
|
||||
("/usr/local/dfstat/quotagraph",
|
||||
"--fs=$mount",
|
||||
"--user=$user",
|
||||
"--data=b",
|
||||
glob("/usr/local/dfstat/quota.stat.????-??")
|
||||
);
|
||||
if (system (@startgraph) != 0) {
|
||||
die "cannot execute @startgraph";
|
||||
}
|
||||
}
|
||||
if ($msg) {
|
||||
|
||||
if ($opts{'d'}) {
|
||||
open (SENDMAIL, ">&1");
|
||||
} else {
|
||||
|
@ -107,12 +84,93 @@ for $ln (@df) {
|
|||
print SENDMAIL "To: <$user\@wsr.ac.at>\r\n";
|
||||
print SENDMAIL "Cc: <system\@wsr.ac.at>\r\n";
|
||||
print SENDMAIL "Subject: Disk Quotas überschritten\r\n";
|
||||
|
||||
}
|
||||
print SENDMAIL "Reply-To: <system\@wsr.ac.at>\r\n";
|
||||
print SENDMAIL "\r\n";
|
||||
print SENDMAIL "$msg\r\n";
|
||||
}
|
||||
|
||||
getopts('ad', \%opts);
|
||||
|
||||
$hostname=`hostname`;
|
||||
chomp($hostname);
|
||||
open (DF, "@@@df@@@ |") or die "cannot call @@@df@@@: $!";
|
||||
|
||||
my $fs = $/;
|
||||
undef ($/);
|
||||
my $df = <DF>;
|
||||
close(DF);
|
||||
$/ = $fs;
|
||||
|
||||
$df =~ s/\n[ \t]+/ /mg;
|
||||
my @df = split(/\n/, $df);
|
||||
for my $ln (@df) {
|
||||
my ($fs, $total, $used, $free, $pct, $mount) = split(/\s+/, $ln);
|
||||
if ($fs =~ m|^/dev/|) {
|
||||
open REPQUOTA, "@@@repquota@@@ $mount 2>/dev/null |" or die "cannot call @@@repquota@@@: $!";
|
||||
while (<REPQUOTA>) {
|
||||
my $msg = "";
|
||||
my $user;
|
||||
if (/(\w+) \s+ -- \s*
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+
|
||||
(\d+)\s+(\d+)\s+(\d+)
|
||||
/x) {
|
||||
#print "ok: $1\n";
|
||||
} elsif (/(\w+) \s+ \+- \s*
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))\s+
|
||||
(\d+)\s+(\d+)\s+(\d+)
|
||||
/x) {
|
||||
print "block limit: $1: $2 > ($3 $4) $5\n";
|
||||
$user = $1;
|
||||
$msg = warnmsg($mount, $2/1024, $3/1024, $4/1024, $5, "MB", $user);
|
||||
|
||||
} elsif (/(\w+) \s+ -\+ \s*
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))
|
||||
/x) {
|
||||
print "file limit: $1: $5 > ($6 $7) $8\n";
|
||||
$user = $1;
|
||||
$msg = warnmsg($mount, $5, $6, $7, $8, "Files", $user);
|
||||
} elsif (/(\w+) \s+ \+\+ \s*
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))\s+
|
||||
(\d+)\s+(\d+)\s+(\d+)\s+(NOT\sSTARTED|EXPIRED|\d+\.\d+\ (?:days|hours))
|
||||
/x) {
|
||||
print "block limit: $1: $2 > ($3 $4) $5\n";
|
||||
$user = $1;
|
||||
$msg = warnmsg($mount, $2/1024, $3/1024, $4/1024, $5, "MB", $user);
|
||||
print "file limit: $1: $6 > ($7 $8) $9\n";
|
||||
$msg .= "\n\n" . warnmsg($mount, $6, $7, $8, $9, "Files", $user);
|
||||
} else {
|
||||
if ($. > 2) { # ignore header lines
|
||||
print "$mount: $.: unparseable: $_";
|
||||
}
|
||||
}
|
||||
if ($msg) {
|
||||
my $timestamp = "/usr/local/dfstat/quotacheck-timestamps/$user";
|
||||
|
||||
if (!-e $timestamp) {
|
||||
sendmail($user, $msg, $mount);
|
||||
open (PMSG, ">$timestamp")
|
||||
or die "cannot open $timestamp: $!";
|
||||
print PMSG (@time);
|
||||
close (PMSG);
|
||||
|
||||
}
|
||||
else{
|
||||
my $comp = -A $timestamp;
|
||||
print STDERR "comp = $comp\n";
|
||||
if ($comp > 5)
|
||||
{
|
||||
sendmail($user, $msg, $mount);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
my $user;
|
||||
my @deletemsg = ("/usr/local/dfstat/quotacheck-timestamps/$user");
|
||||
unlink (@deletemsg);
|
||||
}
|
||||
}
|
||||
close (REPQUOTA);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
|
||||
use Getopt::Long;
|
||||
use Time::Local;
|
||||
|
@ -8,12 +10,16 @@ GetOptions(\%opts, "fs=s", "data=s", "user=s");
|
|||
|
||||
my $lastdate = "";
|
||||
my @data = ();
|
||||
my $ld;
|
||||
|
||||
print STDERR "fs = ", $opts{"fs"}, "\n";
|
||||
print STDERR "user = ", $opts{"user"}, "\n";
|
||||
print STDERR "data = ", $opts{"data"}, "\n";
|
||||
|
||||
sub usage {
|
||||
print STDERR "Usage: $0 --fs=<filesystem> --user=<username> --data=[bi]\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while(<>) {
|
||||
my ($date, $fs, $user, $bused, $bsoft, $bhard, $iused, $isoft, $ihard) = split(/\t/);
|
||||
if (
|
||||
|
@ -22,6 +28,7 @@ while(<>) {
|
|||
|
||||
) {
|
||||
if ($date ne $lastdate) {
|
||||
my $time;
|
||||
if ($date =~ /(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})/) {
|
||||
$time = timelocal($6, $5, $4, $3, $2-1, $1-1900);
|
||||
} else {
|
||||
|
@ -29,36 +36,34 @@ while(<>) {
|
|||
}
|
||||
print "$date $time\n";
|
||||
|
||||
$ld = {};
|
||||
my $ld;
|
||||
if ($opts{data} eq "b") {
|
||||
$ld = [ $bused, $bsoft, $bhard ];
|
||||
} elsif ($opts{data} eq "i") {
|
||||
$ld = [ $iused, $isoft, $ihard ];
|
||||
} else {
|
||||
usage();
|
||||
}
|
||||
push(@data, [ $time, $ld ]);
|
||||
$lastdate = $date;
|
||||
}
|
||||
$ld->{$user . $fs} = $bused if ($opts{"data"} eq "bused");
|
||||
$ld->{$user . $fs} = $bsoft if ($opts{"data"} eq "bsoft");
|
||||
$ld->{$user . $fs} = $bhard if ($opts{"data"} eq "bhard");
|
||||
$ld->{$user . $fs} = $iused if ($opts{"data"} eq "iused");
|
||||
$ld->{$user . $fs} = $isoft if ($opts{"data"} eq "isoft");
|
||||
$ld->{$user . $fs} = $ihard if ($opts{"data"} eq "ihard");
|
||||
}
|
||||
}
|
||||
|
||||
my @top = (sort { ($ld->{$b} <=> $ld->{$a}) } (keys %$ld))[0..9];
|
||||
|
||||
print "@top\n";
|
||||
open (DATA, ">quotastat.data") or die "cannot open quotastat.data for output: $!";
|
||||
for (my $i = 0; $i <= $#data; $i++) {
|
||||
my $time = ($data[$i])->[0];
|
||||
my $data = ($data[$i])->[1];
|
||||
|
||||
print DATA $time;
|
||||
for $j (@top) {
|
||||
print DATA "\t", $data->{$j} + 0;
|
||||
for my $j (@$data) {
|
||||
print DATA "\t", $j + 0;
|
||||
}
|
||||
print DATA "\n";
|
||||
}
|
||||
close(DATA);
|
||||
|
||||
open (CTL, ">quotastat.ctl") or die "cannot open quotastat.ctl for output: $!";
|
||||
open (CTL, ">quotacheck.ctl") or die "cannot open quotacheck.ctl for output: $!";
|
||||
|
||||
# generic settings
|
||||
|
||||
|
@ -73,12 +78,13 @@ my $firsttime = ($data[0])->[0];
|
|||
my $lasttime = ($data[$#data])->[0];
|
||||
|
||||
if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||
$sec = $min = $hour = 0;
|
||||
$mday = 1;
|
||||
$firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
||||
print CTL "set xtics rotate (";
|
||||
$comma = 0;
|
||||
my $comma = 0;
|
||||
my $time;
|
||||
for (;;) {
|
||||
$time = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
||||
if ($comma) {
|
||||
|
@ -95,14 +101,14 @@ if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
|||
$lasttime = $time;
|
||||
print CTL ")\n";
|
||||
} elsif ($lasttime - $firsttime > 30 * 24 * 3600) {
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||
$firsttime -= 86400 * $wday;
|
||||
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||
$sec = $min = $hour = 0;
|
||||
$time = $firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
||||
my $time = $firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
||||
print CTL "set xtics rotate (";
|
||||
$comma = 0;
|
||||
my $comma = 0;
|
||||
for (;;) {
|
||||
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
||||
if ($comma) {
|
||||
|
@ -115,7 +121,7 @@ if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
|||
|
||||
$time += 7 * 24 * 3600;
|
||||
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
||||
$toff = $hour * 3600 + $min * 60 * $sec;
|
||||
my $toff = $hour * 3600 + $min * 60 * $sec;
|
||||
if ($toff != 0) {
|
||||
if ($toff > 12*3600) {
|
||||
$toff = 24 * 3600 - $toff;
|
||||
|
@ -132,11 +138,11 @@ if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
|||
$lasttime = $time;
|
||||
print CTL ")\n";
|
||||
} else {
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
|
||||
$sec = $min = $hour = 0;
|
||||
$time = $firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
||||
my $time = $firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
|
||||
print CTL "set xtics rotate (";
|
||||
$comma = 0;
|
||||
my $comma = 0;
|
||||
for (;;) {
|
||||
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
||||
if ($comma) {
|
||||
|
@ -149,7 +155,7 @@ if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
|||
|
||||
$time += 24 * 3600;
|
||||
($sec,$min,$hour,$mday,$mon,$year) = localtime($time);
|
||||
$toff = $hour * 3600 + $min * 60 * $sec;
|
||||
my $toff = $hour * 3600 + $min * 60 * $sec;
|
||||
if ($toff != 0) {
|
||||
if ($toff > 12*3600) {
|
||||
$toff = 24 * 3600 - $toff;
|
||||
|
@ -169,28 +175,20 @@ if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
|
|||
|
||||
# what to plot
|
||||
|
||||
print CTL "plot ";
|
||||
$comma = 0;
|
||||
$col = 2;
|
||||
print CTL qq{plot "quotastat.data" using 1:2 title "used", "quotastat.data" using 1:3 title "soft", "quotastat.data" using 1:4 title "hard"\n};
|
||||
|
||||
for $i (@top) {
|
||||
if ($comma) {
|
||||
print CTL ", ";
|
||||
} else {
|
||||
$comma = 1;
|
||||
}
|
||||
print CTL "'quotastat.data' using 1:", $col++, " title '$i'";
|
||||
}
|
||||
|
||||
print CTL "\n";
|
||||
close (CTL);
|
||||
|
||||
|
||||
my $rc = system("gnuplot", "quotastat.ctl");
|
||||
my $rc = system("gnuplot", "quotacheck.ctl");
|
||||
print "system returned $rc\n";
|
||||
|
||||
my $fs = $opts{fs};
|
||||
$fs =~ s|/|_|g;
|
||||
|
||||
system("gs -sDEVICE=ppmraw -r150 -dBATCH -sOutputFile=- -q - < quotastat.ps |" .
|
||||
"pnmscale 0.5 |" .
|
||||
"pnmflip -cw |" .
|
||||
"pnmcrop |" .
|
||||
"ppmquant 256 |" .
|
||||
"ppmtogif > quotastat.gif");
|
||||
"ppmtogif >/usr/local/www/wsr/intranet/quotas/$opts{user}$fs.gif");
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
rcstell:
|
||||
|
||||
install: /usr/local/bin/rcstell \
|
||||
/usr/local/bin/rcsinfo \
|
||||
|
||||
|
||||
install_all:
|
||||
$(MAKE) install ROOT=/nfs/wsrdb
|
||||
$(MAKE) install ROOT=/nfs/wsrcom
|
||||
$(MAKE) install ROOT=/nfs/wifosv
|
||||
$(MAKE) install ROOT=/nfs/ihssv
|
||||
$(MAKE) install ROOT=/nfs/wsrtest
|
||||
|
||||
/usr/local/bin/rcsinfo: /usr/local/bin/rcstell
|
||||
ln -s $< $@
|
||||
|
||||
/usr/local/man/man8/%.8: %.man
|
||||
$(INSTALL) $< $@
|
||||
|
||||
clean:
|
||||
rm count
|
|
@ -1,55 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ $# -gt 1 ]
|
||||
then
|
||||
echo "Usage is: $0 [directory]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NAME=`basename $0`
|
||||
|
||||
if [ $# -eq 1 ]
|
||||
then
|
||||
DIR=`echo "$1" | sed -e 's+/RCS/*$++'`
|
||||
cd "$DIR"
|
||||
fi
|
||||
|
||||
if [ ! -d RCS ]
|
||||
then
|
||||
echo "$0: no RCS directory" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
OIFS="$IFS"
|
||||
IFS='
|
||||
'
|
||||
ALLFILES=`ls RCS/* | sed -e 's+^RCS/\(.*\),v+\1+'`
|
||||
FILES=`grep '^locks$' /dev/null RCS/* | sed -e 's+^RCS/\(.*\),v:locks+\1+'`
|
||||
FILEDIFF=`( echo "$ALLFILES"; echo "$FILES" ) | sort | uniq -u`
|
||||
|
||||
for I in $FILES
|
||||
do
|
||||
IFS=${OIFS}:';'
|
||||
set `awk '/^locks/,/;$/ { print }' RCS/${I},v`
|
||||
LOCKER=$2
|
||||
VERSION=$3
|
||||
case "$NAME"
|
||||
in
|
||||
rcsinfo) echo "$I: version $VERSION locked by $LOCKER" ;;
|
||||
rcstell) echo $I ;;
|
||||
*) echo "Internal error: command $NAME unknown" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
IFS='
|
||||
'
|
||||
for I in $FILEDIFF
|
||||
do
|
||||
case "$NAME"
|
||||
in
|
||||
rcsinfo) echo $I;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
|
@ -1,17 +0,0 @@
|
|||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
all: scat $(patsubst %.msg, %.cat, $(wildcard *.msg))
|
||||
|
||||
scat: scat.o
|
||||
scat.o: scat.c scat.h
|
||||
scat.h: scat.en.msg
|
||||
gencat -H scat.h -o scat.en.cat scat.en.msg
|
||||
|
||||
%.cat: %.msg
|
||||
gencat $@ $^
|
||||
|
||||
clean:
|
||||
rm -f *.cat *.o scat core scat.h
|
||||
|
||||
install: $(BINDIR)/scat
|
103
scat/scat.c
103
scat/scat.c
|
@ -1,103 +0,0 @@
|
|||
char scat_c_cvs_version[] =
|
||||
"$Id: scat.c,v 1.3 2000-02-10 00:17:35 hjp Exp $";
|
||||
/* scat - safe cat
|
||||
*
|
||||
* catenate input files and print to standard output.
|
||||
* replace all non-printable characters with C \xXX escapes.
|
||||
*
|
||||
* $Log: scat.c,v $
|
||||
* Revision 1.3 2000-02-10 00:17:35 hjp
|
||||
* Shut up gcc
|
||||
*
|
||||
* Revision 1.2 1999/08/01 18:09:09 hjp
|
||||
* First release
|
||||
*
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <features.h>
|
||||
#include <nl_types.h>
|
||||
|
||||
#include "scat.h"
|
||||
|
||||
char *cmnd;
|
||||
nl_catd catalog;
|
||||
|
||||
static void usage(void) {
|
||||
fprintf(stderr,
|
||||
catgets(catalog, MSG_Set, MSG_USAGE,
|
||||
"Usage: %s [file ...]\n"),
|
||||
cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
static void do_safecat(const char *filename) {
|
||||
FILE *fp;
|
||||
int c;
|
||||
|
||||
|
||||
if (strcmp(filename, "-") == 0) {
|
||||
fp = stdin;
|
||||
} else {
|
||||
if ((fp = fopen(filename, "r")) == NULL) {
|
||||
fprintf(stderr, catgets(catalog, MSG_Set, MSG_OPEN,
|
||||
"%s: cannot open `%s' for reading: %s\n"),
|
||||
cmnd, filename, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
while ((c = getc(fp)) != EOF) {
|
||||
if (isprint(c) || isspace(c)) {
|
||||
if (putchar(c) == EOF) {
|
||||
fprintf(stderr,
|
||||
catgets(catalog, MSG_Set, MSG_WRITE,
|
||||
"%s: cannot write stdout: %s\n"),
|
||||
cmnd, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
if (printf("\\x%02X", c) == EOF) {
|
||||
fprintf(stderr,
|
||||
catgets(catalog, MSG_Set, MSG_WRITE,
|
||||
"%s: cannot write stdout: %s\n"),
|
||||
cmnd, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ferror(fp)) {
|
||||
fprintf(stderr,
|
||||
catgets(catalog, MSG_Set, MSG_READ,
|
||||
"%s: cannot read from `%s': %s\n"),
|
||||
cmnd, filename, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if (strcmp(filename, "-") == 0) {
|
||||
} else {
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
cmnd = argv[0];
|
||||
catalog = catopen("scat", 0);
|
||||
if (argc == 1) {
|
||||
do_safecat("-");
|
||||
} else {
|
||||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
do_safecat(argv[i]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
$set MSG_
|
||||
USAGE Verwendung: %s [File ...]\n
|
||||
OPEN %s: Kann `%s' nicht zum Lesen öffnen: %s\n
|
||||
WRITE %s: Kann nicht auf stdout schreiben: %s\n
|
||||
READ %s: Kann nicht von `%s' lesen: %s\n
|
|
@ -1,5 +0,0 @@
|
|||
$set MSG_
|
||||
USAGE Usage: %s [files]\n
|
||||
OPEN %s: cannot open `%s' for reading: %s\n
|
||||
WRITE %s: cannot write to stdout: %s\n
|
||||
READ %s: cannot read from `%s': %s\n
|
|
@ -1,7 +0,0 @@
|
|||
include GNUmakevars
|
||||
setperm:
|
||||
clean:
|
||||
rm setperm
|
||||
install: $(BINDIR)/setperm
|
||||
|
||||
include GNUmakerules
|
|
@ -1,80 +0,0 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
char *cmnd;
|
||||
|
||||
static void usage(void) {
|
||||
fprintf(stderr, "Usage: %s -F protofile file ...\n", cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uid_t user;
|
||||
gid_t group;
|
||||
mode_t mode;
|
||||
} perm_t;
|
||||
|
||||
static int getperm(const char *filename, perm_t *permp) {
|
||||
struct stat sb;
|
||||
|
||||
if (stat(filename, &sb) == -1) return -1;
|
||||
permp->user = sb.st_uid;
|
||||
permp->group = sb.st_gid;
|
||||
permp->mode = sb.st_mode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setperm(const char *filename, perm_t perm) {
|
||||
int rc = 0;
|
||||
|
||||
if (chown(filename, perm.user, perm.group) == -1) {
|
||||
fprintf (stderr, "%s: cannot change owner of `%s' to %ld:%ld: %s\n",
|
||||
cmnd, filename, (long)perm.user, (long)perm.group, strerror(errno));
|
||||
rc = 1;
|
||||
}
|
||||
if (chmod(filename, perm.mode) == -1) {
|
||||
fprintf (stderr, "%s: cannot change mode of %s to %lo: %s\n",
|
||||
cmnd, filename, (unsigned long)perm.mode, strerror(errno));
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
int c;
|
||||
perm_t perm;
|
||||
int i;
|
||||
|
||||
cmnd = argv[0];
|
||||
|
||||
while ((c = getopt(argc, argv, "o:g:m:F:R")) != EOF) {
|
||||
switch (c) {
|
||||
case 'o':
|
||||
case 'p':
|
||||
case 'm':
|
||||
case 'R':
|
||||
fprintf (stderr, "%s: option `%c' not yet implemented. Sorry\n", cmnd, c);
|
||||
exit(1);
|
||||
case 'F':
|
||||
if (getperm (optarg, &perm) == -1) {
|
||||
fprintf (stderr, "%s: cannot get permissions from %s: %s\n",
|
||||
cmnd, optarg, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
usage ();
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
for (i = optind; i < argc; i ++) {
|
||||
setperm(argv[i], perm);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
shuffle: shuffle.o
|
||||
$(CC) $^ -lant -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o shuffle core foo bar
|
||||
|
||||
install: $(BINDIR)/shuffle
|
||||
|
||||
distclean: clean
|
||||
rm -f *.bak *.d
|
|
@ -1,107 +0,0 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <ant/io.h>
|
||||
#include <ant/string.h>
|
||||
|
||||
char *cmnd;
|
||||
|
||||
char **lines;
|
||||
int nr_lines;
|
||||
int nr_lines_a;
|
||||
|
||||
unsigned int seed;
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-s seed]\n", cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void readfile(const char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
char *ln;
|
||||
|
||||
if (STREQ(filename, "-")) {
|
||||
fp = stdin;
|
||||
} else {
|
||||
fp = efopen(filename, "r");
|
||||
}
|
||||
while ((ln = getline(fp))) {
|
||||
if (nr_lines >= nr_lines_a) {
|
||||
nr_lines_a = nr_lines_a * 3 / 2 + 1;
|
||||
assert (nr_lines_a > nr_lines);
|
||||
lines = realloc(lines, nr_lines_a * sizeof(*lines));
|
||||
assert(lines);
|
||||
}
|
||||
lines[nr_lines++] = strdup(ln);
|
||||
}
|
||||
if (fp != stdin) {
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void shuffle(void) {
|
||||
int i;
|
||||
int j;
|
||||
char *p;
|
||||
|
||||
srand(seed);
|
||||
for (i = 0; i < nr_lines; i++) {
|
||||
j = rand() / ((double)RAND_MAX + 1) * nr_lines;
|
||||
assert (0 <= j && j < nr_lines);
|
||||
p = lines[i];
|
||||
lines[i] = lines[j];
|
||||
lines[j] = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void dump(void) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nr_lines; i++) {
|
||||
puts(lines[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int i;
|
||||
char *p;
|
||||
|
||||
cmnd = argv[0];
|
||||
|
||||
seed = time(NULL);
|
||||
while ((c = getopt(argc, argv, "")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
seed = strtoul(optarg, &p, 0);
|
||||
if (p == optarg || *p != '\0') usage();
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind == argc) {
|
||||
readfile("-");
|
||||
}
|
||||
for (i = optind; i < argc; i++) {
|
||||
readfile(argv[i]);
|
||||
}
|
||||
shuffle();
|
||||
dump();
|
||||
return 0;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
version 5.0
|
||||
set nocompatible
|
||||
let cpo_save=&cpo
|
||||
set cpo=B
|
||||
map! <xHome> <Home>
|
||||
map! <xEnd> <End>
|
||||
map! <S-xF4> <S-F4>
|
||||
map! <S-xF3> <S-F3>
|
||||
map! <S-xF2> <S-F2>
|
||||
map! <S-xF1> <S-F1>
|
||||
map! <xF4> <F4>
|
||||
map! <xF3> <F3>
|
||||
map! <xF2> <F2>
|
||||
map! <xF1> <F1>
|
||||
map <F8> :cn
|
||||
map <xHome> <Home>
|
||||
map <xEnd> <End>
|
||||
map <S-xF4> <S-F4>
|
||||
map <S-xF3> <S-F3>
|
||||
map <S-xF2> <S-F2>
|
||||
map <S-xF1> <S-F1>
|
||||
map <xF4> <F4>
|
||||
map <xF3> <F3>
|
||||
map <xF2> <F2>
|
||||
map <xF1> <F1>
|
||||
map! }I\begin{yyplcwendO
|
||||
map! >I<yypa/O
|
||||
let &cpo=cpo_save
|
||||
unlet cpo_save
|
||||
set autoindent
|
||||
set exrc
|
||||
set number
|
||||
set ruler
|
||||
set shiftwidth=4
|
||||
set showmatch
|
||||
set textwidth=72
|
|
@ -1,13 +0,0 @@
|
|||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
all: slowcat
|
||||
install: $(BINDIR)/slowcat
|
||||
|
||||
clean:
|
||||
rm -f *.bak *.o core slowcat
|
||||
|
||||
distclean: clean
|
||||
rm -f *.d
|
||||
|
||||
-include *.d
|
|
@ -1,70 +0,0 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
char *cmnd;
|
||||
|
||||
static void usage(void) {
|
||||
fprintf(stderr, "Usage: %s [-d delay] file ...\n", cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
static void do_cat(FILE *fp, double delay) {
|
||||
int c;
|
||||
|
||||
while ((c = getc(fp)) != EOF) {
|
||||
putchar(c);
|
||||
usleep(delay * 1E6);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int rc = 0;
|
||||
int c;
|
||||
double delay = 0.5;
|
||||
|
||||
cmnd = argv[0];
|
||||
|
||||
while ((c = getopt(argc, argv, "d:")) != EOF) {
|
||||
char *p;
|
||||
switch (c) {
|
||||
case 'd':
|
||||
p = NULL;
|
||||
delay = strtod(optarg, &p);
|
||||
if (!p || *p) usage();
|
||||
if (delay < 0 || delay > ULONG_MAX / 1E6) usage();
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
|
||||
if (optind == argc) {
|
||||
do_cat(stdin, delay);
|
||||
} else {
|
||||
int i;
|
||||
|
||||
for (i = optind; i < argc; i++) {
|
||||
FILE *fp = fopen(argv[i], "r");
|
||||
if (fp) {
|
||||
do_cat(fp, delay);
|
||||
fclose(fp);
|
||||
} else {
|
||||
fprintf(stderr, "%s: cannot open %s for reading: %s\n",
|
||||
argv[0], argv[i], strerror(errno));
|
||||
rc++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
# $Id: GNUmakefile,v 1.1 2001-04-11 14:31:28 hjp Exp $
|
||||
|
||||
include GNUmakevars
|
||||
|
||||
clean:
|
||||
|
||||
install: $(SBINDIR)/mac-port-bay $(SBINDIR)/mac-port
|
||||
|
||||
include GNUmakerules
|
||||
|
||||
# $Log: GNUmakefile,v $
|
||||
# Revision 1.1 2001-04-11 14:31:28 hjp
|
||||
# mac-port: convert mac address to switch port using snmp.
|
||||
#
|
|
@ -1,31 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# $Id: mac-port,v 1.1 2001-04-11 14:31:29 hjp Exp $
|
||||
#
|
||||
# find the port of a baystack 350 T switch to which a given
|
||||
# mac address is connected.
|
||||
#
|
||||
use strict;
|
||||
|
||||
sub usage {
|
||||
print STDERR "Usage: $0 switch mac-address\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if (@ARGV != 2) {usage();}
|
||||
|
||||
my @hmac = split(/:/, $ARGV[1]);
|
||||
|
||||
my $switch = $ARGV[0];
|
||||
|
||||
my @dmac = map { hex } @hmac;
|
||||
|
||||
my $object = "17.4.3.1.2." . join(".", @dmac);
|
||||
|
||||
system("snmpget", $switch, "public", $object);
|
||||
|
||||
# $Log: mac-port,v $
|
||||
# Revision 1.1 2001-04-11 14:31:29 hjp
|
||||
# mac-port: convert mac address to switch port using snmp.
|
||||
#
|
|
@ -1,29 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
#
|
||||
# $Id: mac-port-bay,v 1.1 2001-04-11 14:31:29 hjp Exp $
|
||||
#
|
||||
# find the port of a baystack 350 T switch to which a given
|
||||
# mac address is connected.
|
||||
#
|
||||
use strict;
|
||||
|
||||
sub usage {
|
||||
print STDERR "Usage: $0 mac-address\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if (@ARGV != 1) {usage();}
|
||||
|
||||
my @hmac = split(/:/, $ARGV[0]);
|
||||
|
||||
my @dmac = map { hex } @hmac;
|
||||
|
||||
my $object = "17.4.3.1.2." . join(".", @dmac);
|
||||
|
||||
system("snmpget", "bay-switch-1", "public", $object);
|
||||
|
||||
# $Log: mac-port-bay,v $
|
||||
# Revision 1.1 2001-04-11 14:31:29 hjp
|
||||
# mac-port: convert mac address to switch port using snmp.
|
||||
#
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
while(<>) {
|
||||
if (/^\t\t\t( [0-9a-f]{2,4})+$/) {
|
||||
@hex = split;
|
||||
foreach $i (@hex) {
|
||||
@c = pack("H4", $i);
|
||||
foreach $j (@c) {
|
||||
print "$j";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
} else {
|
||||
print
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# print summary of tcpdump output
|
||||
|
||||
sub dumpstats {
|
||||
print "-" x 60, "\n";
|
||||
print "$time_last\n";
|
||||
for $i (sort { $sum{$a} <=> $sum{$b} } keys (%sum)) {
|
||||
printf("\t%6d %s\n", $sum{$i}, $i);
|
||||
}
|
||||
}
|
||||
|
||||
while (<>) {
|
||||
if (m/^(\d\d:\d\d):\d\d\.\d{6} ([-\w\.]+) \> ([-\w\.]+): (.*)/) {
|
||||
$time = $1;
|
||||
$from = $2;
|
||||
$to = $3;
|
||||
$rest = $4;
|
||||
if ($time ne $time_last) {
|
||||
dumpstats();
|
||||
undef %sum;
|
||||
$time_last = $time;
|
||||
}
|
||||
if ($rest =~ m/^. (\d+):(\d+)\((\d+)\)/) {
|
||||
# tcp
|
||||
$sum{$from . " > " . $to} += $3;
|
||||
} elsif ($rest =~ m/^. ack (\d+) win (\d+) \(DF\)/) {
|
||||
# tcp ack
|
||||
$sum{$from . " > " . $to} += 0;
|
||||
} else {
|
||||
print stderr "unparseable2: $_";
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
print stderr "unparseable1: $_";
|
||||
}
|
||||
}
|
||||
dumpstats();
|
|
@ -1,54 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# print summary of tcpdump output
|
||||
|
||||
sub dumpstats {
|
||||
print "-" x 60, "\n";
|
||||
print "$time_last\n";
|
||||
for $i (sort { $sum{$a} <=> $sum{$b} } keys (%sum)) {
|
||||
printf("\t%6d %s\n", $sum{$i}, $i);
|
||||
}
|
||||
}
|
||||
|
||||
$maxsecs = 0;
|
||||
$minsecs = 86400;
|
||||
|
||||
while (<>) {
|
||||
if (m/^(\d\d:\d\d:\d\d)\.\d{6} ([-\w\.]+) \> ([-\w\.]+): (.*)/) {
|
||||
$time = $1;
|
||||
$from = $2;
|
||||
$to = $3;
|
||||
$rest = $4;
|
||||
@t = split(/:/, $time);
|
||||
$secs = $t[0] * 3600 + $t[1] * 60 + $t[2];
|
||||
if ($secs < $minsecs) {$minsecs = $secs}
|
||||
if ($secs > $maxsecs) {$maxsecs = $secs}
|
||||
|
||||
if ($rest =~ m/^. (\d+):(\d+)\((\d+)\)/) {
|
||||
# tcp
|
||||
$con = "$from > $to";
|
||||
$tsum{$con} += $3;
|
||||
if (!$sum{$con}) {
|
||||
$sum{$con} = [];
|
||||
}
|
||||
$sum{$con}->[$secs] += $3;
|
||||
|
||||
|
||||
} elsif ($rest =~ m/^. ack (\d+) win (\d+) \(DF\)/) {
|
||||
# tcp ack
|
||||
} else {
|
||||
#print stderr "unparseable2: $_";
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
#print stderr "unparseable1: $_";
|
||||
}
|
||||
}
|
||||
|
||||
for $c ((sort {$tsum{$b} <=> $tsum{$a}} keys %tsum)[0..9]) {
|
||||
print "# ", $c, " ", $tsum{$c}, "\n";
|
||||
for ($s = $minsecs; $s <= $maxsecs; $s++) {
|
||||
print $c, "\t", $s, "\t", $sum{$c}->[$s] + 0, "\n";
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
$count = $ack = $prevtime = 0;
|
||||
|
||||
while (<STDIN>) {
|
||||
if (/${ARGV[0]}/) {
|
||||
print "# ", $_;
|
||||
# 20:22:42.441592 calypso.wsr.ac.at.ftp-data > octopussy.wsr.ac.at.1365: . 1:1461(1460) ack 1 win 57344 (DF)
|
||||
if (/^(\d\d):(\d\d):(\d\d).(\d\d\d\d\d\d) /) {
|
||||
print "# time: $1 $2 $3 $4\n";
|
||||
$time = $1 * 3600 + $2 * 60 + $3 + $4 * 0.000001;
|
||||
if ($prevtime == 0) { $prevtime = $time };
|
||||
$time -= $prevtime;
|
||||
}
|
||||
if (/(\d+):(\d+)\((\d+)\)/) {
|
||||
print "# sequence: $1 $2 $3\n";
|
||||
# filter out initial seq. number but allow some packet loss
|
||||
if ($2 == $1 + $3 && $1 <= $count + 300000) {
|
||||
$count = $2;
|
||||
}
|
||||
}
|
||||
if (/ ack (\d+)/) {
|
||||
print "# ack: $1\n";
|
||||
# filter out initial seq. number but allow some packet loss
|
||||
if ($1 <= $ack + 300000) {
|
||||
$ack = $1;
|
||||
}
|
||||
}
|
||||
print $time, "\t", $count, "\t", $ack, "\n";
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
include GNUmakevars
|
||||
include GNUmakerules
|
||||
|
||||
all: time_t
|
||||
|
||||
time_t:
|
||||
clean:
|
||||
rm time_t
|
||||
install: $(BINDIR)/time_t
|
|
@ -1,48 +0,0 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
char *cmnd;
|
||||
|
||||
static void usage(void) {
|
||||
fprintf(stderr, "Usage: %s time_t ...\n", cmnd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
char *format = "%Y-%m-%d %H:%M:%S %Z";
|
||||
int c;
|
||||
|
||||
cmnd = argv[0];
|
||||
|
||||
while ((c = getopt(argc, argv, "f:")) != EOF) {
|
||||
switch(c) {
|
||||
case 'f':
|
||||
format = optarg;
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
default:
|
||||
assert("this" == "unreachable");
|
||||
}
|
||||
}
|
||||
|
||||
if (optind >= argc) usage();
|
||||
|
||||
for (i = optind; i < argc; i++) {
|
||||
time_t t = strtoul(argv[i], NULL, 0);
|
||||
struct tm *tmp;
|
||||
char buf[1024];
|
||||
|
||||
tmp = localtime(&t);
|
||||
strftime(buf, sizeof(buf), format, tmp);
|
||||
printf("%s\n", buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* vim:sw=4
|
||||
*/
|
|
@ -1,38 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
CONFDIR=../../configure
|
||||
CONFDIR_exists=$(shell [ -d $(CONFDIR) ] && echo ok)
|
||||
|
||||
all: configure dus fnp fnpa fnpc fqdn isodate psg
|
||||
|
||||
clean:
|
||||
rm fnp fnpa fnpc customize
|
||||
|
||||
install: \
|
||||
$(BINDIR)/dus \
|
||||
$(BINDIR)/fnp \
|
||||
$(BINDIR)/fnpa \
|
||||
$(BINDIR)/fnpc \
|
||||
$(BINDIR)/fqdn \
|
||||
$(BINDIR)/isodate \
|
||||
$(BINDIR)/psg \
|
||||
|
||||
fnp: fnp.sh
|
||||
fnpa: fnpa.sh
|
||||
fnpc: fnpc.sh
|
||||
|
||||
%: %.sh customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
customize: configure
|
||||
sh ./configure
|
||||
|
||||
ifeq ($(CONFDIR_exists),ok)
|
||||
|
||||
configure: $(CONFDIR)/start $(CONFDIR)/find-printf $(CONFDIR)/finish
|
||||
cat $^ > $@
|
||||
|
||||
endif
|
||||
|
||||
include GNUmakerules
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
echo "#!/bin/sh" > customize.$$
|
||||
echo "sed \\" > customize.$$
|
||||
chmod +x customize.$$
|
||||
|
||||
################################################################
|
||||
# $Id: configure,v 1.2 2001-03-19 22:48:23 hjp Exp $
|
||||
# find a ln which understands -sf
|
||||
#
|
||||
touch find-printf.$$.1
|
||||
today=`date '+%Y-%m-%d'`
|
||||
for i in /bin/find /usr/bin/find /usr/local/bin/find
|
||||
do
|
||||
if [ "`$i find-printf.$$.1 -printf '%TY-%Tm-%Td %p'`" = "$today find-printf.$$.1" ]
|
||||
then
|
||||
echo $i works
|
||||
find="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$find" ]
|
||||
then
|
||||
echo could not find a working find command, sorry.
|
||||
exit 1
|
||||
fi
|
||||
echo " -e 's,@@@find@@@,$find,g' \\" >> customize.$$
|
||||
rm find-printf.$$.?
|
||||
|
||||
# $Log: configure,v $
|
||||
# Revision 1.2 2001-03-19 22:48:23 hjp
|
||||
# GNUmakefile: try to rebuild configure only if source dir is there.
|
||||
#
|
||||
# configure: Fixed test for find -printf.
|
||||
#
|
||||
# psg: include f option on Linux.
|
||||
#
|
||||
# Revision 1.1 2001/03/19 22:44:39 hjp
|
||||
# *** empty log message ***
|
||||
#
|
||||
################################################################
|
||||
# finish
|
||||
# Add trailing newline and rename temp file to final name
|
||||
#
|
||||
echo >> customize.$$
|
||||
|
||||
mv customize.$$ customize
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/sh
|
||||
@@@find@@@ "$@" -printf "%TY-%Tm-%Td %TH:%TM:%TS %5k %-8u %-8g %m %p\t%l\n"
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/sh
|
||||
@@@find@@@ "$@" -printf "%AY-%Am-%Ad %AH:%AM:%AS %5k %-8u %-8g %m %p\t%l\n"
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/sh
|
||||
@@@find@@@ "$@" -printf "%CY-%Cm-%Cd %CH:%CM:%CS %5k %-8u %-8g %m %p\t%l\n"
|
|
@ -1,9 +0,0 @@
|
|||
#!/bin/sh
|
||||
[ $# -ge 2 ] && { echo "Usage: $0 [hostname]" >&2; exit 1; }
|
||||
if [ $# -eq 1 ]
|
||||
then
|
||||
hostname=$1
|
||||
else
|
||||
hostname="`/bin/hostname`"
|
||||
fi
|
||||
/usr/bin/nslookup $hostname | /bin/grep Name: | /bin/sed -e 's/.* *//'
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/sh
|
||||
date '+%Y-%m-%dT%H:%M:%S'
|
9
tiny/psg
9
tiny/psg
|
@ -1,9 +0,0 @@
|
|||
#!/bin/sh
|
||||
case `uname` in
|
||||
Linux)
|
||||
ps auxwwf | grep "$1"
|
||||
;;
|
||||
HP-UX)
|
||||
ps -ef | grep "$1"
|
||||
;;
|
||||
esac
|
|
@ -1,25 +0,0 @@
|
|||
include GNUmakevars
|
||||
|
||||
all: truncate
|
||||
|
||||
clean:
|
||||
rm truncate customize
|
||||
|
||||
install: $(BINDIR) $(BINDIR)/truncate $(MAN1DIR)/truncate.1
|
||||
|
||||
%: %.pl customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
%: %.sh customize
|
||||
sh ./customize < $< > $@
|
||||
chmod +x $@
|
||||
|
||||
customize: configure
|
||||
sh ./configure
|
||||
|
||||
$(BINDIR):
|
||||
mkdir -p $@
|
||||
|
||||
include GNUmakerules
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
echo "#!/bin/sh" > customize.$$
|
||||
echo "sed \\" > customize.$$
|
||||
chmod +x customize.$$
|
||||
|
||||
################################################################
|
||||
# find a find which understands -printf
|
||||
# (like gnu find)
|
||||
#
|
||||
now=`date '+%Y%m%d' `
|
||||
touch find_printf.$now.$$
|
||||
|
||||
for i in /usr/bin/find /usr/local/bin/find
|
||||
do
|
||||
ts=`$i find_printf.$now.$$ -printf '%TY%Tm%Td\n'`
|
||||
if [ "x$ts" = "x$now" ]
|
||||
then
|
||||
echo $i works
|
||||
find_printf="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$find_printf" ]
|
||||
then
|
||||
echo could not find a working find_printf command, sorry.
|
||||
exit 1
|
||||
fi
|
||||
echo " -e 's,@@@find_printf@@@,$find_printf,g' \\" >> customize.$$
|
||||
rm find_printf.$now.$$
|
||||
|
||||
|
||||
################################################################
|
||||
# finish
|
||||
# Add trailing newline and rename temp file to final name
|
||||
#
|
||||
echo >> customize.$$
|
||||
|
||||
mv customize.$$ customize
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue