17a1f163611dad67791de0383542b0493ac76b5e
[mono.git] / mcs / class / System.Data / System.Data.OleDb / libgda.cs
1 //
2 // System.Data.OleDb.libgda
3 //
4 // Authors:
5 //   Rodrigo Moya (rodrigo@ximian.com)
6 //   Tim Coleman (tim@timcoleman.com)
7 //
8 // Copyright (C) Rodrigo Moya, 2002
9 // Copyright (C) Tim Coleman, 2002
10 //
11
12 using System.Data;
13 using System.Data.Common;
14 using System.Runtime.InteropServices;
15
16 namespace System.Data.OleDb
17 {
18         internal enum GdaCommandOptions {
19                 IgnoreErrors = 1,
20                 StopOnErrors = 1 << 1,
21                 BadOption = 1 << 2,
22         };
23
24         internal enum GdaCommandType {
25                 Sql = 0,
26                 Xml = 1,
27                 Procedure = 2,
28                 Table = 3,
29                 Schema = 4,
30                 Invalid = 5
31         };
32
33         internal enum GdaValueType {
34                 Null = 0,
35                 Bigint = 1,
36                 Binary = 2,
37                 Boolean = 3,
38                 Date = 4,
39                 Double = 5,
40                 GeometricPoint = 6,
41                 Integer = 7,
42                 List = 8,
43                 Numeric = 9,
44                 Single = 10,
45                 Smallint = 11,
46                 String = 12,
47                 Time = 13,
48                 Timestamp = 14,
49                 Tinyint = 15,
50                 Type = 16,
51                 Unknown = 17
52         };
53
54         [StructLayout(LayoutKind.Sequential)]
55         internal class GdaList
56         {
57                 public IntPtr data;
58                 public IntPtr next;
59                 public IntPtr prev;
60         }
61         
62         sealed internal class libgda
63         {
64                 private static IntPtr gdaClient = IntPtr.Zero;
65
66                 public static IntPtr GdaClient
67                 {
68                         get {
69                                 if (gdaClient == IntPtr.Zero)
70                                         gdaClient = gda_client_new ();
71
72                                 return gdaClient;
73                         }
74                 }
75                 
76                 [DllImport("gda-2")]
77                 public static extern void gda_init (string app_id, string version, int nargs, string[] args);
78
79                 [DllImport("gda-2")]
80                 public static extern GdaValueType gda_value_get_vtype (IntPtr value);
81
82                 [DllImport("gda-2")]
83                 public static extern bool gda_value_get_boolean (IntPtr value);
84                 
85                 [DllImport("gda-2")]
86                 public static extern int gda_data_model_get_n_rows (IntPtr model);
87
88                 [DllImport("gda-2")]
89                 public static extern int gda_data_model_get_n_columns (IntPtr model);
90
91                 [DllImport("gda-2")]
92                 public static extern IntPtr gda_data_model_get_value_at (IntPtr model, int col, int row);
93                 
94                 [DllImport("gda-2")]
95                 public static extern IntPtr gda_client_new ();
96
97                 [DllImport("gda-2")]
98                 public static extern IntPtr gda_client_open_connection (IntPtr client, string dsn, string username, string password);
99
100                 [DllImport("gda-2")]
101                 public static extern bool gda_connection_is_open (IntPtr cnc);
102                 
103                 [DllImport("gda-2")]
104                 public static extern bool gda_connection_close (IntPtr cnc);
105
106                 [DllImport("gda-2")]
107                 public static extern string gda_connection_get_database (IntPtr cnc);
108
109                 [DllImport("gda-2")]
110                 public static extern string gda_connection_get_dsn (IntPtr cnc);
111
112                 [DllImport("gda-2")]
113                 public static extern string gda_connection_get_cnc_string (IntPtr cnc);
114
115                 [DllImport("gda-2")]
116                 public static extern string gda_connection_get_provider (IntPtr cnc);
117
118                 [DllImport("gda-2")]
119                 public static extern string gda_connection_get_username (IntPtr cnc);
120
121                 [DllImport("gda-2")]
122                 public static extern string gda_connection_get_password (IntPtr cnc);
123
124                 [DllImport("gda-2")]
125                 public static extern IntPtr gda_transaction_new (string name);
126
127                 [DllImport("gda-2")]
128                 public static extern IntPtr gda_transaction_get_name (IntPtr xaction);
129
130                 [DllImport("gda-2")]
131                 public static extern IntPtr gda_transaction_set_name (IntPtr xaction, string name);
132         
133                 [DllImport("gda-2")]
134                 public static extern bool gda_connection_begin_transaction (IntPtr cnc, IntPtr xaction);
135
136                 [DllImport("gda-2")]
137                 public static extern bool gda_connection_commit_transaction (IntPtr cnc, IntPtr xaction);
138
139                 [DllImport("gda-2")]
140                 public static extern bool gda_connection_rollback_transaction (IntPtr cnc, IntPtr xaction);
141
142                 [DllImport("gda-2")]
143                 public static extern IntPtr gda_connection_execute_command (IntPtr cnc, IntPtr cmd, IntPtr parameterList);
144                 
145                 [DllImport("gda-2")]
146                 public static extern int gda_connection_execute_non_query (IntPtr cnc, IntPtr command, IntPtr parameterList);
147
148                 [DllImport("gda-2")]
149                 public static extern IntPtr gda_connection_execute_single_command (IntPtr cnc, IntPtr command, IntPtr parameterList);
150
151                 [DllImport("gda-2")]
152                 public static extern IntPtr gda_command_new (string text, GdaCommandType type, GdaCommandOptions options);
153
154                 [DllImport("gda-2")]
155                 public static extern void gda_command_set_text (IntPtr cmd, string text);
156
157                 [DllImport("gda-2")]
158                 public static extern void gda_command_set_command_type (IntPtr cmd, GdaCommandType type);
159         }
160 }