/* Copyright (c) 1997-2004, Perforce Software, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTR IBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Include math.h here because it's included by some Perl headers and on * Win32 it must be included with C++ linkage. Including it here prevents it * from being reincluded later when we include the Perl headers with C linkage. */ #ifdef OS_NT # include <math.h> #endif #include "clientapi.h" #include "spec.h" #include "diff.h" /* When including Perl headers, make sure the linkage is C, not C++ */ extern "C" { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" } /******************************************************************************* * Sort out Perl oddities. ******************************************************************************/ #ifdef Error // Defined for unknown reasons by old versions of Perl to be Perl_Error # undef Error #endif /* * Later versions of perl have a different calling interface */ #ifdef PERL_REVISION # define PERL_CALL_METHOD( method, ctx ) call_method( method, ctx ) #else # define PERL_CALL_METHOD( method, ctx ) perl_call_method( method, ctx ) #endif #ifndef dTHX /* * Threaded Perl context macros aren't available in earlier Perl versions */ # define dTHX 1 #endif /******************************************************************************* * Now proceed with the normal stuff ******************************************************************************/ #include "clientuserperl.h" ClientUserPerl::ClientUserPerl( SV * perlUI ) { this->perlUI = perlUI; debug = 0; perlDiffs = 0; } void ClientUserPerl::Edit( FileSys *f1, Error *e ) { dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs( perlUI ); XPUSHs( sv_2mortal( newSVpv( f1->Name(), 0 ) ) ); PUTBACK; PERL_CALL_METHOD( "Edit", G_VOID ); // Clean up stack for return SPAGAIN; PUTBACK; FREETMPS; LEAVE; } void ClientUserPerl::ErrorPause( char *errBuf, Error *e ) { dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs( perlUI ); XPUSHs( sv_2mortal( newSVpv( errBuf, 0 ) ) ); PUTBACK; PERL_CALL_METHOD( "ErrorPause", G_VOID ); // Clean up stack for return SPAGAIN; PUTBACK; FREETMPS; LEAVE; } void ClientUserPerl::HandleError( Error *e ) { StrBuf errBuf; e->Fmt( &errBuf ); dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs( perlUI ); XPUSHs( sv_2mortal( newSVpv( errBuf.Text(), errBuf.Length() ) ) ); PUTBACK; PERL_CALL_METHOD( "OutputError", G_VOID ); // Clean up stack for return SPAGAIN; PUTBACK; FREETMPS; LEAVE; } void ClientUserPerl::InputData( StrBuf *strbuf, Error *e ) { I32 n; /* Number of items returned */ int useHash = 0; dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs( perlUI ); PUTBACK; n = PERL_CALL_METHOD( "InputData", G_SCALAR ); SPAGAIN; if ( ! n ) { PUTBACK; return; } if ( debug ) printf( "InputData: Received input from Perl space\n" ); SV *sv = POPs; HV *hv; if ( SvROK( sv ) ) { // We've been passed a reference - hopefully to a hash hv = (HV *)SvRV( sv ); useHash = 1; if ( debug ) printf( "InputData: Input looks like a hash ref\n" ); } else if ( SvTYPE( sv ) == SVt_PV ) { strbuf->Set( SvPV( sv, PL_na ) ); } else if ( SvTYPE( sv ) == SVt_PVHV ) { hv = (HV *)sv; useHash = 1; if ( debug ) printf( "InputData: Input is hash.\n" ); } else { warn( "Invalid data returned from InputData() method" ); } if( useHash ) { /* * If we've been sent a specdef string by the server we use * a form. We Format the form into a StrBuf and return that * to our caller */ if ( varList->GetVar( "specdef" ) ) HashToForm( hv, strbuf ); else warn( "Can't convert hashref into a form. No spec supplied" ); } PUTBACK; FREETMPS; LEAVE; } void ClientUserPerl::OutputError( char *errBuf ) { dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs( perlUI ); XPUSHs( sv_2mortal( newSVpv( errBuf, 0 ) ) ); PUTBACK; PERL_CALL_METHOD( "OutputError", G_VOID ); // Clean up stack for return SPAGAIN; PUTBACK; FREETMPS; LEAVE; } void ClientUserPerl::OutputInfo( char level, const_char *data ) { int lev; dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); // Put args on stack lev = level - '0'; XPUSHs( perlUI ); XPUSHs( sv_2mortal( newSViv( lev ) ) ); // Must cast to char * to keep perl 5.5 happy XPUSHs( sv_2mortal( newSVpv( (char *)data, 0 ) ) ); PUTBACK; PERL_CALL_METHOD( "OutputInfo", G_VOID ); // Clean up stack for return SPAGAIN; PUTBACK; FREETMPS; LEAVE; } /* * Tagged output format. For this we create a hash mapping the tags * to the values. Then we pass the HV to the perl sub */ void ClientUserPerl::OutputStat( StrDict *varList ) { HV *hv; SV *href; StrPtr var, val; StrDict *input = varList; StrPtr *data = varList->GetVar( "data" ); StrPtr *spec = varList->GetVar( "specdef" ); SpecDataTable specData; Error e; // Enter new Perl scope dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); if ( debug ) printf( "OutputStat: starting to parse data\n" ); // Create a new HV and make it mortal hv = newHV(); sv_2mortal( (SV *)hv ); /* * If both spec and data are defined, then the user has set both the * "tag" and "specstring" protocol options so we do them the * favour of parsing the spec here and presenting the parsed * spec as a hash of key->value pairs. If not, then we just * produce a direct hash from the StrDict object. */ if ( spec && data ) { if ( debug ) printf( "OutputStat: spec and data both defined\n" ); Spec s( spec->Text(), "" ); // Use ParseNoValid to avoid invalid data in the form causing // an unnecessary parse failure. s.ParseNoValid( data->Text(), &specData, &e ); if ( e.Test() ) { HandleError( &e ); return; } input = specData.Dict(); } // Now store the rest if ( debug ) printf( "OutputStat: Converting dictionary to hash\n" ); DictToHash( input, hv ); if ( debug ) printf( "OutputStat: Conversion done.\n" ); // Now call the perl sub and pass a ref to the HV as its arg href = sv_2mortal( newRV( (SV *)hv ) ); XPUSHs( perlUI ); XPUSHs( href ); PUTBACK; PERL_CALL_METHOD( "OutputStat", G_VOID ); SPAGAIN; PUTBACK; FREETMPS; LEAVE; } void ClientUserPerl::OutputText( const_char *data, int length ) { dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); // Put args on stack XPUSHs( perlUI ); XPUSHs( sv_2mortal( newSVpv( (char *)data, 0 ) ) ); XPUSHs( sv_2mortal( newSViv( length ) ) ); PUTBACK; PERL_CALL_METHOD( "OutputText", G_VOID ); // Clean up stack for return SPAGAIN; PUTBACK; FREETMPS; LEAVE; } void ClientUserPerl::OutputBinary( const_char *data, int length ) { dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); // Put args on stack XPUSHs( perlUI ); XPUSHs( sv_2mortal( newSVpv( (char *)data, 0 ) ) ); XPUSHs( sv_2mortal( newSViv( length ) ) ); PUTBACK; PERL_CALL_METHOD( "OutputBinary", G_VOID ); // Clean up stack for return SPAGAIN; PUTBACK; FREETMPS; LEAVE; } /* * Prompts the user for input. If noEcho is true, then we call the * ClientUser version as that deals with Terminal handling nicely. */ void ClientUserPerl::Prompt( const StrPtr &msg, StrBuf &rsp, int noEcho, Error *e ) { int n; if ( noEcho ) { ClientUser::Prompt( msg, rsp, noEcho, e ); return; } dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); // Put args on stack XPUSHs( perlUI ); XPUSHs( sv_2mortal( newSVpv( msg.Text(), msg.Length() ) ) ); PUTBACK; n = PERL_CALL_METHOD( "Prompt", G_SCALAR ); // Clean up stack for return SPAGAIN; if ( n == 1 ) rsp.Set( POPp ); PUTBACK; FREETMPS; LEAVE; } /* * Support for capturing the output of "p4 diff". Since the Diff class only * supports writing its output to a FILE object, we write it to a temp file, * and then read that in redirecting it via OutputText() to the client. */ void ClientUserPerl::Diff( FileSys *f1, FileSys *f2, int doPage, char *diffFlags, Error *e ) { /* * If the user has asked to do the diffs in Perl space, then * we just defer it to their P4::UI implementation. Otherwise we * do the honours here and push out the results through the normal * channels. */ if ( perlDiffs ) { dTHX; dSP; ENTER; SAVETMPS; PUSHMARK(SP); /* * Note: ClientUser::Diff() is not invoked by the server unless * the MD5 sum of the client file differs from that of the * server file, so the check below is probably redundant. It's * included here in case this behaviour varies across server * versions (past and future). */ int differs = f1->Compare( f2, e ); XPUSHs( perlUI ); XPUSHs( sv_2mortal( newSVpv( f1->Name(), 0 ) ) ); XPUSHs( sv_2mortal( newSVpv( f2->Name(), 0 ) ) ); XPUSHs( sv_2mortal( newSVpv( diffFlags, 0 ) ) ); XPUSHs( sv_2mortal( newSViv( differs ) ) ); PUTBACK; PERL_CALL_METHOD( "Diff", G_VOID ); // Clean up stack for return SPAGAIN; PUTBACK; FREETMPS; LEAVE; return; } /* * Not doing diffs in Perl space. */ if ( !f1->IsTextual() || !f2->IsTextual() ) { if ( f1->Compare( f2, e ) ) { StrRef s( "(... files differ ...)" ); OutputText( s.Text(), s.Length() ); } return; } // Got two text files to diff. We diff them to a temp file // and then call OutputText() for each line in the file FileSys *f1_bin = FileSys::Create( FST_BINARY ); FileSys *f2_bin = FileSys::Create( FST_BINARY ); FileSys *t = FileSys::CreateGlobalTemp( f1->GetType() ); f1_bin->Set( f1->Name() ); f2_bin->Set( f2->Name() ); { // In its own block to make sure that the Diff object gets // deleted before the FileSys objects do. #ifndef OS_NEXT :: #endif Diff d; StrBuf b; d.SetInput( f1_bin, f2_bin, diffFlags, e ); if ( ! e->Test() ) d.SetOutput( t->Name(), e ); if ( ! e->Test() ) d.DiffWithFlags( diffFlags ); d.CloseOutput( e ); if ( ! e->Test() ) t->Open( FOM_READ, e ); if ( ! e->Test() ) t->ReadWhole( &b, e ); if ( ! e->Test() ) OutputText( b.Text(), b.Length() ); } delete t; delete f1_bin; delete f2_bin; if ( e->Test() ) HandleError( e ); } /* * Convert a dictionary to a hash. Numbered elements are converted * into an array member of the hash. */ void ClientUserPerl::DictToHash( StrDict *d, HV *hv ) { AV *av = 0; SV *rv = 0; SV **svp = 0; int i; int seq; StrBuf key; StrRef var, val; StrPtr *data = d->GetVar( "data" ); for( i = 0; d->GetVar( i, var, val ); i++ ) { if( var == "func" ) continue; InsertItem( hv, &var, &val ); } } /* * Split a key into its base name and its index. i.e. for a key "how1,0" * the base name is "how" and they index is "1,0" */ void ClientUserPerl::SplitKey( const StrPtr *key, StrBuf &base, StrBuf &index ) { int i; base = *key; index = ""; // Start at the end and work back till we find the first char that is // neither a digit, nor a comma. That's the split point. for ( i = key->Length(); i; i-- ) { char prev = (*key)[ i-1 ]; if ( !isdigit( prev ) && prev != ',' ) { base.Set( key->Text(), i ); index.Set( key->Text() + i ); break; } } } /* * Insert an element into the response structure. The element may need to * be inserted into an array nested deeply within the enclosing hash. */ void ClientUserPerl::InsertItem( HV *hv, const StrPtr *var, const StrPtr *val ) { SV **svp = 0; AV *av = 0; StrBuf base, index; StrRef comma( "," ); if ( debug ) printf( "\tInserting key %s, value %s \n", var->Text(), val->Text() ); SplitKey( var, base, index ); if ( debug ) printf( "\t\tbase=%s, index=%s\n", base.Text(), index.Text() ); // If there's no index, then we insert into the top level hash // but if the key is already defined then we need to rename the key. This // is probably one of those special keys like otherOpen which can be // both an array element and a scalar. The scalar comes last, so we // just rename it to "otherOpens" to avoid trashing the previous key // value if ( index == "" ) { svp = hv_fetch( hv, base.Text(), base.Length(), 0 ); if ( svp ) base.Append( "s" ); if ( debug ) printf( "\tCreating new scalar hash member %s\n", base.Text() ); hv_store( hv, base.Text(), base.Length(), newSVpv( val->Text(), val->Length() ), 0 ); return; } // // Get or create the parent AV from the hash. // svp = hv_fetch( hv, base.Text(), base.Length(), 0 ); if ( ! svp ) { if ( debug ) printf( "\tCreating new array hash member %s\n", base.Text() ); av = newAV(); hv_store( hv, base.Text(), base.Length(), newRV( (SV*)av) ,0 ); } if ( svp && ! SvROK( *svp ) ) { StrBuf msg; msg.Set( "Key (" ); msg.Append( base.Text() ); msg.Append( ") not a reference!" ); warn( msg.Text() ); return; } if ( svp && SvROK( *svp ) ) av = (AV *) SvRV( *svp ); // The index may be a simple digit, or it could be a comma separated // list of digits. For each "level" in the index, we need a containing // AV and an HV inside it. if ( debug ) printf( "\tFinding correct index level...\n" ); for( const char *c = 0 ; c = index.Contains( comma ); ) { StrBuf level; level.Set( index.Text(), c - index.Text() ); index.Set( c + 1 ); // Found another level so we need to get/create a nested AV // under the current av. If the level is "0", then we create a new // one, otherwise we just pop the most recent AV off the parent if ( debug ) printf( "\t\tgoing down...\n" ); svp = av_fetch( av, level.Atoi(), 0 ); if ( ! svp ) { AV *tav = newAV(); av_store( av, level.Atoi(), newRV( (SV*)tav) ); av = tav; } else { if ( ! SvROK( *svp ) ) { warn( "Not an array reference." ); return; } if ( SvTYPE( SvRV( *svp ) ) != SVt_PVAV ) { warn( "Not an array reference." ); return; } av = (AV *) SvRV( *svp ); } } if ( debug ) printf( "\tInserting value %s\n", val->Text() ); av_push( av, newSVpv( val->Text(), 0 ) ); } void ClientUserPerl::HashToForm( HV *hv, StrBuf *b ) { HV *flatHv = 0; StrPtr *specdef = 0; if ( debug ) printf( "HashToForm: Converting hash input into a form.\n" ); specdef = varList->GetVar( "specdef" ); /* * Also need now to go through the hash looking for AV elements * as they need to be flattened before parsing. Yuk! */ if ( ! ( flatHv = FlattenHash( hv ) ) ) { warn( "Failed to convert Perl hash to Perforce form"); return; } if ( debug ) printf( "HashToForm: Flattened hash input.\n" ); SpecDataTable specData; Spec s( specdef->Text(), "" ); char *key; SV *val; I32 klen; for ( hv_iterinit( flatHv ); val = hv_iternextsv( flatHv, &key, &klen ); ) { if ( !SvPOK( val ) ) continue; specData.Dict()->SetVar( key, SvPV( val, PL_na ) ); } s.Format( &specData, b ); if ( debug ) printf( "HashToForm: Form looks like this\n%s\n", b->Text() ); } // Flatten array elements in a hash into something Perforce can parse. HV * ClientUserPerl::FlattenHash( HV *hv ) { HV *fl; SV *val; char *key; I32 klen; if ( debug ) printf( "FlattenHash: Flattening hash contents\n" ); fl = (HV *)sv_2mortal( (SV *)newHV() ); for ( hv_iterinit( hv ); val = hv_iternextsv( hv, &key, &klen ); ) { if ( SvROK( val ) ) { /* Objects are not permitted in forms. Like it or lump it */ if ( sv_isobject( val ) ) { StrBuf msg; msg << key << " field contains an object. " << "Perforce forms may not contain Perl objects. " "Permitted types are strings, numbers and arrays"; warn( msg.Text() ); return NULL; } if ( SvTYPE( SvRV( val ) ) == SVt_PVAV ) { if ( debug ) printf( "FlattenHash: Flattening %s array\n", key ); // Flatten this array by constructing keys from the parent // hash key and the array index AV *av = (AV *)SvRV( val ); for ( int i = 0; i <= av_len( av ); i++ ) { StrBuf newKey; if ( debug ) printf( "Parsing element %d\n", i ); SV **elem = av_fetch( av, i, 0 ); if ( ! elem ) { StrBuf msg; msg << key << " field contains a bizarre array. " << "Array elements may only contain strings " << "and numbers."; warn( msg.Text() ); return NULL; } if ( debug ) printf( "Fetched element %d\n", i ); newKey.Set( key ); newKey << i; if ( debug ) printf( "Formatted element %d( %s )\n", i, newKey.Text() ); hv_store( fl, newKey.Text(), newKey.Length(), SvREFCNT_inc(*elem), 0 ); if ( debug ) printf( "Stored element %d\n", i ); } } } else { if ( debug ) printf( "FlattenHash: Found non-array member %s\n", key ); // Just store the element as is hv_store( fl, key, klen, SvREFCNT_inc(val), 0 ); } } return fl; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#18 | 4158 | Tony Smith |
Copyright notice updates. No functional change. |
||
#17 | 3550 | Tony Smith |
Add OutputBinary() support to P4Perl. This allows "p4 print" to work with clients that do not use "local" line endings amongst other things. |
||
#16 | 2596 | Tony Smith |
Bug fix: Allow form parsing to accept forms that are initialised (deliberately) with invalid data. |
||
#15 | 2411 | Tony Smith |
Port bug fix from P4Ruby to P4Perl. Certain variable names get reused in tagged mode and this causes the hash members to lose their earlier contents when the later value comes along. Specifically this is otherLock and otherOpen in the output of "p4 fstat". This slightly unpleasant fix simply renames the later variable name by appending an "s" to it. So otherLock becomes otherLocks and otherOpen becomes otherOpens. Now otherOpen is an array containing the user/client of the other users who have the file open and otherLock is a single-element array containing the user/client of the user who has the file locked. otherOpens contains the number of other users who have the file opened. otherLocks contains an empty string. Since the latter two are quite redundant they may be explicitly removed in a future release. |
||
#14 | 2373 | Tony Smith |
Bug fix: Forms parsing was not correctly handling fields with embedded digits like the P4DTI-* fields in a job. This fix should make the detection of the base variable name and its index more reliable |
||
#13 | 2223 | Tony Smith |
Relegated previous support for "p4 diff" to the bottom drawer and use the Diff class provided in the P4 API to send the diff listings through the OutputText() interface. This has two main advantages over the old implementation: (a) same output as "p4 diff" as it uses the same classes and (b) doesn't require extra perl modules. The old implementation is still available - you just have to call P4::Client::DoPerlDiffs() to specify your preference. |
||
#12 | 2084 | Tony Smith |
Removed ugly hack preserving the specdef in perl hashes. There's no need for it as the server kindly provides it when you run the "p4 XXX -i". A little tidying of the test harness. It's not great, but there's at least something in there to check the form parsing now. |
||
#11 | 2010 | Tony Smith |
Bug fix. Fix crash when bizarre input is supplied as allegedly valid form fields. |
||
#10 | 1980 | Tony Smith |
Porting changes. Make P4/Perl build with ActivePerl > 623. They've messed up the PerlIO headers now so you can't use fprintf in an XSUB anymore. Also they're now including math.h and on Windows that must be included with C++ linkage so we now include it before we include the other perl headers that have to be included with C linkage. |
||
#9 | 1976 | Tony Smith |
Add support for ClientUser::Diff() to P4/Perl. Uses the Algorithm::Diff module to perform the diffs. Thanks to Wilson Snyder. |
||
#8 | 1975 | Tony Smith | Reverse previous change | ||
#7 | 1974 | Tony Smith |
Possible fix for ActivePerl build problems. Submitting now just so I don't lose the change but this will shortly be removed again from the head rev. |
||
#6 | 1693 | Tony Smith | Minor fix to add support for 2002.1 API to P4-Client. | ||
#5 | 1615 | Tony Smith |
Add debugging support to the ClientUserPerl class. It's not complete, but it's targeted at the code which deals with tagged output parsing which is the most complex code by far. |
||
#4 | 1515 | Tony Smith |
Bug fix. Make sure all perl header files are included with C linkage preventing problems with redefinition of Perl_malloc() et al. |
||
#3 | 1084 | Tony Smith |
Bug fix: Fetching data using Tagged() or ParseForms() mode could give "attempt to free unreferenced scalar" errors on completion. When flattening the structured hashes into a Perforce form, the reference counts on the contents of the hash were not being incremented leading to their premature destruction. |
||
#2 | 1050 | Tony Smith |
Fix for parsing of complex tagged output with nested data items such as the output from "p4 filelog" for a file with integration records. P4-Client can now handle any level of nested data in the response from the Perforce server, but complex structures of this type may not be supplied for conversion into a Perforce form. That's OK as no Perforce forms have nested data items. Updated current build to 1.1050 |
||
#1 | 1011 | Tony Smith |
Moved Perl API stuff one level down to make way for upcoming Ruby interface. |
||
//guest/tony_smith/perforce/API/P4-Client/lib/clientuserperl.cc | |||||
#8 | 977 | Tony Smith |
Fix broken form parsing. Two problems: first off, the specdef was not being saved in the hash for later use so forms could not be reconstructed from the hash data structure. Secondly, multi-line elements parsed into array members of the hash were not being flattened prior to reconstructing the form so they would be empty. |
||
#7 | 976 | Tony Smith |
Fix for multi-line field handling bug. The array handling code was dependent on all results for a given tag being supplied before moving on to the next tag, but this is not true for all Perforce commands. i.e. p4 client -o -> tags not fragmented p4 describe -s -> oops. Now the implementation is not fussy about the order in which elements arrive other than that tagN comes before tagN+1. Any number of other elements may come in between them. |
||
#6 | 962 | Tony Smith |
Added support for presenting multi-line elements of a form as a single array member of the hashref in tagged/specstring output. |
||
#5 | 930 | Tony Smith | Back port previous changes to Perl 5.005_03 | ||
#4 | 929 | Tony Smith |
Add support for form parsing to Perl API. Allows Perforce specs (change, client, user etc.) to be parsed by the API and returned as Perl hashes rather than strings which must be parsed by the user. P4 module also has some new methods which make it easy to use this feature. Sample code: ------------------- use P4; my $p4 = new P4; $p4->ParseForms(); $p4->Init() or die( "Can't connect to Perforce" ); $p4->Edit( "filename" ); my $change = p4->GetChange(); $change->{ 'Description' } = "Some text"; $p4->SubmitSpec( $change ); print( $p4->ErrorCount() ? "Submit failed\n" : "Submit OK\n" ); ------------------- |
||
#3 | 798 | Tony Smith |
Removed extra inclusion of stdhdrs.h which is included by clientapi.h anyway. |
||
#2 | 582 | Tony Smith |
Improved docs in UI.pm and fixed minor bug which caused problems when calling scripts attempt to save the hashref passed to UI::OutputInfo() for later use. It was casued by the members of the hash being mortal variables. They will now persist if referred to. A couple of other minor bug fixes to UI.pm. Changes file has the details. |
||
#1 | 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. |
||
//guest/tony_smith/perforce/API/P4-Client-0.51/lib/clientuserperl.cc | |||||
#2 | 529 | Tony Smith |
Threaded Perl fix. Mustn't use dTHX on old perls, it doesn't exist. Also updated the Changes file with a comment I missed earlier. |
||
#1 | 527 | Tony Smith | Release P4::Client version 0.51 with Win32 support | ||
//guest/tony_smith/perforce/API/P4-Client-0.50/lib/clientuserperl.cc | |||||
#2 | 526 | Tony Smith | Initial port of P4::Client interface to Win32. | ||
#1 | 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 |
||
//guest/tony_smith/perforce/API/P4-ClientApi-0.05/lib/clientuserperl.cc | |||||
#1 | 501 | Tony Smith |
First publicly released version of the Perl interface to the Perforce API. |