Last active
January 11, 2016 03:19
-
-
Save rgchris/7e98988709ec5d635775 to your computer and use it in GitHub Desktop.
Obtain SQLite version with Rebol 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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