<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Tony Smith's Utilities - Perforce Public Depot</TITLE> <META content="text/html; charset=iso8859-1" http-equiv=Content-Type> <BODY bgColor=#ffffff> <CENTER> <A name=toc><H2>Perforce API Tools</H2></A> </CENTER> <p> Congratulations! You have found the source code for my Perl extension for the Perforce API. Before you can compile it successfully, you will need to download the Perforce API tarball separately from the <a href="ftp://ftp.perforce.com/pub/perforce">Perforce FTP Site</a>. <h3>Licence </h3> <p>This extension is distributed under the terms of <a href="http://public.perforce.com/guest/tony_smith/perforce/API/P4-Client/LICENSE">this</a> license, which is basically the BSD license. You use it at your own risk. <h3>Support </h3> <p> Please send cries for help/comments/suggestions/ports/patches to <a href="mailto:tony@perforce.com">tony@perforce.com</a>. I'll deal with them as quickly as possible. <h3>Download</h3> <table border="1" width="100%"> <tr> <th width="48%">Stable</th> <th width="52%">Development</th> </tr> <tr> <td valign="top" width="48%"> <p><a href="http://public.perforce.com:8080/@md=d&cd=//guest/tony_smith/perforce/API/&cdf=//guest/tony_smith/perforce/API/P4-Client-0.51.tar.gz&sr=530@//guest/tony_smith/perforce/API/P4-Client-0.52.tar.gz">P4-Client-0.52.tar.gz</a></p> <p>Also available from <a href="http://www.cpan.org">CPAN</a> (under Author SMEE). Currently not yet on the module list.</p> </td> <td width="52%"> <p>Version 0.53<br> Sync the files under</p> <p> //guest/tony_smith/perforce/API/P4-Client/... </p> <p>to get the development version. Minor bug fixes only.</p> </td> </tr> </table> <h3>Porting Matrix</h3> <p>The following porting combinations have been successfully built and tested and should compile without problems. Perl's build environment is not ideally suited to C++ extensions (or at least I haven't found a really good way of making it work with C++ extensions) so you building on other platforms may require some fiddling with the compiler rules. See hints/linux.pl and the PORTING file for hints on how to go about it.</p> <p>If you port it to another platform, please send me the hints file so we can make it available for other users.</p> <table border="1" cellpadding="5"> <tr> <th>Platform</th> <th>Perl Versions</th> <tr> <td>FreeBSD</td> <td>Perl 5.5_003<br> Perl 5.6.0</td> </tr> <tr> <td>Linux</td> <td>Perl 5.5_003<br> Perl 5.6.0</td> </tr> <tr> <td>Microsoft Windows2000</td> <td>Perl 5.6.0</td> </tr> </table> <h3>Example</h3> <p>Here's a sample perl script using the API ( example.pl )</p> <pre>#!/usr/bin/perl -w #******************************************************************************* #* #* First derive a class from P4::UI so we can override the default behaviour #* with our own. Specifically, we want to cache the results of fstat's on #* multiple files and allow the caller to iterate through them later. #* #******************************************************************************* package P4::Fstat; use P4::UI; use strict; use vars qw( @ISA ); # Derive this class from P4::UI @ISA = qw( P4::UI ); # # Define a constructor for this class # sub new { my $class = shift; my $self = new P4::UI; $self->{'Records'} = []; bless( $self, $class ); return $self; } # # p4 fstat produces tagged output which is printed by the OutputStat # method in P4::UI so override that to get our own behaviour. P4::Client # arranges for the tagged output to be passed to this method as a hash, # but it will get cleaned up on return so you have to copy the data if # you want to save it. # sub OutputStat { my $self = shift; my $record = shift; my $newrec = {}; foreach my $key ( keys %$record ) { $newrec->{ $key } = $record->{ $key }; } push( @{$self->{'Records'}}, $newrec ); return; } # # Fetch the next record from the result set. Returns undef when # there are no more records remaining. # sub Fetch { my $self = shift; if ( scalar( @{$self->{'Records'}} ) ) { return ( shift( @{$self->{'Records'}} ) ); } return undef; } # # Return all remaining records at once in an array # sub Records { my $self = shift; return @{$self->{'Records'}}; } # # Can be used to flush the rest of the results if you no longer want them # sub Flush { my $self = shift; $self->{'Records'} = (); } #******************************************************************************* #* #* Now we go back to the main package and start execution. #* #******************************************************************************* package main; use Carp; use P4::Client; my $p4 = new P4::Client; my $ui = new P4::Fstat; $p4->Init() or croak( "Can't connect to Perforce server" ); # Example call showing the use of the Records() method for getting # the results. $p4->Fstat( $ui, "..." ); foreach my $file ( $ui->Records() ) { print("Found file: ", $file->{'depotFile'}, "\n" ); } # Now run it again, but iterate through the records counting them my $rec; my $count = 0; $p4->Fstat( $ui, "..." ); $count++ while ( $rec = $ui->Fetch() ); print( "\nCounted $count files\n\n" ); </pre> </BODY></HTML>
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#19 | 6259 | Tony Smith | Update P4Perl/P4Ruby html pages with deprecation notice. | ||
#18 | 2580 | Tony Smith |
Update build matrices for P4Perl and P4Ruby as both compile and work happily with the 2002.2 API. |
||
#17 | 1164 | Tony Smith |
Reworked exception handling (hopefully for the last time) in P4/Ruby. Now exceptions are raised on completion of Perforce commands if any errors or warnings were received as part of executing the command. This change also adds documentation, and indexes the Ruby interface off my main page. Bad form to combine so many changes in one changelist, but it's getting late and I want to get them submitted! |
||
#16 | 1012 | Tony Smith | Index page update | ||
#15 | 1011 | Tony Smith |
Moved Perl API stuff one level down to make way for upcoming Ruby interface. |
||
#14 | 1000 | Tony Smith |
Add docs for Solaris port done by Jeremey Russell: "We got everything working on a Solaris 2.8 server using gcc 2.95.3, Perl 5.6.0, the Solaris27 Perforce API and the solaris.pl hint file that I sent you." |
||
#13 | 999 | Tony Smith |
Latest stable release of P4-Client (1.977) and first stable beta release of P4 (0.982). Also added the changelogs to the index page. |
||
#12 | 978 | Tony Smith |
New version of index file to help P4Web provide the right version of the docs |
||
#11 | 927 | Tony Smith | Correct bad link | ||
#10 | 926 | Tony Smith |
Reorganise layout of API stuff. Current builds maintained under current/ directory, released versions under released/ . All version numbers are <major>.<changelist> so syncing to the changelist number gets you the code for that build. Also updated the index page and added HTMLised versions of the pod to make it easy to see if this is what you need. |
||
#9 | 604 | Tony Smith | Attempt to make Konqueror browse the page properly through P4Web | ||
#8 | 583 | Tony Smith | Tidy up the Perl API index file. | ||
#7 | 578 | Tony Smith |
Release 0.52 of P4::Client hits the streets. Minor bug fix release. |
||
#6 | 568 | Tony Smith | Minor updates to index page | ||
#5 | 549 | Tony Smith |
Renamed the working directory to P4-Client as I've discovered that MakeMaker is quite happy with that and doesn't require a version number in the directory name. |
||
#4 | 527 | Tony Smith | Release P4::Client version 0.51 with Win32 support | ||
#3 | 509 | Tony Smith |
Renamed P4::ClientApi to P4::Client as it's more friendly and that's what it's called on CPAN. Subsequent changes include the actual renaming inside the code, this just creates the branch |
||
#2 | 504 | Tony Smith | Switch to webkeeper and P4Web URLs instead of P4DB. | ||
#1 | 501 | Tony Smith |
First publicly released version of the Perl interface to the Perforce API. |