Added SQLite and LuaSQLite, Lua plugins can now use SQLite.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1368 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
92e782068f
commit
499962029a
@ -41,7 +41,7 @@ ifeq ($(release),1)
|
|||||||
################
|
################
|
||||||
CC_OPTIONS = -s -g -O3 -DNDEBUG
|
CC_OPTIONS = -s -g -O3 -DNDEBUG
|
||||||
CXX_OPTIONS = -s -g -O3 -DNDEBUG
|
CXX_OPTIONS = -s -g -O3 -DNDEBUG
|
||||||
LNK_OPTIONS = -lstdc++ -pthread -O3
|
LNK_OPTIONS = -lstdc++ -ldl -pthread -O3
|
||||||
BUILDDIR = build/release/
|
BUILDDIR = build/release/
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -51,7 +51,7 @@ ifeq ($(profile),1)
|
|||||||
################
|
################
|
||||||
CC_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
|
CC_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
|
||||||
CXX_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
|
CXX_OPTIONS = -s -g -ggdb -O3 -pg -DNDEBUG
|
||||||
LNK_OPTIONS = -lstdc++ -pthread -ggdb -O3 -pg
|
LNK_OPTIONS = -lstdc++ -ldl -pthread -ggdb -O3 -pg
|
||||||
BUILDDIR = build/profile/
|
BUILDDIR = build/profile/
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -61,7 +61,7 @@ ifeq ($(pedantic),1)
|
|||||||
################
|
################
|
||||||
CC_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
CC_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
||||||
CXX_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
CXX_OPTIONS = -s -g -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
|
||||||
LNK_OPTIONS = -lstdc++ -pthread -ggdb
|
LNK_OPTIONS = -lstdc++ -ldl -pthread -ggdb
|
||||||
BUILDDIR = build/pedantic/
|
BUILDDIR = build/pedantic/
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -71,7 +71,7 @@ else
|
|||||||
################
|
################
|
||||||
CC_OPTIONS = -s -ggdb -g -D_DEBUG -O3
|
CC_OPTIONS = -s -ggdb -g -D_DEBUG -O3
|
||||||
CXX_OPTIONS = -s -ggdb -g -D_DEBUG
|
CXX_OPTIONS = -s -ggdb -g -D_DEBUG
|
||||||
LNK_OPTIONS = -lstdc++ -pthread -g -ggdb
|
LNK_OPTIONS = -lstdc++ -ldl -pthread -g -ggdb
|
||||||
BUILDDIR = build/debug/
|
BUILDDIR = build/debug/
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
27
Install/LuaSQLite3-LICENSE.txt
Normal file
27
Install/LuaSQLite3-LICENSE.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/************************************************************************
|
||||||
|
* lsqlite3 *
|
||||||
|
* Copyright (C) 2002-2013 Tiago Dionizio, Doug Currie *
|
||||||
|
* All rights reserved. *
|
||||||
|
* Author : Tiago Dionizio <tiago.dionizio@ist.utl.pt> *
|
||||||
|
* Author : Doug Currie <doug.currie@alum.mit.edu> *
|
||||||
|
* Library : lsqlite3 - a SQLite 3 database binding for Lua 5 *
|
||||||
|
* *
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining *
|
||||||
|
* a copy of this software and associated documentation files (the *
|
||||||
|
* "Software"), to deal in the Software without restriction, including *
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish, *
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to *
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to *
|
||||||
|
* the following conditions: *
|
||||||
|
* *
|
||||||
|
* The above copyright notice and this permission notice shall be *
|
||||||
|
* included in all copies or substantial portions of the Software. *
|
||||||
|
* *
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY *
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, *
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE *
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||||
|
************************************************************************/
|
@ -9,6 +9,7 @@ MCServer*debug.cmd
|
|||||||
banned.example.ini
|
banned.example.ini
|
||||||
groups.example.ini
|
groups.example.ini
|
||||||
Lua-LICENSE.txt
|
Lua-LICENSE.txt
|
||||||
|
LuaSQLite3-LICENSE.txt
|
||||||
MersenneTwister-LICENSE.txt
|
MersenneTwister-LICENSE.txt
|
||||||
settings.example.ini
|
settings.example.ini
|
||||||
users.example.ini
|
users.example.ini
|
||||||
|
@ -54,6 +54,7 @@ function Initialize(Plugin)
|
|||||||
f:write(n, "\n");
|
f:write(n, "\n");
|
||||||
end
|
end
|
||||||
f:close();
|
f:close();
|
||||||
|
LOG("API.txt written.");
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -136,6 +137,35 @@ function Initialize(Plugin)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Debug SQLite binding
|
||||||
|
local TestDB, ErrCode, ErrMsg = sqlite3.open("test.sqlite");
|
||||||
|
if (TestDB ~= nil) then
|
||||||
|
local function ShowRow(UserData, NumCols, Values, Names)
|
||||||
|
assert(UserData == 'UserData');
|
||||||
|
LOG("New row");
|
||||||
|
for i = 1, NumCols do
|
||||||
|
LOG(" " .. Names[i] .. " = " .. Values[i]);
|
||||||
|
end
|
||||||
|
return 0;
|
||||||
|
end
|
||||||
|
local sql = [=[
|
||||||
|
CREATE TABLE numbers(num1,num2,str);
|
||||||
|
INSERT INTO numbers VALUES(1, 11, "ABC");
|
||||||
|
INSERT INTO numbers VALUES(2, 22, "DEF");
|
||||||
|
INSERT INTO numbers VALUES(3, 33, "UVW");
|
||||||
|
INSERT INTO numbers VALUES(4, 44, "XYZ");
|
||||||
|
SELECT * FROM numbers;
|
||||||
|
]=]
|
||||||
|
local Res = TestDB:exec(sql, ShowRow, 'UserData');
|
||||||
|
if (Res ~= sqlite3.OK) then
|
||||||
|
LOG("TestDB:exec() failed: " .. Res .. " (" .. TestDB:errmsg() .. ")");
|
||||||
|
end;
|
||||||
|
TestDB:close();
|
||||||
|
else
|
||||||
|
-- This happens if for example SQLite cannot open the file (eg. a folder with the same name exists)
|
||||||
|
LOG("SQLite3 failed to open DB! (" .. ErrCode .. ", " .. ErrMsg ..")");
|
||||||
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2195,6 +2195,74 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="SQLite"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\source\sqlite\lsqlite3.c"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release profiled|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\source\sqlite\sqlite3.c"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release profiled|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\source\sqlite\sqlite3.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\source\sqlite\urls.txt"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Config files"
|
Name="Config files"
|
||||||
|
@ -18,6 +18,16 @@ extern "C"
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// fwd: SQLite/lsqlite3.c
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
LUALIB_API int luaopen_lsqlite3(lua_State * L);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool report_errors(lua_State * lua, int status)
|
bool report_errors(lua_State * lua, int status)
|
||||||
{
|
{
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
@ -73,6 +83,7 @@ bool cPlugin_NewLua::Initialize(void)
|
|||||||
luaL_openlibs(m_LuaState);
|
luaL_openlibs(m_LuaState);
|
||||||
tolua_AllToLua_open(m_LuaState);
|
tolua_AllToLua_open(m_LuaState);
|
||||||
ManualBindings::Bind(m_LuaState);
|
ManualBindings::Bind(m_LuaState);
|
||||||
|
luaopen_lsqlite3(m_LuaState);
|
||||||
|
|
||||||
// Inject the identification global variables into the state:
|
// Inject the identification global variables into the state:
|
||||||
lua_pushlightuserdata(m_LuaState, this);
|
lua_pushlightuserdata(m_LuaState, this);
|
||||||
|
2175
source/SQLite/lsqlite3.c
Normal file
2175
source/SQLite/lsqlite3.c
Normal file
File diff suppressed because it is too large
Load Diff
138114
source/SQLite/sqlite3.c
Normal file
138114
source/SQLite/sqlite3.c
Normal file
File diff suppressed because it is too large
Load Diff
7174
source/SQLite/sqlite3.h
Normal file
7174
source/SQLite/sqlite3.h
Normal file
File diff suppressed because it is too large
Load Diff
9
source/SQLite/urls.txt
Normal file
9
source/SQLite/urls.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
SQLite:
|
||||||
|
http://www.sqlite.org
|
||||||
|
SQLite is in public domain
|
||||||
|
|
||||||
|
LuaSQLite3:
|
||||||
|
http://lua.sqlite.org
|
||||||
|
http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki -- documentation
|
||||||
|
License for LuaSQLite is stored in $/install/LuaSQLite3-LICENSE.txt and distributed with the executables
|
Loading…
Reference in New Issue
Block a user