You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by ji...@apache.org on 2013/05/23 20:39:13 UTC

svn commit: r1485815 - in /steve/trunk/cmdline: check_quorum.pl close_issue.pl make_issue.pl reminder.pl steve.pm vote.pl votegroup.pl

Author: jim
Date: Thu May 23 18:39:12 2013
New Revision: 1485815

URL: http://svn.apache.org/r1485815
Log:
Pull all shared subs to steve.pm

Added:
    steve/trunk/cmdline/steve.pm   (with props)
Modified:
    steve/trunk/cmdline/check_quorum.pl
    steve/trunk/cmdline/close_issue.pl
    steve/trunk/cmdline/make_issue.pl
    steve/trunk/cmdline/reminder.pl
    steve/trunk/cmdline/vote.pl
    steve/trunk/cmdline/votegroup.pl

Modified: steve/trunk/cmdline/check_quorum.pl
URL: http://svn.apache.org/viewvc/steve/trunk/cmdline/check_quorum.pl?rev=1485815&r1=1485814&r2=1485815&view=diff
==============================================================================
--- steve/trunk/cmdline/check_quorum.pl (original)
+++ steve/trunk/cmdline/check_quorum.pl Thu May 23 18:39:12 2013
@@ -30,21 +30,8 @@
 # 
 # Originally created by Roy Fielding
 #
-$ECHO     = '/bin/echo';
-$CAT      = '/bin/cat';
-$MD5      = '/sbin/md5';
-$OPENSSL  = '/usr/bin/openssl';
-$SENDMAIL = '/usr/sbin/sendmail';
-
-$homedir  = '/home/voter';
-$issuedir = "$homedir/issues";
-
-$ENV{'PATH'}    = "$homedir/bin:/usr/bin:/usr/sbin:/bin:/sbin";
-$ENV{'LOGNAME'} = 'voter';
-$ENV{'GROUP'}   = 'voter';
-$ENV{'USER'}    = 'voter';
-$ENV{'HOME'}    = "/home/voter";
-$ENV{'MAIL'}    = '/var/mail/voter';
+
+use steve;
 
 umask(0077);
 $| = 1;                                     # Make STDOUT unbuffered
@@ -153,86 +140,3 @@ print("Quorum information has been sent 
 print("Total: $num_voted of $num_group ($pct_voted\%)\n");
 exit(0);
 
-# ==========================================================================
-# ==========================================================================
-sub get_input_line {
-    local ($prompt, $quit_able) = @_;
-    local ($_);
-
-    do {
-        print("Enter ", $prompt, $quit_able ? " (q=quit): " : ": ");
-        $_ = <STDIN>;
-        chomp;
-        exit(0) if ($quit_able && /^q$/i);
-    } while (/^$/);
-
-    return $_;
-}
-
-# ==========================================================================
-sub get_group {
-    local ($groupfile) = @_;
-    local ($_, @rv);
-
-    open(INFILE, $groupfile) || die "$pname: cannot open $groupfile: $!\n";
-    while ($_ = <INFILE>) {
-        chomp;
-        s/#.*$//;
-        s/\s+$//;
-        s/^\s+//;
-        next if (/^$/);
-        push(@rv, $_);
-    }
-    close(INFILE);
-    return @rv;
-}
-
-# ==========================================================================
-sub filestuff {
-    local ($filename) = @_;
-    local ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-           $atime,$mtime,$ctime,$blksize,$blocks);
-
-    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-     $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
-
-    return "$ino:$mtime";
-}
-
-# ==========================================================================
-sub get_hash_of {
-    local ($item) = @_;
-    local ($rv);
-
-    if (-x $MD5) {
-        $rv = `$MD5 -q -s "$item"` || die "$pname: failed md5: $!\n";
-    }
-    else {
-        $rv = `$ECHO "$item" | $OPENSSL md5`
-              || die "$pname: failed openssl md5: $!\n";
-    }
-    chomp $rv;
-    return $rv;
-}
-
-# ==========================================================================
-sub read_tally {
-    local ($filename) = @_;
-    local ($_, %rv);
-
-    %rv = ();
-
-    open(INFILE, $filename) || die "$pname: cannot open $filename: $!\n";
-    while ($_ = <INFILE>) {
-        chomp;
-        if (/\] (\S+) (\S+)$/o) {
-            $rv{$1} = $2;
-        }
-        else {
-            warn "Invalid vote in tally: $_";
-        }
-    }
-    close(INFILE);
-
-    return %rv;
-}

Modified: steve/trunk/cmdline/close_issue.pl
URL: http://svn.apache.org/viewvc/steve/trunk/cmdline/close_issue.pl?rev=1485815&r1=1485814&r2=1485815&view=diff
==============================================================================
--- steve/trunk/cmdline/close_issue.pl (original)
+++ steve/trunk/cmdline/close_issue.pl Thu May 23 18:39:12 2013
@@ -26,22 +26,8 @@
 #
 # Originally created by Roy Fielding
 #
-$ECHO     = '/bin/echo';
-$CAT      = '/bin/cat';
-$MD5      = '/sbin/md5';
-$OPENSSL  = '/usr/bin/openssl';
-$TOUCH    = '/usr/bin/touch';
-$SENDMAIL = '/usr/sbin/sendmail';
-
-$homedir  = '/home/voter';
-$issuedir = "$homedir/issues";
-
-$ENV{'PATH'}    = "$homedir/bin:/usr/bin:/usr/sbin:/bin:/sbin";
-$ENV{'LOGNAME'} = 'voter';
-$ENV{'GROUP'}   = 'voter';
-$ENV{'USER'}    = 'voter';
-$ENV{'HOME'}    = '/home/voter';
-$ENV{'MAIL'}    = '/var/mail/voter';
+
+use steve;
 
 umask(0077);
 $| = 1;                                     # Make STDOUT unbuffered
@@ -165,63 +151,3 @@ close(MAIL);
 print "Issue closed.  Mail has been sent to the vote monitors.\n";
 exit(0);
 
-# ==========================================================================
-# ==========================================================================
-sub get_input_line {
-    local ($prompt, $quit_able) = @_;
-    local ($_);
-
-    do {
-        print("Enter ", $prompt, $quit_able ? " (q=quit): " : ": ");
-        $_ = <STDIN>;
-        chomp;
-        exit(0) if ($quit_able && /^q$/i);
-    } while (/^$/);
-
-    return $_;
-}
-
-# ==========================================================================
-sub filestuff {
-    local ($filename) = @_;
-    local ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-           $atime,$mtime,$ctime,$blksize,$blocks);
-
-    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-     $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
-
-    return "$ino:$mtime";
-}
-
-# ==========================================================================
-sub get_hash_of {
-    local ($item) = @_;
-    local ($rv);
-
-    if (-x $MD5) {
-        $rv = `$MD5 -q -s "$item"` || die "$pname: failed md5: $!\n";
-    }
-    else {
-        $rv = `$ECHO "$item" | $OPENSSL md5`
-              || die "$pname: failed openssl md5: $!\n";
-    }
-    chomp $rv;
-    return $rv;
-}
-
-# ==========================================================================
-sub hash_file {
-    local ($filename) = @_;
-    local ($rv);
-
-    if (-x $MD5) {
-        $rv = `$MD5 -q "$filename"` || die "$pname: failed md5: $!\n";
-    }
-    else {
-        $rv = `$CAT "$filename" | $OPENSSL md5`
-              || die "$pname: failed openssl md5: $!\n";
-    }
-    chomp $rv;
-    return $rv;
-}
-

Modified: steve/trunk/cmdline/make_issue.pl
URL: http://svn.apache.org/viewvc/steve/trunk/cmdline/make_issue.pl?rev=1485815&r1=1485814&r2=1485815&view=diff
==============================================================================
--- steve/trunk/cmdline/make_issue.pl (original)
+++ steve/trunk/cmdline/make_issue.pl Thu May 23 18:39:12 2013
@@ -40,24 +40,7 @@ BEGIN {
 require "getopts.pl";
 use randomize;
 use ballots;
-
-$ECHO     = '/bin/echo';
-$CAT      = '/bin/cat';
-$MD5      = '/sbin/md5';
-$OPENSSL  = '/usr/bin/openssl';
-$TOUCH    = '/usr/bin/touch';
-$SENDMAIL = '/usr/sbin/sendmail';
-
-$homedir  = '/home/voter';
-$issuedir = "$homedir/issues";
-$host     = 'people.apache.org';
-
-$ENV{'PATH'}    = "$homedir/bin:/usr/bin:/usr/sbin:/bin:/sbin";
-$ENV{'LOGNAME'} = 'voter';
-$ENV{'GROUP'}   = 'voter';
-$ENV{'USER'}    = 'voter';
-$ENV{'HOME'}    = '/home/voter';
-$ENV{'MAIL'}    = '/var/mail/voter';
+use steve;
 
 umask(0077);
 $| = 1;                                     # Make STDOUT unbuffered
@@ -512,91 +495,3 @@ for this issue: $monitors
 EndExplain
 }
 
-# ==========================================================================
-sub get_input_line {
-    local ($prompt, $quit_able) = @_;
-    local ($_);
-
-    do {
-        print("Enter ", $prompt, $quit_able ? " (q=quit): " : ": ");
-        $_ = <STDIN>;
-        chomp;
-        exit(0) if ($quit_able && /^q$/i);
-    } while (/^$/);
-
-    return $_;
-}
-
-# ==========================================================================
-sub get_group {
-    local ($groupfile) = @_;
-    local ($_, @rv);
-
-    open(INFILE, $groupfile) || die "$pname: cannot open $groupfile: $!\n";
-    while ($_ = <INFILE>) {
-        chomp;
-        s/#.*$//;
-        s/\s+$//;
-        s/^\s+//;
-        next if (/^$/);
-        die "$pname: voter must be an Internet e-mail address\n"
-            unless (/\@/);
-        push(@rv, $_);
-    }
-    close(INFILE);
-    return @rv;
-}
-
-# ==========================================================================
-sub filestuff {
-    local ($filename) = @_;
-    local ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-           $atime,$mtime,$ctime,$blksize,$blocks);
-
-    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-     $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
-
-    return "$ino:$mtime";
-}
-
-# ==========================================================================
-sub get_hash_of {
-    local ($item) = @_;
-    local ($rv);
-
-    if (-x $MD5) {
-        $rv = `$MD5 -q -s "$item"` || die "$pname: failed md5: $!\n";
-    }
-    else {
-        $rv = `$ECHO "$item" | $OPENSSL md5`
-              || die "$pname: failed openssl md5: $!\n";
-    }
-    chomp($rv);
-    return $rv;
-}
-
-# ==========================================================================
-sub hash_file {
-    local ($filename) = @_;
-    local ($rv);
-
-    if (-x $MD5) {
-        $rv = `$MD5 -q "$filename"` || die "$pname: failed md5: $!\n";
-    }
-    else {
-        $rv = `$CAT "$filename" | $OPENSSL md5`
-              || die "$pname: failed openssl md5: $!\n";
-    }
-    chomp($rv);
-    return $rv;
-}
-
-# ==========================================================================
-sub debug_hash {
-    print "==============================================================\n";
-    foreach $voter (@voters) {
-        print "$hash1{$voter} $hash2{$voter} $voter\n";
-    }
-    print "==============================================================\n";
-}
-

Modified: steve/trunk/cmdline/reminder.pl
URL: http://svn.apache.org/viewvc/steve/trunk/cmdline/reminder.pl?rev=1485815&r1=1485814&r2=1485815&view=diff
==============================================================================
--- steve/trunk/cmdline/reminder.pl (original)
+++ steve/trunk/cmdline/reminder.pl Thu May 23 18:39:12 2013
@@ -27,23 +27,8 @@ BEGIN {
     unshift @INC, "/home/voter/bin";
 }
 use randomize;
+use steve;
 
-$ECHO     = '/bin/echo';
-$CAT      = '/bin/cat';
-$MD5      = '/sbin/md5';
-$OPENSSL  = '/usr/bin/openssl';
-$SENDMAIL = '/usr/sbin/sendmail';
-
-$homedir  = '/home/voter';
-$issuedir = "$homedir/issues";
-$host     = 'people.apache.org';
-
-$ENV{'PATH'}    = "$homedir/bin:/usr/bin:/usr/sbin:/bin:/sbin";
-$ENV{'LOGNAME'} = 'voter';
-$ENV{'GROUP'}   = 'voter';
-$ENV{'USER'}    = 'voter';
-$ENV{'HOME'}    = '/home/voter';
-$ENV{'MAIL'}    = '/var/mail/voter';
 
 umask(0077);
 $| = 1;                                     # Make STDOUT unbuffered
@@ -252,66 +237,3 @@ for this issue: $monitors
 EndExplain
 }
 
-# ==========================================================================
-sub get_input_line {
-    local ($prompt, $quit_able) = @_;
-    local ($_);
-
-    do {
-        print("Enter ", $prompt, $quit_able ? " (q=quit): " : ": ");
-        $_ = <STDIN>;
-        chomp;
-        exit(0) if ($quit_able && /^q$/i);
-    } while (/^$/);
-
-    return $_;
-}
-
-# ==========================================================================
-sub found_in_group {
-    local ($voter, $groupfile) = @_;
-    local ($_);
-
-    open(INFILE, $groupfile) || return 0;
-    while ($_ = <INFILE>) {
-        chomp;
-        s/#.*$//;
-        s/\s+$//;
-        s/^\s+//;
-        if ($_ eq $voter) {
-            close(INFILE);
-            return 1;
-        }
-    }
-    close(INFILE);
-    return 0;
-}
-
-# ==========================================================================
-sub filestuff {
-    local ($filename) = @_;
-    local ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-           $atime,$mtime,$ctime,$blksize,$blocks);
-
-    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-     $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
-
-    return "$ino:$mtime";
-}
-
-# ==========================================================================
-sub get_hash_of {
-    local ($item) = @_;
-    local ($rv);
-
-    if (-x $MD5) {
-        $rv = `$MD5 -q -s "$item"` || die "$pname: failed md5: $!\n";
-    }
-    else {
-        $rv = `$ECHO "$item" | $OPENSSL md5`
-              || die "$pname: failed openssl md5: $!\n";
-    }
-    chomp $rv;
-    return $rv;
-}
-

Added: steve/trunk/cmdline/steve.pm
URL: http://svn.apache.org/viewvc/steve/trunk/cmdline/steve.pm?rev=1485815&view=auto
==============================================================================
--- steve/trunk/cmdline/steve.pm (added)
+++ steve/trunk/cmdline/steve.pm Thu May 23 18:39:12 2013
@@ -0,0 +1,207 @@
+#!/usr/bin/perl
+#####
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#####
+# steve.pm
+# shared functions for Apache Steve.
+#
+
+$ECHO     = '/bin/echo';
+$CAT      = '/bin/cat';
+$MD5      = '/sbin/md5';
+$OPENSSL  = '/usr/bin/openssl';
+$TOUCH    = '/usr/bin/touch';
+$SENDMAIL = '/usr/sbin/sendmail';
+$DIFF     = '/usr/bin/diff';
+$MV       = '/bin/mv';
+
+
+$homedir  = '/home/voter';
+$issuedir = "$homedir/issues";
+$host     = 'people.apache.org';
+
+$ENV{'PATH'}    = "$homedir/bin:/usr/bin:/usr/sbin:/bin:/sbin";
+$ENV{'LOGNAME'} = 'voter';
+$ENV{'GROUP'}   = 'voter';
+$ENV{'USER'}    = 'voter';
+$ENV{'HOME'}    = '/home/voter';
+$ENV{'MAIL'}    = '/var/mail/voter';
+
+# ==========================================================================
+sub get_input_line {
+    local ($prompt, $quit_able) = @_;
+    local ($_);
+
+    do {
+        print("Enter ", $prompt, $quit_able ? " (q=quit): " : ": ");
+        $_ = <STDIN>;
+        chomp;
+        exit(0) if ($quit_able && /^q$/i);
+    } while (/^$/);
+
+    return $_;
+}
+
+# ==========================================================================
+sub get_group {
+    local ($groupfile) = @_;
+    local ($_, @rv);
+
+    open(INFILE, $groupfile) || die "$pname: cannot open $groupfile: $!\n";
+    while ($_ = <INFILE>) {
+        chomp;
+        s/#.*$//;
+        s/\s+$//;
+        s/^\s+//;
+        next if (/^$/);
+        die "$pname: voter must be an Internet e-mail address\n"
+            unless (/\@/);
+        push(@rv, $_);
+    }
+    close(INFILE);
+    return @rv;
+}
+
+# ==========================================================================
+sub filestuff {
+    local ($filename) = @_;
+    local ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+           $atime,$mtime,$ctime,$blksize,$blocks);
+
+    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+     $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
+
+    return "$ino:$mtime";
+}
+
+# ==========================================================================
+sub get_hash_of {
+    local ($item) = @_;
+    local ($rv);
+
+    if (-x $MD5) {
+        $rv = `$MD5 -q -s "$item"` || die "$pname: failed md5: $!\n";
+    }
+    else {
+        $rv = `$ECHO "$item" | $OPENSSL md5`
+              || die "$pname: failed openssl md5: $!\n";
+    }
+    chomp($rv);
+    return $rv;
+}
+
+# ==========================================================================
+sub hash_file {
+    local ($filename) = @_;
+    local ($rv);
+
+    if (-x $MD5) {
+        $rv = `$MD5 -q "$filename"` || die "$pname: failed md5: $!\n";
+    }
+    else {
+        $rv = `$CAT "$filename" | $OPENSSL md5`
+              || die "$pname: failed openssl md5: $!\n";
+    }
+    chomp($rv);
+    return $rv;
+}
+
+# ==========================================================================
+sub debug_hash {
+    print "==============================================================\n";
+    foreach $voter (@voters) {
+        print "$hash1{$voter} $hash2{$voter} $voter\n";
+    }
+    print "==============================================================\n";
+}
+
+# ==========================================================================
+sub read_tally {
+    local ($filename) = @_;
+    local ($_, %rv);
+
+    %rv = ();
+
+    open(INFILE, $filename) || die "$pname: cannot open $filename: $!\n";
+    while ($_ = <INFILE>) {
+        chomp;
+        if (/\] (\S+) (\S+)$/o) {
+            $rv{$1} = $2;
+        }
+        else {
+            warn "Invalid vote in tally: $_";
+        }
+    }
+    close(INFILE);
+
+    return %rv;
+}
+
+# ==========================================================================
+sub found_in_group {
+    local ($voter, $groupfile) = @_;
+    local ($_);
+
+    open(INFILE, $groupfile) || return 0;
+    while ($_ = <INFILE>) {
+        chomp;
+        s/#.*$//;
+        s/\s+$//;
+        s/^\s+//;
+        if ($_ eq $voter) {
+            close(INFILE);
+            return 1;
+        }
+    }
+    close(INFILE);
+    return 0;
+}
+
+# ==========================================================================
+sub get_date {
+    local ($sec, $min, $hour, $mday, $mon, $year) = gmtime(time);
+
+    return sprintf("%04d/%02d/%02d %02d:%02d:%02d", 1900 + $year,
+                   $mon+1, $mday, $hour, $min, $sec);
+}
+
+# ==========================================================================
+sub contains_duplicates {
+    local ($str) = @_;
+    local (%ctr, $ch);
+
+    foreach $ch (split(//, $str)) {
+        $ctr{$ch} = 1;
+    }
+    return (length($str) != scalar(keys(%ctr)));
+}
+
+# ==========================================================================
+
+sub not_valid {
+  my (@votes, %valid);
+  @votes = split(//, shift(@_));
+  for (@_) {
+      chomp;
+      $valid{$_} = 1;
+  }
+  for (@votes) {
+      return 1 unless $valid{$_} == 1;
+  }
+  return 0;
+}
+
+1;

Propchange: steve/trunk/cmdline/steve.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: steve/trunk/cmdline/vote.pl
URL: http://svn.apache.org/viewvc/steve/trunk/cmdline/vote.pl?rev=1485815&r1=1485814&r2=1485815&view=diff
==============================================================================
--- steve/trunk/cmdline/vote.pl (original)
+++ steve/trunk/cmdline/vote.pl Thu May 23 18:39:12 2013
@@ -56,21 +56,8 @@
 # 
 # Originally created by Roy Fielding
 #
-$ECHO     = '/bin/echo';
-$CAT      = '/bin/cat';
-$MD5      = '/sbin/md5';
-$OPENSSL  = '/usr/bin/openssl';
-$SENDMAIL = '/usr/sbin/sendmail';
-
-$homedir  = '/home/voter';
-$issuedir = "$homedir/issues";
-
-$ENV{'PATH'}    = "$homedir/bin:/usr/bin:/usr/sbin:/bin:/sbin";
-$ENV{'LOGNAME'} = 'voter';
-$ENV{'GROUP'}   = 'voter';
-$ENV{'USER'}    = 'voter';
-$ENV{'HOME'}    = "/home/voter";
-$ENV{'MAIL'}    = '/var/mail/voter';
+
+use steve;
 
 umask(0077);
 $| = 1;                                     # Make STDOUT unbuffered
@@ -302,114 +289,3 @@ print "Mail has been sent to voter and t
 print "You may re-vote until issue is closed; only last vote is counted.\n";
 exit(0);
 
-# ==========================================================================
-# ==========================================================================
-sub get_input_line {
-    local ($prompt, $quit_able) = @_;
-    local ($_);
-
-    do {
-        print("Enter ", $prompt, $quit_able ? " (q=quit): " : ": ");
-        $_ = <STDIN>;
-        chomp;
-        exit(0) if ($quit_able && /^q$/i);
-    } while (/^$/);
-
-    return $_;
-}
-
-# ==========================================================================
-sub get_group {
-    local ($groupfile) = @_;
-    local ($_, @rv);
-
-    open(INFILE, $groupfile) || die "$pname: cannot open $groupfile: $!\n";
-    while ($_ = <INFILE>) {
-        chomp;
-        s/#.*$//;
-        s/\s+$//;
-        s/^\s+//;
-        next if (/^$/);
-        push(@rv, $_);
-    }
-    close(INFILE);
-    return @rv;
-}
-
-# ==========================================================================
-sub filestuff {
-    local ($filename) = @_;
-    local ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-           $atime,$mtime,$ctime,$blksize,$blocks);
-
-    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-     $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
-
-    return "$ino:$mtime";
-}
-
-# ==========================================================================
-sub get_hash_of {
-    local ($item) = @_;
-    local ($rv);
-
-    if (-x $MD5) {
-        $rv = `$MD5 -q -s "$item"` || die "$pname: failed md5: $!\n";
-    }
-    else {
-        $rv = `$ECHO "$item" | $OPENSSL md5`
-              || die "$pname: failed openssl md5: $!\n";
-    }
-    chomp $rv;
-    return $rv;
-}
-
-# ==========================================================================
-sub hash_file {
-    local ($filename) = @_;
-    local ($rv);
-
-    if (-x $MD5) {
-        $rv = `$MD5 -q "$filename"` || die "$pname: failed md5: $!\n";
-    }
-    else {
-        $rv = `$CAT "$filename" | $OPENSSL md5`
-              || die "$pname: failed openssl md5: $!\n";
-    }
-    chomp $rv;
-    return $rv;
-}
-
-# ==========================================================================
-sub get_date {
-    local ($sec, $min, $hour, $mday, $mon, $year) = gmtime(time);
-
-    return sprintf("%04d/%02d/%02d %02d:%02d:%02d", 1900 + $year,
-                   $mon+1, $mday, $hour, $min, $sec);
-}
-
-# ==========================================================================
-sub contains_duplicates {
-    local ($str) = @_;
-    local (%ctr, $ch);
-
-    foreach $ch (split(//, $str)) {
-        $ctr{$ch} = 1;
-    }
-    return (length($str) != scalar(keys(%ctr)));
-}
-
-# ==========================================================================
-
-sub not_valid {
-  my (@votes, %valid);
-  @votes = split(//, shift(@_));
-  for (@_) {
-      chomp;
-      $valid{$_} = 1;
-  }
-  for (@votes) {
-      return 1 unless $valid{$_} == 1;
-  }
-  return 0;
-}

Modified: steve/trunk/cmdline/votegroup.pl
URL: http://svn.apache.org/viewvc/steve/trunk/cmdline/votegroup.pl?rev=1485815&r1=1485814&r2=1485815&view=diff
==============================================================================
--- steve/trunk/cmdline/votegroup.pl (original)
+++ steve/trunk/cmdline/votegroup.pl Thu May 23 18:39:12 2013
@@ -26,15 +26,7 @@
 # Originally created by Roy Fielding
 #
 require "getopts.pl";
-
-$DIFF     = '/usr/bin/diff';
-$MV       = '/bin/mv';
-$CAT      = '/bin/cat';
-$MD5      = '/sbin/md5';
-$OPENSSL  = '/usr/bin/openssl';
-
-$homedir  = '/home/voter';
-$issuedir = "$homedir/issues";
+use steve;
 
 $ENV{'PATH'} = "$homedir/bin:/usr/bin:/usr/sbin:/bin:/sbin";
 
@@ -179,55 +171,3 @@ print &hash_file($votersfile), ': ', $pf
 
 exit(0);
 
-# ==========================================================================
-# ==========================================================================
-sub get_input_line {
-    local ($prompt, $quit_able) = @_;
-    local ($_);
-
-    do {
-        print("Enter ", $prompt, $quit_able ? " (q=quit): " : ": ");
-        $_ = <STDIN>;
-        chomp;
-        exit(0) if ($quit_able && /^q$/i);
-    } while (/^$/);
-
-    return $_;
-}
-
-# ==========================================================================
-sub get_group {
-    local ($groupfile) = @_;
-    local ($_, @rv);
-
-    open(INFILE, $groupfile) || die "$pname: cannot open $groupfile: $!\n";
-    while ($_ = <INFILE>) {
-        chomp;
-        s/#.*$//;
-        s/\s+$//;
-        s/^\s+//;
-        next if (/^$/);
-        die "$pname: voter must be an Internet e-mail address\n"
-            unless (/\@/);
-        push(@rv, $_);
-    }
-    close(INFILE);
-    return @rv;
-}
-
-# ==========================================================================
-sub hash_file {
-    local ($filename) = @_;
-    local ($rv);
-
-    if (-x $MD5) {
-        $rv = `$MD5 -q "$filename"` || die "$pname: failed md5: $!\n";
-    }
-    else {
-        $rv = `$CAT "$filename" | $OPENSSL md5`
-              || die "$pname: failed openssl md5: $!\n";
-    }
-    chomp($rv);
-    return $rv;
-}
-