FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Rebol-SQLite/src/sqlite-command-open.c at main · Siskin-framework/Rebol-SQLite · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
Siskin-framework
/
Rebol-SQLite
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
4
Code
Issues
3
Pull requests
0
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Rebol-SQLite
/
src
/
sqlite-command-open.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (40 loc) · 1.45 KB
Breadcrumbs
Rebol-SQLite
/
src
/
sqlite-command-open.c
Copy path
File metadata and controls
50 lines (40 loc) · 1.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
// ____ __ __ ______ __
// / __ \/ /__/ /__ ___ /_ __/__ ____/ /
// / /_/ / / _ / -_|_-<_ / / / -_) __/ _ \
// \____/_/\_,_/\__/___(@)_/ \__/\__/_// /
// ~~~ oldes.huhuman at gmail.com ~~~ /_/
//
// SPDX-License-Identifier: MIT
// =============================================================================
// Rebol/SQLite extension
// =============================================================================
// Use on your own risc!
#include
"sqlite-rebol-extension.h"
int
cmd_sqlite_open
(
RXIFRM
*
frm
,
void
*
reb_ctx
) {
REBSER
*
filename
;
REBHOB
*
hob
;
SQLITE_CONTEXT
*
ctx
;
int
rc
;
filename
=
utf8_string
(
RXA_ARG
(
frm
,
1
));
hob
=
RL_MAKE_HANDLE_CONTEXT
(
Handle_SQLiteDB
);
if
(!
hob
) {
RXA_SERIES
(
frm
,
1
)
=
"[SQLITE] Failed to allocate a handle!"
;
return
RXR_ERROR
;
}
ctx
=
(
SQLITE_CONTEXT
*
)
hob
->
data
;
// Initialize embedded sqlite-vec extension.
// (Maybe it should be done on the request only...)
rc
=
sqlite3_auto_extension
((
void
(
*
)(
void
))
sqlite3_vec_init
);
if
(
rc
!=
SQLITE_OK
) goto
error
;
rc
=
sqlite3_open
(
SERIES_TEXT
(
filename
),
&
ctx
->
db
);
if
(
rc
!=
SQLITE_OK
) goto
error
;
RXA_HANDLE
(
frm
,
1
)
=
hob
;
RXA_HANDLE_TYPE
(
frm
,
1
)
=
hob
->
sym
;
RXA_HANDLE_FLAGS
(
frm
,
1
)
=
hob
->
flags
;
RXA_TYPE
(
frm
,
1
)
=
RXT_HANDLE
;
return
RXR_VALUE
;
error
:
snprintf
((
char
*
)
error_buffer
,
254
,
"[SQLITE] %s"
,
sqlite3_errstr
(
rc
));
RXA_SERIES
(
frm
,
1
)
=
(
void
*
)
error_buffer
;
return
RXR_ERROR
;
}
Back
|
FazBrowse Home
|
New Git URL