* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / FirebirdSql.Data.Firebird / FirebirdSql.Data.Embedded / FbClient.cs
1 /*
2  *      Firebird ADO.NET Data provider for .NET and Mono 
3  * 
4  *         The contents of this file are subject to the Initial 
5  *         Developer's Public License Version 1.0 (the "License"); 
6  *         you may not use this file except in compliance with the 
7  *         License. You may obtain a copy of the License at 
8  *         http://www.firebirdsql.org/index.php?op=doc&id=idpl
9  *
10  *         Software distributed under the License is distributed on 
11  *         an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
12  *         express or implied. See the License for the specific 
13  *         language governing rights and limitations under the License.
14  * 
15  *      Copyright (c) 2002, 2005 Carlos Guzman Alvarez
16  *      All Rights Reserved.
17  */
18
19 using System;
20 using System.Runtime.InteropServices;
21 using System.Security;
22
23 namespace FirebirdSql.Data.Embedded
24 {
25         [SuppressUnmanagedCodeSecurity]
26         internal sealed class FbClient
27         {
28                 #region Conditional     directives
29
30 #if     (LINUX)
31         #if     (FBCLIENT)
32                         public const string     DllPath = "libfbclient";
33         #elif (GDS32)
34                         public const string     DllPath = "libgds";
35         #elif (VULCAN)
36                         public const string     DllPath = "libfirebird32";
37         #elif (FYRACLE)
38                         public const string     DllPath = "fyracle";
39         #else
40                         public const string     DllPath = "libfbembed";
41         #endif
42 #else
43         #if     (FBCLIENT)
44                         public const string     DllPath = "fbclient";
45         #elif (GDS32)
46                         public const string     DllPath = "gds32";
47         #elif (VULCAN)
48                         public const string     DllPath = "firebird32";
49         #elif (FYRACLE)
50                         public const string     DllPath = "fyracle";
51         #else
52                         public const string DllPath = "fbembed";
53         #endif
54 #endif
55
56                 #endregion
57
58                 #region Constructors
59
60                 private FbClient()
61                 {
62                 }
63
64                 #endregion
65
66                 #region Array Functions
67
68                 [DllImport(FbClient.DllPath)]
69                 public static extern int isc_array_get_slice(
70                         [In, Out] int[] statusVector,
71                         ref     int dbHandle,
72                         ref     int trHandle,
73                         ref     long arrayId,
74                         IntPtr desc,
75                         byte[] destArray,
76                         ref     int sliceLength);
77
78                 [DllImport(FbClient.DllPath)]
79                 public static extern int isc_array_put_slice(
80                         [In, Out] int[] statusVector,
81                         ref     int dbHandle,
82                         ref     int trHandle,
83                         ref     long arrayId,
84                         IntPtr desc,
85                         byte[] sourceArray,
86                         ref     int sliceLength);
87
88                 /*
89                 [DllImport(FbClient.DllPath)]
90                 public static extern int isc_array_get_slice(
91                         [In, Out] int[] statusVector,
92                         string tableName,
93                         string columnName,
94                         ref     short sqlDtype,
95                         ref     short sqlLength,
96                         ref     short dimensions,
97                         IntPtr desc);
98                   
99                 [DllImport(FbClient.DllPath)]
100                 public static extern int isc_array_lookup_bounds(
101                         [In, Out] int[] statusVector,
102                         ref     int dbHandle,
103                         ref     int trHandle,
104                         string tableName,
105                         string columnName,
106                         IntPtr desc);
107
108                 [DllImport(FbClient.DllPath)]
109                 public static extern int isc_array_lookup_desc(
110                         [In, Out] int[] statusVector,
111                         ref     int dbHandle,
112                         ref     int trHandle,
113                         string tableName,
114                         string columnName,
115                         IntPtr desc);
116                 */
117                 #endregion
118
119                 #region Blob functions
120
121                 [DllImport(FbClient.DllPath)]
122                 public static extern int isc_create_blob2(
123                         [In, Out] int[] statusVector,
124                         ref     int dbHandle,
125                         ref     int trHandle,
126                         ref     int blobHandle,
127                         ref     long blobId,
128                         short bpbLength,
129                         byte[] bpbAddress);
130
131                 [DllImport(FbClient.DllPath)]
132                 public static extern int isc_open_blob2(
133                         [In, Out] int[] statusVector,
134                         ref     int dbHandle,
135                         ref     int trHandle,
136                         ref     int blobHandle,
137                         ref     long blobId,
138                         short bpbLength,
139                         byte[] bpbAddress);
140
141                 [DllImport(FbClient.DllPath)]
142                 public static extern int isc_get_segment(
143                         [In, Out] int[] statusVector,
144                         ref     int blobHandle,
145                         ref     short actualSegLength,
146                         short segBufferLength,
147                         byte[] segBuffer);
148
149                 [DllImport(FbClient.DllPath)]
150                 public static extern int isc_put_segment(
151                         [In, Out] int[] statusVector,
152                         ref     int blobHandle,
153                         short segBufferLength,
154                         byte[] segBuffer);
155
156                 [DllImport(FbClient.DllPath)]
157                 public static extern int isc_cancel_blob(
158                         [In, Out] int[] statusVector,
159                         ref     int blobHandle);
160
161                 [DllImport(FbClient.DllPath)]
162                 public static extern int isc_close_blob(
163                         [In, Out] int[] statusVector,
164                         ref     int blobHandle);
165
166                 /*
167                 [DllImport(FbClient.DllPath)]
168                 public static extern int isc_blob_info(
169                         [In, Out] int[] statusVector,
170                         ref     int blobHandle,
171                         short itemListBufferLength,
172                         byte[] itemListBuffer,
173                         short resultBufferLength,
174                         byte[] resultBuffer);
175                 */
176
177                 #endregion
178
179                 #region Database functions
180
181                 [DllImport(FbClient.DllPath)]
182                 public static extern int isc_attach_database(
183                         [In, Out] int[] statusVector,
184                         short dbNameLength,
185                         string dbName,
186                         ref     int dbHandle,
187                         short parmBufferLength,
188                         byte[] parmBuffer);
189
190                 [DllImport(FbClient.DllPath)]
191                 public static extern int isc_detach_database(
192                         [In, Out] int[] statusVector,
193                         ref     int dbHandle);
194
195                 [DllImport(FbClient.DllPath)]
196                 public static extern int isc_database_info(
197                         [In, Out] int[] statusVector,
198                         ref     int dbHandle,
199                         short itemListBufferLength,
200                         byte[] itemListBuffer,
201                         short resultBufferLength,
202                         byte[] resultBuffer);
203
204                 [DllImport(FbClient.DllPath)]
205                 public static extern int isc_create_database(
206                         [In, Out] int[] statusVector,
207                         short dbNameLength,
208                         string dbName,
209                         ref     int dbHandle,
210                         short parmBufferLength,
211                         byte[] parmBuffer,
212                         short dbType);
213
214                 [DllImport(FbClient.DllPath)]
215                 public static extern int isc_drop_database(
216                         [In, Out] int[] statusVector,
217                         ref     int dbHandle);
218
219                 #endregion
220
221                 #region Events functions
222
223                 /*
224                 [DllImport(FbClient.DllPath)]
225                 public static extern int isc_event_block(
226                                 ref     byte[] event_buffer,
227                                 ref     byte[] result_buffer,
228                                 short id_count,
229                                 string eventName);
230
231                 [DllImport(FbClient.DllPath)]
232                 public static extern void isc_event_counts(
233                         [In, Out] int[] statusVector,
234                         short bufferLength,
235                         byte[] eventBuffer,
236                         byte[] resultBuffer);
237
238                 [DllImport(FbClient.DllPath)]
239                 public static extern int isc_que_events(
240                         [In, Out] int[] statusVector,
241                         ref     int dbHandle,
242                         ref     int eventId,
243                         short length,
244                         byte[] eventBuffer,
245                         IntPtr eventFunction,
246                         IntPtr eventFunctionArg);
247
248                 [DllImport(FbClient.DllPath)]
249                 public static extern int isc_cancel_events(
250                         [In, Out] int[] statusVector,
251                         ref     int dbHandle,
252                         ref     int eventId);
253
254                 [DllImport(FbClient.DllPath)]
255                 public static extern int isc_wait_for_event(
256                         [In, Out] int[] statusVector,
257                         ref     int dbHandle,
258                         short length,
259                         byte[] eventBuffer,
260                         byte[] resultBuffer);
261                 */
262
263                 #endregion
264
265                 #region Transaction     functions
266
267                 [DllImport(FbClient.DllPath)]
268                 public static extern int isc_start_multiple(
269                         [In, Out]       int[] statusVector,
270                         ref     int trHandle,
271                         short dbHandleCount,
272                         IntPtr tebVectorAddress);
273
274                 [DllImport(FbClient.DllPath)]
275                 public static extern int isc_commit_transaction(
276                         [In, Out] int[] statusVector,
277                         ref     int trHandle);
278
279                 [DllImport(FbClient.DllPath)]
280                 public static extern int isc_commit_retaining(
281                         [In, Out] int[] statusVector,
282                         ref     int trHandle);
283
284                 [DllImport(FbClient.DllPath)]
285                 public static extern int isc_rollback_transaction(
286                         [In, Out] int[] statusVector,
287                         ref     int trHandle);
288
289                 [DllImport(FbClient.DllPath)]
290                 public static extern int isc_rollback_retaining(
291                         [In, Out] int[] statusVector,
292                         ref     int trHandle);
293
294                 /*
295                 [DllImport(FbClient.DllPath)]
296                 public static extern int isc_start_transaction(
297                         [In, Out] int[] statusVector,
298                         ref     int trHandle,
299                         short dbHandleCount,
300                         ref     int dbHandle,
301                         short tpbLength,
302                         byte[] tpbAddress);
303                   
304                 [DllImport(FbClient.DllPath)]
305                 public static extern int isc_prepare_transaction(
306                         [In, Out] int[] statusVector,
307                         ref     int trHandle);
308
309                 [DllImport(FbClient.DllPath)]
310                 public static extern int isc_prepare_transaction2(
311                         [In, Out] int[] statusVector,
312                         ref     int trHandle,
313                         short msgLength,
314                         byte[] message);
315                 */
316
317                 #endregion
318
319                 #region DSQL functions
320
321                 [DllImport(FbClient.DllPath)]
322                 public static extern int isc_dsql_allocate_statement(
323                         [In, Out] int[] statusVector,
324                         ref     int dbHandle,
325                         ref     int stmtHandle);
326
327                 [DllImport(FbClient.DllPath)]
328                 public static extern int isc_dsql_describe(
329                         [In, Out] int[] statusVector,
330                         ref     int stmtHandle,
331                         short daVersion,
332                         IntPtr xsqlda);
333
334                 [DllImport(FbClient.DllPath)]
335                 public static extern int isc_dsql_describe_bind(
336                         [In, Out] int[] statusVector,
337                         ref     int stmtHandle,
338                         short daVersion,
339                         IntPtr xsqlda);
340
341                 [DllImport(FbClient.DllPath)]
342                 public static extern int isc_dsql_prepare(
343                         [In, Out] int[] statusVector,
344                         ref     int trHandle,
345                         ref     int stmtHandle,
346                         short length,
347                         byte[] statement,
348                         short dialect,
349                         IntPtr xsqlda);
350
351                 [DllImport(FbClient.DllPath)]
352                 public static extern int isc_dsql_execute(
353                         [In, Out] int[] statusVector,
354                         ref     int trHandle,
355                         ref     int stmtHandle,
356                         short daVersion,
357                         IntPtr xsqlda);
358
359                 [DllImport(FbClient.DllPath)]
360                 public static extern int isc_dsql_execute2(
361                         [In, Out] int[] statusVector,
362                         ref     int trHandle,
363                         ref     int stmtHandle,
364                         short da_version,
365                         IntPtr inXsqlda,
366                         IntPtr outXsqlda);
367
368                 [DllImport(FbClient.DllPath)]
369                 public static extern int isc_dsql_fetch(
370                         [In, Out] int[] statusVector,
371                         ref     int stmtHandle,
372                         short daVersion,
373                         IntPtr xsqlda);
374
375                 [DllImport(FbClient.DllPath)]
376                 public static extern int isc_dsql_free_statement(
377                         [In, Out] int[] statusVector,
378                         ref     int stmtHandle,
379                         short option);
380
381                 [DllImport(FbClient.DllPath)]
382                 public static extern int isc_dsql_sql_info(
383                         [In, Out] int[] statusVector,
384                         ref     int stmtHandle,
385                         short itemsLength,
386                         byte[] items,
387                         short bufferLength,
388                         byte[] buffer);
389
390                 [DllImport(FbClient.DllPath)]
391                 public static extern int isc_vax_integer(
392                         byte[] buffer,
393                         short length);
394
395                 /*
396                 [DllImport(FbClient.DllPath)]
397                 public static extern int isc_dsql_execute_immediate(
398                         [In, Out] int[] statusVector,
399                         ref     int dbHandle,
400                         ref     int trHandle,
401                         short length,
402                         string statement,
403                         short dialect,
404                         IntPtr xsqlda);
405
406                 [DllImport(FbClient.DllPath)]
407                 public static extern int isc_dsql_exec_immed2(
408                         [In, Out] int[] statusVector,
409                         ref     int dbHandle,
410                         ref     int trHandle,
411                         short length,
412                         string statement,
413                         short dialect,
414                         IntPtr inXsqlda,
415                         IntPtr outXsqlda);
416
417                 [DllImport(FbClient.DllPath)]
418                 public static extern int isc_dsql_set_cursor_name(
419                         [In, Out] int[] statusVector,
420                         ref     int stmtHandle,
421                         string cursorName,
422                         short type);
423                 */
424
425                 #endregion
426
427                 #region Services functions
428
429                 [DllImport(FbClient.DllPath)]
430                 public static extern int isc_service_attach(
431                         [In, Out] int[] statusVector,
432                         short serviceLength,
433                         string service,
434                         ref     int svcHandle,
435                         short spbLength,
436                         byte[] spb);
437
438                 [DllImport(FbClient.DllPath)]
439                 public static extern int isc_service_start(
440                         [In, Out] int[] statusVector,
441                         ref     int svcHandle,
442                         ref     int reserved,
443                         short spbLength,
444                         byte[] spb);
445
446                 [DllImport(FbClient.DllPath)]
447                 public static extern int isc_service_detach(
448                         [In, Out] int[] statusVector,
449                         ref     int svcHandle);
450
451                 [DllImport(FbClient.DllPath)]
452                 public static extern int isc_service_query(
453                         [In, Out] int[] statusVector,
454                         ref     int svcHandle,
455                         ref     int reserved,
456                         short sendSpbLength,
457                         byte[] sendSpb,
458                         short requestSpbLength,
459                         byte[] requestSpb,
460                         short bufferLength,
461                         byte[] buffer);
462
463                 #endregion
464
465                 #region Error handling
466
467                 /*
468                 [DllImport(FbClient.DllPath)]
469                 public static extern int isc_interprete(
470                         byte[] buffer,
471                         ref     int[] statusVector);
472
473                 [DllImport(FbClient.DllPath)]
474                 public static extern int isc_sqlcode(ref int[] statusVector);
475                 */
476
477                 #endregion
478         }
479 }