| 1 | # | ||||||||||
| 2 | # Copyright (c) 2003,2004,2005 Alexander Taler (dissent@0--0.org) | ||||||||||
| 3 | # | ||||||||||
| 4 | # All rights reserved. This program is free software; you can redistribute it | ||||||||||
| 5 | # and/or modify it under the same terms as Perl itself. | ||||||||||
| 6 | # | ||||||||||
| 7 | |||||||||||
| 8 | package VCS::LibCVS::Client::Connection::Ext; | ||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use IPC::Open2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | =head1 NAME | ||||||||||
| 15 | |||||||||||
| 16 | VCS::LibCVS::Client::Connection::Ext - a connection to a remote cvs server | ||||||||||
| 17 | |||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||
| 19 | |||||||||||
| 20 | my $conn = VCS::LibCVS::Client::Connection->new($root); | ||||||||||
| 21 | |||||||||||
| 22 | =head1 DESCRIPTION | ||||||||||
| 23 | |||||||||||
| 24 | A connection to an invocation of "cvs server" on a remote machine. See | ||||||||||
| 25 | VCS::LibCVS::Client::Connection for an explanation of the API. | ||||||||||
| 26 | |||||||||||
| 27 | The connection to the remove machine is established through an external | ||||||||||
| 28 | program. The default is "ssh", but it can be overridden by setting the | ||||||||||
| 29 | environment variable CVS_RSH. | ||||||||||
| 30 | |||||||||||
| 31 | =head1 SUPERCLASS | ||||||||||
| 32 | |||||||||||
| 33 | VCS::LibCVS::Client::Connection | ||||||||||
| 34 | |||||||||||
| 35 | =cut | ||||||||||
| 36 | |||||||||||
| 37 | ############################################################################### | ||||||||||
| 38 | # Class constants | ||||||||||
| 39 | ############################################################################### | ||||||||||
| 40 | |||||||||||
| 41 | 1 | ▶ | use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/Client/Connection/Ext.pm,v 1.7 2005/10/10 12:52:11 dissent Exp $ '; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 42 | |||||||||||
| 43 | 1 | ▶ | use vars ('@ISA'); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 44 | 1 | @ISA = ("VCS::LibCVS::Client::Connection"); | |||||||||
| 45 | |||||||||||
| 46 | ############################################################################### | ||||||||||
| 47 | # Initializer | ||||||||||
| 48 | ############################################################################### | ||||||||||
| 49 | |||||||||||
| 50 | # register which protocols this subclass supports. | ||||||||||
| 51 | 1 | ▶ | sub BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 52 | 1 | my $class = "VCS::LibCVS::Client::Connection::Ext"; | |||||||||
| 53 | 1 | $VCS::LibCVS::Client::Connection::Protocol_map{"ext"} = $class; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | ############################################################################### | ||||||||||
| 57 | # Private variables | ||||||||||
| 58 | ############################################################################### | ||||||||||
| 59 | |||||||||||
| 60 | # $self->{Root} VCS::LibCVS::Datum::Root object for my repository. | ||||||||||
| 61 | |||||||||||
| 62 | ############################################################################### | ||||||||||
| 63 | # Class routines | ||||||||||
| 64 | ############################################################################### | ||||||||||
| 65 | |||||||||||
| 66 | ############################################################################### | ||||||||||
| 67 | # Instance routines | ||||||||||
| 68 | ############################################################################### | ||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub connect { | ||||||||
|
Subroutine
connect: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 71 | 0 | my $self = shift; | |||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | return if $self->connected(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | |||||||||||
| 75 | 0 | $self->SUPER::connect(); | |||||||||
| 76 | |||||||||||
| 77 | 0 | my $user = $self->{Root}->{UserName}; | |||||||||
| 78 | 0 | ▶ | my $user_arg = (defined $user) ? ('-l ' . $user) : ""; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | |||||||||||
| 80 | my $command = ('${CVS_RSH:-ssh} ' . | ||||||||||
| 81 | $user_arg . | ||||||||||
| 82 | ' ' . $self->{Root}->{HostName} . | ||||||||||
| 83 | 0 | ' ${CVS_SERVER:-cvs} server'); | |||||||||
| 84 | 0 | $self->{SubFromServer} = IO::Handle->new(); | |||||||||
| 85 | 0 | $self->{SubToServer} = IO::Handle->new(); | |||||||||
| 86 | 0 | IPC::Open2::open2($self->{SubFromServer}, $self->{SubToServer}, $command); | |||||||||
| 87 | 0 | $self->connect_fin(); | |||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | 0 | ▶ | sub disconnect { | ||||||||
|
Subroutine
disconnect: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 91 | 0 | my $self = shift; | |||||||||
| 92 | |||||||||||
| 93 | 0 | ▶ | return if ! $self->connected(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 94 | |||||||||||
| 95 | 0 | $self->SUPER::disconnect(); | |||||||||
| 96 | 0 | $self->{SubFromServer}->close(); | |||||||||
| 97 | 0 | $self->{SubToServer}->close(); | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | ############################################################################### | ||||||||||
| 101 | # Private routines | ||||||||||
| 102 | ############################################################################### | ||||||||||
| 103 | |||||||||||
| 104 | =head1 SEE ALSO | ||||||||||
| 105 | |||||||||||
| 106 | VCS::LibCVS::Client | ||||||||||
| 107 | VCS::LibCVS::Client::Connection | ||||||||||
| 108 | |||||||||||
| 109 | =cut | ||||||||||
| 110 | |||||||||||
| 111 | 1 | 1; | |||||||||