resurected sqlite3 and lsqlite3 (nw)

This commit is contained in:
Miodrag Milanovic 2016-11-07 16:12:06 +01:00
parent a607313235
commit cf4a8b9e03
31 changed files with 224258 additions and 0 deletions

4
3rdparty/README.md vendored
View File

@ -28,6 +28,8 @@ libjpeg - [Custom BSD-like](https://github.com/numenta/nupic/blob/master/externa
linenoise-ng - [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause)
lsqlite3 - [The MIT License (MIT)](http://opensource.org/licenses/MIT)
lua - [The MIT License (MIT)](http://opensource.org/licenses/MIT)
lua-zlib - [The MIT License (MIT)](http://opensource.org/licenses/MIT)
@ -52,6 +54,8 @@ softfloat - [U.C. Berkeley open-source license](https://github.com/mamedev/mame/
sol2 - [The MIT License (MIT)](http://opensource.org/licenses/MIT)
sqlite3 - Public Domain
winpcap - [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause)
zlib - [zlib license](http://opensource.org/licenses/Zlib)

245
3rdparty/lsqlite3/HISTORY vendored Normal file
View File

@ -0,0 +1,245 @@
2016-November-??
Version "0.9.4"
Since the "0.9.3-devel" release of this Lua library...
Added second module 'lsqlite3complete' that statically links sqlite.c. Continue to use
'lsqlite3' for dynamic linking to 'sqlite3.so' or 'sqlite3.dll'.
Added Online Backup API
Added unit tests for NULs in BLOBs and TEXT columns. (Refute defect report.)
Use lua_createtable() in lieu of lua_newtable() when number of table elements is known.
This will improve performance.
Thanks to Egil Hjelmeland for the suggestion.
2015-January-06
Version "0.9.3"
Since the "0.9.2-devel" release of this Lua library...
Added lversion() function to report library version, "0.9.3".
Added db:load_extension() function to support SQLite extension libraries.
Added some tests for new funcitons and Lua 5.3 64-bit integers in the database.
Fixed longstanding bug: if db is no longer live, it is auto-closed by gc, but there may still
be live prepared statements. Executing these statements would produce an error. Prepared
statements now hold a reference to the db to prevent it from being collected while the prepared
statement is live. Manually closing the db will continue to finalize the statements, as before.
Fixed bug in PUSH_INT64 macro for Lua < 5.3 introduced in version 0.9.2-devel.
2015-January-04
Version "0.9.2-devel"
Since the "0.9.1-devel" release of this Lua library...
Lua 5.3 compatibility (backward compatible with Lua 5.2 and Lua 5.1.5).
Finally uses sqlite3_prepare_v2() to preserve detailed error codes in statement stepping
With Lua 5.3, 64-bit integer database values are supported for reading and writing columns;
all other values, e.g., status and counts, are now also returned as integers. The only use of
doubles is for values of that type read from or written to columns.
Added support for stmt:last_insert_rowid() as requested
2013-April-08
Version "0.9.1-devel"
Since the "0.9-devel" release of this Lua library...
Updated examples and tests from Dmitry Pashkevich.
2013-March-30
Version "0.9-devel"
Since the "0.8-devel" release of this Lua library...
Updates for Lua 5.2 (backward compatible with Lua 5.1.5).
Uses lunitx-0.6-1.rockspec for Lua 5.2 compatible testing.
Added sqlite3.update_hook(), sqlite3.commit_hook() and
sqlite3.rollback_hook() at the suggesiton of Dmitry Pashkevich, who
also contributed examples and some testing assistance on this release.
Converted Makefile to depend on luarocks.
2011-January-10
Version "0.8-devel"
Since the "0.7-devel" release of this Lua library...
Added a missing lua_pop in dbvm_bind_names()
Now dbvm_bind_index() binds a boolean as 1 or 0
Thanks to Ronny Dierckx
Since the "0.6-devel" release of this Lua library...
Made db_exec_callback thread safe.
Thanks to Grant Robinson.
Bug fix in dbvm_bind_index error message.
Thanks to Dirk Feytons.
Added a few casts and changed a few comments to ANSI C style.
Thanks to Corey Stup.
Note that Thomas Lauer has a patch referenced on LuaForge
to make collations thread safe(r). This issue is still
under investigation: the patch has wide ranging affect
and to me it appears unsafe wrt GC. The whole issue of
thread references in callbacks deserves thorough review.
A new design that places referenced values in the upvalues
of the callback function (rather than in the registry of
the function defining thread) would be preferable. It may
also make sense to keep thread references in a shared
environment of the library's functions, and/or require
all callbacks to be defined in the main lua state (so
they the state is guaranteed to outlive other threads).
-=-
2007-August-15 e
Version "0.6-devel"
Since the "0.5-devel" release of this Lua library...
Tested with SQLite 3.4.2
Added some documentation.
Thanks to Thomas Lauer...
Moved line 525 ("luaL_checktype(L, 2, LUA_TTABLE);")
below the declarations to eliminate non-gcc compiler errors.
Added create-collation, and associated test case.
-=-
2006-October-02 e
Since the "0.1-devel" release of this Lua library...
- updated for Lua 5.1
- provide automatic re-preparation of queries after schema changes
- made prepared statements with bindings work with for-loops
- added some compatibility names
- added many test cases, and ported Mike Roth's tests and examples
-=-
Below is a header comment from the 2004 "0.1" version of the library...
/************************************************************************
$Id: lsqlite3.c,v 1.3 2004/09/05 17:50:32 tngd Exp $
To consider:
------------
EXPERIMENTAL APIs
* sqlite3_progress_handler (implemented)
* sqlite3_commit_hook
TODO?
* sqlite3_create_collation
Changes:
04-09-2004
----------
* changed second return value of db:compile to be the rest of the
sql statement that was not processed instead of the number of
characters of sql not processed (situation in case of success).
* progress callback register function parameter order changed.
number of opcodes is given before the callback now.
29-08-2004 e
------------
* added version() (now supported in sqlite 3.0.5)
* added db:errmsg db:errcode db:total_changes
* rename vm:get_column to vm:get_value
* merge in Tiago's v1.11 change in dbvm_tostring
23-06-2004 e
------------
* heavily revised for SQLite3 C API
* row values now returned as native type (not always text)
* added db:nrows (named rows)
* added vm:bind_blob
* added vm:get_column
* removed encode_binary decode_binary (no longer needed or supported)
* removed version encoding error_string (unsupported in v 3.0.1 -- soon?)
09-04-2004
----------
* renamed db:rows to db:urows
* renamed db:prows to db:rows
* added vm:get_unames()
* added vm:get_utypes()
* added vm:get_uvalues()
08-04-2004
----------
* changed db:encoding() and db:version() to use sqlite_libencoding() and
sqlite_libversion()
* added vm:columns()
* added vm:get_named_types()
* added vm:get_named_values()
* added db:prows - like db:rows but returns a table with the column values
instead of returning multiple columns seperatly on each iteration
* added compatibility functions idata,iname,itype,data,type
* added luaopen_sqlite_module. allow the library to be loaded without
setting a global variable. does the same as luaopen_sqlite, but does not
set the global name "sqlite".
* vm:bind now also returns an error string in case of error
31-03-2004 - 01-04-2004
-----------------------
* changed most of the internals. now using references (luaL_ref) in
most of the places
* make the virtual machine interface seperate from the database
handle. db:compile now returns a vm handle
* added db:rows [for ... in db:rows(...) do ... end]
* added db:close_vm
* added sqlite.encode_binary and sqlite.decode_binary
* attempt to do a strict checking on the return type of the user
defined functions returned values
18-01-2004
----------
* add check on sql function callback to ensure there is enough stack
space to pass column values as parameters
03-12-2003
----------
* callback functions now have to return boolean values to abort or
continue operation instead of a zero or non-zero value
06-12-2003
----------
* make version member of sqlite table a function instead of a string
************************************************************************/

19
3rdparty/lsqlite3/Makefile vendored Normal file
View File

@ -0,0 +1,19 @@
# Makefile for lsqlite3 library for Lua
LIBNAME= lsqlite3
LUAEXE= lua
ROCKSPEC= $(shell find . -name $(LIBNAME)-*-*.rockspec)
all: install
install:
luarocks make $(ROCKSPEC)
test:
$(LUAEXE) test/test.lua
$(LUAEXE) test/tests-sqlite3.lua lsqlite3
$(LUAEXE) test/tests-sqlite3.lua lsqlite3complete
.PHONY: all test install

8
3rdparty/lsqlite3/README vendored Normal file
View File

@ -0,0 +1,8 @@
LuaSQLite 3 provides a means to manipulate SQLite3
databases directly from lua using Lua 5.
To use this library you need SQLite3 library.
You can get it from http://www.sqlite.org/
Lua 5 is available from http://www.lua.org/

1155
3rdparty/lsqlite3/doc/lsqlite3.wiki vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
local sqlite3 = require("lsqlite3")
local db = sqlite3.open_memory()
assert( db:exec "CREATE TABLE test (col1, col2)" )
assert( db:exec "INSERT INTO test VALUES (1, 2)" )
assert( db:exec "INSERT INTO test VALUES (2, 4)" )
assert( db:exec "INSERT INTO test VALUES (3, 6)" )
assert( db:exec "INSERT INTO test VALUES (4, 8)" )
assert( db:exec "INSERT INTO test VALUES (5, 10)" )
do
local square_error_sum = 0
local function step(ctx, a, b)
local error = a - b
local square_error = error * error
square_error_sum = square_error_sum + square_error
end
local function final(ctx)
ctx:result_number( square_error_sum / ctx:aggregate_count() )
end
assert( db:create_aggregate("my_stats", 2, step, final) )
end
--for a,b in db:urows("SELECT col1, col2 FROM test")
--do print("a b: ", a, b) end
for my_stats in db:urows("SELECT my_stats(col1, col2) FROM test")
do print("my_stats:", my_stats) end

21
3rdparty/lsqlite3/examples/function.lua vendored Normal file
View File

@ -0,0 +1,21 @@
local sqlite3 = require("lsqlite3")
local db = sqlite3.open_memory()
assert( db:exec "CREATE TABLE test (col1, col2)" )
assert( db:exec "INSERT INTO test VALUES (1, 2)" )
assert( db:exec "INSERT INTO test VALUES (2, 4)" )
assert( db:exec "INSERT INTO test VALUES (3, 6)" )
assert( db:exec "INSERT INTO test VALUES (4, 8)" )
assert( db:exec "INSERT INTO test VALUES (5, 10)" )
assert( db:create_function("my_sum", 2, function(ctx, a, b)
ctx:result_number( a + b )
end))
for col1, col2, sum in db:urows("SELECT *, my_sum(col1, col2) FROM test") do
print(col1, col2, sum)
end

View File

@ -0,0 +1,349 @@
local sqlite3 = require("lsqlite3")
local db
optbl = { [sqlite3.UPDATE] = "UPDATE";
[sqlite3.INSERT] = "INSERT";
[sqlite3.DELETE] = "DELETE"
}
setmetatable(optbl,
{__index=function(t,n) return string.format("Unknown op %d",n) end})
function update_hook(ud, op, dname, tname, rowid)
print("Sqlite Update Hook:", optbl[op], dname, tname, rowid)
end
function commit_hook(ud)
print("<Sqlite Commit Hook>")
end
function rollback_hook(ud)
print("<Sqlite Rollback Hook>")
end
-- db:exec wrapper with result assertion
function db_exec(stmt)
if db:exec(stmt) ~= sqlite3.OK then
print("Sqlite ERROR: ", db:errmsg())
end
end
-- debug output for database table
function db_print_tables(...)
for i = 1,select('#',...) do
name = select(i,...)
print(string.format("\n%s contents:", name))
for row in db:nrows("SELECT * FROM " .. name) do
print(row.id, row.content)
end
end
end
local tests = {}
-- runs specified test with all necessary setup
-- @param string name
function run_test(name)
-- banner
print(string.format([[
==========================
%s
==========================
]], name))
-- setup
db = sqlite3.open_memory()
local udtbl = {0, 0, 0}
db:update_hook(update_hook, udtbl)
db:commit_hook(commit_hook, udtbl)
db:rollback_hook(rollback_hook, udtbl)
-- run test
tests[name]()
-- destroy
db:close()
end
function tests.insert_select()
db_exec[[
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TABLE T2 ( id INTEGER PRIMARY KEY, content VARCHAR );
INSERT INTO T1 VALUES (NULL, 'Hello World');
INSERT INTO T1 VALUES (NULL, 'Hello Lua');
INSERT INTO T1 VALUES (NULL, 'Hello Sqlite3');
INSERT INTO T2 SELECT * FROM T1;
]]
db_print_tables('T1', 'T2')
end
function tests.trigger_insert()
db_exec[[
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TABLE T2 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TRIGGER after_insert_T1
AFTER INSERT ON T1
FOR EACH ROW
BEGIN
INSERT INTO T2 VALUES(NEW.id, NEW.content);
END;
INSERT INTO T1 VALUES (NULL, 'Hello World');
INSERT INTO T1 VALUES (NULL, 'Hello Lua');
INSERT INTO T1 VALUES (NULL, 'Hello Sqlite3');
]]
db_print_tables('T1', 'T2')
end
function tests.cascade_delete()
db_exec[[
PRAGMA foreign_keys = ON;
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TABLE T2 ( id INTEGER PRIMARY KEY REFERENCES T1 ON DELETE CASCADE, content VARCHAR );
CREATE TABLE T3 ( id INTEGER PRIMARY KEY REFERENCES T2 ON DELETE CASCADE, content VARCHAR );
INSERT INTO T1 VALUES (NULL, 'a');
INSERT INTO T1 VALUES (NULL, 'b');
INSERT INTO T1 VALUES (NULL, 'c');
INSERT INTO T1 VALUES (NULL, 'd');
INSERT INTO T2 SELECT * FROM T1;
INSERT INTO T3 SELECT * FROM T2;
DELETE FROM T1 WHERE id < 3;
]]
db_print_tables('T1', 'T2', 'T3')
end
function tests.cascade_update()
db_exec[[
PRAGMA foreign_keys = ON;
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TABLE T2 ( id INTEGER PRIMARY KEY REFERENCES T1 ON UPDATE CASCADE, content VARCHAR );
CREATE TABLE T3 ( id INTEGER PRIMARY KEY REFERENCES T2 ON UPDATE CASCADE, content VARCHAR );
INSERT INTO T1 VALUES (NULL, 'a');
INSERT INTO T1 VALUES (NULL, 'b');
INSERT INTO T1 VALUES (NULL, 'c');
INSERT INTO T1 VALUES (NULL, 'd');
INSERT INTO T2 SELECT * FROM T1;
INSERT INTO T3 SELECT * FROM T2;
UPDATE T1 SET id = id + 10 WHERE id < 3;
]]
db_print_tables('T1', 'T2', 'T3')
end
-- hook "anomaly"
-- implicit one-statement transaction rollback demonstration
function tests.cascade_update_restrict()
db_exec[[
PRAGMA foreign_keys = ON;
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TABLE T2 ( id INTEGER PRIMARY KEY REFERENCES T1 ON UPDATE RESTRICT, content VARCHAR );
CREATE TABLE T3 ( id INTEGER PRIMARY KEY REFERENCES T2 ON UPDATE RESTRICT, content VARCHAR );
INSERT INTO T1 VALUES (NULL, 'a');
INSERT INTO T1 VALUES (NULL, 'b');
INSERT INTO T1 VALUES (NULL, 'c');
INSERT INTO T1 VALUES (NULL, 'd');
INSERT INTO T2 SELECT * FROM T1;
INSERT INTO T3 SELECT * FROM T2;
-- this update gets reverted but the update_hook with rowid=11 *DOES* get triggered
UPDATE T1 SET id = id + 10 WHERE id < 3;
]]
db_print_tables('T1', 'T2', 'T3')
end
-- hook "anomaly"
-- case is analogous to cascade_update_restrict
function tests.cascade_delete_restrict()
db_exec[[
PRAGMA foreign_keys = ON;
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TABLE T2 ( id INTEGER PRIMARY KEY REFERENCES T1 ON DELETE RESTRICT, content VARCHAR );
CREATE TABLE T3 ( id INTEGER PRIMARY KEY REFERENCES T2 ON DELETE RESTRICT, content VARCHAR );
INSERT INTO T1 VALUES (NULL, 'a');
INSERT INTO T1 VALUES (NULL, 'b');
INSERT INTO T1 VALUES (NULL, 'c');
INSERT INTO T1 VALUES (NULL, 'd');
INSERT INTO T2 SELECT * FROM T1;
INSERT INTO T3 SELECT * FROM T2;
DELETE FROM T1 WHERE id < 3;
]]
db_print_tables('T1', 'T2', 'T3')
end
-- no anomalies here
function tests.fk_violate_insert()
db_exec[[
PRAGMA foreign_keys = ON;
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TABLE T2 ( id INTEGER PRIMARY KEY REFERENCES T1, content VARCHAR);
INSERT INTO T1 VALUES (NULL, 'a');
INSERT INTO T1 VALUES (NULL, 'b');
INSERT INTO T2 VALUES(99, 'xxx');
]]
db_print_tables('T1', 'T2')
end
-- hook "anomaly"
function tests.fk_violate_update()
db_exec[[
PRAGMA foreign_keys = ON;
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TABLE T2 ( id INTEGER PRIMARY KEY REFERENCES T1, content VARCHAR);
INSERT INTO T1 VALUES (NULL, 'a');
INSERT INTO T1 VALUES (NULL, 'b');
INSERT INTO T2 VALUES(1, 'a');
-- update doesn't succeed but we get a hook for tuple with rowid=99 in T2
UPDATE T2 SET id = 99 WHERE id = 1;
]]
db_print_tables('T1', 'T2')
end
-- like fk_violate_update but wrapped inside an explicit transaction
function tests.transaction_fk_violate_update()
db_exec[[
PRAGMA foreign_keys = ON;
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TABLE T2 ( id INTEGER PRIMARY KEY REFERENCES T1, content VARCHAR);
BEGIN TRANSACTION;
INSERT INTO T1 VALUES (NULL, 'a');
INSERT INTO T1 VALUES (NULL, 'b');
INSERT INTO T2 VALUES(1, 'a');
-- Doesn't trigger rollback hook because the implicit update statement transaction
-- is nested inside our explicit transaction. However we *do* get an error.
UPDATE T2 SET id = 99 WHERE id = 1;
COMMIT;
]]
db_print_tables('T1', 'T2')
end
function tests.cascade_update_setnull()
db_exec[[
PRAGMA foreign_keys = ON;
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
CREATE TABLE T2 ( id INTEGER PRIMARY KEY, content INTEGER REFERENCES T1(id) ON UPDATE SET NULL);
INSERT INTO T1 VALUES (NULL, 'a');
INSERT INTO T1 VALUES (NULL, 'b');
INSERT INTO T1 VALUES (NULL, 'c');
INSERT INTO T1 VALUES (NULL, 'd');
INSERT INTO T2 SELECT NULL, id FROM T1;
UPDATE T1 SET id = id + 10 WHERE id < 3;
]]
db_print_tables('T1', 'T2')
end
function tests.transaction_commit()
db_exec[[
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
BEGIN TRANSACTION;
INSERT INTO T1 VALUES (NULL, 'Hello World');
INSERT INTO T1 VALUES (NULL, 'Hello Lua');
COMMIT;
]]
db_print_tables('T1')
end
function tests.transaction_rollback()
db_exec[[
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
BEGIN TRANSACTION;
INSERT INTO T1 VALUES (NULL, 'Hello World');
INSERT INTO T1 VALUES (NULL, 'Hello Lua');
ROLLBACK;
]]
db_print_tables('T1')
end
function tests.savepoint_nested_commit()
db_exec[[
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
SAVEPOINT S1;
INSERT INTO T1 VALUES (NULL, 'Hello World');
INSERT INTO T1 VALUES (NULL, 'Hello Lua');
SAVEPOINT S2;
INSERT INTO T1 VALUES (NULL, 'Hello Sqlite3');
-- nested commit doesn't trigger commit_hook
RELEASE S2;
INSERT INTO T1 VALUES (NULL, 'Hello transactions');
RELEASE S1;
]]
db_print_tables('T1')
end
function tests.savepoint_nested_rollback()
db_exec[[
CREATE TABLE T1 ( id INTEGER PRIMARY KEY, content VARCHAR );
SAVEPOINT S1;
INSERT INTO T1 VALUES (NULL, 'Hello World');
INSERT INTO T1 VALUES (NULL, 'Hello Lua');
SAVEPOINT S2;
INSERT INTO T1 VALUES (NULL, 'Hello Sqlite3');
-- nested rollback doesn't trigger rollback_hook
ROLLBACK TO S2;
INSERT INTO T1 VALUES (NULL, 'Hello transactions');
RELEASE S1;
]]
db_print_tables('T1')
end
-- run_test('fk_violate_insert')
for k,v in pairs(tests) do
run_test(k)
end

122
3rdparty/lsqlite3/examples/order.lua vendored Normal file
View File

@ -0,0 +1,122 @@
local sqlite3 = require("lsqlite3")
local db = assert( sqlite3:open_memory() )
assert( db:exec[[
CREATE TABLE customer (
id INTEGER PRIMARY KEY,
name VARCHAR(40)
);
CREATE TABLE invoice (
id INTEGER PRIMARY KEY,
customer INTEGER NOT NULL,
title VARCHAR(80) NOT NULL,
article1 VARCHAR(40) NOT NULL,
price1 REAL NOT NULL,
article2 VARCHAR(40),
price2 REAL
);
CREATE TABLE invoice_overflow (
id INTEGER PRIMARY KEY,
invoice INTEGER NOT NULL,
article VARCHAR(40) NOT NULL,
price REAL NOT NULL
);
INSERT INTO customer VALUES(
1, "Michael" );
INSERT INTO invoice VALUES(
1, 1, "Computer parts", "harddisc", 89.90, "floppy", 9.99 );
INSERT INTO customer VALUES(
2, "John" );
INSERT INTO invoice VALUES(
2, 2, "Somme food", "apples", 2.79, "pears", 5.99 );
INSERT INTO invoice_overflow VALUES(
NULL, 2, "grapes", 6.34 );
INSERT INTO invoice_overflow VALUES(
NULL, 2, "strawberries", 4.12 );
INSERT INTO invoice_overflow VALUES(
NULL, 2, "tomatoes", 6.17 );
INSERT INTO invoice VALUES(
3, 2, "A new car", "Cybercar XL-1000", 65000.00, NULL, NULL );
]] )
local function customer_name(id)
local stmt = db:prepare("SELECT name FROM customer WHERE id = ?")
stmt:bind_values(id)
stmt:step()
local r = stmt:get_uvalues()
stmt:finalize()
return r
end
local function all_invoices()
return db:nrows("SELECT id, customer, title FROM invoice")
end
local function all_articles(invoice)
local function iterator()
local stmt, row
-- Get the articles that are contained in the invoice table itself.
stmt = db:prepare("SELECT article1, price1, article2, price2 FROM invoice WHERE id = ?")
stmt:bind_values(invoice)
stmt:step()
row = stmt:get_named_values()
-- Every Invoice has at least one article.
coroutine.yield(row.article1, row.price1)
-- Maybe the Invoice has a second article?
if row.article2 then
-- Yes, there is a second article, so return it.
coroutine.yield(row.article2, row.price2)
-- When there was an second article, maybe there are even
-- more articles in the overflow table? We will see...
stmt = db:prepare("SELECT article, price FROM invoice_overflow WHERE invoice = ? ORDER BY id")
stmt:bind_values(invoice)
for row in stmt:nrows() do
coroutine.yield(row.article, row.price)
end
end
end
return coroutine.wrap(iterator)
end
for invoice in all_invoices() do
local id = invoice.id
local name = customer_name(invoice.customer)
local title = invoice.title
print()
print("Invoice #"..id..", "..name..": '"..title.."'")
print("----------------------------------------")
for article, price in all_articles(id) do
print( string.format("%20s %8.2f", article, price) )
end
print()
end

16
3rdparty/lsqlite3/examples/simple.lua vendored Normal file
View File

@ -0,0 +1,16 @@
local sqlite3 = require("lsqlite3")
local db = sqlite3.open_memory()
db:exec[[
CREATE TABLE test (id INTEGER PRIMARY KEY, content);
INSERT INTO test VALUES (NULL, 'Hello World');
INSERT INTO test VALUES (NULL, 'Hello Lua');
INSERT INTO test VALUES (NULL, 'Hello Sqlite3')
]]
for row in db:nrows("SELECT * FROM test") do
print(row.id, row.content)
end

22
3rdparty/lsqlite3/examples/smart.lua vendored Normal file
View File

@ -0,0 +1,22 @@
local sqlite3 = require("lsqlite3")
local db = sqlite3.open_memory()
db:exec[[ CREATE TABLE test (id INTEGER PRIMARY KEY, content) ]]
local stmt = db:prepare[[ INSERT INTO test VALUES (:key, :value) ]]
stmt:bind_names{ key = 1, value = "Hello World" }
stmt:step()
stmt:reset()
stmt:bind_names{ key = 2, value = "Hello Lua" }
stmt:step()
stmt:reset()
stmt:bind_names{ key = 3, value = "Hello Sqlite3" }
stmt:step()
stmt:finalize()
for row in db:nrows("SELECT * FROM test") do
print(row.id, row.content)
end

View File

@ -0,0 +1,39 @@
local sqlite3 = require("lsqlite3")
local db = sqlite3.open_memory()
db:exec[[
CREATE TABLE test (
id INTEGER PRIMARY KEY,
content VARCHAR
);
]]
local insert_stmt = assert( db:prepare("INSERT INTO test VALUES (NULL, ?)") )
local function insert(data)
insert_stmt:bind_values(data)
insert_stmt:step()
insert_stmt:reset()
end
local select_stmt = assert( db:prepare("SELECT * FROM test") )
local function select()
for row in select_stmt:nrows() do
print(row.id, row.content)
end
end
insert("Hello World")
print("First:")
select()
insert("Hello Lua")
print("Second:")
select()
insert("Hello Sqlite3")
print("Third:")
select()

20
3rdparty/lsqlite3/examples/tracing.lua vendored Normal file
View File

@ -0,0 +1,20 @@
local sqlite3 = require("lsqlite3")
local db = sqlite3.open_memory()
db:trace( function(ud, sql)
print("Sqlite Trace:", sql)
end )
db:exec[[
CREATE TABLE test ( id INTEGER PRIMARY KEY, content VARCHAR );
INSERT INTO test VALUES (NULL, 'Hello World');
INSERT INTO test VALUES (NULL, 'Hello Lua');
INSERT INTO test VALUES (NULL, 'Hello Sqlite3');
]]
for row in db:rows("SELECT * FROM test") do
-- NOP
end

View File

@ -0,0 +1,31 @@
local sqlite3 = require("lsqlite3")
local db = sqlite3.open_memory()
optbl = { [sqlite3.UPDATE] = "UPDATE";
[sqlite3.INSERT] = "INSERT";
[sqlite3.DELETE] = "DELETE"
}
setmetatable(optbl,
{__index=function(t,n) return string.format("Unknown op %d",n) end})
udtbl = {0, 0, 0}
db:update_hook( function(ud, op, dname, tname, rowid)
print("Sqlite Update Hook:", optbl[op], dname, tname, rowid)
end, udtbl)
db:exec[[
CREATE TABLE test ( id INTEGER PRIMARY KEY, content VARCHAR );
INSERT INTO test VALUES (NULL, 'Hello World');
INSERT INTO test VALUES (NULL, 'Hello Lua');
INSERT INTO test VALUES (NULL, 'Hello Sqlite3');
UPDATE test SET content = 'Hello Again World' WHERE id = 1;
DELETE FROM test WHERE id = 2;
]]
for row in db:nrows("SELECT * FROM test") do
print(row.id, row.content)
end

99
3rdparty/lsqlite3/extras/Makefile vendored Normal file
View File

@ -0,0 +1,99 @@
# Makefile for lsqlite3 library for Lua
# This file is old and crufty.
# We recommend you make lsqlite3 using luarocks.
# A local make+install (to test source changes) can be done with:
# sudo luarocks make lsqlite3-0.9-1.rockspec
#
# manual setup (change these to reflect your Lua installation)
#
BASE= /usr/local
LUAINC= -I$(BASE)/include
LUALIB=
SQLITE3INC= -I$(BASE)/include
SQLITE3LIB= -L$(BASE)/lib -lsqlite3
# Windows' LUALIB is the same as the Lua executable's directory...
# LUALIB= -L$(BASE)/bin -llua51
#
POD2HTML= perl -x -S doc/pod2html.pl
LUAEXE= lua
INSTALL= install -p
INSTALLPATH= $(LUAEXE) installpath.lua
TMP=./tmp
DISTDIR=./archive
# OS detection
#
SHFLAGS=-shared
UNAME= $(shell uname)
ifeq "$(UNAME)" "Linux"
_SO=so
SHFLAGS=-shared -fPIC
endif
ifneq "" "$(findstring BSD,$(UNAME))"
_SO=so
endif
ifeq "$(UNAME)" "Darwin"
_SO=so
SHFLAGS=-fPIC -arch i686 -arch x86_64
# SOFLAGS=-dynamiclib -single_module -undefined dynamic_lookup -arch i686 -arch x86_64
SOFLAGS=-dynamic -bundle -undefined dynamic_lookup -all_load -arch i686 -arch x86_64
endif
ifneq "" "$(findstring msys,$(OSTYPE))" # 'msys'
_SO=dll
endif
ifndef _SO
$(error $(UNAME))
$(error Unknown OS)
endif
# no need to change anything below here - HAH!
CFLAGS= $(INCS) $(DEFS) $(WARN) -O2 -fomit-frame-pointer $(SHFLAGS)
WARN= -Wall #-ansi -pedantic -Wall
INCS= $(LUAINC) $(SQLITE3INC)
LIBS= $(LUALIB) $(SQLITE3LIB)
MYNAME= sqlite3
MYLIB= l$(MYNAME)
VER=$(shell svnversion -c . | sed 's/.*://')
TARFILE = $(DISTDIR)/$(MYLIB)-$(VER).tar.gz
OBJS= $(MYLIB).o
T= $(MYLIB).$(_SO)
all: $(T)
test: $(T)
$(LUAEXE) test.lua
$(LUAEXE) tests-sqlite3.lua
$(T): $(OBJS)
$(CC) $(SHFLAGS) $(SOFLAGS) -o $@ $(OBJS) $(LIBS)
install: $(T)
$(INSTALL) $< `$(INSTALLPATH) $(MYLIB)`
clean:
rm -f $(OBJS) $T core core.* a.out test.db
html:
$(POD2HTML) --title="LuaSQLite 3" --infile=doc/lsqlite3.pod --outfile=doc/lsqlite3.html
dist: html
echo 'Exporting...'
mkdir -p $(TMP)
mkdir -p $(DISTDIR)
svn export . $(TMP)/$(MYLIB)-$(VER)
mkdir -p $(TMP)/$(MYLIB)-$(VER)/doc
cp -p doc/lsqlite3.html $(TMP)/$(MYLIB)-$(VER)/doc
echo 'Compressing...'
tar -zcf $(TARFILE) -C $(TMP) $(MYLIB)-$(VER)
rm -fr $(TMP)/$(MYLIB)-$(VER)
echo 'Done.'
.PHONY: all test clean dist install

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
-- Script to find the install path for a C module. Public domain.
if not arg or not arg[1] then
io.write("Usage: lua installpath.lua modulename\n")
os.exit(1)
end
for p in string.gfind(package.cpath, "[^;]+") do
if string.sub(p, 1, 1) ~= "." then
local p2 = string.gsub(arg[1], "%.", string.sub(package.config, 1, 1))
io.write(string.gsub(p, "%?", p2), "\n")
return
end
end
error("no suitable installation path found")

View File

@ -0,0 +1,43 @@
package = "lsqlite3"
version = "0.9.4-0"
source = {
url = "http://lua.sqlite.org/index.cgi/zip/lsqlite3_fsl09x.zip?uuid=fsl_9x",
file = "lsqlite3_fsl09x.zip"
}
description = {
summary = "A binding for Lua to the SQLite3 database library",
detailed = [[
lsqlite3 is a thin wrapper around the public domain SQLite3 database engine.
The lsqlite3 module supports the creation and manipulation of SQLite3 databases.
After a require('lsqlite3') the exported functions are called with prefix sqlite3.
However, most sqlite3 functions are called via an object-oriented interface to
either database or SQL statement objects.
]],
license = "MIT/X11",
homepage = "http://lua.sqlite.org/"
}
dependencies = {
"lua >= 5.1, < 5.4"
}
external_dependencies = {
SQLITE = {
header = "sqlite3.h"
}
}
build = {
type = "builtin",
modules = {
lsqlite3 = {
sources = { "lsqlite3.c" },
defines = {'LSQLITE_VERSION="0.9.4"'},
libraries = { "sqlite3" },
incdirs = { "$(SQLITE_INCDIR)" },
libdirs = { "$(SQLITE_LIBDIR)" }
},
lsqlite3complete = {
sources = { "lsqlite3.c", "sqlite3.c" },
defines = {'LSQLITE_VERSION="0.9.4"', 'luaopen_lsqlite3=luaopen_lsqlite3complete'}
}
},
copy_directories = { 'doc', 'examples' }
}

2366
3rdparty/lsqlite3/lsqlite3.c vendored Normal file

File diff suppressed because it is too large Load Diff

68
3rdparty/lsqlite3/test/test-dyld.lua vendored Normal file
View File

@ -0,0 +1,68 @@
--
-- test for load_extension
--
-- before running this script, you must compile extension-functions.c
-- e.g., in directory extras:
-- gcc -fno-common -dynamiclib extension-functions.c -o libsqlitefunctions.dylib
--
-- then run this script from the top level directory: lua test/test-dyld.lua
local sqlite3 = require "lsqlite3"
local os = os
local lunit = require "lunitx"
local tests_sqlite3
if _VERSION >= 'Lua 5.2' then
tests_sqlite3 = lunit.module('tests-sqlite3','seeall')
_ENV = tests_sqlite3
else
module('tests_sqlite3', lunit.testcase, package.seeall)
tests_sqlite3 = _M
end
-- compat
function lunit_wrap (name, fcn)
tests_sqlite3['test_o_'..name] = fcn
end
function lunit_TestCase (name)
return lunit.module(name,'seeall')
end
local db_dyld = lunit_TestCase("Load Extension")
function db_dyld.setup()
db_dyld.db = assert( sqlite3.open_memory() )
assert_equal( sqlite3.OK, db_dyld.db:exec("CREATE TABLE test (id, name)") )
assert_equal( sqlite3.OK, db_dyld.db:exec("INSERT INTO test VALUES (1, 'Hello World')") )
assert_equal( sqlite3.OK, db_dyld.db:exec("INSERT INTO test VALUES (2, 'Hello Lua')") )
assert_equal( sqlite3.OK, db_dyld.db:exec("INSERT INTO test VALUES (3, 'Hello sqlite3')") )
end
function db_dyld.teardown()
assert( db_dyld.db:close() )
end
function db_dyld.test()
local db = db_dyld.db
assert_function( db.load_extension )
assert_true( db:load_extension "extras/libsqlitefunctions" )
for row in db:nrows("SELECT log10(id) as val FROM test WHERE name='Hello World'") do
assert_equal (row.val, 0.0)
end
for row in db:nrows("SELECT reverse(name) as val FROM test WHERE id = 2") do
assert_equal (row.val, 'auL olleH')
end
for row in db:nrows("SELECT padl(name, 16) as val FROM test WHERE id = 3") do
assert_equal (row.val, ' Hello sqlite3')
end
end

153
3rdparty/lsqlite3/test/test.lua vendored Normal file
View File

@ -0,0 +1,153 @@
local sqlite3 = require("lsqlite3")
local width = 78
local function line(pref, suff)
pref = pref or ''
suff = suff or ''
local len = width - 2 - string.len(pref) - string.len(suff)
print(pref .. string.rep('-', len) .. suff)
end
local db, vm
local assert_, assert = assert, function (test)
if (not test) then
error(db:errmsg(), 2)
end
end
line(sqlite3.version())
os.remove('test.db')
db = sqlite3.open('test.db')
line(nil, 'db:exec')
db:exec('CREATE TABLE t(a, b)')
line(nil, 'prepare')
vm = db:prepare('insert into t values(?, :bork)')
assert(vm, db:errmsg())
assert(vm:bind_parameter_count() == 2)
assert(vm:bind_values(2, 4) == sqlite3.OK)
assert(vm:step() == sqlite3.DONE)
assert(vm:reset() == sqlite3.OK)
assert(vm:bind_names{ 'pork', bork = 'nono' } == sqlite3.OK)
assert(vm:step() == sqlite3.DONE)
assert(vm:reset() == sqlite3.OK)
assert(vm:bind_names{ bork = 'sisi' } == sqlite3.OK)
assert(vm:step() == sqlite3.DONE)
assert(vm:reset() == sqlite3.OK)
assert(vm:bind_names{ 1 } == sqlite3.OK)
assert(vm:step() == sqlite3.DONE)
assert(vm:finalize() == sqlite3.OK)
line("select * from t", 'db:exec')
assert(db:exec('select * from t', function (ud, ncols, values, names)
--table.setn(values, 2)
print(table.unpack(values))
return sqlite3.OK
end) == sqlite3.OK)
line("select * from t", 'db:prepare')
vm = db:prepare('select * from t')
assert(vm, db:errmsg())
print(vm:get_unames())
while (vm:step() == sqlite3.ROW) do
print(vm:get_uvalues())
end
assert(vm:finalize() == sqlite3.OK)
line('udf', 'scalar')
local function do_query(sql)
local r
local vm = db:prepare(sql)
assert(vm, db:errmsg())
print('====================================')
print(vm:get_unames())
print('------------------------------------')
r = vm:step()
while (r == sqlite3.ROW) do
print(vm:get_uvalues())
r = vm:step()
end
assert(r == sqlite3.DONE)
assert(vm:finalize() == sqlite3.OK)
print('====================================')
end
local function udf1_scalar(ctx, v)
local ud = ctx:user_data()
ud.r = (ud.r or '') .. tostring(v)
ctx:result_text(ud.r)
end
db:create_function('udf1', 1, udf1_scalar, { })
do_query('select udf1(a) from t')
line('udf', 'aggregate')
local function udf2_aggregate(ctx, ...)
local ud = ctx:get_aggregate_data()
if (not ud) then
ud = {}
ctx:set_aggregate_data(ud)
end
ud.r = (ud.r or 0) + 2
end
local function udf2_aggregate_finalize(ctx, v)
local ud = ctx:get_aggregate_data()
ctx:result_number(ud and ud.r or 0)
end
db:create_aggregate('udf2', 1, udf2_aggregate, udf2_aggregate_finalize, { })
do_query('select udf2(a) from t')
if (true) then
line(nil, '100 insert exec')
db:exec('delete from t')
local t = os.time()
for i = 1, 100 do
db:exec('insert into t values('..i..', '..(i * 2 * -1^i)..')')
end
print('elapsed: '..(os.time() - t))
do_query('select count(*) from t')
line(nil, '100000 insert exec T')
db:exec('delete from t')
local t = os.time()
db:exec('begin')
for i = 1, 100000 do
db:exec('insert into t values('..i..', '..(i * 2 * -1^i)..')')
end
db:exec('commit')
print('elapsed: '..(os.time() - t))
do_query('select count(*) from t')
line(nil, '100000 insert prepare/bind T')
db:exec('delete from t')
local t = os.time()
local vm = db:prepare('insert into t values(?, ?)')
db:exec('begin')
for i = 1, 100000 do
vm:bind_values(i, i * 2 * -1^i)
vm:step()
vm:reset()
end
vm:finalize()
db:exec('commit')
print('elapsed: '..(os.time() - t))
do_query('select count(*) from t')
end
line(nil, "db:close")
assert(db:close() == sqlite3.OK)
line(sqlite3.version())

1208
3rdparty/lsqlite3/test/tests-sqlite3.lua vendored Normal file

File diff suppressed because it is too large Load Diff

5811
3rdparty/sqlite3/shell.c vendored Normal file

File diff suppressed because it is too large Load Diff

199484
3rdparty/sqlite3/sqlite3.c vendored Normal file

File diff suppressed because it is too large Load Diff

10371
3rdparty/sqlite3/sqlite3.h vendored Normal file

File diff suppressed because it is too large Load Diff

560
3rdparty/sqlite3/sqlite3ext.h vendored Normal file
View File

@ -0,0 +1,560 @@
/*
** 2006 June 7
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This header file defines the SQLite interface for use by
** shared libraries that want to be imported as extensions into
** an SQLite instance. Shared libraries that intend to be loaded
** as extensions by SQLite should #include this file instead of
** sqlite3.h.
*/
#ifndef SQLITE3EXT_H
#define SQLITE3EXT_H
#include "sqlite3.h"
/*
** The following structure holds pointers to all of the SQLite API
** routines.
**
** WARNING: In order to maintain backwards compatibility, add new
** interfaces to the end of this structure only. If you insert new
** interfaces in the middle of this structure, then older different
** versions of SQLite will not be able to load each other's shared
** libraries!
*/
struct sqlite3_api_routines {
void * (*aggregate_context)(sqlite3_context*,int nBytes);
int (*aggregate_count)(sqlite3_context*);
int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
int (*bind_double)(sqlite3_stmt*,int,double);
int (*bind_int)(sqlite3_stmt*,int,int);
int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
int (*bind_null)(sqlite3_stmt*,int);
int (*bind_parameter_count)(sqlite3_stmt*);
int (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
const char * (*bind_parameter_name)(sqlite3_stmt*,int);
int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
int (*busy_timeout)(sqlite3*,int ms);
int (*changes)(sqlite3*);
int (*close)(sqlite3*);
int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
int eTextRep,const char*));
int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
int eTextRep,const void*));
const void * (*column_blob)(sqlite3_stmt*,int iCol);
int (*column_bytes)(sqlite3_stmt*,int iCol);
int (*column_bytes16)(sqlite3_stmt*,int iCol);
int (*column_count)(sqlite3_stmt*pStmt);
const char * (*column_database_name)(sqlite3_stmt*,int);
const void * (*column_database_name16)(sqlite3_stmt*,int);
const char * (*column_decltype)(sqlite3_stmt*,int i);
const void * (*column_decltype16)(sqlite3_stmt*,int);
double (*column_double)(sqlite3_stmt*,int iCol);
int (*column_int)(sqlite3_stmt*,int iCol);
sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol);
const char * (*column_name)(sqlite3_stmt*,int);
const void * (*column_name16)(sqlite3_stmt*,int);
const char * (*column_origin_name)(sqlite3_stmt*,int);
const void * (*column_origin_name16)(sqlite3_stmt*,int);
const char * (*column_table_name)(sqlite3_stmt*,int);
const void * (*column_table_name16)(sqlite3_stmt*,int);
const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
const void * (*column_text16)(sqlite3_stmt*,int iCol);
int (*column_type)(sqlite3_stmt*,int iCol);
sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
int (*complete)(const char*sql);
int (*complete16)(const void*sql);
int (*create_collation)(sqlite3*,const char*,int,void*,
int(*)(void*,int,const void*,int,const void*));
int (*create_collation16)(sqlite3*,const void*,int,void*,
int(*)(void*,int,const void*,int,const void*));
int (*create_function)(sqlite3*,const char*,int,int,void*,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*));
int (*create_function16)(sqlite3*,const void*,int,int,void*,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*));
int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
int (*data_count)(sqlite3_stmt*pStmt);
sqlite3 * (*db_handle)(sqlite3_stmt*);
int (*declare_vtab)(sqlite3*,const char*);
int (*enable_shared_cache)(int);
int (*errcode)(sqlite3*db);
const char * (*errmsg)(sqlite3*);
const void * (*errmsg16)(sqlite3*);
int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
int (*expired)(sqlite3_stmt*);
int (*finalize)(sqlite3_stmt*pStmt);
void (*free)(void*);
void (*free_table)(char**result);
int (*get_autocommit)(sqlite3*);
void * (*get_auxdata)(sqlite3_context*,int);
int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
int (*global_recover)(void);
void (*interruptx)(sqlite3*);
sqlite_int64 (*last_insert_rowid)(sqlite3*);
const char * (*libversion)(void);
int (*libversion_number)(void);
void *(*malloc)(int);
char * (*mprintf)(const char*,...);
int (*open)(const char*,sqlite3**);
int (*open16)(const void*,sqlite3**);
int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
void (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
void *(*realloc)(void*,int);
int (*reset)(sqlite3_stmt*pStmt);
void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_double)(sqlite3_context*,double);
void (*result_error)(sqlite3_context*,const char*,int);
void (*result_error16)(sqlite3_context*,const void*,int);
void (*result_int)(sqlite3_context*,int);
void (*result_int64)(sqlite3_context*,sqlite_int64);
void (*result_null)(sqlite3_context*);
void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
void (*result_value)(sqlite3_context*,sqlite3_value*);
void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
const char*,const char*),void*);
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
char * (*snprintf)(int,char*,const char*,...);
int (*step)(sqlite3_stmt*);
int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
char const**,char const**,int*,int*,int*);
void (*thread_cleanup)(void);
int (*total_changes)(sqlite3*);
void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
sqlite_int64),void*);
void * (*user_data)(sqlite3_context*);
const void * (*value_blob)(sqlite3_value*);
int (*value_bytes)(sqlite3_value*);
int (*value_bytes16)(sqlite3_value*);
double (*value_double)(sqlite3_value*);
int (*value_int)(sqlite3_value*);
sqlite_int64 (*value_int64)(sqlite3_value*);
int (*value_numeric_type)(sqlite3_value*);
const unsigned char * (*value_text)(sqlite3_value*);
const void * (*value_text16)(sqlite3_value*);
const void * (*value_text16be)(sqlite3_value*);
const void * (*value_text16le)(sqlite3_value*);
int (*value_type)(sqlite3_value*);
char *(*vmprintf)(const char*,va_list);
/* Added ??? */
int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
/* Added by 3.3.13 */
int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
int (*clear_bindings)(sqlite3_stmt*);
/* Added by 3.4.1 */
int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
void (*xDestroy)(void *));
/* Added by 3.5.0 */
int (*bind_zeroblob)(sqlite3_stmt*,int,int);
int (*blob_bytes)(sqlite3_blob*);
int (*blob_close)(sqlite3_blob*);
int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
int,sqlite3_blob**);
int (*blob_read)(sqlite3_blob*,void*,int,int);
int (*blob_write)(sqlite3_blob*,const void*,int,int);
int (*create_collation_v2)(sqlite3*,const char*,int,void*,
int(*)(void*,int,const void*,int,const void*),
void(*)(void*));
int (*file_control)(sqlite3*,const char*,int,void*);
sqlite3_int64 (*memory_highwater)(int);
sqlite3_int64 (*memory_used)(void);
sqlite3_mutex *(*mutex_alloc)(int);
void (*mutex_enter)(sqlite3_mutex*);
void (*mutex_free)(sqlite3_mutex*);
void (*mutex_leave)(sqlite3_mutex*);
int (*mutex_try)(sqlite3_mutex*);
int (*open_v2)(const char*,sqlite3**,int,const char*);
int (*release_memory)(int);
void (*result_error_nomem)(sqlite3_context*);
void (*result_error_toobig)(sqlite3_context*);
int (*sleep)(int);
void (*soft_heap_limit)(int);
sqlite3_vfs *(*vfs_find)(const char*);
int (*vfs_register)(sqlite3_vfs*,int);
int (*vfs_unregister)(sqlite3_vfs*);
int (*xthreadsafe)(void);
void (*result_zeroblob)(sqlite3_context*,int);
void (*result_error_code)(sqlite3_context*,int);
int (*test_control)(int, ...);
void (*randomness)(int,void*);
sqlite3 *(*context_db_handle)(sqlite3_context*);
int (*extended_result_codes)(sqlite3*,int);
int (*limit)(sqlite3*,int,int);
sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
const char *(*sql)(sqlite3_stmt*);
int (*status)(int,int*,int*,int);
int (*backup_finish)(sqlite3_backup*);
sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);
int (*backup_pagecount)(sqlite3_backup*);
int (*backup_remaining)(sqlite3_backup*);
int (*backup_step)(sqlite3_backup*,int);
const char *(*compileoption_get)(int);
int (*compileoption_used)(const char*);
int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*),
void(*xDestroy)(void*));
int (*db_config)(sqlite3*,int,...);
sqlite3_mutex *(*db_mutex)(sqlite3*);
int (*db_status)(sqlite3*,int,int*,int*,int);
int (*extended_errcode)(sqlite3*);
void (*log)(int,const char*,...);
sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
const char *(*sourceid)(void);
int (*stmt_status)(sqlite3_stmt*,int,int);
int (*strnicmp)(const char*,const char*,int);
int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);
int (*wal_autocheckpoint)(sqlite3*,int);
int (*wal_checkpoint)(sqlite3*,const char*);
void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);
int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);
int (*vtab_config)(sqlite3*,int op,...);
int (*vtab_on_conflict)(sqlite3*);
/* Version 3.7.16 and later */
int (*close_v2)(sqlite3*);
const char *(*db_filename)(sqlite3*,const char*);
int (*db_readonly)(sqlite3*,const char*);
int (*db_release_memory)(sqlite3*);
const char *(*errstr)(int);
int (*stmt_busy)(sqlite3_stmt*);
int (*stmt_readonly)(sqlite3_stmt*);
int (*stricmp)(const char*,const char*);
int (*uri_boolean)(const char*,const char*,int);
sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
const char *(*uri_parameter)(const char*,const char*);
char *(*vsnprintf)(int,char*,const char*,va_list);
int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
/* Version 3.8.7 and later */
int (*auto_extension)(void(*)(void));
int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,
void(*)(void*));
int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,
void(*)(void*),unsigned char);
int (*cancel_auto_extension)(void(*)(void));
int (*load_extension)(sqlite3*,const char*,const char*,char**);
void *(*malloc64)(sqlite3_uint64);
sqlite3_uint64 (*msize)(void*);
void *(*realloc64)(void*,sqlite3_uint64);
void (*reset_auto_extension)(void);
void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,
void(*)(void*));
void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,
void(*)(void*), unsigned char);
int (*strglob)(const char*,const char*);
/* Version 3.8.11 and later */
sqlite3_value *(*value_dup)(const sqlite3_value*);
void (*value_free)(sqlite3_value*);
int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);
int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);
/* Version 3.9.0 and later */
unsigned int (*value_subtype)(sqlite3_value*);
void (*result_subtype)(sqlite3_context*,unsigned int);
/* Version 3.10.0 and later */
int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);
int (*strlike)(const char*,const char*,unsigned int);
int (*db_cacheflush)(sqlite3*);
/* Version 3.12.0 and later */
int (*system_errno)(sqlite3*);
/* Version 3.14.0 and later */
int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
char *(*expanded_sql)(sqlite3_stmt*);
};
/*
** This is the function signature used for all extension entry points. It
** is also defined in the file "loadext.c".
*/
typedef int (*sqlite3_loadext_entry)(
sqlite3 *db, /* Handle to the database. */
char **pzErrMsg, /* Used to set error string on failure. */
const sqlite3_api_routines *pThunk /* Extension API function pointers. */
);
/*
** The following macros redefine the API routines so that they are
** redirected through the global sqlite3_api structure.
**
** This header file is also used by the loadext.c source file
** (part of the main SQLite library - not an extension) so that
** it can get access to the sqlite3_api_routines structure
** definition. But the main library does not want to redefine
** the API. So the redefinition macros are only valid if the
** SQLITE_CORE macros is undefined.
*/
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
#define sqlite3_aggregate_context sqlite3_api->aggregate_context
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_aggregate_count sqlite3_api->aggregate_count
#endif
#define sqlite3_bind_blob sqlite3_api->bind_blob
#define sqlite3_bind_double sqlite3_api->bind_double
#define sqlite3_bind_int sqlite3_api->bind_int
#define sqlite3_bind_int64 sqlite3_api->bind_int64
#define sqlite3_bind_null sqlite3_api->bind_null
#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
#define sqlite3_bind_text sqlite3_api->bind_text
#define sqlite3_bind_text16 sqlite3_api->bind_text16
#define sqlite3_bind_value sqlite3_api->bind_value
#define sqlite3_busy_handler sqlite3_api->busy_handler
#define sqlite3_busy_timeout sqlite3_api->busy_timeout
#define sqlite3_changes sqlite3_api->changes
#define sqlite3_close sqlite3_api->close
#define sqlite3_collation_needed sqlite3_api->collation_needed
#define sqlite3_collation_needed16 sqlite3_api->collation_needed16
#define sqlite3_column_blob sqlite3_api->column_blob
#define sqlite3_column_bytes sqlite3_api->column_bytes
#define sqlite3_column_bytes16 sqlite3_api->column_bytes16
#define sqlite3_column_count sqlite3_api->column_count
#define sqlite3_column_database_name sqlite3_api->column_database_name
#define sqlite3_column_database_name16 sqlite3_api->column_database_name16
#define sqlite3_column_decltype sqlite3_api->column_decltype
#define sqlite3_column_decltype16 sqlite3_api->column_decltype16
#define sqlite3_column_double sqlite3_api->column_double
#define sqlite3_column_int sqlite3_api->column_int
#define sqlite3_column_int64 sqlite3_api->column_int64
#define sqlite3_column_name sqlite3_api->column_name
#define sqlite3_column_name16 sqlite3_api->column_name16
#define sqlite3_column_origin_name sqlite3_api->column_origin_name
#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
#define sqlite3_column_table_name sqlite3_api->column_table_name
#define sqlite3_column_table_name16 sqlite3_api->column_table_name16
#define sqlite3_column_text sqlite3_api->column_text
#define sqlite3_column_text16 sqlite3_api->column_text16
#define sqlite3_column_type sqlite3_api->column_type
#define sqlite3_column_value sqlite3_api->column_value
#define sqlite3_commit_hook sqlite3_api->commit_hook
#define sqlite3_complete sqlite3_api->complete
#define sqlite3_complete16 sqlite3_api->complete16
#define sqlite3_create_collation sqlite3_api->create_collation
#define sqlite3_create_collation16 sqlite3_api->create_collation16
#define sqlite3_create_function sqlite3_api->create_function
#define sqlite3_create_function16 sqlite3_api->create_function16
#define sqlite3_create_module sqlite3_api->create_module
#define sqlite3_create_module_v2 sqlite3_api->create_module_v2
#define sqlite3_data_count sqlite3_api->data_count
#define sqlite3_db_handle sqlite3_api->db_handle
#define sqlite3_declare_vtab sqlite3_api->declare_vtab
#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
#define sqlite3_errcode sqlite3_api->errcode
#define sqlite3_errmsg sqlite3_api->errmsg
#define sqlite3_errmsg16 sqlite3_api->errmsg16
#define sqlite3_exec sqlite3_api->exec
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_expired sqlite3_api->expired
#endif
#define sqlite3_finalize sqlite3_api->finalize
#define sqlite3_free sqlite3_api->free
#define sqlite3_free_table sqlite3_api->free_table
#define sqlite3_get_autocommit sqlite3_api->get_autocommit
#define sqlite3_get_auxdata sqlite3_api->get_auxdata
#define sqlite3_get_table sqlite3_api->get_table
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_global_recover sqlite3_api->global_recover
#endif
#define sqlite3_interrupt sqlite3_api->interruptx
#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
#define sqlite3_libversion sqlite3_api->libversion
#define sqlite3_libversion_number sqlite3_api->libversion_number
#define sqlite3_malloc sqlite3_api->malloc
#define sqlite3_mprintf sqlite3_api->mprintf
#define sqlite3_open sqlite3_api->open
#define sqlite3_open16 sqlite3_api->open16
#define sqlite3_prepare sqlite3_api->prepare
#define sqlite3_prepare16 sqlite3_api->prepare16
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
#define sqlite3_profile sqlite3_api->profile
#define sqlite3_progress_handler sqlite3_api->progress_handler
#define sqlite3_realloc sqlite3_api->realloc
#define sqlite3_reset sqlite3_api->reset
#define sqlite3_result_blob sqlite3_api->result_blob
#define sqlite3_result_double sqlite3_api->result_double
#define sqlite3_result_error sqlite3_api->result_error
#define sqlite3_result_error16 sqlite3_api->result_error16
#define sqlite3_result_int sqlite3_api->result_int
#define sqlite3_result_int64 sqlite3_api->result_int64
#define sqlite3_result_null sqlite3_api->result_null
#define sqlite3_result_text sqlite3_api->result_text
#define sqlite3_result_text16 sqlite3_api->result_text16
#define sqlite3_result_text16be sqlite3_api->result_text16be
#define sqlite3_result_text16le sqlite3_api->result_text16le
#define sqlite3_result_value sqlite3_api->result_value
#define sqlite3_rollback_hook sqlite3_api->rollback_hook
#define sqlite3_set_authorizer sqlite3_api->set_authorizer
#define sqlite3_set_auxdata sqlite3_api->set_auxdata
#define sqlite3_snprintf sqlite3_api->snprintf
#define sqlite3_step sqlite3_api->step
#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
#define sqlite3_total_changes sqlite3_api->total_changes
#define sqlite3_trace sqlite3_api->trace
#ifndef SQLITE_OMIT_DEPRECATED
#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
#endif
#define sqlite3_update_hook sqlite3_api->update_hook
#define sqlite3_user_data sqlite3_api->user_data
#define sqlite3_value_blob sqlite3_api->value_blob
#define sqlite3_value_bytes sqlite3_api->value_bytes
#define sqlite3_value_bytes16 sqlite3_api->value_bytes16
#define sqlite3_value_double sqlite3_api->value_double
#define sqlite3_value_int sqlite3_api->value_int
#define sqlite3_value_int64 sqlite3_api->value_int64
#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
#define sqlite3_value_text sqlite3_api->value_text
#define sqlite3_value_text16 sqlite3_api->value_text16
#define sqlite3_value_text16be sqlite3_api->value_text16be
#define sqlite3_value_text16le sqlite3_api->value_text16le
#define sqlite3_value_type sqlite3_api->value_type
#define sqlite3_vmprintf sqlite3_api->vmprintf
#define sqlite3_vsnprintf sqlite3_api->vsnprintf
#define sqlite3_overload_function sqlite3_api->overload_function
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
#define sqlite3_clear_bindings sqlite3_api->clear_bindings
#define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob
#define sqlite3_blob_bytes sqlite3_api->blob_bytes
#define sqlite3_blob_close sqlite3_api->blob_close
#define sqlite3_blob_open sqlite3_api->blob_open
#define sqlite3_blob_read sqlite3_api->blob_read
#define sqlite3_blob_write sqlite3_api->blob_write
#define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2
#define sqlite3_file_control sqlite3_api->file_control
#define sqlite3_memory_highwater sqlite3_api->memory_highwater
#define sqlite3_memory_used sqlite3_api->memory_used
#define sqlite3_mutex_alloc sqlite3_api->mutex_alloc
#define sqlite3_mutex_enter sqlite3_api->mutex_enter
#define sqlite3_mutex_free sqlite3_api->mutex_free
#define sqlite3_mutex_leave sqlite3_api->mutex_leave
#define sqlite3_mutex_try sqlite3_api->mutex_try
#define sqlite3_open_v2 sqlite3_api->open_v2
#define sqlite3_release_memory sqlite3_api->release_memory
#define sqlite3_result_error_nomem sqlite3_api->result_error_nomem
#define sqlite3_result_error_toobig sqlite3_api->result_error_toobig
#define sqlite3_sleep sqlite3_api->sleep
#define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit
#define sqlite3_vfs_find sqlite3_api->vfs_find
#define sqlite3_vfs_register sqlite3_api->vfs_register
#define sqlite3_vfs_unregister sqlite3_api->vfs_unregister
#define sqlite3_threadsafe sqlite3_api->xthreadsafe
#define sqlite3_result_zeroblob sqlite3_api->result_zeroblob
#define sqlite3_result_error_code sqlite3_api->result_error_code
#define sqlite3_test_control sqlite3_api->test_control
#define sqlite3_randomness sqlite3_api->randomness
#define sqlite3_context_db_handle sqlite3_api->context_db_handle
#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
#define sqlite3_limit sqlite3_api->limit
#define sqlite3_next_stmt sqlite3_api->next_stmt
#define sqlite3_sql sqlite3_api->sql
#define sqlite3_status sqlite3_api->status
#define sqlite3_backup_finish sqlite3_api->backup_finish
#define sqlite3_backup_init sqlite3_api->backup_init
#define sqlite3_backup_pagecount sqlite3_api->backup_pagecount
#define sqlite3_backup_remaining sqlite3_api->backup_remaining
#define sqlite3_backup_step sqlite3_api->backup_step
#define sqlite3_compileoption_get sqlite3_api->compileoption_get
#define sqlite3_compileoption_used sqlite3_api->compileoption_used
#define sqlite3_create_function_v2 sqlite3_api->create_function_v2
#define sqlite3_db_config sqlite3_api->db_config
#define sqlite3_db_mutex sqlite3_api->db_mutex
#define sqlite3_db_status sqlite3_api->db_status
#define sqlite3_extended_errcode sqlite3_api->extended_errcode
#define sqlite3_log sqlite3_api->log
#define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64
#define sqlite3_sourceid sqlite3_api->sourceid
#define sqlite3_stmt_status sqlite3_api->stmt_status
#define sqlite3_strnicmp sqlite3_api->strnicmp
#define sqlite3_unlock_notify sqlite3_api->unlock_notify
#define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint
#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint
#define sqlite3_wal_hook sqlite3_api->wal_hook
#define sqlite3_blob_reopen sqlite3_api->blob_reopen
#define sqlite3_vtab_config sqlite3_api->vtab_config
#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict
/* Version 3.7.16 and later */
#define sqlite3_close_v2 sqlite3_api->close_v2
#define sqlite3_db_filename sqlite3_api->db_filename
#define sqlite3_db_readonly sqlite3_api->db_readonly
#define sqlite3_db_release_memory sqlite3_api->db_release_memory
#define sqlite3_errstr sqlite3_api->errstr
#define sqlite3_stmt_busy sqlite3_api->stmt_busy
#define sqlite3_stmt_readonly sqlite3_api->stmt_readonly
#define sqlite3_stricmp sqlite3_api->stricmp
#define sqlite3_uri_boolean sqlite3_api->uri_boolean
#define sqlite3_uri_int64 sqlite3_api->uri_int64
#define sqlite3_uri_parameter sqlite3_api->uri_parameter
#define sqlite3_uri_vsnprintf sqlite3_api->vsnprintf
#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2
/* Version 3.8.7 and later */
#define sqlite3_auto_extension sqlite3_api->auto_extension
#define sqlite3_bind_blob64 sqlite3_api->bind_blob64
#define sqlite3_bind_text64 sqlite3_api->bind_text64
#define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension
#define sqlite3_load_extension sqlite3_api->load_extension
#define sqlite3_malloc64 sqlite3_api->malloc64
#define sqlite3_msize sqlite3_api->msize
#define sqlite3_realloc64 sqlite3_api->realloc64
#define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension
#define sqlite3_result_blob64 sqlite3_api->result_blob64
#define sqlite3_result_text64 sqlite3_api->result_text64
#define sqlite3_strglob sqlite3_api->strglob
/* Version 3.8.11 and later */
#define sqlite3_value_dup sqlite3_api->value_dup
#define sqlite3_value_free sqlite3_api->value_free
#define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64
#define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64
/* Version 3.9.0 and later */
#define sqlite3_value_subtype sqlite3_api->value_subtype
#define sqlite3_result_subtype sqlite3_api->result_subtype
/* Version 3.10.0 and later */
#define sqlite3_status64 sqlite3_api->status64
#define sqlite3_strlike sqlite3_api->strlike
#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
/* Version 3.12.0 and later */
#define sqlite3_system_errno sqlite3_api->system_errno
/* Version 3.14.0 and later */
#define sqlite3_trace_v2 sqlite3_api->trace_v2
#define sqlite3_expanded_sql sqlite3_api->expanded_sql
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
/* This case when the file really is being compiled as a loadable
** extension */
# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v;
# define SQLITE_EXTENSION_INIT3 \
extern const sqlite3_api_routines *sqlite3_api;
#else
/* This case when the file is being statically linked into the
** application */
# define SQLITE_EXTENSION_INIT1 /*no-op*/
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
# define SQLITE_EXTENSION_INIT3 /*no-op*/
#endif
#endif /* SQLITE3EXT_H */

