-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathSQLiteNativeMethods.cs
285 lines (205 loc) · 10.6 KB
/
SQLiteNativeMethods.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
//
// Adopted from Mono.Data.Sqlite.UnsafeNativeMethods.cs
//
// Author(s):
// Robert Simpson ([email protected])
//
// Adapted and modified for the Mono Project by
// Marek Habersack ([email protected])
//
//
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
// Copyright (C) 2007 Marek Habersack
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
/********************************************************
* ADO.NET 2.0 Data Provider for Sqlite Version 3.X
* Written by Robert Simpson ([email protected])
*
* Released to the public domain, use at your own risk!
********************************************************/
namespace GitSvnAuthManager
{
using System;
using System.Security;
using System.Runtime.InteropServices;
#if !PLATFORM_COMPACTFRAMEWORK
[SuppressUnmanagedCodeSecurity]
#endif
internal static class SQLiteNativeMethods
{
private const string SQLITE_DLL = EncryptedSQLiteDb.SQLITE_DLL;
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_sleep (uint dwMilliseconds);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_libversion ();
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_free (IntPtr p);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_open (byte[] utf8Filename, out IntPtr db);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_interrupt (IntPtr db);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_close (IntPtr db);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_exec (IntPtr db, byte[] strSql, IntPtr pvCallback, IntPtr pvParam, out IntPtr errMsg, out int len);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_errmsg (IntPtr db);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_changes (IntPtr db);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_busy_timeout (IntPtr db, int ms);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_prepare_v2 (IntPtr db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_prepare (IntPtr db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_bind_blob (IntPtr stmt, int index, Byte[] value, int nSize, IntPtr nTransient);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_bind_double (IntPtr stmt, int index, double value);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_bind_int (IntPtr stmt, int index, int value);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_bind_int64 (IntPtr stmt, int index, long value);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_bind_null (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_bind_text (IntPtr stmt, int index, byte[] value, int nlen, IntPtr pvReserved);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_bind_parameter_count (IntPtr stmt);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_bind_parameter_name (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_bind_parameter_index (IntPtr stmt, byte[] strName);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_column_count (IntPtr stmt);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_name (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_decltype (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_step (IntPtr stmt);
[DllImport(SQLITE_DLL)]
internal static extern double sqlite3_column_double (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_column_int (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern Int64 sqlite3_column_int64 (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_text (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_blob (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_column_bytes (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern TypeAffinity sqlite3_column_type (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_finalize (IntPtr stmt);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_reset (IntPtr stmt);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_aggregate_count (IntPtr context);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_value_blob (IntPtr p);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_value_bytes (IntPtr p);
[DllImport(SQLITE_DLL)]
internal static extern double sqlite3_value_double (IntPtr p);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_value_int (IntPtr p);
[DllImport(SQLITE_DLL)]
internal static extern Int64 sqlite3_value_int64 (IntPtr p);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_value_text (IntPtr p);
[DllImport(SQLITE_DLL)]
internal static extern TypeAffinity sqlite3_value_type (IntPtr p);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_result_blob (IntPtr context, byte[] value, int nSize, IntPtr pvReserved);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_result_double (IntPtr context, double value);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_result_error (IntPtr context, byte[] strErr, int nLen);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_result_int (IntPtr context, int value);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_result_int64 (IntPtr context, Int64 value);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_result_null (IntPtr context);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_result_text (IntPtr context, byte[] value, int nLen, IntPtr pvReserved);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_aggregate_context (IntPtr context, int nBytes);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_table_column_metadata (IntPtr db, byte[] dbName, byte[] tblName, byte[] colName, out IntPtr ptrDataType, out IntPtr ptrCollSeq, out int notNull, out int primaryKey, out int autoInc);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_database_name (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_database_name16 (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_table_name (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_table_name16 (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_origin_name (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_origin_name16 (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_text16 (IntPtr stmt, int index);
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
internal static extern int sqlite3_open16 (string utf16Filename, out IntPtr db);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_errmsg16 (IntPtr db);
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
internal static extern int sqlite3_prepare16_v2 (IntPtr db, string pSql, int sqlLen, out IntPtr stmt, IntPtr unused);
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
internal static extern int sqlite3_bind_text16 (IntPtr stmt, int index, string value, int nlen, int nTransient);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_name16 (IntPtr stmt, int index);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_column_decltype16 (IntPtr stmt, int index, out int len);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_value_text16 (IntPtr p);
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
internal static extern void sqlite3_result_error16 (IntPtr context, string strName, int nLen);
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
internal static extern void sqlite3_result_text16 (IntPtr context, string strName, int nLen, IntPtr pvReserved);
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int sqlite3_encryptfile (string fileName);
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int sqlite3_decryptfile (string fileName);
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int sqlite3_encryptedstatus (string fileName, out int fileStatus);
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int sqlite3_compressfile (string fileName);
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int sqlite3_decompressfile (string fileName);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_key (IntPtr db, byte[] key, int keylen);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_rekey (IntPtr db, byte[] key, int keylen);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_cursor_rowid (IntPtr stmt, int cursor, out long rowid);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_table_cursor (IntPtr stmt, int db, int tableRootPage);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_last_insert_rowid (IntPtr db);
}
}