Remove some deprecated libraries
[mono.git] / mcs / class / FirebirdSql.Data.Firebird / FirebirdSql.Data.Gds / GdsServiceManager.cs
index ce7d2b963f24a9b17719361ff52a16ced448550b..0fd46726b05498481fc02aca9d5c711f85ce0817 100644 (file)
-/*\r
- *     Firebird ADO.NET Data provider for .NET and     Mono \r
- * \r
- *        The contents of this file are subject to the Initial \r
- *        Developer's Public License Version 1.0 (the "License"); \r
- *        you may not use this file except in compliance with the \r
- *        License. You may obtain a copy of the License at \r
- *        http://www.firebirdsql.org/index.php?op=doc&id=idpl\r
- *\r
- *        Software distributed under the License is distributed on \r
- *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either \r
- *        express or implied. See the License for the specific \r
- *        language governing rights and limitations under the License.\r
- * \r
- *     Copyright (c) 2002, 2005 Carlos Guzman Alvarez\r
- *     All Rights Reserved.\r
- */\r
-\r
-using System;\r
-using System.IO;\r
-using FirebirdSql.Data.Common;\r
-\r
-namespace FirebirdSql.Data.Gds\r
-{\r
-       internal sealed class GdsServiceManager : IServiceManager\r
-       {\r
-               #region Fields\r
-\r
-               private int handle;\r
-               private GdsConnection connection;\r
-\r
-               #endregion\r
-\r
-               #region Properties\r
-\r
-               public int Handle\r
-               {\r
-                       get { return this.handle; }\r
-               }\r
-\r
-               public bool IsLittleEndian\r
-               {\r
-                       get { return false; }\r
-               }\r
-\r
-               #endregion\r
-\r
-               #region Constructors\r
-\r
-               public GdsServiceManager()\r
-               {\r
-               }\r
-\r
-               #endregion\r
-\r
-               #region Methods\r
-\r
-               public void Attach(ServiceParameterBuffer spb, string dataSource, int port, string service)\r
-               {\r
-                       lock (this)\r
-                       {\r
-                               try\r
-                               {\r
-                                       if (this.connection == null)\r
-                                       {\r
-                                               this.connection = new GdsConnection();\r
-                                       }\r
-\r
-                                       this.connection.Connect(dataSource, port, 8192, Charset.DefaultCharset);\r
-\r
-                                       this.connection.Send.Write(IscCodes.op_service_attach);\r
-                                       this.connection.Send.Write(0);\r
-                                       this.connection.Send.Write(service);\r
-                                       this.connection.Send.WriteBuffer(spb.ToArray());\r
-                                       this.connection.Send.Flush();\r
-\r
-                                       try\r
-                                       {\r
-                                               this.handle = this.connection.ReadGenericResponse().ObjectHandle;\r
-                                       }\r
-                                       catch (IscException)\r
-                                       {\r
-                                               try\r
-                                               {\r
-                                                       this.Detach();\r
-                                               }\r
-                                               catch\r
-                                               {\r
-                                               }\r
-\r
-                                               throw;\r
-                                       }\r
-                               }\r
-                               catch (IOException)\r
-                               {\r
-                                       this.connection.Disconnect();\r
-\r
-                                       throw new IscException(IscCodes.isc_net_write_err);\r
-                               }\r
-                       }\r
-               }\r
-\r
-               public void Detach()\r
-               {\r
-                       lock (this)\r
-                       {\r
-                               try\r
-                               {\r
-                                       this.connection.Send.Write(IscCodes.op_service_detach);\r
-                                       this.connection.Send.Write(this.Handle);\r
-                                       this.connection.Send.Flush();\r
-\r
-                                       this.connection.ReadGenericResponse();\r
-\r
-                                       this.handle = 0;\r
-                               }\r
-                               catch (IOException)\r
-                               {\r
-                                       throw new IscException(IscCodes.isc_network_error);\r
-                               }\r
-                               finally\r
-                               {\r
-                                       try\r
-                                       {\r
-                                               this.connection.Disconnect();\r
-                                       }\r
-                                       catch (IOException)\r
-                                       {\r
-                                               throw new IscException(IscCodes.isc_network_error);\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-\r
-               public void Start(ServiceParameterBuffer spb)\r
-               {\r
-                       lock (this)\r
-                       {\r
-                               try\r
-                               {\r
-                                       this.connection.Send.Write(IscCodes.op_service_start);\r
-                                       this.connection.Send.Write(this.Handle);\r
-                                       this.connection.Send.Write(0);\r
-                                       this.connection.Send.WriteBuffer(spb.ToArray(), spb.Length);\r
-                                       this.connection.Send.Flush();\r
-\r
-                                       try\r
-                                       {\r
-                                               this.connection.ReadGenericResponse();\r
-                                       }\r
-                                       catch (IscException)\r
-                                       {\r
-                                               throw;\r
-                                       }\r
-                               }\r
-                               catch (IOException)\r
-                               {\r
-                                       throw new IscException(IscCodes.isc_net_write_err);\r
-                               }\r
-                       }\r
-               }\r
-\r
-               public void Query(\r
-                       ServiceParameterBuffer  spb,\r
-                       int                                             requestLength,\r
-                       byte[]                                  requestBuffer,\r
-                       int                                             bufferLength,\r
-                       byte[]                                  buffer)\r
-               {\r
-                       lock (this)\r
-                       {\r
-                               try\r
-                               {\r
-                                       this.connection.Send.Write(IscCodes.op_service_info);   //      operation\r
-                                       this.connection.Send.Write(this.Handle);                                //      db_handle\r
-                                       this.connection.Send.Write((int)0);                                             //      incarnation                                     \r
-                                       this.connection.Send.WriteTyped(\r
-                                               IscCodes.isc_spb_version, spb.ToArray());                       //      Service parameter buffer\r
-                                       this.connection.Send.WriteBuffer(\r
-                                               requestBuffer, requestLength);                                          //      request buffer\r
-                                       this.connection.Send.Write(bufferLength);                               //      result buffer length\r
-\r
-                                       this.connection.Send.Flush();\r
-\r
-                                       GdsResponse r = this.connection.ReadGenericResponse();\r
-\r
-                                       Buffer.BlockCopy(r.Data, 0, buffer, 0, bufferLength);\r
-                               }\r
-                               catch (IOException)\r
-                               {\r
-                                       throw new IscException(IscCodes.isc_network_error);\r
-                               }\r
-                       }\r
-               }\r
-\r
-               #endregion\r
-\r
-               #region Buffer creation methods\r
-\r
-               public ServiceParameterBuffer CreateParameterBuffer()\r
-               {\r
-                       return new ServiceParameterBuffer();\r
-               }\r
-\r
-               #endregion\r
-       }\r
-}\r
+/*
+ *     Firebird ADO.NET Data provider for .NET and Mono 
+ * 
+ *        The contents of this file are subject to the Initial 
+ *        Developer's Public License Version 1.0 (the "License"); 
+ *        you may not use this file except in compliance with the 
+ *        License. You may obtain a copy of the License at 
+ *        http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ *        Software distributed under the License is distributed on 
+ *        an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
+ *        express or implied. See the License for the specific 
+ *        language governing rights and limitations under the License.
+ * 
+ *     Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ *     All Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using FirebirdSql.Data.Common;
+
+namespace FirebirdSql.Data.Gds
+{
+       internal sealed class GdsServiceManager : IServiceManager
+       {
+               #region Fields
+
+               private int handle;
+               private GdsConnection connection;
+
+               #endregion
+
+               #region Properties
+
+               public int Handle
+               {
+                       get { return this.handle; }
+               }
+
+               public bool IsLittleEndian
+               {
+                       get { return false; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public GdsServiceManager()
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void Attach(ServiceParameterBuffer spb, string dataSource, int port, string service)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       if (this.connection == null)
+                                       {
+                                               this.connection = new GdsConnection();
+                                       }
+
+                                       this.connection.Connect(dataSource, port, 8192, Charset.DefaultCharset);
+
+                                       this.connection.Send.Write(IscCodes.op_service_attach);
+                                       this.connection.Send.Write(0);
+                                       this.connection.Send.Write(service);
+                                       this.connection.Send.WriteBuffer(spb.ToArray());
+                                       this.connection.Send.Flush();
+
+                                       try
+                                       {
+                                               this.handle = this.connection.ReadGenericResponse().ObjectHandle;
+                                       }
+                                       catch (IscException)
+                                       {
+                                               try
+                                               {
+                                                       this.Detach();
+                                               }
+                                               catch
+                                               {
+                                               }
+
+                                               throw;
+                                       }
+                               }
+                               catch (IOException)
+                               {
+                                       this.connection.Disconnect();
+
+                                       throw new IscException(IscCodes.isc_net_write_err);
+                               }
+                       }
+               }
+
+               public void Detach()
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.connection.Send.Write(IscCodes.op_service_detach);
+                                       this.connection.Send.Write(this.Handle);
+                                       this.connection.Send.Flush();
+
+                                       this.connection.ReadGenericResponse();
+
+                                       this.handle = 0;
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_network_error);
+                               }
+                               finally
+                               {
+                                       try
+                                       {
+                                               this.connection.Disconnect();
+                                       }
+                                       catch (IOException)
+                                       {
+                                               throw new IscException(IscCodes.isc_network_error);
+                                       }
+                               }
+                       }
+               }
+
+               public void Start(ServiceParameterBuffer spb)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.connection.Send.Write(IscCodes.op_service_start);
+                                       this.connection.Send.Write(this.Handle);
+                                       this.connection.Send.Write(0);
+                                       this.connection.Send.WriteBuffer(spb.ToArray(), spb.Length);
+                                       this.connection.Send.Flush();
+
+                                       try
+                                       {
+                                               this.connection.ReadGenericResponse();
+                                       }
+                                       catch (IscException)
+                                       {
+                                               throw;
+                                       }
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_net_write_err);
+                               }
+                       }
+               }
+
+               public void Query(
+                       ServiceParameterBuffer  spb,
+                       int                                             requestLength,
+                       byte[]                                  requestBuffer,
+                       int                                             bufferLength,
+                       byte[]                                  buffer)
+               {
+                       lock (this)
+                       {
+                               try
+                               {
+                                       this.connection.Send.Write(IscCodes.op_service_info);   //      operation
+                                       this.connection.Send.Write(this.Handle);                                //      db_handle
+                                       this.connection.Send.Write((int)0);                                             //      incarnation                                     
+                                       this.connection.Send.WriteTyped(
+                                               IscCodes.isc_spb_version, spb.ToArray());                       //      Service parameter buffer
+                                       this.connection.Send.WriteBuffer(
+                                               requestBuffer, requestLength);                                          //      request buffer
+                                       this.connection.Send.Write(bufferLength);                               //      result buffer length
+
+                                       this.connection.Send.Flush();
+
+                                       GdsResponse r = this.connection.ReadGenericResponse();
+
+                                       Buffer.BlockCopy(r.Data, 0, buffer, 0, bufferLength);
+                               }
+                               catch (IOException)
+                               {
+                                       throw new IscException(IscCodes.isc_network_error);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Buffer creation methods
+
+               public ServiceParameterBuffer CreateParameterBuffer()
+               {
+                       return new ServiceParameterBuffer();
+               }
+
+               #endregion
+       }
+}