/******************************************************************************* Copyright (c) 2010, 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 : P4Bridge.cs * * Author : dbb * * Description : Class containing the dll imports for the P4Bridge dll. * ******************************************************************************/ using System; using System.Collections; using System.Runtime.InteropServices; using System.Text; namespace Perforce.P4 { /// /// Class wrapper for the definitions of delegates required to model the /// callbacks from the bridge dll. /// public class P4CallBacks { /*********************************************************************** * * Delegates * **********************************************************************/ /// /// Delegate definition for the Logging callback from the dll. /// /// Log Level Lower values are more serious /// than higher values. /// Name of the cpp file containing the call. /// /// Line number in the cpp file of the call. /// Descriptive message to be logged. public delegate void LogMessageDelegate(int log_level, String file, int line, String message); /// /// Delegate definition for the tagged output delegate. /// /// /// Each call of this delegate by the bridge provides a single Key:Value /// pair for the current object. When all the Key:Value pairs for an /// object have been sent, the bridge will make one final call with null /// for the values of the key and value to signify it is complete. Each /// object generated by a command will have an object ID that unique for /// that command. /// /// Id if the command making the callback /// Object ID for the object /// The Key of this Key:Value pair /// The Key of this Key:Value pair public delegate void TaggedOutputDelegate(uint cmdID, int objID, [MarshalAs(UnmanagedType.LPStr)] String key, IntPtr value); /// /// Delegate definition for the error callback. /// /// Id if the command making the callback /// Severity of the error /// Error Message public delegate void ErrorDelegate(uint cmdID, int severity, int errorId, IntPtr info); /// /// Delegate definition for the info results callback. /// /// /// The "info" results generally are the output of commands that are run /// not using tagged protocol /// /// Id of the command making the callback /// Unique Id of the message from the server /// /// public delegate void InfoResultsDelegate(uint cmdID, int msgID, int level, IntPtr info); /// /// Delegate definition for the text results callback. /// /// /// If this callback is used, the text output generated by a command /// will be delivered by one or more call to the supplied delegate. /// It multiple calls are made, the entire text is obtained by /// concatenating the text from each call. /// /// Id if the command making the callback /// Text output produced by the command public delegate void TextResultsDelegate(uint cmdID, IntPtr info); /// /// Delegate definition for the binary results callback. /// /// /// If this callback is used, the binary output generated by a command /// will be delivered by one or more call to the supplied delegate. /// It multiple calls are made, the entire output is obtained by /// concatenating the data from each call. /// /// Id if the command making the callback /// Binary data generated by the command /// The size in bytes of the data public delegate void BinaryResultsDelegate(uint cmdID, IntPtr data, int count); /// /// Delegate definition for the prompt callback. /// /// Id if the command making the callback /// Prompt message from the server /// Character buffer to receive the response /// Size of the buffer /// Display flog public delegate void PromptDelegate(uint cmdID, IntPtr msg, IntPtr rspBuf, int bufSz, bool dispayText); /// /// Delegate definition for the Resolve callback passing a CLientMerge object. /// /// P4ClientMerge used to handle the resolve /// Resolve result public delegate int ResolveDelegate(uint cmdID, IntPtr Merger); /// /// Delegate definition for the Resolve callback passing a CLientResolve object. /// /// Id if the command making the callback /// P4ClientReslove used to handle the resolve /// Preview only /// Resolve result public delegate int ResolveADelegate(uint cmdID, IntPtr Resolver, bool preview); } /// /// Class containing the DLL imports for the P4Bridge DLL. /// internal class P4Bridge { /*********************************************************************** * * DllImports * **********************************************************************/ /// /// Create a new P4BridgeServer in the DLL and connect to the /// specified P4 Server. /// /// Host:port for the P4 server. /// User name for the login. /// Can be null/blank if only running commands that do not require /// a login. /// Password for the login. Can be null/blank if /// only running commands that do not require a login. /// Workspace (client) to be used by the /// connection. Can be null/blank if only running commands that do /// not require a login. /// Function pointer for the logging callback. Can /// be null if logging is not desired. /// Handle (pointer) to the P4BridgeServer [DllImport("p4bridge.dll", EntryPoint = "Connect", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr ConnectA( String server, String user, String password, String ws_client, P4CallBacks.LogMessageDelegate logfn); /// /// Create a new P4BridgeServer in the DLL and connect to the /// specified P4 Server. /// /// Host:port for the P4 server. /// User name for the login. /// Can be null/blank if only running commands that do not require /// a login. /// Password for the login. Can be null/blank if /// only running commands that do not require a login. /// Workspace (client) to be used by the /// connection. Can be null/blank if only running commands that do /// not require a login. /// Function pointer for the logging callback. Can /// be null if logging is not desired. /// Handle (pointer) to the P4BridgeServer [DllImport("p4bridge.dll", EntryPoint = "Connect", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr ConnectW(String server, IntPtr user, IntPtr password, IntPtr ws_client, IntPtr logfn); /// /// Create a new P4BridgeServer in the DLL and connect to the /// specified P4 Server. /// /// Host:port for the P4 server. /// User name for the login. /// Can be null/blank if only running commands that do not require /// a login. /// Password for the login. Can be null/blank if /// only running commands that do not require a login. /// Workspace (client) to be used by the /// connection. Can be null/blank if only running commands that do /// not require a login. /// Flag to pass to the trust command. /// Fingerprint to pass to the trust /// command. /// Function pointer for the logging callback. Can /// be null if logging is not desired. /// Handle (pointer) to the P4BridgeServer [DllImport("p4bridge.dll", EntryPoint = "TrustedConnect", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr TrustedConnectA(String server, String user, String password, String ws_client, String trust_flag, String fingerprint, P4CallBacks.LogMessageDelegate logfn); /// /// Create a new P4BridgeServer in the DLL and connect to the /// specified P4 Server. /// /// Host:port for the P4 server. /// User name for the login. /// Can be null/blank if only running commands that do not require /// a login. /// Password for the login. Can be null/blank if /// only running commands that do not require a login. /// Workspace (client) to be used by the /// connection. Can be null/blank if only running commands that do /// not require a login. /// Flag to pass to the trust command. /// Fingerprint to pass to the trust /// command. /// Function pointer for the logging callback. Can /// be null if logging is not desired. /// Handle (pointer) to the P4BridgeServer [DllImport("p4bridge.dll", EntryPoint = "TrustedConnect", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr TrustedConnectW(String server, IntPtr user, IntPtr password, IntPtr ws_client, String trust_flag, String fingerprint, IntPtr logfn); /// /// Get the error message generated by the previous connection (if any) /// /// Error Message. Null if no error occurred [DllImport("p4bridge.dll", EntryPoint = "GetConnectionError", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetConnectionError(); /// /// Sets the character set used by the P4Bridge server if connection is /// to Unicode enabled server. /// /// Handle of the P4BridgeServer /// Character set to use for Unicode data /// exchanged with the P4 Server /// Character set to use for files /// stored in /// the client' host file space /// null if no error, otherwise a pointer to an error /// message. [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr SetCharacterSet(IntPtr pServer, String charSet, String FileCharSet); /// /// Close the connection /// /// P4BridgeServer Handle [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int Disconnect(IntPtr pServer); /// /// Close the connection /// /// P4BridgeServer Handle [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int CloseConnection(IntPtr pServer); /// /// Check if the server supports Unicode /// /// /// Note: Is set during connection so is valid immediately after /// Connect() successfully completes. /// /// P4BridgeServer Handle /// [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool IsUnicode(IntPtr pServer); /// /// Check to see what API level the server supports /// /// /// Note: Is set during connection so is valid immediately after /// Connect() successfully completes. /// /// P4BridgeServer Handle /// [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int APILevel(IntPtr pServer); /// /// Check if the server requires the login command be used /// /// /// Note: Is set during connection so is valid immediately after /// Connect() successfully completes. /// /// P4BridgeServer Handle /// [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool UseLogin(IntPtr pServer); /// /// Check if the server supports extended submit options (2006.2 higher) /// /// /// Note: Is set during connection so is valid immediately after /// Connect() successfully completes. /// /// P4BridgeServer Handle /// [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern bool SupportsExtSubmit(IntPtr pServer); /// /// Run a command on the P4 Server /// /// /// The A version is used to pass ASCII parameters /// /// P4BridgeServer Handle /// Command. i.e "fstat" /// Unique Id for the run of the command /// If true, use tagged protocol the receive the /// output /// Arguments for the command /// Argument count /// [DllImport("p4bridge.dll", EntryPoint = "RunCommand", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern bool RunCommandA( IntPtr pServer, String cmd, uint cmdId, bool tagged, String[] args, int argc); /// /// Run a command on the P4 Server /// /// /// The W version is used to pass Unicode (wide) parameters /// /// P4BridgeServer Handle /// Command. i.e "fstat" /// Unique Id for the run of the command /// If true, use tagged protocol the receive the /// output /// Arguments for the command /// Argument count /// [DllImport("p4bridge.dll", EntryPoint = "RunCommand", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern bool RunCommandW( IntPtr pServer, String cmd, uint cmdId, bool tagged, IntPtr[] args, int argc); /// /// Cancel a running command /// /// P4BridgeServer Handle /// Unique Id for the run of the command [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void CancelCommand(IntPtr pServer, uint CmdId); /// /// Release the UI created for a command after it has been completed /// /// P4BridgeServer Handle /// Unique Id for the run of the command [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void ReleaseConnection(IntPtr pServer, uint cmdId, UInt64 releaseTime); /// /// Free the connection created for a command and disconnect from /// the server /// /// P4BridgeServer Handle /// Unique Id for the run of the command [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int FreeConnections(IntPtr pServer, UInt64 currentTime); /*********************************************************************** * * Callback management * **********************************************************************/ /// /// Set the callback for tagged output /// /// P4BridgeServer Handle /// Pinned pointer to the callback delegate [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void SetTaggedOutputCallbackFn(IntPtr pServer, IntPtr pNew); /// /// Set the callback for error output /// /// P4BridgeServer Handle /// Pinned pointer to the callback delegate [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void SetErrorCallbackFn(IntPtr pServer, IntPtr pNew); /// /// Set the callback for Info (non tagged) output /// /// P4BridgeServer Handle /// Pinned pointer to the callback delegate [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void SetInfoResultsCallbackFn(IntPtr pServer, IntPtr pcb); /// /// Set the callback for text output /// /// P4BridgeServer Handle /// Pinned pointer to the callback delegate [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void SetTextResultsCallbackFn(IntPtr pServer, IntPtr pNew); /// /// Set the callback for binary output /// /// P4BridgeServer Handle /// Pinned pointer to the callback delegate [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void SetBinaryResultsCallbackFn(IntPtr pServer, IntPtr pNew); /// /// Set the call back to receive input prompts from the sever /// /// P4BridgeServer Handle /// Pinned pointer to the callback delegate [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void SetPromptCallbackFn(IntPtr pServer, IntPtr pNew); /*********************************************************************** * * Output retrieval * **********************************************************************/ /// /// Get the number of entries in the tagged output for the last command /// /// P4BridgeServer Handle /// StrDictListIterator Handle (pointer) used to read the data [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int GetTaggedOutputCount(IntPtr pServer, uint cmdId); /// /// Get the tagged output for the last command /// /// P4BridgeServer Handle /// StrDictListIterator Handle (pointer) used to read the data [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetTaggedOutput(IntPtr pServer, uint cmdId); /// /// Get the error output for the last command /// /// P4BridgeServer Handle /// P4ClientErrorList Handle (pointer) used to read the data [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetErrorResults(IntPtr pServer, uint cmdId); /// /// Get the info output for the last command /// /// P4BridgeServer Handle /// Handle (pointer) to the string data [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int GetInfoResultsCount(IntPtr pServer, uint cmdId); /// /// Get the info output for the last command /// /// P4BridgeServer Handle /// Handle (pointer) to the string data [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetInfoResults(IntPtr pServer, uint cmdId); /// /// Get the text output for the last command /// /// P4BridgeServer Handle /// Handle (pointer) to the string data [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetTextResults(IntPtr pServer, uint cmdId); /// /// Get the byte count for the binary output for the last command /// /// P4BridgeServer Handle /// Handle (pointer) to the data bytes [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int GetBinaryResultsCount(IntPtr pServer, uint cmdId); /// /// Get the binary output for the last command /// /// P4BridgeServer Handle /// Handle (pointer) to the data bytes [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetBinaryResults(IntPtr pServer, uint cmdId); /*********************************************************************** * * Command Data Set * **********************************************************************/ /// /// Set the data set using Unicode data /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// New Unicode data set [DllImport("p4bridge.dll", EntryPoint = "SetDataSet", CallingConvention = CallingConvention.Cdecl)] public static extern void SetDataSetW(IntPtr pServer, uint cmdId, IntPtr data); /// /// Set the data set using Unicode data /// /// P4BridgeServer Handle /// New ASCII data set [DllImport("p4bridge.dll", EntryPoint = "SetDataSet", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void SetDataSetA(IntPtr pServer, uint cmdId, String data); /// /// Read the data set /// /// /// The data will be encoded in ASII or Unicode, depending on the /// server configuration and character set set previously with /// SetCharacterSet(). /// /// P4BridgeServer Handle /// The data in the data set [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetDataSet(IntPtr pServer, uint cmdId); /*********************************************************************** * * Connect parameters * **********************************************************************/ /// /// Set the connection parameters using Unicode strings. /// /// P4BridgeServer Handle /// New port /// New workspace /// New password /// New workspace [DllImport("p4bridge.dll", EntryPoint = "set_connection", CallingConvention = CallingConvention.Cdecl)] public static extern void set_connectionW(IntPtr pServer, IntPtr newPort, IntPtr newUser, IntPtr newPassword, IntPtr newClient); /// /// Set the connection parameters using ASCII strings. /// /// P4BridgeServer Handle /// New port /// New workspace /// New password /// New workspace [DllImport("p4bridge.dll", EntryPoint = "set_connection", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void set_connectionA( IntPtr pServer, String newPort, String newUser, String newPassword, String newClient); /// /// Set the client workspace using a Unicode string /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// Client Workspace name [DllImport("p4bridge.dll", EntryPoint = "set_client", CallingConvention = CallingConvention.Cdecl)] public static extern void set_clientW(IntPtr pServer, IntPtr workspace); /// /// Set the client workspace using a ASCII string /// /// P4BridgeServer Handle /// Client Workspace name [DllImport("p4bridge.dll", EntryPoint = "set_client", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void set_clientA(IntPtr pServer, String workspace); /// /// Get the name of the client workspace /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// Client workspace name [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr get_client(IntPtr pServer); /// /// Set the user name using a Unicode string /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// User name [DllImport("p4bridge.dll", EntryPoint = "set_user", CallingConvention = CallingConvention.Cdecl)] public static extern void set_userW(IntPtr pServer, IntPtr workspace); /// /// Set the user name using a ASCII string /// /// P4BridgeServer Handle /// User name [DllImport("p4bridge.dll", EntryPoint = "set_user", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void set_userA(IntPtr pServer, String workspace); /// /// Get the name of the current user /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// The user's name [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr get_user(IntPtr pServer); /// /// Set the connection string using a Unicode string /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// Connection String [DllImport("p4bridge.dll", EntryPoint = "set_port", CallingConvention = CallingConvention.Cdecl)] public static extern void set_portW(IntPtr pServer, IntPtr workspace); /// /// Set the connection string using a ASCII string /// /// P4BridgeServer Handle /// Connection String [DllImport("p4bridge.dll", EntryPoint = "set_port", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void set_portA(IntPtr pServer, String workspace); /// /// Get the connection string. /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// host:port used by the connection [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr get_port(IntPtr pServer); /// /// Set the user's password using a Unicode string /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// User's password [DllImport("p4bridge.dll", EntryPoint = "set_password", CallingConvention = CallingConvention.Cdecl)] public static extern void set_passwordW(IntPtr pServer, IntPtr workspace); /// /// Set the user's password using an ASCII string /// /// P4BridgeServer Handle /// User's password [DllImport("p4bridge.dll", EntryPoint = "set_password", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void set_passwordA(IntPtr pServer, String workspace); /// /// Get the password used for the connection /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// The password [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr get_password(IntPtr pServer); /// /// Gets the current working directory for the P4BridgeServer. /// /// P4BridgeServer Handle /// The current working directory for the P4BridgeServer. [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr get_cwd(IntPtr pServer); /// /// Sets the current working directory for the P4BridgeServer using a Unicode string. /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// The new working directory [DllImport("p4bridge.dll", EntryPoint = "set_cwd", CallingConvention = CallingConvention.Cdecl)] public static extern void set_cwdW(IntPtr pServer, IntPtr cwd); /// /// Sets the current working directory for the P4BridgeServer using an ASCII string. /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// The new working directory [DllImport("p4bridge.dll", EntryPoint = "set_cwd", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void set_cwdA(IntPtr pServer, string cwd); /// /// Set the program name using a Unicode string /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// program name [DllImport("p4bridge.dll", EntryPoint = "set_programName", CallingConvention = CallingConvention.Cdecl)] public static extern void set_programNameW(IntPtr pServer, IntPtr workspace); /// /// Set the program name using an ASCII string /// /// P4BridgeServer Handle /// program name [DllImport("p4bridge.dll", EntryPoint = "set_programName", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void set_programNameA(IntPtr pServer, String workspace); /// /// Get the program name used for the connection /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// program name [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr get_programName(IntPtr pServer); /// /// Set the program version using a Unicode string /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// program version [DllImport("p4bridge.dll", EntryPoint = "set_programVer", CallingConvention = CallingConvention.Cdecl)] public static extern void set_programVerW(IntPtr pServer, IntPtr programVer); /// /// Set the program version using an ASCII string /// /// P4BridgeServer Handle /// program version [DllImport("p4bridge.dll", EntryPoint = "set_programVer", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void set_programVerA(IntPtr pServer, String programVer); /// /// Get the program version used for the connection /// /// /// The encoding should match that set by SetCharacterSet() /// /// P4BridgeServer Handle /// program version [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr get_programVer(IntPtr pServer); /// /// Get the character set used for the connection. /// /// Pointer to the P4BridgeServer /// The ANSI string representing the characterset name [DllImport("p4bridge.dll", EntryPoint = "get_charset", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr get_charset( IntPtr pServer ); /// /// Get the config file for the current connection, if any. /// /// Pointer to the P4BridgeServer /// The config file [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr get_config( IntPtr pServer ); /// /// Get the config file for the specified directory, if any. /// /// Pointer to the P4BridgeServer /// The config file [DllImport("p4bridge.dll", EntryPoint = "get_config_cwd", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr get_configA( string cwd ); [DllImport("p4bridge.dll", EntryPoint = "get_config_cwd", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr get_configW(IntPtr pcwd); /*********************************************************************** * * Environment Variables * **********************************************************************/ [DllImport("p4bridge.dll", EntryPoint = "Get", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern IntPtr GetA(string var); [DllImport("p4bridge.dll", EntryPoint = "Get", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetW(IntPtr var); [DllImport("p4bridge.dll", EntryPoint = "Set", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern void SetA(string var, string val); [DllImport("p4bridge.dll", EntryPoint = "Set", CallingConvention = CallingConvention.Cdecl)] public static extern void SetW(IntPtr var, IntPtr val); [DllImport("p4bridge.dll", EntryPoint = "GetTicketFile", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetTicketFile(); [DllImport("p4bridge.dll", EntryPoint = "GetTicket", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetTicket(IntPtr port, IntPtr user); /*********************************************************************** * * IsIgnored * **********************************************************************/ [DllImport("p4bridge.dll", EntryPoint = "IsIgnored", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern bool IsIgnoredA(string Path); [DllImport("p4bridge.dll", EntryPoint = "IsIgnored", CallingConvention = CallingConvention.Cdecl)] public static extern bool IsIgnoredW(IntPtr Path); /*********************************************************************** * * StrDictListIterator Functions * * The StrDictListIterator is used to read tagged data from a command. * It allows the client to step through the 'objects' represented in the * tagged data as StrDict (string dictionaries) * **********************************************************************/ /// /// Get the Next item (a StrDict based object) /// /// StrDictListIterator Handle /// StrDictList Handle, null if end of list [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetNextItem(IntPtr pObj); /// /// Get the next dictionary entry for the current item. /// /// StrDictListIterator Handle /// Handle to a Key:Value pair [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetNextEntry(IntPtr pObj); /// /// Delete the StrDictListIterator object when it is no longer needed /// /// StrDictListIterator Handle [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void Release(IntPtr pObj); /*********************************************************************** * * KeyValuePair Functions * * KeyValuePair objects represent a dictionary entry in s StrDict * **********************************************************************/ /// /// Retrieve the key /// /// KeyValuePair Handle /// Key string [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetKey(IntPtr pObj); /// /// Retrieve the value /// /// KeyValuePair Handle /// String value [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetValue(IntPtr pObj); /*********************************************************************** * * P4ErrorList Functions * * P4ErrorList represents the list of errors (and warnings) generated by * the execution of a command. * **********************************************************************/ /// /// Severity of the error /// /// P4ErrorList Handle /// Severity level [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int Severity(IntPtr pObj); /// /// Generic code of the error /// /// P4ErrorList Handle /// Generic error code [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int ErrorCode(IntPtr pObj); /// /// Get the error's message. /// /// P4ErrorList Handle /// Error Message [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr Message(IntPtr pObj); /********************************************************************** * * GetNext: Get the next error message. * * pObj: Pointer to the P4ClientError. * * Return: Pointer to the next error message. * **********************************************************************/ /// /// Get the next error in the list /// /// P4ErrorList Handle /// null indicates the end of the list [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr Next(IntPtr pObj); /*********************************************************************** * * P4ClientInfoMessage Functions * * P4ClientInfoMessage represents the list of info messages generated by * the execution of a command. * **********************************************************************/ /// /// Severity of the error /// /// P4ClientInfoMessage Handle /// Severity level [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern char MessageLevel(IntPtr pObj); /// /// Code of the message /// /// P4ClientInfoMessage Handle /// Generic error code [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int InfoMsgCode(IntPtr pObj); /// /// Get the message text. /// /// P4ClientInfoMessage Handle /// Error Message [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr InfoMessage(IntPtr pObj); /// /// Get the next message in the list /// /// P4ClientInfoMessage Handle /// null indicates the end of the list [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr NextInfoMsg(IntPtr pObj); } /********************************************************************** * * P4ClientMerge * * This simple class is a ClientMerge object. * *********************************************************************/ /// /// Class containing the DLL imports for the P4Bridge DLL. /// internal class P4ClientMergeBridge { [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_AutoResolve")] public static extern int AutoResolve(IntPtr pObj, int forceMerge); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_Resolve")] public static extern int Resolve(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_DetectResolve")] public static extern int DetectResolve(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_IsAcceptable")] public static extern int IsAcceptable(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetBaseFile")] public static extern IntPtr GetBaseFile(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetYourFile")] public static extern IntPtr GetYourFile(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetTheirFile")] public static extern IntPtr GetTheirFile(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetResultFile")] public static extern IntPtr GetResultFile(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetYourChunks")] public static extern int GetYourChunks(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetTheirChunks")] public static extern int GetTheirChunks(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetBothChunks")] public static extern int GetBothChunks(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetConflictChunks")] public static extern int GetConflictChunks(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetMergeDigest")] public static extern IntPtr GetMergeDigest(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetYourDigest")] public static extern IntPtr GetYourDigest(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetTheirDigest")] public static extern IntPtr GetTheirDigest(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CM_GetLastError")] public static extern IntPtr GetLastError(IntPtr pObj); /********************************************************************** * * SetResolveCallbackFn: Set the callback for replying to a resolve * callback. * * pServer: Pointer to the P4BridgeServer * * pNew: The new callback function pointer * * Return: None **********************************************************************/ [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void SetResolveCallbackFn( IntPtr pServer, IntPtr pNew); } /********************************************************************** * * P4ClientResolve * * This simple class is a ClientResolve object. * *********************************************************************/ /// /// Class containing the DLL imports for the P4Bridge DLL. /// internal class P4ClientResolveBridge { [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_AutoResolve")] public static extern int AutoResolve(IntPtr pObj, int force); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_Resolve")] public static extern int Resolve(IntPtr pObj, bool preview); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetType")] public static extern IntPtr GetResolveType(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetMergeAction")] public static extern IntPtr GetMergeAction(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetYoursAction")] public static extern IntPtr GetYoursAction(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetTheirAction")] public static extern IntPtr GetTheirAction(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetMergePrompt")] public static extern IntPtr GetMergePrompt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetYoursPrompt")] public static extern IntPtr GetYoursPrompt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetTheirPrompt")] public static extern IntPtr GetTheirPrompt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetMergeOpt")] public static extern IntPtr GetMergeOpt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetYoursOpt")] public static extern IntPtr GetYoursOpt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetTheirOpt")] public static extern IntPtr GetTheirOpt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetSkipOpt")] public static extern IntPtr GetSkipOpt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetHelpOpt")] public static extern IntPtr GetHelpOpt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetAutoOpt")] public static extern IntPtr GetAutoOpt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetPrompt")] public static extern IntPtr GetPrompt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetTypePrompt")] public static extern IntPtr GetTypePrompt(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetUsageError")] public static extern IntPtr GetUsageError(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetHelp")] public static extern IntPtr GetHelp(IntPtr pObj); [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CR_GetLastError")] public static extern IntPtr GetLastError(IntPtr pObj); /********************************************************************** * * SetResolveCallbackFn: Set the callback for replying to a resolve A * callback. * * pServer: Pointer to the P4BridgeServer * * pNew: The new callback function pointer * * Return: None **********************************************************************/ [DllImport("p4bridge.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void SetResolveACallbackFn(IntPtr pServer, IntPtr pNew); } }