[p4] processing server data using tags

Liu, Ye YLiu at bgcpartners.com
Mon Nov 24 12:47:03 PST 2008

Dear Perforce Users,


I am trying to use perforce C++ API to process server output.


Here is my program: p4api.cc


int main( int argc, char **argv )


      ClientUser ui;

      ClientApi client;

      StrBuf msg;

      Error e;

      StrPtr* pChange=NULL;


      // Any special protocol mods


      client.SetProtocol("tag", "");


      // Connect to server


      client.Init( &e );


      if( e.Test() )


          e.Fmt( &msg );

          fprintf( stderr, "%s\n", msg.Text() );

          return 1;



      // Run the command "argv[1] argv[2...]"


      client.SetArgv( argc - 2, argv + 2 );

      client.RunTag( argv[1], &ui );

      // pChange is always NULL


      printf("%s", pChange->Value());


// Close connection


      client.Final( &e );


      if( e.Test() )


          e.Fmt( &msg );

          fprintf( stderr, "%s\n", msg.Text() );

          return 1;



      return 0;



I ran this program using: p4api.exe changelist -o 33 and got core dump
because pChange is NULL. But I can run this command: p4 -Ztag change -o
33 and get output as:

... Change 33

... Date 2008/11/21 16:38:02

... Client yliu_esnydev143a_1666

... User yliu

... Status pending

... Description modify test form-commit


... Jobs0 testjob3


I think the way I get the tag data is not correct. Can someone take a
look at my program and show me what is the right to get tag data?





CONFIDENTIAL: This e-mail has been sent to you by one of the BGC entities (collectively BGC)
listed at the following link http://www.bgcpartners.com/legal/disclaimers/index.html#email_disclaimer.
The link contains company and FSA registration numbers. This e-mail, including its contents and
attachments, if any, are confidential. If you are not the named recipient please notify the sender and
immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose
its contents to anybody else. Copyright and any other intellectual property rights in its contents are the
sole property of BGC and its affiliates. E-mail transmission cannot be guaranteed to be secure or error-free.
The sender therefore does not accept liability for any errors or omissions in the contents of this
message which arise as a result of e-mail transmission.  If verification is required please request a
hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any
attachments for viruses. We make no representation or warranty as to the absence of viruses in this
e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our
customers and business, we may monitor and read e-mails sent to and from our server(s). 
The registered offices of the BGC entities are at 1 Churchill Place, London, E14 5RD.  
For any issues arising from this email please reply to the sender. 
The FSA register appears at http://www.fsa.gov.uk/register/.  
The FSA regulates the financial services industry in the United Kingdom and is located at 
25 The North Colonnade, Canary Wharf, London, E14 5HS.

More information about the perforce-user mailing list