| 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::Local; | ||||||||||
| 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::Local - a connection to a local 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 the localhost. See | ||||||||||
| 25 | VCS::LibCVS::Client::Connection for an explanation of the API. | ||||||||||
| 26 | |||||||||||
| 27 | No authentication is required to establish this connection. | ||||||||||
| 28 | |||||||||||
| 29 | =head1 SUPERCLASS | ||||||||||
| 30 | |||||||||||
| 31 | VCS::LibCVS::Client::Connection | ||||||||||
| 32 | |||||||||||
| 33 | =cut | ||||||||||
| 34 | |||||||||||
| 35 | ############################################################################### | ||||||||||
| 36 | # Class constants | ||||||||||
| 37 | ############################################################################### | ||||||||||
| 38 | |||||||||||
| 39 | 1 | ▶ | use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/Client/Connection/Local.pm,v 1.16 2005/10/10 12:52:11 dissent Exp $ '; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | |||||||||||
| 41 | 1 | ▶ | use vars ('@ISA'); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 42 | 1 | @ISA = ("VCS::LibCVS::Client::Connection"); | |||||||||
| 43 | |||||||||||
| 44 | ############################################################################### | ||||||||||
| 45 | # Initializer | ||||||||||
| 46 | ############################################################################### | ||||||||||
| 47 | |||||||||||
| 48 | # register which protocols this subclass supports. | ||||||||||
| 49 | 1 | ▶ | sub BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 50 | 1 | my $class = "VCS::LibCVS::Client::Connection::Local"; | |||||||||
| 51 | 1 | $VCS::LibCVS::Client::Connection::Protocol_map{"local"} = $class; | |||||||||
| 52 | 1 | $VCS::LibCVS::Client::Connection::Protocol_map{"fork"} = $class; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | ############################################################################### | ||||||||||
| 56 | # Private variables | ||||||||||
| 57 | ############################################################################### | ||||||||||
| 58 | |||||||||||
| 59 | # $self->{PID} The process Id of the child process. | ||||||||||
| 60 | |||||||||||
| 61 | ############################################################################### | ||||||||||
| 62 | # Class routines | ||||||||||
| 63 | ############################################################################### | ||||||||||
| 64 | |||||||||||
| 65 | ############################################################################### | ||||||||||
| 66 | # Instance routines | ||||||||||
| 67 | ############################################################################### | ||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | sub connect { | ||||||||
|
Subroutine
connect: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 70 | 0 | my $self = shift; | |||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | return if $self->connected(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | |||||||||||
| 74 | 0 | $self->SUPER::connect(); | |||||||||
| 75 | 0 | $self->{SubFromServer} = IO::Handle->new(); | |||||||||
| 76 | 0 | $self->{SubToServer} = IO::Handle->new(); | |||||||||
| 77 | $self->{PID} = IPC::Open2::open2($self->{SubFromServer}, | ||||||||||
| 78 | $self->{SubToServer}, | ||||||||||
| 79 | 0 | "cvs server"); | |||||||||
| 80 | 0 | $self->connect_fin(); | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | 0 | ▶ | sub disconnect { | ||||||||
|
Subroutine
disconnect: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 84 | 0 | my $self = shift; | |||||||||
| 85 | |||||||||||
| 86 | 0 | ▶ | return if ! $self->connected(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | |||||||||||
| 88 | 0 | $self->SUPER::disconnect(); | |||||||||
| 89 | 0 | $self->{SubFromServer}->close(); | |||||||||
| 90 | 0 | $self->{SubToServer}->close(); | |||||||||
| 91 | 0 | waitpid ($self->{PID}, 0); | |||||||||
| 92 | } | ||||||||||
| 93 | |||||||||||
| 94 | ############################################################################### | ||||||||||
| 95 | # Private routines | ||||||||||
| 96 | ############################################################################### | ||||||||||
| 97 | |||||||||||
| 98 | =head1 SEE ALSO | ||||||||||
| 99 | |||||||||||
| 100 | VCS::LibCVS::Client | ||||||||||
| 101 | VCS::LibCVS::Client::Connection | ||||||||||
| 102 | |||||||||||
| 103 | =cut | ||||||||||
| 104 | |||||||||||
| 105 | 1 | 1; | |||||||||