/******************************************************************************* Copyright (c) 2001-2008, 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 CONTRIBUTORS "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. *******************************************************************************/ /******************************************************************************* * Name : p4clientapi.h * * Author : Tony Smith <tony@perforce.com> or <tony@smee.org> * * Description : Ruby bindings for the Perforce API. Definitions of our * main interface to Perforce * ******************************************************************************/ /******************************************************************************* * P4ClientApi class - where we register our Ruby classes and plumb together * the components ******************************************************************************/ class Enviro; class P4ClientApi { public: P4ClientApi(); ~P4ClientApi(); // Tagged mode - can be enabled/disabled on a per-command basis void Tagged( int enable ); int IsTagged() { return IsTag(); } // Set track mode - track usage of this command on the server int SetTrack( int enable ); int GetTrack() { return IsTrackMode() != 0; } // Set streams mode void SetStreams( int enable ); int IsStreams() { return IsStreamsMode() != 0; }; // Returns bool, but may raise exception int SetCharset( const char *c ); // Set API level for backwards compatibility void SetApiLevel( int level ); void SetClient( const char *c ) { client.SetClient( c ); } void SetCwd( const char *c ); void SetEnviroFile( const char *c ); void SetHost( const char *h ) { client.SetHost( h ); } void SetIgnoreFile( const char *f ) { client.SetIgnoreFile( f ); } void SetMaxResults( int v ) { maxResults = v; } void SetMaxScanRows( int v ) { maxScanRows = v; } void SetMaxLockTime( int v ) { maxLockTime = v; } VALUE SetEnv( const char *var, const char *val ); void SetLanguage( const char *l ) { client.SetLanguage( l ); } void SetPassword( const char *p ) { client.SetPassword( p ); } void SetPort( const char *p ) { client.SetPort( p ); } void SetProg( const char *p ) { prog = p; } void SetProtocol( const char *var, const char *val ); void SetTicketFile( const char *p ); void SetUser( const char *u ) { client.SetUser( u ); } void SetVersion( const char *v ) { version = v; } int GetApiLevel() { return apiLevel; } const StrPtr &GetCharset() { return client.GetCharset(); } const StrPtr &GetClient() { return client.GetClient(); } const StrPtr &GetConfig() { return client.GetConfig(); } const StrPtr &GetCwd() { return client.GetCwd(); } const char * GetEnv( const char *v); const StrPtr *GetEnviroFile(); const StrPtr &GetHost() { return client.GetHost(); } const StrPtr &GetIgnoreFile() { return client.GetIgnoreFile();} const StrPtr &GetLanguage() { return client.GetLanguage(); } const StrPtr &GetPassword() { return client.GetPassword(); } const StrPtr &GetPort() { return client.GetPort(); } const StrPtr &GetProg() { return prog; } const StrPtr &GetTicketFile() { return ticketFile; } const StrPtr &GetUser() { return client.GetUser(); } const StrPtr &GetVersion() { return version; } int IsIgnored( const char *path ); int GetMaxResults() { return maxResults; } int GetMaxScanRows() { return maxScanRows; } int GetMaxLockTime() { return maxLockTime; } int GetServerLevel(); int ServerCaseSensitive(); int ServerUnicode(); // Session management VALUE Connect(); // P4Exception on error VALUE Connected(); // Return true if connected and not dropped. VALUE Disconnect(); // Executing commands. VALUE Run( const char *cmd, int argc, char * const *argv ); VALUE SetInput( VALUE input ); // Result handling VALUE GetErrors() { return ui.GetResults().GetErrors();} VALUE GetWarnings() { return ui.GetResults().GetWarnings();} VALUE GetMessages() { return ui.GetResults().GetMessages();} VALUE GetTrackOutput() { return ui.GetResults().GetTrack();} // Spec parsing VALUE ParseSpec( const char * type, const char *form ); VALUE FormatSpec( const char *type, VALUE hash ); VALUE SpecFields( const char * type ); // Exception levels: // // 0 - No exceptions raised // 1 - Exceptions raised for errors // 2 - Exceptions raised for errors and warnings // void ExceptionLevel( int i ) { exceptionLevel = i; } int ExceptionLevel() { return exceptionLevel; } void Except( const char *func, Error *e ); void Except( const char *func, const char *msg ); void Except( const char *func, const char *msg, const char *cmd ); // // Debugging support. Debug levels are: // // 1: Debugs commands being executed // 2: Debug UI method calls // 3: Show garbage collection // int GetDebug() { return debug; } void SetDebug( int d ); // Handler support VALUE SetHandler( VALUE handler ); VALUE GetHandler() { return ui.GetHandler(); } // Progress API support VALUE SetProgress( VALUE progress ); VALUE GetProgress() { return ui.GetProgress(); } // Ruby garbage collection void GCMark(); private: void RunCmd(const char *cmd, ClientUser *ui, int argc, char * const *argv); VALUE ConnectOrReconnect(); // internal connect method enum { S_TAGGED = 0x0001, S_CONNECTED = 0x0002, S_CMDRUN = 0x0004, S_UNICODE = 0x0008, S_CASEFOLDING = 0x0010, S_TRACK = 0x0020, S_STREAMS = 0x0040, S_INITIAL_STATE = 0x0041, S_RESET_MASK = 0x001E, }; void InitFlags() { flags = S_INITIAL_STATE; } void ResetFlags() { flags &= ~S_RESET_MASK; } void SetTag() { flags |= S_TAGGED; } void ClearTag() { flags &= ~S_TAGGED; } int IsTag() { return flags & S_TAGGED; } void SetConnected() { flags |= S_CONNECTED; } void ClearConnected() { flags &= ~S_CONNECTED; } int IsConnected() { return flags & S_CONNECTED; } void SetCmdRun() { flags |= S_CMDRUN; } void ClearCmdRun() { flags &= ~S_CMDRUN; } int IsCmdRun() { return flags & S_CMDRUN; } void SetUnicode() { flags |= S_UNICODE; } void ClearUnicode() { flags &= ~S_UNICODE; } int IsUnicode() { return flags & S_UNICODE; } void SetCaseFold() { flags |= S_CASEFOLDING; } void ClearCaseFold() { flags &= ~S_CASEFOLDING; } int IsCaseFold() { return flags & S_CASEFOLDING; } void SetTrackMode() { flags |= S_TRACK; } void ClearTrackMode() { flags &= ~S_TRACK; } int IsTrackMode() { return flags & S_TRACK; } void SetStreamsMode() { flags |= S_STREAMS; } void ClearStreamsMode() { flags &= ~S_STREAMS; } int IsStreamsMode() { return flags & S_STREAMS; } private: ClientApi client; ClientUserRuby ui; Enviro * enviro; SpecMgr specMgr; StrBuf prog; StrBuf version; StrBuf ticketFile; int depth; int debug; int exceptionLevel; int apiLevel; int server2; int flags; int maxResults; int maxScanRows; int maxLockTime; };
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15524 | surajdolby |
Populate -o //guest/perforce_software/p4ruby/main/... //guest/surajdolby/p4ruby/.... |
||
//guest/perforce_software/p4ruby/main/ext/P4/p4clientapi.h | |||||
#2 | 14694 | tjuricek |
Add `enviro_file` property to `P4` object that calls SetEnviroFile and GetEnviroFile underneath. P4RUBY-169 Imported from Git Author: Tristan Juricek <tjuricek@perforce.com> 1418331105 -0800 Committer: Tristan Juricek <tjuricek@perforce.com> 1418331105 -0800 sha1: 141f8b9f65b4c56ce5a42144d8c185285effaa12 push-state: complete parent-changes: 98f9b10c0c37b44bfc8659e7934440fe1252c4c2=[974326] |
||
#1 | 14682 | Git Fusion |
Git Fusion branch management Imported from Git ghost-of-change-num: 960958 ghost-of-sha1: 005052ae424bd69f426f7209e741ca1c8c3253c7 ghost-precedes-sha1: ad052c71a568ef12165e143a6866ad9ceffbb4a1 parent-branch: None@960958 push-state: incomplete |