View File

@ -59,6 +59,7 @@
# USE_SYSTEM_LIB_JPEG = 1
# USE_SYSTEM_LIB_FLAC = 1
# USE_SYSTEM_LIB_LUA = 1
# USE_SYSTEM_LIB_SQLITE3 = 1
# USE_SYSTEM_LIB_PORTMIDI = 1
# USE_SYSTEM_LIB_PORTAUDIO = 1
# USE_BUNDLED_LIB_SDL2 = 1
@ -421,6 +422,10 @@ ifdef USE_SYSTEM_LIB_LUA
PARAMS += --with-system-lua='$(USE_SYSTEM_LIB_LUA)'
endif
ifdef USE_SYSTEM_LIB_SQLITE3
PARAMS += --with-system-sqlite3='$(USE_SYSTEM_LIB_SQLITE3)'
endif
ifdef USE_SYSTEM_LIB_PORTMIDI
PARAMS += --with-system-portmidi='$(USE_SYSTEM_LIB_PORTMIDI)'
endif

View File

@ -10,6 +10,7 @@ local extlibs = {
zlib = { "z", "3rdparty/zlib" },
jpeg = { "jpeg", "3rdparty/libjpeg" },
flac = { "FLAC", "3rdparty/libflac/include" },
sqlite3 = { "sqlite3", "3rdparty/sqlite3" },
portmidi = { "portmidi", "3rdparty/portmidi/pm_common" },
portaudio = { "portaudio", "3rdparty/portaudio/include" },
lua = { "lua", "3rdparty/lua/src" },
@ -36,6 +37,11 @@ newoption {
description = 'Use system FLAC library',
}
newoption {
trigger = 'with-system-sqlite3',
description = 'Use system SQLite library',
}
newoption {
trigger = 'with-system-portmidi',
description = 'Use system PortMidi library',

View File

@ -560,14 +560,48 @@ project "lualibs"
includedirs {
ext_includedir("lua"),
ext_includedir("zlib"),
ext_includedir("sqlite3"),
}
files {
MAME_DIR .. "3rdparty/lsqlite3/lsqlite3.c",
MAME_DIR .. "3rdparty/lua-zlib/lua_zlib.c",
MAME_DIR .. "3rdparty/luafilesystem/src/lfs.c",
MAME_DIR .. "3rdparty/lua-linenoise/linenoise.c",
}
--------------------------------------------------
-- SQLite3 library objects
--------------------------------------------------
if not _OPTIONS["with-system-sqlite3"] then
project "sqlite3"
uuid "5cb3d495-57ed-461c-81e5-80dc0857517d"
kind "StaticLib"
configuration { "gmake" }
buildoptions_c {
"-Wno-discarded-qualifiers",
"-Wno-unused-but-set-variable",
"-Wno-bad-function-cast",
"-Wno-undef",
}
if _OPTIONS["gcc"]~=nil and string.find(_OPTIONS["gcc"], "clang") then
buildoptions_c {
"-Wno-incompatible-pointer-types-discards-qualifiers",
}
end
configuration { }
files {
MAME_DIR .. "3rdparty/sqlite3/sqlite3.c",
}
else
links {
ext_lib("sqlite3"),
}
end
end
--------------------------------------------------
-- portmidi library objects

View File

@ -239,6 +239,7 @@ end
links {
ext_lib("zlib"),
ext_lib("flac"),
ext_lib("sqlite3"),
}
if _OPTIONS["NO_USE_MIDI"]~="1" then

View File

@ -35,6 +35,7 @@ extern "C" {
int luaopen_zlib(lua_State *L);
int luaopen_lfs(lua_State *L);
int luaopen_linenoise(lua_State *L);
int luaopen_lsqlite3(lua_State *L);
}
namespace sol
@ -526,6 +527,7 @@ lua_engine::lua_engine()
sol()["package"]["preload"]["zlib"] = &luaopen_zlib;
sol()["package"]["preload"]["lfs"] = &luaopen_lfs;
sol()["package"]["preload"]["linenoise"] = &luaopen_linenoise;
sol()["package"]["preload"]["lsqlite3"] = &luaopen_lsqlite3;
lua_gc(m_lua_state, LUA_GCRESTART, 0);
}