forked from github/server
remove old SQL patch code, we have sqlite now.
rearrange the SlickEdit projects.
This commit is contained in:
parent
28726e2bea
commit
fa98528d72
|
@ -2,6 +2,7 @@
|
|||
<Workspace Version="10.0" VendorName="SlickEdit">
|
||||
<Projects>
|
||||
<Project File="eressea.vpj"/>
|
||||
<Project File="server.vpj"/>
|
||||
<Project File="tests.vpj"/>
|
||||
</Projects>
|
||||
</Workspace>
|
||||
|
|
1114
se/eressea.vpj
1114
se/eressea.vpj
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,316 @@
|
|||
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
|
||||
<Project
|
||||
Version="10.0"
|
||||
VendorName="SlickEdit"
|
||||
TemplateName="GNU C/C++"
|
||||
WorkingDir="."
|
||||
BuildSystem="vsbuild">
|
||||
<Config
|
||||
Name="Debug"
|
||||
Type="gnuc"
|
||||
DebugCallbackName="gdb"
|
||||
Version="1"
|
||||
OutputFile="%bdserver"
|
||||
CompilerConfigName="Latest Version"
|
||||
Defines='"/DUSE_AUTOCONF"'>
|
||||
<Menu>
|
||||
<Target
|
||||
Name="Compile"
|
||||
MenuCaption="&Compile"
|
||||
Dialog="_gnuc_options_form Compile"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
OutputExts="*.o"
|
||||
SaveOption="SaveCurrent"
|
||||
RunFromDir="%rw">
|
||||
<Exec
|
||||
CmdLine='gcc -c %xup %defd -g -Wall -Werror -Wsign-compare -Wunreachable-code -Wunused -Wuninitialized %~other -o "%bd%n%oe" %i %f'
|
||||
OtherOptions="-std=c99"/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="Link"
|
||||
MenuCaption="&Link"
|
||||
ShowOnMenu="Never"
|
||||
Dialog="_gnuc_options_form Link"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
SaveOption="SaveCurrent"
|
||||
RunFromDir="%rw">
|
||||
<Exec CmdLine='gcc %xup -g -Wall -Werror -o "%o" %objs'/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="Build"
|
||||
MenuCaption="&Build"
|
||||
Dialog="_gnuc_options_form Compile"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
SaveOption="SaveWorkspaceFiles"
|
||||
RunFromDir="%rw"
|
||||
DependsRef="Debug">
|
||||
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t build'/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="Rebuild"
|
||||
MenuCaption="&Rebuild"
|
||||
Dialog="_gnuc_options_form Compile"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
SaveOption="SaveWorkspaceFiles"
|
||||
RunFromDir="%rw"
|
||||
DependsRef="Debug">
|
||||
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t rebuild'/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="Debug"
|
||||
MenuCaption="&Debug"
|
||||
Dialog="_gnuc_options_form Run/Debug"
|
||||
BuildFirst="1"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
SaveOption="SaveNone"
|
||||
RunFromDir="%rw">
|
||||
<Exec CmdLine='vsdebugio -prog "%o"'/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="Execute"
|
||||
MenuCaption="E&xecute"
|
||||
Dialog="_gnuc_options_form Run/Debug"
|
||||
BuildFirst="1"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
SaveOption="SaveWorkspaceFiles"
|
||||
RunFromDir="%rw"
|
||||
RunInXterm="1">
|
||||
<Exec CmdLine='"%o"'/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="dash"
|
||||
MenuCaption="-"
|
||||
Deletable="0">
|
||||
<Exec/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="GNU C Options"
|
||||
MenuCaption="GNU C &Options..."
|
||||
ShowOnMenu="HideIfNoCmdLine"
|
||||
Deletable="0"
|
||||
SaveOption="SaveNone">
|
||||
<Exec
|
||||
CmdLine="gnucoptions"
|
||||
Type="Slick-C"/>
|
||||
</Target>
|
||||
</Menu>
|
||||
<List Name="GNUC Options">
|
||||
<Item
|
||||
Name="LinkerOutputType"
|
||||
Value="Executable"/>
|
||||
</List>
|
||||
<Includes>
|
||||
<Include Dir="/usr/include/lua5.2"/>
|
||||
<Include Dir="../build-i686-gcc-Debug/include"/>
|
||||
<Include Dir="../src"/>
|
||||
<Include Dir="../storage"/>
|
||||
<Include Dir="../quicklist"/>
|
||||
<Include Dir="../critbit"/>
|
||||
<Include Dir="../iniparser"/>
|
||||
<Include Dir="../crypto"/>
|
||||
</Includes>
|
||||
<Libs PreObjects="0">
|
||||
<Lib File="%bderessea.a"/>
|
||||
<Lib File="/usr/lib/libtolua.a"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/liblua5.2.so"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/libncurses.so"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/libsqlite3.so"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/libm.a"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/libpthread.a"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/libdl.a"/>
|
||||
</Libs>
|
||||
<Dependencies Name="Debug">
|
||||
<Dependency Project="eressea.vpj"/>
|
||||
</Dependencies>
|
||||
</Config>
|
||||
<Config
|
||||
Name="Release"
|
||||
Type="gnuc"
|
||||
DebugCallbackName="gdb"
|
||||
Version="1"
|
||||
OutputFile="%bdserver"
|
||||
CompilerConfigName="Latest Version"
|
||||
Defines='"/DUSE_AUTOCONF"'>
|
||||
<Menu>
|
||||
<Target
|
||||
Name="Compile"
|
||||
MenuCaption="&Compile"
|
||||
Dialog="_gnuc_options_form Compile"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
OutputExts="*.o"
|
||||
SaveOption="SaveCurrent"
|
||||
RunFromDir="%rw">
|
||||
<Exec
|
||||
CmdLine='gcc -c %xup %defd -Wall -Werror -Wsign-compare -Wunreachable-code -Wunused -Wuninitialized %~other -o "%bd%n%oe" %i %f'
|
||||
OtherOptions="-std=c99"/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="Link"
|
||||
MenuCaption="&Link"
|
||||
ShowOnMenu="Never"
|
||||
Dialog="_gnuc_options_form Link"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
SaveOption="SaveCurrent"
|
||||
RunFromDir="%rw">
|
||||
<Exec CmdLine='gcc %xup -Wall -Werror -o "%o" %objs'/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="Build"
|
||||
MenuCaption="&Build"
|
||||
Dialog="_gnuc_options_form Compile"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
SaveOption="SaveWorkspaceFiles"
|
||||
RunFromDir="%rw"
|
||||
DependsRef="Release">
|
||||
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t build'/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="Rebuild"
|
||||
MenuCaption="&Rebuild"
|
||||
Dialog="_gnuc_options_form Compile"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
SaveOption="SaveWorkspaceFiles"
|
||||
RunFromDir="%rw"
|
||||
DependsRef="Release">
|
||||
<Exec CmdLine='"%(VSLICKBIN1)vsbuild" "%w" "%r" -t rebuild'/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="Debug"
|
||||
MenuCaption="&Debug"
|
||||
Dialog="_gnuc_options_form Run/Debug"
|
||||
BuildFirst="1"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
SaveOption="SaveNone"
|
||||
RunFromDir="%rw">
|
||||
<Exec CmdLine='vsdebugio -prog "%o"'/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="Execute"
|
||||
MenuCaption="E&xecute"
|
||||
Dialog="_gnuc_options_form Run/Debug"
|
||||
BuildFirst="1"
|
||||
CaptureOutputWith="ProcessBuffer"
|
||||
Deletable="0"
|
||||
SaveOption="SaveWorkspaceFiles"
|
||||
RunFromDir="%rw"
|
||||
RunInXterm="1">
|
||||
<Exec CmdLine='"%o"'/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="dash"
|
||||
MenuCaption="-"
|
||||
Deletable="0">
|
||||
<Exec/>
|
||||
</Target>
|
||||
<Target
|
||||
Name="GNU C Options"
|
||||
MenuCaption="GNU C &Options..."
|
||||
ShowOnMenu="HideIfNoCmdLine"
|
||||
Deletable="0"
|
||||
SaveOption="SaveNone">
|
||||
<Exec
|
||||
CmdLine="gnucoptions"
|
||||
Type="Slick-C"/>
|
||||
</Target>
|
||||
</Menu>
|
||||
<List Name="GNUC Options">
|
||||
<Item
|
||||
Name="LinkerOutputType"
|
||||
Value="Executable"/>
|
||||
</List>
|
||||
<Includes>
|
||||
<Include Dir="/usr/include/lua5.2"/>
|
||||
<Include Dir="../build-i686-gcc-Debug/include"/>
|
||||
<Include Dir="../src"/>
|
||||
<Include Dir="../storage"/>
|
||||
<Include Dir="../quicklist"/>
|
||||
<Include Dir="../critbit"/>
|
||||
<Include Dir="../iniparser"/>
|
||||
<Include Dir="../crypto"/>
|
||||
</Includes>
|
||||
<Libs PreObjects="0">
|
||||
<Lib File="%bderessea.a"/>
|
||||
<Lib File="/usr/lib/libtolua.a"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/liblua5.2.so"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/libncurses.so"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/libsqlite3.so"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/libm.a"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/libpthread.a"/>
|
||||
<Lib File="/usr/lib/i386-linux-gnu/libdl.a"/>
|
||||
</Libs>
|
||||
<Dependencies Name="Release">
|
||||
<Dependency Project="eressea.vpj"/>
|
||||
</Dependencies>
|
||||
</Config>
|
||||
<Files>
|
||||
<Folder
|
||||
Name="Source Files"
|
||||
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d;*.m;*.mm;*.go">
|
||||
<F N="../src/bind_building.c"/>
|
||||
<F N="../src/bind_eressea.c"/>
|
||||
<F N="../src/bind_faction.c"/>
|
||||
<F N="../src/bind_gmtool.c"/>
|
||||
<F N="../src/bind_hashtable.c"/>
|
||||
<F N="../src/bind_message.c"/>
|
||||
<F N="../src/bind_monsters.c"/>
|
||||
<F N="../src/bind_process.c"/>
|
||||
<F N="../src/bind_region.c"/>
|
||||
<F N="../src/bind_settings.c"/>
|
||||
<F N="../src/bind_ship.c"/>
|
||||
<F N="../src/bind_sqlite.c"/>
|
||||
<F N="../src/bind_storage.c"/>
|
||||
<F N="../src/bind_unit.c"/>
|
||||
<F N="../src/bindings.c"/>
|
||||
<F N="../src/console.c"/>
|
||||
<F N="../src/eressea.pkg.c"/>
|
||||
<F N="../src/gmtool.c"/>
|
||||
<F N="../src/helpers.c"/>
|
||||
<F N="../src/listbox.c"/>
|
||||
<F N="../src/main.c"/>
|
||||
<F N="../src/process.pkg.c"/>
|
||||
<F N="../src/settings.pkg.c"/>
|
||||
<F N="../src/sqlite.c"/>
|
||||
</Folder>
|
||||
<Folder
|
||||
Name="Header Files"
|
||||
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
|
||||
<F N="../src/bind_building.h"/>
|
||||
<F N="../src/bind_eressea.h"/>
|
||||
<F N="../src/bind_faction.h"/>
|
||||
<F N="../src/bind_gmtool.h"/>
|
||||
<F N="../src/bind_hashtable.h"/>
|
||||
<F N="../src/bind_message.h"/>
|
||||
<F N="../src/bind_process.h"/>
|
||||
<F N="../src/bind_region.h"/>
|
||||
<F N="../src/bind_settings.h"/>
|
||||
<F N="../src/bind_ship.h"/>
|
||||
<F N="../src/bind_storage.h"/>
|
||||
<F N="../src/bind_unit.h"/>
|
||||
<F N="../src/bindings.h"/>
|
||||
<F N="../src/gmtool.h"/>
|
||||
<F N="../src/gmtool_structs.h"/>
|
||||
<F N="../src/helpers.h"/>
|
||||
<F N="../src/listbox.h"/>
|
||||
</Folder>
|
||||
<Folder
|
||||
Name="Resource Files"
|
||||
Filters="*.ico;*.cur;*.dlg"/>
|
||||
<Folder
|
||||
Name="Bitmaps"
|
||||
Filters="*.bmp"/>
|
||||
<Folder
|
||||
Name="Other Files"
|
||||
Filters=""/>
|
||||
</Files>
|
||||
</Project>
|
|
@ -81,6 +81,8 @@ set (ERESSEA_SRC
|
|||
)
|
||||
|
||||
set(SERVER_SRC
|
||||
main.c
|
||||
console.c
|
||||
helpers.c
|
||||
process.pkg.c
|
||||
eressea.pkg.c
|
||||
|
@ -115,7 +117,7 @@ set (SERVER_SRC
|
|||
${SERVER_SRC})
|
||||
endif(CURSES_FOUND)
|
||||
|
||||
add_executable(eressea ${SERVER_SRC} main.c)
|
||||
add_executable(eressea ${SERVER_SRC})
|
||||
target_link_libraries(eressea
|
||||
${TOLUA_LIBRARIES}
|
||||
${LUA_LIBRARIES}
|
||||
|
|
|
@ -23,6 +23,7 @@ without prior permission by the authors of Eressea.
|
|||
#include "bind_gmtool.h"
|
||||
#include "bind_region.h"
|
||||
#include "helpers.h"
|
||||
#include "console.h"
|
||||
|
||||
#include <kernel/config.h>
|
||||
|
||||
|
@ -61,7 +62,6 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/console.h>
|
||||
#include <util/language.h>
|
||||
#include <util/lists.h>
|
||||
#include <util/log.h>
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#include "gmtool.h"
|
||||
#include "gmtool_structs.h"
|
||||
#include "console.h"
|
||||
#include "listbox.h"
|
||||
|
||||
#include <modules/xmas.h>
|
||||
#include <modules/gmcmd.h>
|
||||
|
@ -56,8 +58,6 @@
|
|||
#include <util/lists.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/console.h>
|
||||
#include <util/listbox.h>
|
||||
|
||||
#include <storage.h>
|
||||
#include <lua.h>
|
||||
|
|
|
@ -67,7 +67,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <quicklist.h>
|
||||
#include <util/rand.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/sql.h>
|
||||
#include <util/translation.h>
|
||||
#include <util/unicode.h>
|
||||
#include <util/umlaut.h>
|
||||
|
@ -100,7 +99,6 @@ bool lomem = false;
|
|||
FILE *logfile;
|
||||
FILE *updatelog;
|
||||
const struct race *new_race[MAXRACES];
|
||||
bool sqlpatch = false;
|
||||
bool battledebug = false;
|
||||
int turn = -1;
|
||||
|
||||
|
@ -2172,7 +2170,6 @@ void kernel_done(void)
|
|||
*/
|
||||
translation_done();
|
||||
gc_done();
|
||||
sql_done();
|
||||
}
|
||||
|
||||
const char *localenames[] = {
|
||||
|
@ -2316,10 +2313,6 @@ void remove_empty_factions(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (f->subscription) {
|
||||
sql_print(("UPDATE subscriptions set status='DEAD' where id=%u;\n",
|
||||
f->subscription));
|
||||
}
|
||||
|
||||
*fp = f->next;
|
||||
funhash(f);
|
||||
|
@ -3012,14 +3005,8 @@ void attrib_init(void)
|
|||
|
||||
void kernel_init(void)
|
||||
{
|
||||
char zBuffer[MAX_PATH];
|
||||
attrib_init();
|
||||
translation_init();
|
||||
|
||||
if (sqlpatch) {
|
||||
sprintf(zBuffer, "%s/patch-%d.sql", datapath(), turn);
|
||||
sql_init(zBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
static order * defaults[MAXLOCALES];
|
||||
|
@ -3147,7 +3134,6 @@ void load_inifile(dictionary * d)
|
|||
}
|
||||
|
||||
verbosity = iniparser_getint(d, "eressea:verbose", 2);
|
||||
sqlpatch = iniparser_getint(d, "eressea:sqlpatch", false);
|
||||
battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0;
|
||||
|
||||
str = iniparser_getstring(d, "eressea:locales", "de,en");
|
||||
|
|
|
@ -46,7 +46,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <quicklist.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/sql.h>
|
||||
#include <util/variant.h>
|
||||
#include <util/unicode.h>
|
||||
#include <attributes/otherfaction.h>
|
||||
|
@ -419,10 +418,6 @@ void set_alliance(faction * a, faction * b, int status)
|
|||
|
||||
void renumber_faction(faction * f, int no)
|
||||
{
|
||||
if (f->subscription) {
|
||||
sql_print(("UPDATE subscriptions set faction='%s' where id=%u;\n",
|
||||
itoa36(no), f->subscription));
|
||||
}
|
||||
funhash(f);
|
||||
f->no = no;
|
||||
fhash(f);
|
||||
|
|
|
@ -66,7 +66,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/rand.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/sql.h>
|
||||
#include <util/umlaut.h>
|
||||
#include <util/unicode.h>
|
||||
|
||||
|
|
12
src/laws.c
12
src/laws.c
|
@ -80,7 +80,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <quicklist.h>
|
||||
#include <util/rand.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/sql.h>
|
||||
#include <util/umlaut.h>
|
||||
#include <util/message.h>
|
||||
#include <util/rng.h>
|
||||
|
@ -1448,17 +1447,6 @@ static void remove_idle_players(void)
|
|||
char info[256];
|
||||
sprintf(info, "%d Einheiten, %d Personen, %d Silber",
|
||||
f->no_units, f->num_total, f->money);
|
||||
if (f->subscription) {
|
||||
sql_print(
|
||||
("UPDATE subscriptions SET lastturn=%d, info='%s' WHERE id=%u;\n",
|
||||
f->lastorders, info, f->subscription));
|
||||
}
|
||||
} else {
|
||||
if (f->subscription) {
|
||||
sql_print(
|
||||
("UPDATE subscriptions SET status='ACTIVE', lastturn=%d, firstturn=greatest(firstturn,%d) WHERE id=%u;\n",
|
||||
f->lastorders, f->lastorders - f->age, f->subscription));
|
||||
}
|
||||
}
|
||||
|
||||
if (NMRTimeout() > 0 && turn - f->lastorders >= (NMRTimeout() - 1)) {
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <util/log.h>
|
||||
#include <quicklist.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/sql.h>
|
||||
#include <util/unicode.h>
|
||||
|
||||
/* libc includes */
|
||||
|
@ -685,13 +684,6 @@ int autoseed(newfaction ** players, int nsize, int max_agediff)
|
|||
f = u->faction;
|
||||
fset(f, FFL_ISNEW);
|
||||
f->alliance = nextf->allies;
|
||||
log_printf(stdout, "New faction (%s), %s at %s\n", itoa36(f->no),
|
||||
f->email, regionname(r, NULL));
|
||||
if (f->subscription) {
|
||||
sql_print(
|
||||
("UPDATE subscriptions SET status='ACTIVE', faction='%s', firstturn=%d, lastturn=%d WHERE id=%u;\n",
|
||||
factionid(f), f->lastorders, f->lastorders, f->subscription));
|
||||
}
|
||||
|
||||
/* remove duplicate email addresses */
|
||||
nfp = &nextf->next;
|
||||
|
|
|
@ -11,7 +11,6 @@ SET(_FILES
|
|||
attrib.c
|
||||
base36.c
|
||||
bsdstring.c
|
||||
console.c
|
||||
crmessage.c
|
||||
dice.c
|
||||
event.c
|
||||
|
@ -26,7 +25,6 @@ nrmessage.c
|
|||
parser.c
|
||||
rand.c
|
||||
resolve.c
|
||||
sql.c
|
||||
strings.c
|
||||
translation.c
|
||||
umlaut.c
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
**/
|
||||
|
||||
#include <platform.h>
|
||||
#include "sql.h"
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static FILE *sqlstream = NULL;
|
||||
static char *sqlfilename = NULL;
|
||||
|
||||
void sql_init(const char *filename)
|
||||
{
|
||||
if (sqlfilename != NULL)
|
||||
free(sqlfilename);
|
||||
sqlfilename = _strdup(filename);
|
||||
}
|
||||
|
||||
void _sql_print(const char *format, ...)
|
||||
{
|
||||
if (!sqlstream && sqlfilename) {
|
||||
sqlstream = fopen(sqlfilename, "wt+");
|
||||
free(sqlfilename);
|
||||
sqlfilename = NULL;
|
||||
}
|
||||
if (sqlstream != NULL) {
|
||||
va_list marker;
|
||||
va_start(marker, format);
|
||||
vfprintf(sqlstream, format, marker);
|
||||
va_end(marker);
|
||||
}
|
||||
}
|
||||
|
||||
void sql_done(void)
|
||||
{
|
||||
if (sqlstream)
|
||||
fclose(sqlstream);
|
||||
if (sqlfilename)
|
||||
free(sqlfilename);
|
||||
sqlstream = NULL;
|
||||
sqlfilename = NULL;
|
||||
}
|
||||
|
||||
const char *sqlquote(const char *str)
|
||||
{
|
||||
#define BUFFERS 4
|
||||
#define BUFSIZE 1024
|
||||
static char sqlstring[BUFSIZE * BUFFERS]; /* STATIC_RESULT: used for return, not across calls */
|
||||
static int index = 0; /* STATIC_XCALL: used across calls */
|
||||
char *start = sqlstring + index * BUFSIZE;
|
||||
char *o = start;
|
||||
const char *i = str;
|
||||
while (*i && o - start < BUFSIZE - 1) {
|
||||
if (*i != '\'' && *i != '\"') {
|
||||
*o++ = *i++;
|
||||
} else
|
||||
++i;
|
||||
}
|
||||
*o = '\0';
|
||||
index = (index + 1) % BUFFERS;
|
||||
return start;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
**/
|
||||
|
||||
#ifndef H_UTIL_SQL
|
||||
#define H_UTIL_SQL
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void sql_init(const char *filename);
|
||||
extern void sql_done(void);
|
||||
extern const char *sqlquote(const char *str);
|
||||
extern void _sql_print(const char *format, ...);
|
||||
|
||||
#define sql_print(x) _sql_print x
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue