diff options
author | Peter Palfrader <peter@palfrader.org> | 2004-04-24 12:25:10 +0000 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2004-04-24 12:25:10 +0000 |
commit | 75da8751b1e5a5a39f8743b44971224b0ab34c31 (patch) | |
tree | 3e194bcac050e2876c1821fd40f00b91dff63a91 /Echolot/Tools.pm | |
parent | 82c0bb931633d67a7e60bddb756264edcd4620b6 (diff) |
Move duplicated IO::Handle preperations for GnuPG::Interface to Echolot::Tools::make_gpg_fds.
Diffstat (limited to 'Echolot/Tools.pm')
-rw-r--r-- | Echolot/Tools.pm | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/Echolot/Tools.pm b/Echolot/Tools.pm index fd202f5..9dea6a3 100644 --- a/Echolot/Tools.pm +++ b/Echolot/Tools.pm @@ -18,6 +18,7 @@ Echolot::Tools - Tools for echolot use strict; use HTML::Template; use Digest::MD5 qw{}; +use IO::Handle; use GnuPG::Interface; use Echolot::Log; @@ -263,8 +264,15 @@ sub write_HTML_file($$;$%) { return 1; }; - - +sub make_gpg_fds() { + my %fds = ( + stdin => IO::Handle->new(), + stdout => IO::Handle->new(), + stderr => IO::Handle->new(), + status => IO::Handle->new() ); + my $handles = GnuPG::Handles->new( %fds ); + return ($fds{'stdin'}, $fds{'stdout'}, $fds{'stderr'}, $fds{'status'}, $handles); +}; sub crypt_symmetrically($$) { my ($msg, $direction) = @_; @@ -281,18 +289,7 @@ sub crypt_symmetrically($$) { $GnuPG->options->meta_interactive( 0 ); $GnuPG->passphrase( Echolot::Globals::get()->{'storage'}->get_secret() ); - my ( $stdin_fh, $stdout_fh, $stderr_fh, $status_fh ) - = ( IO::Handle->new(), - IO::Handle->new(), - IO::Handle->new(), - IO::Handle->new(), - ); - my $handles = GnuPG::Handles->new ( - stdin => $stdin_fh, - stdout => $stdout_fh, - stderr => $stderr_fh, - status => $status_fh - ); + my ( $stdin_fh, $stdout_fh, $stderr_fh, $status_fh, $handles ) = make_gpg_fds(); my $pid = $direction eq 'encrypt' ? $GnuPG->encrypt_symmetrically( handles => $handles ) : |