Alien-SVN

 view release on metacpan or  search on metacpan

src/subversion/subversion/bindings/swig/perl/native/Core.pm  view on Meta::CPAN

which gives it an auth_baton and putting the other
ones in an array.  The first return value of this
function is the auth_baton, the second is a reference
to an array containing the references to the callbacks.

These callback arrays should be stored in the object
the auth_baton is attached to.

=back

=cut

sub auth_open_helper {
    my $args = shift;
    my (@auth_providers,@auth_callbacks);

    foreach my $arg (@{$args}) {
        if (ref($arg) eq '_p_svn_auth_provider_object_t') {
            push @auth_providers, $arg;
        } else {
            push @auth_callbacks, $arg;
        }
    }
    my $auth_baton = SVN::Core::auth_open(\@auth_providers);
    return ($auth_baton,\@auth_callbacks);
}

# import the INVALID and IGNORED constants
our $INVALID_REVNUM = $SVN::_Core::SWIG_SVN_INVALID_REVNUM;
our $IGNORED_REVNUM = $SVN::_Core::SWIG_SVN_IGNORED_REVNUM;

package _p_svn_stream_t;
use SVN::Base qw(Core svn_stream_);

package SVN::Stream;
use IO::Handle;
our @ISA = qw(IO::Handle);

=head1 OTHER OBJECTS

=head2 svn_stream_t - SVN::Stream

You can use native perl io handles (including io globs) as
svn_stream_t in subversion functions. Returned svn_stream_t are also
translated into perl io handles, so you could access them with regular
print, read, etc.

Note that some functions take a stream to read from or write to, but do not
close the stream while still holding the reference to the io handle.
In this case the handle won't be destroyed properly.
You should always set up the correct default pool before calling
such functions.

=cut

use Symbol ();

sub new
{
    my $class = shift;
    my $self = bless Symbol::gensym(), ref($class) || $class;
    tie *$self, $self;
    *$self->{svn_stream} = shift;
    $self;
}

sub svn_stream {
    my $self = shift;
    *$self->{svn_stream};
}

sub TIEHANDLE
{
    return $_[0] if ref($_[0]);
    my $class = shift;
    my $self = bless Symbol::gensym(), $class;
    *$self->{svn_stream} = shift;
    $self;
}

sub CLOSE
{
    my $self = shift;
    *$self->{svn_stream}->close
        if *$self->{svn_stream};
    undef *$self->{svn_stream};
}

sub GETC
{
    my $self = shift;
    my $buf;
    return $buf if $self->read($buf, 1);
    return undef;
}

sub print
{
    my $self = shift;
    $self->WRITE($_[0], length($_[0]));
}

sub PRINT
{
    my $self = shift;
    if (defined $\) {
        if (defined $,) {
            $self->print(join($,, @_).$\);
        } else {
            $self->print(join("",@_).$\);
        }
    } else {
        if (defined $,) {
            $self->print(join($,, @_));
        } else {
            $self->print(join("",@_));
        }
    }
}

sub PRINTF
{
    my $self = shift;
    my $fmt = shift;
    $self->print(sprintf($fmt, @_));
}

sub getline
{
    my $self = shift;
    *$self->{pool} ||= SVN::Core::pool_create(undef);
    my ($buf, $eof) = *$self->{svn_stream}->readline($/, *$self->{pool});
    return undef if $eof && !length($buf);
    return $eof ? $buf : $buf.$/;
}

src/subversion/subversion/bindings/swig/perl/native/Core.pm  view on Meta::CPAN

use SVN::Base qw(Core svn_pool_);

=head2 svn_pool_t - SVN::Pool

The perl bindings significantly simplify the usage of pools, while
still being manually adjustable.

For functions requiring a pool as the last argument (which are, almost all
of the subversion functions), the pool argument is optional. The default pool
is used if it is omitted. When C<SVN::Core> is loaded, it creates a
new default pool, which is also available from C<SVN::Core-E<gt>gpool>.

For callback functions providing a pool to your subroutine, you could
also use $pool-E<gt>default to make it the default pool in the scope.

=head3 Methods

=over 4

=item new([$parent])

Create a new pool. The pool is a root pool if $parent is not supplied.

=item new_default([$parent])

Create a new pool. The pool is a root pool if $parent is not supplied.
Set the new pool as default pool.

=item new_default_sub

Create a new subpool of the current default pool, and set the
resulting pool as new default pool.

=item clear

Clear the pool.

=item DESTROY

Destroy the pool. If the pool was the default pool, restore the
previous default pool. This is normally called
automatically when the SVN::Pool object is no longer used and
destroyed by the perl garbage collector.

=back

=cut

{
    # block is here to restrict no strict refs to this block
    no strict 'refs';
    *{"apr_pool_$_"} = *{"SVN::_Core::apr_pool_$_"}
        for qw/clear destroy/;
}

my @POOLSTACK;

sub new {
    my ($class, $parent) = @_;
    $parent = $$parent if ref($parent) eq 'SVN::Pool';
    my $self = bless \create($parent), $class;
    return $self;
}

sub new_default_sub {
    my $parent = ref($_[0]) ? ${+shift} : $SVN::_Core::current_pool;
    my $self = SVN::Pool->new_default($parent);
    return $self;
}

sub new_default {
    my $self = new(@_);
    $self->default;
    return $self;
}

sub default {
    my $self = shift;
    push @POOLSTACK, $SVN::_Core::current_pool
        unless $$SVN::_Core::current_pool == 0;
    $SVN::_Core::current_pool = $$self;
}

sub clear {
    my $self = shift;
    apr_pool_clear($$self);
}

my $globaldestroy;

END {
    $globaldestroy = 1;
}

my %WRAPPOOL;

# Create a cloned _p_apr_pool_t pointing to the same apr_pool_t
# but on different address. this allows pools that are from C
# to have proper lifetime.
sub _wrap {
    my ($class, $rawpool) = @_;
    my $pool = \$rawpool;
    bless $pool, '_p_apr_pool_t';
    my $npool = \$pool;
    bless $npool, $class;
    $WRAPPOOL{$npool} = 1;
    $npool;
}

use Scalar::Util 'reftype';

sub DESTROY {
    return if $globaldestroy;
    my $self = shift;
    # for some reason, REF becomes SCALAR in perl -c or after apr_terminate
    return if reftype($self) eq 'SCALAR';
    if ($$self eq $SVN::_Core::current_pool) {
        $SVN::_Core::current_pool = pop @POOLSTACK;
    }
    if (exists $WRAPPOOL{$self}) {
        delete $WRAPPOOL{$self};
    }
    else {
        apr_pool_destroy($$self)
    }
}

package _p_svn_error_t;
use SVN::Base qw(Core svn_error_t_);

sub strerror {
    return SVN::Error::strerror($_[$[]->apr_err());
}

sub handle_error {
    return SVN::Error::handle_error(@_);
}

sub expanded_message {
    return SVN::Error::expanded_message(@_);
}

sub handle_warning {
    # need to swap parameter order.
    return SVN::Error::handle_warning($_[$[+1],$_[$[]);
}

foreach my $function (qw(compose clear quick_wrap)) {
    no strict 'refs';
    my $real_function = \&{"SVN::_Core::svn_error_$function"};
    *{"_p_svn_error_t::$function"} = sub {
        return $real_function->(@_);
    }
}

package SVN::Error;
use SVN::Base qw(Core svn_error_);
use SVN::Base qw(Core SVN_ERR_);
use Carp;
our @CARP_NOT = qw(SVN::Base SVN::Client SVN::Core SVN::Delta
                   SVN::Delta::Editor SVN::Error SVN::Fs SVN::Node
                   SVN::Pool SVN::Ra SVN::Ra::Callbacks SVN::Ra::Reporter
                   SVN::Repos SVN::Stream SVN::TxDelta SVN::Wc);

=head2 svn_error_t - SVN::Error

src/subversion/subversion/bindings/swig/perl/native/Core.pm  view on Meta::CPAN


Other failure. This can happen if some unknown error condition occurs.

=back

=cut

package SVN::Auth::SSL;
use SVN::Base qw(Core SVN_AUTH_SSL_);

package _p_svn_lock_t;
use SVN::Base qw(Core svn_lock_t_);

=head2 _p_svn_lock_t

Objects of this class contain information about locks placed on files
in a repository.  It has the following accessor methods:

=over

=item path

The full path to the file which is locked, starting with a forward slash (C</>).

=item token

A string containing the lock token, which is a unique URI.

=item owner

The username of whoever owns the lock.

=item comment

A comment associated with the lock, or undef if there isn't one.

=item is_dav_comment

True if the comment was made by a generic DAV client.

=item creation_date

Time at which the lock was created, as the number of microseconds since
00:00:00 S<January 1>, 1970 UTC.  Divide it by 1_000_000 to get a Unix
time_t value.

=item expiration_date

When the lock will expire.  Has the value '0' if the lock will never expire.

=back

=cut

package SVN::MD5;
use overload
    '""' => sub { SVN::Core::md5_digest_to_cstring(${$_[0]})};

sub new {
    my ($class, $digest) = @_;
    bless \$digest, $class;
}

=head1 AUTHORS

Chia-liang Kao E<lt>clkao@clkao.orgE<gt>

=head1 COPYRIGHT

    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.

=cut

1;



( run in 1.788 second using v1.01-cache-2.11-cpan-39bf76dae61 )