#!/usr/bin/perl4.036 # PERL 4 LIBRARY DIRECTORY # Where are you going to put those .pl files you should have just configured? # and if perl isn't going to be able to find find.pl, then add a colon and # the path to that here as well. $localpl_dir = "/usr/local/lib/perl4"; ## END OF CONFIG ######################################################### ($progname = $0) =~ s/^.*\/([^\/]+)/$1/; $modvers{'lspipe'} = "RELEASE_MARKER"; ($modvers{'lspipe'} =~ /^REL.*KER$/) && ($modvers{'lspipe'} = '$Id: lspipe,v 1.8 1996/10/03 21:48:45 alexis Exp alexis $') =~ s/^.*,v (\S+) .*$/$1/; push(@INC,split(/:/, $localpl_dir)); require "msgs.pl"; ($modvers{'msgs.pl'} ne "1.7") && (!$ENV{'IGNORE_REQUIRE_VERSIONS'}) && &error("configuration error: wrong version of msgs.pl"); @monnames = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); sub usage { print STDERR "Usage: $progname -V\n"; print STDERR " $progname [ -t ] [ -r ] [ -a file ]\n"; exit 1; } sub show_version { print "$progname version $modvers{'lspipe'}\n"; exit 0; } sub sortfnc { local($rc); local($a_idx, $a_mtime) = split($;, $a); local($b_idx, $b_mtime) = split($;, $b); ($sort_idx) && ($rc = ($a_idx <=> $b_idx)); ($sort_mtime) && ($rc = ($a_mtime <=> $b_mtime)); ($sort_reverse) && ($rc = -$rc); return($rc); } $sort_idx = 1; $sort_mtime = 0; $sort_reverse = 0; while ($ARGV[0] =~ /^-./) { $_ = shift @ARGV; # -V is print the version number if (/^-V$/) { &show_version; } elsif (/^-t$/) { $sort_mtime = 1; } elsif (/^-r$/) { $sort_reverse = 1; } elsif (/^-a(.*)/) { $teefile = ($1 ? $1 : shift); $teefile || &usage; } else { &usage; } } $ARGV[0] && &usage(); while (($name,$passwd,$uid) = getpwent) { ($login{$uid}) || ($login{$uid} = $name); } while (($name,$passwd,$gid) = getgrent) { ($group{$gid}) || ($group{$gid} = $name); } if ($teefile) { open(TEE_HANDLE, ">$teefile") || &error("can't open roots file: $!"); $out_handle = TEE_HANDLE; } else { $out_handle = STDOUT; } while (<>) { chop; if (readlink) { ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = lstat($_); $type_char = 'l'; } elsif (($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($_)) { $type_char = '-' if -f _; $type_char = 'd' if -d _; $type_char = 'p' if -p _; $type_char = 's' if -S _; $type_char = 'b' if -b _; $type_char = 'c' if -c _; } else { $type_char = '!'; } $mode_owner_read_char = ($mode & 00400) ? 'r' : '-'; $mode_owner_write_char = ($mode & 00200) ? 'w' : '-'; $mode_owner_exec_char = ($mode & 00100) ? 'x' : '-'; $mode_owner_exec_char = 'S' if ($mode & 04000); $mode_owner_exec_char = 's' if (($mode & 04100) == 04100); $mode_group_read_char = ($mode & 00040) ? 'r' : '-'; $mode_group_write_char = ($mode & 00020) ? 'w' : '-'; $mode_group_exec_char = ($mode & 00010) ? 'x' : '-'; $mode_group_exec_char = 'S' if ($mode & 02000); $mode_group_exec_char = 's' if (($mode & 02010) == 02010); $mode_other_read_char = ($mode & 00004) ? 'r' : '-'; $mode_other_write_char = ($mode & 00002) ? 'w' : '-'; $mode_other_exec_char = ($mode & 00001) ? 'x' : '-'; ($lsec,$lmin,$lhour,$lmday,$lmon,$lyear,$lwday,$lyday,$lisdst) = localtime($mtime); ($nsec,$nmin,$nhour,$nmday,$nmon,$nyear,$nwday,$nyday,$nisdst) = localtime(time); if (($nyear > $lyear) || ($nyear == $lyear && $nmon > $lmon) || ($nyear == $lyear && $nmon == $lmon && $nmday > $lmday)) { $byear = $nyear; $bnmon = $nmon; $bday = $nmday; $syear = $lyear; $snmon = $lmon; $sday = $lmday; } else { $byear = $lyear; $bnmon = $lmon; $bday = $lmday; $syear = $nyear; $snmon = $nmon; $sday = $nmday; } if ($byear - $syear >= 2) { $showyear = 1; } elsif ($byear == $syear) { $showyear = 0; } elsif ($bmon > $smon) { $showyear = 1; } elsif ($bmon < $smon) { $showyear = 0; } elsif ($bday >= $sday) { $showyear = 1; } else { $showyear = 0; } if ($showyear) { $yearhour = sprintf("%5d", $lyear+1900); } else { $yearhour = sprintf("%02d:%02d", $lhour, $lmin); } $lsdat{++$count,$mtime} = sprintf("%1s%1s%1s%1s%1s%1s%1s%1s%1s%1s %2d %-8s %-8s %8d %s %2d %s %s\n", $type_char, $mode_owner_read_char, $mode_owner_write_char, $mode_owner_exec_char, $mode_group_read_char, $mode_group_write_char, $mode_group_exec_char, $mode_other_read_char, $mode_other_write_char, $mode_other_exec_char, $nlink, $login{$uid}, $group{$gid}, $size, $monnames[$lmon], $lmday, $yearhour, $_); ($teefile) && printf STDOUT "%s\n", $_; } foreach $lskey (sort sortfnc keys(%lsdat)) { print $out_handle $lsdat{$lskey}; } ($teefile) && close TEE_HANDLE;