forked from Faithlife/System.Data.SQLite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeMethods.cs
More file actions
132 lines (99 loc) · 6.57 KB
/
Copy pathNativeMethods.cs
File metadata and controls
132 lines (99 loc) · 6.57 KB
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
using System.Runtime.InteropServices;
namespace System.Data.SQLite
{
internal static class NativeMethods
{
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_bind_blob(SqliteStatementHandle stmt, int ordinal, byte[] value, int count, IntPtr free);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_bind_double(SqliteStatementHandle stmt, int ordinal, double value);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_bind_int(SqliteStatementHandle stmt, int ordinal, int value);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_bind_int64(SqliteStatementHandle stmt, int ordinal, long value);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_bind_null(SqliteStatementHandle stmt, int ordinal);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern int sqlite3_bind_parameter_index(SqliteStatementHandle stmt, byte[] zName);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_bind_text(SqliteStatementHandle stmt, int ordinal, byte[] value, int count, IntPtr free);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_close_v2(IntPtr db);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern IntPtr sqlite3_column_blob(SqliteStatementHandle stmt, int index);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern int sqlite3_column_bytes(SqliteStatementHandle stmt, int index);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern int sqlite3_column_count(SqliteStatementHandle stmt);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern IntPtr sqlite3_column_decltype(SqliteStatementHandle stmt, int index);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern double sqlite3_column_double(SqliteStatementHandle stmt, int index);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern int sqlite3_column_int(SqliteStatementHandle stmt, int index);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern long sqlite3_column_int64(SqliteStatementHandle stmt, int index);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern IntPtr sqlite3_column_text(SqliteStatementHandle stmt, int index);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteColumnType sqlite3_column_type(SqliteStatementHandle statement, int ordinal);
[DllImport(c_dllName, EntryPoint = "sqlite3_config", CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_config_log(SQLiteConfigOpsEnum op, SQLiteLogCallback func, IntPtr pvUser);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern int sqlite3_db_readonly(SqliteDatabaseHandle db, [MarshalAs(UnmanagedType.LPStr)] string zDbName);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern IntPtr sqlite3_errstr(SQLiteErrorCode rc);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern IntPtr sqlite3_errmsg(SqliteDatabaseHandle db);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_finalize(IntPtr stmt);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_key(SqliteDatabaseHandle db, byte[] key, int keylen);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_open_v2(byte[] utf8Filename, out SqliteDatabaseHandle db, SQLiteOpenFlags flags, byte[] vfs);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public unsafe static extern SQLiteErrorCode sqlite3_prepare_v2(SqliteDatabaseHandle db, byte* pSql, int nBytes, out SqliteStatementHandle stmt, out byte* pzTail);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern void sqlite3_progress_handler(SqliteDatabaseHandle db, int virtualMachineInstructions, SQLiteProgressCallback callback, IntPtr userData);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_reset(SqliteStatementHandle stmt);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern SQLiteErrorCode sqlite3_step(SqliteStatementHandle stmt);
[DllImport(c_dllName, CallingConvention = c_callingConvention)]
public static extern int sqlite3_total_changes(SqliteDatabaseHandle db);
const string c_dllName = "SQLite.Interop.dll";
const CallingConvention c_callingConvention = CallingConvention.Cdecl;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void SQLiteLogCallback(IntPtr pUserData, int errorCode, IntPtr pMessage);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate int SQLiteProgressCallback(IntPtr pUserData);
// These are the options to the internal sqlite3_config call.
internal enum SQLiteConfigOpsEnum
{
SQLITE_CONFIG_NONE = 0, // nil
SQLITE_CONFIG_SINGLETHREAD = 1, // nil
SQLITE_CONFIG_MULTITHREAD = 2, // nil
SQLITE_CONFIG_SERIALIZED = 3, // nil
SQLITE_CONFIG_MALLOC = 4, // sqlite3_mem_methods*
SQLITE_CONFIG_GETMALLOC = 5, // sqlite3_mem_methods*
SQLITE_CONFIG_SCRATCH = 6, // void*, int sz, int N
SQLITE_CONFIG_PAGECACHE = 7, // void*, int sz, int N
SQLITE_CONFIG_HEAP = 8, // void*, int nByte, int min
SQLITE_CONFIG_MEMSTATUS = 9, // boolean
SQLITE_CONFIG_MUTEX = 10, // sqlite3_mutex_methods*
SQLITE_CONFIG_GETMUTEX = 11, // sqlite3_mutex_methods*
// previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused
SQLITE_CONFIG_LOOKASIDE = 13, // int int
SQLITE_CONFIG_PCACHE = 14, // sqlite3_pcache_methods*
SQLITE_CONFIG_GETPCACHE = 15, // sqlite3_pcache_methods*
SQLITE_CONFIG_LOG = 16, // xFunc, void*
SQLITE_CONFIG_URI = 17, // int
SQLITE_CONFIG_PCACHE2 = 18, // sqlite3_pcache_methods2*
SQLITE_CONFIG_GETPCACHE2 = 19, // sqlite3_pcache_methods2*
SQLITE_CONFIG_COVERING_INDEX_SCAN = 20, // int
SQLITE_CONFIG_SQLLOG = 21, // xSqllog, void*
SQLITE_CONFIG_MMAP_SIZE = 22, // sqlite3_int64, sqlite3_int64
SQLITE_CONFIG_WIN32_HEAPSIZE = 23 // int nByte
}
}