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
|
-
|
!
-
|
!
-
|
|
|
!
-
|
!
| #module "mod_SQLite"
#define SQLITE_OK 0
#define SQLITE_ERROR 1
#define SQLITE_INTERNAL 2
#define SQLITE_PERM 3
#define SQLITE_ABORT 4
#define SQLITE_BUSY 5
#define SQLITE_LOCKED 6
#define SQLITE_NOMEM 7
#define SQLITE_READONLY 8
#define SQLITE_INTERRUPT 9
#define SQLITE_IOERR 10
#define SQLITE_CORRUPT 11
#define SQLITE_NOTFOUND 12
#define SQLITE_FULL 13
#define SQLITE_CANTOPEN 14
#define SQLITE_PROTOCOL 15
#define SQLITE_EMPTY 16
#define SQLITE_SCHEMA 17
#define SQLITE_TOOBIG 18
#define SQLITE_CONSTRAINT 19
#define SQLITE_MISMATCH 20
#define SQLITE_MISUSE 21
#define SQLITE_NOLFS 22
#define SQLITE_AUTH 23
#define SQLITE_FORMAT 24
#define SQLITE_RANGE 25
#define SQLITE_NOTADB 26
#define SQLITE_ROW 100
#define SQLITE_DONE 101
#define SQLITE_INTEGER 1
#define SQLITE_FLOAT 2
#define SQLITE_TEXT 3
#define SQLITE_BLOB 4
#define SQLITE_NULL 5
#uselib "sqlite3"
#func sqlite_open "sqlite3_open" sptr, var
#func sqlite_close "sqlite3_close" int
#func sqlite_errmsg "sqlite3_errmsg" int
#func sqlite_exec "sqlite3_exec" int, sptr, int, int, int
#func sqlite_prepare "sqlite3_prepare" int, sptr, int, var, int
#func sqlite_finalize "sqlite3_finalize" int
#func sqlite_step "sqlite3_step" int
#func sqlite_column_count "sqlite3_column_count" int
#func sqlite_column_type "sqlite3_column_type" int, int
#func sqlite_column_text "sqlite3_column_text" int, int
#func sqlite_column_int "sqlite3_column_int" int, int
#func sqlite_column_double_ "sqlite3_column_double" int, int
#uselib "kernel32"
#func _VirtualProtect "VirtualProtect" int, int, int, int
#deffunc sqlite_column_double int p1, int p2
sqlite_column_double_ p1, p2
r = 0.0
prm = varptr(r)
res = callfunc( prm, varptr(_sqlite_column_double_func), 1 )
return r
#deffunc dbini
pDB = 0
pSQL= 0
c = ","
_sqlite_column_double_func = $8bec8b55,$18dd0845,$c35d
_VirtualProtect varptr(_sqlite_column_double_func), length(_sqlite_column_double_func)*4, $40, varptr(prm)
return 0
#deffunc dbbye
return
#deffunc dbopen str p1, int p2
if pDB : return SQLITE_ERROR
sqlite_open p1, pDB
return
#deffunc dbclose
if pSQL {
sqlite_finalize pSQL : pSQL = 0
}
if pDB {
sqlite_close pDB : pDB = 0
}
return
#deffunc dbstat
return 0
#deffunc dbspchr int p1
c = strf("%c", p1)
return
#deffunc dbsend str p1
if 0 = pDB : return SQLITE_ERROR
if 0 ! pSQL : sqlite_finalize pSQL : pSQL = 0
sqlite_prepare pDB, p1, strlen(p1), pSQL, 0
return
#deffunc dbgets var p1
if 0 = pDB || 0 = pSQL : return SQLITE_ERROR
p1 = ""
sqlite_step pSQL
if SQLITE_ROW != stat {
sqlite_finalize pSQL
pSQL = 0
return 1
}
sqlite_column_count pSQL
column = stat
repeat column
sqlite_column_type pSQL, cnt
switch stat
case SQLITE_INTEGER:
sqlite_column_int pSQL, cnt
p1 += "" + stat
swbreak
case SQLITE_FLOAT
sqlite_column_double pSQL, cnt
p1 += "" + refdval
swbreak
case SQLITE_TEXT
sqlite_column_text pSQL, cnt
dupptr sqlite_ptr, stat, 1024, 2
p1 += "" + sqlite_ptr
swbreak
case SQLITE_BLOB
swbreak
case SQLITE_NULL
swbreak
swend
if cnt < column - 1 {
p1 += "" + c
}
loop
p1 += "\n"
return 0
#global
|