Skip to content

Instantly share code, notes, and snippets.

@rgchris
Last active January 11, 2016 03:19
Show Gist options
  • Select an option

  • Save rgchris/7e98988709ec5d635775 to your computer and use it in GitHub Desktop.

Select an option

Save rgchris/7e98988709ec5d635775 to your computer and use it in GitHub Desktop.
Obtain SQLite version with Rebol 3
#!/usr/local/bin/ren-c
Rebol [
Title: "SQLite Init"
Date: 10-Jan-2016
Author: "Christopher Ross-Gill"
Comment: [
"Ren/C branch build with LibFFI"
http://stackoverflow.com/a/34710721/292969
]
]
stringify: use [libc strlen][
libc: make library! switch/default fourth system/version [
2 [%libc.dylib]
3 [make error! "Don't know where LibC is for Windows"]
][
%libc.so.6
]
strlen: make routine! compose [
[
s [pointer]
return: [uint64]
]
(libc) "strlen"
]
stringify: func [
pointer [integer!]
/local length struct
] [
length: strlen pointer
struct: make struct! [
s: [uint8 [length]] pointer
]
to string! values-of struct
]
]
sqlite3: make object! [
api: make object! [
library: make library! switch/default fourth system/version [
2 [%libsqlite3.dylib]
3 [%sqlite3.dll]
][%libsqlite3.so]
version: make routine! reduce [
[return: [uint64]]
library
"sqlite3_libversion"
]
]
]
probe to tuple! stringify sqlite3/api/version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment